Repository navigation
[https://nvbugs/6901613][fix] Two-pass variance in the same kernel: reduce and share the mean, then sum… - #20092
Merged
schetlur-nv merged 1 commit intoOct 23, 2026
Conversation
… adaptive LayerNorm The FP32 one-pass E[x^2] - mean^2 variance cancels catastrophically for rows whose mean is large relative to their spread (e.g. 2 x 15.6875 then 5118 x 15.75 at D=5120), going negative so rsqrtf(var + eps) turns the whole row into NaN. Reduce the mean first, then the sum of squares of the register-cached values centered on it. Add a regression test for the reported row in plain, affine and modulation modes. Signed-off-by: trtllm-agent <[email protected]>
Contributor
Collaborator
|
/bot run |
Collaborator
|
PR_Github #77688 [ run ] triggered by Bot. Commit: |
Collaborator
|
PR_Github #77688 [ run ] completed with state |
Contributor
|
Bug engineer ownership @o-stoner, as the engineer assigned to the linked bug, you are responsible for driving this bot PR to resolution. Please coordinate review, address feedback and required code changes, get CI passing, and verify the original failure before driving it to merge. If the PR is obsolete or superseded, close it with a reason. Keep this PR updated with blockers and the next step. |
BowenFu
approved these changes
Oct 23, 2026
schetlur-nv
approved these changes
Oct 23, 2026
1 task done
ll2088
added a commit
to ll2088/sglang
that referenced
this pull request
Oct 30, 2026
Ported from NVIDIA/TensorRT-LLM#20092 Generated by autojump (AI); review before merging.
ll2088
added a commit
to ll2088/sglang
that referenced
this pull request
Oct 30, 2026
Ported from NVIDIA/TensorRT-LLM#20092 Generated by autojump (AI); review before merging.
ll2088
added a commit
to ll2088/sglang
that referenced
this pull request
Oct 30, 2026
Ported from NVIDIA/TensorRT-LLM#20092 Generated by autojump (AI); review before merging.
ll2088
added a commit
to ll2088/sglang
that referenced
this pull request
Oct 30, 2026
Ported from NVIDIA/TensorRT-LLM#20092 Generated by autojump (AI); review before merging.
ll2088
added a commit
to ll2088/sglang
that referenced
this pull request
Oct 30, 2026
Ported from NVIDIA/TensorRT-LLM#20092 Generated by autojump (AI); review before merging.
1 task done
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
rsqrtf(var + eps)returns NaN for the whole row.rsqrtf(s2c/D + eps); added a regression test with an FP64 reference.bash .repair-bot/run_repro.shTest plan
Links
Reproduction comparison
Not run: the NVBug report states the failure ToT reproduced (DRIVER_RESULT=product_failure rep=1 passes_before=0 required=10)
Signature: DRIVER_RESULT=product_failure rep=1 passes_before=0 required=10
Dev Engineer Review
The kernel now computes the mean and then sums squared deviations from it. This avoids the cancellation risk in
E[x²] − mean²for rows with large means and small variance. No public API changes are reported.QA Engineer Review
The new regression test covers BF16 rows with large means and small variance. It checks plain, affine, and modulation modes at two epsilon values against a two-pass FP64 reference. It also checks finite output and numerical closeness. The test-list search result was not available, so CI and manual-QA listing status is unconfirmed. Coverage verdict: needs follow-up to confirm appropriate test-list inclusion and test execution.
Per-File QA Perspective
cpp/tensorrt_llm/kernels/fusedAdaptiveLayerNormKernel.cu: Verify normalized outputs for rows with large means and small variance. The kernel now uses a two-pass variance calculation withblockReduceSum.tests/unittest/_torch/visual_gen/kernels/parallel/test_fused_dit_layernorm_shift_scale.py: Addstest_bf16_large_mean_small_variancefor plain, affine, and modulation modes. Test-list inclusion and execution status are unconfirmed.