Repository navigation
fix(layernorm): center FP32 statistics before variance reduction - #270
Open
superme1one wants to merge 1 commit into
Open
superme1one wants to merge 1 commit into
superme1one wants to merge 1 commit into
Conversation
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.
Summary
Center FP32 LayerNorm statistics before reducing variance and use the centered values consistently in backward.
Motivation
Large means with small variance caused cancellation and non-finite results in the original FP32 implementation.
Type of Change
fix; no public API removal.Platforms Affected
CUDA FP32 LayerNorm, tested through the Iluvatar compatibility build.
Smoke Test Result
Forward, input gradient, weight gradient and bias gradient passed all 60 checks for 15 conditioning cases and all 792 checks for 198 boundary cases against FP64 references computed from the exact same FP32 inputs. The original control failed 32/60 stress checks and produced 15,882 non-finite checked values. Against independent PyTorch FP32 references, the candidate differs in 12/60 stress and 190/792 extended checks; that FP32 reference also differs from the FP64 oracle in the same number of checks. Tolerances were preserved.
The combined candidate stack passed 228 CPU tests (3 skips) and 229 Iluvatar GPU tests (2 CPU-only death checks skipped), with no failures. Coverage includes optimizer state, shared parameters, autograd and checkpoint round trips. The GPU build uses CoreX 4.3.0.20250624 with a separately recorded compatibility layer. NVIDIA execution and hosted CI are pending.
Test Results on Supported Platforms
Validated on the platforms listed above. Local formatting and patch-application checks passed. Hosted CI is tracked separately from the recorded target-platform tests. Affected backends not available in this session require their normal CI/owner checks.
Benchmark / Performance Impact
Numerical-stability fix. This is not a bitwise-equivalence claim.
Notes for Reviewers
Base:
InfiniTensor/InfiniTrain@e19a56dcb56bec11f1af63c089a1e8ae03ff24c7. Verification date: 2026-11-16. Detailed test inputs, source hashes and logs are retained in the separate validation package; performance reports are excluded from the source patch.Closes #266.
CI approval status at submission
The upstream pull-request workflows are
action_requiredand have not scheduled jobs. A repository maintainer needs to approve the runs. Target-platform tests are recorded above. This repository did not automatically run checks for the feature-branch push. Local formatting and target-platform results are recorded above. Backend tests requiring upstream infrastructure remain pending.