Repository navigation
Conversation
Assert the tensor reference and non-null gradients before tensor operations so the precision regression satisfies the pinned type checker.
Contributor
Author
|
Could a maintainer rerun the cancelled macOS job for current head |
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.
Problem
ClassWeightedReducer casts stored class weights to the loss dtype before multiplication. That prematurely rounds weights and can zero a small coefficient before its product with a large loss becomes representable. It also computes products such as
40000 * 2in float16 before averaging, so a representable batch mean can become infinite.Changes
Convert weights directly to the accumulation dtype, multiply and average float16/bfloat16 losses in float32, and return the scalar in the original loss dtype. The registered weight buffer keeps its precision. Tests compare independent float64 values and gradients, cover reordered anchors and small weights, and retain float16 overflow coverage.
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/reducers/test_class_weighted_reducer.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.