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

meta-pytorch / opacus / 22937064483
80%

Build:
DEFAULT BRANCH: main
Ran 11 Mar 2026 04:43AM UTC
Jobs 3
Files 136
Run time 1min
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: 79.181% (-0.09%) from 79.266%
22937064483

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

0 of 9 new or added lines in 1 file covered. (0.0%)

5895 of 7445 relevant lines covered (79.18%)

1.76 hits per line

Uncovered Changes

Lines Coverage ∆ File
9
71.91
-7.1% opacus/utils/fast_gradient_clipping_utils.py
Jobs
ID Job ID Ran Files Coverage
1 run-2 - 22937064483.1 11 Mar 2026 04:52AM UTC 135
78.95
GitHub Action Run
2 run-1 - 22937064483.2 11 Mar 2026 04:53AM UTC 135
78.96
GitHub Action Run
3 run-3 - 22937064483.3 11 Mar 2026 04:43AM UTC 72
47.49
GitHub Action Run
Source Files on build 22937064483
  • Tree
  • List 136
  • Changed 1
  • Source Changed 1
  • Coverage Changed 1
Coverage ∆ File Lines Relevant Covered Missed Hits/Line
  • Back to Repo
  • Github Actions Build #22937064483
  • 8493eeb2 on github
  • Prev Build on main (#22777940919)
  • Next Build on main (#22986895468)
  • 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