Repository navigation
Patch stale clipping bound for FastGradientClipping - #847
Open
eddiestudies wants to merge 3 commits into
Open
eddiestudies wants to merge 3 commits into
eddiestudies wants to merge 3 commits into
Conversation
|
This pull request has been imported. If you are a Meta employee, you can view this in D123688838. (Because this pull request was imported automatically, there will not be any future comments.) |
eddiestudies
commented
Oct 23, 2026
| @@ -0,0 +1,6 @@ | |||
| [settings] | |||
Contributor
Author
There was a problem hiding this comment.
This helps with the ordering issue with linting vs isort
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Types of changes
This test passes through max_grad_norm for scenarios where the optimizer changes it between steps. Previously, the original max_grad_norm was saved and used throughout and the scheduled max_grad_norm in the optimizer was ignored.
Motivation and Context / Related issue
When Opacus wraps the user's objects, some privacy affecting values are saved as scalars. These copies can become stale if any algorithm requires changing them or the user mutates them.
For FastGradientClipping, the scheduled max_grad_norm is ignored since the original scalar value is read directly instead of the optimizer's max_grad_norm.
This PR resolves this bug in GradSampleHooksFastGradientClipping and warns users if the module's and optimizer's max_grad_norm differ when the DP loss is built.
This PR also adds xfails for locations where stale values can lead to incorrect behavior.
An .isort.cfg is also added to reduce the nuances when running isort and black for linting.
How Has This Been Tested (if it applies)
Added tests for each of the clipping_bound_owner effects. Added tests for similar bugs.
Checklist