|
Ran
|
Jobs
3
|
Files
136
|
Run time
1min
|
Badge
README BADGES
|
push
github
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
| 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 |
| ID | Job ID | Ran | Files | Coverage | |
|---|---|---|---|---|---|
| 1 | run-3 - 22838718324.1 | 72 |
47.61 |
GitHub Action Run | |
| 2 | run-2 - 22838718324.2 | 135 |
79.03 |
GitHub Action Run | |
| 3 | run-1 - 22838718324.3 | 135 |
79.04 |
GitHub Action Run |
| Coverage | ∆ | File | Lines | Relevant | Covered | Missed | Hits/Line |
|---|