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

meta-pytorch / opacus / 22792141746
80%

Build:
DEFAULT BRANCH: main
Ran 07 Mar 2026 04:39AM 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

06 Mar 2026 07:03PM UTC coverage: 79.266% (+0.9%) from 78.35%
22792141746

push

github

meta-codesync[bot]
Fix adaptive noise accounting (#807)

Summary:
## Types of changes

- [x] Bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to change)
- [ ] Docs change / refactoring / dependency upgrade

## Motivation and Context / Related issue
This PR fixes incorrect privacy accounting for `AdaClipDPOptimizer`.

The AdaClip optimizer internally adjusts the `noise_multiplier` based on Theorem 1 from the [AdaClip paper](https://arxiv.org/pdf/1905.03871.pdf):
`σ_eff = (σ^-2 - (2σ_u)^-2)^(-1/2)`

where `σ` is the user-provided noise multiplier and `σ_u` is the `unclipped_num_std` parameter.

The adjusted `σ_eff` is used internally for noise generation during training. However, privacy accountants (rdp, prv,...) were using this adjusted value instead of the original user-provided `σ` for privacy budget calculations, resulting in **incorrect epsilon values**.

Introduced an `accounting_noise_multiplier` property that:
- Returns `noise_multiplier` for standard `DPOptimizer` (backward compatible)
- Returns the original user-provided value for `AdaClipDPOptimizer` (before adjustment)
- Is used by the accountant hook for correct privacy accounting

The internal noise generation continues to use the adjusted value as intended by the AdaClip algorithm, while privacy accounting now uses the correct original value.
## Update!!
As of commit [1f9283a](https://github.com/meta-pytorch/opacus/pull/807/commits/1f9283ab3)
Refactored the noise adjustment to be calculated **locally within the `add_noise()` method** where it's actually needed, rather than modifying `self.noise_multiplier` at initialization.

Now:
- `self.noise_multiplier` always holds the **original user-provided value** (σ)
- The adjusted value (σ_eff) is calculated on-the-fly only when adding noise to gradients
- Privacy accountants automatically ... (continued)

104 of 107 new or added lines in 4 files covered. (97.2%)

5895 of 7437 relevant lines covered (79.27%)

1.76 hits per line

Uncovered Changes

Lines Coverage ∆ File
1
92.54
69.96% opacus/optimizers/adaclipoptimizer.py
1
98.89
opacus/tests/accounting_noise_multiplier_test.py
1
25.0
0.0% opacus/utils/adaptive_clipping/adaptive_clipping_utils.py
Jobs
ID Job ID Ran Files Coverage
1 run-1 - 22792141746.1 07 Mar 2026 04:49AM UTC 135
79.04
GitHub Action Run
2 run-3 - 22792141746.2 07 Mar 2026 04:39AM UTC 72
47.61
GitHub Action Run
3 run-2 - 22792141746.3 07 Mar 2026 04:48AM UTC 135
79.03
GitHub Action Run
Source Files on build 22792141746
  • Tree
  • List 136
  • Changed 5
  • Source Changed 3
  • Coverage Changed 5
Coverage ∆ File Lines Relevant Covered Missed Hits/Line
  • Back to Repo
  • Github Actions Build #22792141746
  • 9d3c2b01 on github
  • Prev Build on main (#22702602767)
  • Next Build on main (#22814031459)
  • 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