• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

meta-pytorch / opacus / 22887396714 / 2
80%
main: 80%

Build:
DEFAULT BRANCH: main
Ran 10 Mar 2026 04:52AM UTC
Files 135
Run time 3s
Badge
Embed ▾
README BADGES
x

If you need to use a raster PNG badge, change the '.svg' to '.png' in the link

Markdown

Textile

RDoc

HTML

Rst

09 Mar 2026 05:54PM UTC coverage: 78.949% (-0.09%) from 79.035%
22887396714.2

push

github

meta-codesync[bot]
Fix GitHub issue #792: Fast gradient clipping ignores ignore_index masking (#808)

Summary:
Pull Request resolved: https://github.com/meta-pytorch/opacus/pull/808

Context/Motivation: Fixes https://github.com/meta-pytorch/opacus/issues/792

When using fast/ghost gradient clipping for NLP tasks, `DPLossFastGradientClipping`
computes per-sample mean loss via `.mean(dim=1)`, which divides by the full sequence
length. This ignores the `ignore_index` parameter from the criterion (e.g.,
`CrossEntropyLoss(ignore_index=-100)`), causing masked/padded positions to dilute
the loss. For tasks like SQuAD where only a few tokens are real targets out of a
long sequence, the loss becomes orders of magnitude too small, preventing training.

This diff:
- Modified `DPLossFastGradientClipping.__call__()` to check for `ignore_index` on the
  criterion and compute mean only over non-ignored positions when present
- Added regression test `github_issue_test.py` verifying ignore_index is respected
  for both mean and sum reductions, plus a backwards-compatibility test for the
  no-masking case

Reviewed By: aparna-aketi

Differential Revision: D95489302

fbshipit-source-id: d02146a71

5798 of 7344 relevant lines covered (78.95%)

0.79 hits per line

Source Files on job run-2 - 22887396714.2
  • Tree
  • List 135
  • Changed 1
  • Source Changed 1
  • Coverage Changed 1
Coverage ∆ File Lines Relevant Covered Missed Hits/Line
  • Back to Build 22887396714
  • 8493eeb2 on github
  • Prev Job for on main (#22777940919.2)
  • Next Job for on main (#22937064483.2)
  • Delete
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc