Repository navigation
Fix BatchNorm/LieBN parameter resets and bias being applied when disabled - #44
Merged
Merged
Conversation
|
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
bruAristimunha
approved these changes
Oct 19, 2026
bruAristimunha
left a comment
Contributor
There was a problem hiding this comment.
Thanks @lucas-heck, good catch. With rebias=False, the old code still applied the bias. That bias was created with torch.empty and never reset, so it was uninitialized memory, which makes this a real correctness fix.
Checked before merging:
- Full suite with all four open PRs merged together: green.
SPDBatchNormMean/SPDBatchNormMeanVar: after perturbing every parameter,reset_parameters()restores the identity bias and unit weight, and the parameter objects stay the same (so optimizer state remains valid). LieBN is covered by your new test.
Minor, non-blocking:
- Old
SPDBatchNormMean(rebias=False)checkpoints containparametrizations.bias.original, soload_state_dict(strict=True)will now report an unexpected key. Those weights were uninitialized anyway, so I'd just mention it in the release notes. - The "eye → assign if parametrized, else
copy_" block now appears three times. A small shared helper could remove the repetition at some point, but it isn't needed for this PR.
I'll merge main into the branch to resolve the CHANGELOG.md conflict, then merge. Thanks!
# Conflicts: # CHANGELOG.md
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.
Problem
SPDBatchNormMean's was still applying an trainable bias whenrebias=False.After parametrization,
reset_parameters()was modifying the temporary tensors instead of the underlying parameters, which was preventing biases and scales from resetting correctly inSPDBatchNormMean,SPDBatchNormMeanVar, andSPDBatchNormLie.Fix
Only create and parametrize the layer’s bias when
rebiasis enabled.Reset of parametrized parameters now is done through assignment, which invokes their
right_inverse.Verification
Added tests for disabled bias and LieBN resets after training across all the metrics.