Repository navigation
Widen center-invariant norms before computing squared deviations - #776
Merged
KevinMusgrave merged 3 commits intoNov 8, 2026
Merged
Conversation
Contributor
Author
|
Could a maintainer rerun the cancelled macOS job for current head |
Exercise overflow both before reduction and in the final scalar, with float64 value and gradient references. The focused four-dtype suite passes 21 tests. The policy check is blocked by the pre-existing expired certifi assessment; shared verification will be completed after its re-assessment.
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
CenterInvariantRegularizer computes norms and squared deviations in the input dtype. For bfloat16 centers
[16, 0]and[17, 0], this gives 64 instead of the reference loss 68.0625. Float16 norms around 300 also overflow when squared, before the final centered loss is computed.Changes
Promote low-precision centers before computing their norms and retain float32 through reduction. Float32/float64 inputs and custom Lp norms retain their existing behavior. Tests check the squared-norm variance and its analytic gradient against float64 references; the integration test reference now also uses float64.
The component documentation, numerical rationale, and unreleased notes describe the behavior.
Validation
TEST_DEVICE=cpu TEST_DTYPES=float32,float64,bfloat16 OMP_NUM_THREADS=1 python -m pytest tests/regularizers/test_center_invariant_regularizer.py -q: 10 passed.git diff --checkpassed.The checksum-verified pinned Code Polishy 0.31.10 commands were attempted.
check --git-changesis blocked by an unavailable policy-owned CPython 3.12 interpreter/security providers.test --changed --base 0db540f1b8adb0f65ea91075ee1625e13176758bcould not start the declared suites because the repository-specific.venv/bin/uvis absent. The direct focused tests below ran in the available Python/PyTorch environment; these results do not constitute a pass of the complete locked verification gates. Float16 execution is also blocked on this host byRuntimeError: Failed to initialize cpuinfo!; its parameterized cases are retained for supported CI hosts.