Repository navigation
fix: honor x_stride1 in rmsnorm normalize pass - #1782
Open
YuvrajSinghBhadoria2 wants to merge 1 commit into
Open
YuvrajSinghBhadoria2 wants to merge 1 commit into
YuvrajSinghBhadoria2 wants to merge 1 commit into
Conversation
The variance pass and the output store already honour x_stride1/y_stride1, but the normalize pass loaded X + cols as if the last dim were contiguous. For an input whose last-dim stride is not 1 the row RMS was computed from the correct elements while the values scaled by that RMS were read from somewhere else, so the output was silently wrong rather than out of bounds. Read with cols * x_stride1 in the normalize pass, and add regression tests covering contiguous, last-dim-strided and out= view inputs in fp32, fp16 and bf16, with and without a weight. Fixes ModelTC#1467. Signed-off-by: Yuvraj Singh Bhadoria <yuvrajsinghbhado2030@gmail.com>
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.
What
_rms_norm_fwd_fusedacceptsx_stride1and uses it in the variance pass, and the store usesy_stride1, but the normalize pass loaded the input as if its last dim were contiguous:For an input with
stride(-1) != 1the row RMS was computed from the correct elements while the values scaled by that RMS were read from somewhere else, so the result was silently wrong rather than out of bounds.This changes the load to
X + cols * x_stride1, matching the variance pass above it and the store below it.Tests
Adds
unit_tests/common/basemodel/triton_kernel/test_rmsnorm.pycovering:x.t()), compared against the reference and against the same values laid out contiguouslyout=as a strided view, including a check that padding outside the view is not writtenThe tests require CUDA and I did not run them locally (this machine has no GPU and no torch/triton); they are written to
pytest.skipwithout CUDA so the CPU test jobs stay green. The kernel change is a one-line index fix and does not alter the launch configuration.Relation to #1468
This replaces #1468, which carries the identical one-line change but also adds an unrelated 232-line
fused_moe/deepep_scatter_gather.pythat the reviewer asked to remove; that PR has been untouched since August. This one contains only the fix and the regression tests. #1468 reported the strided fp32 max error going from 5.83 to 0.0 on a B200 for the same change, with no measurable perf cost.Fixes #1467.
Signed-off-by: Yuvraj Singh Bhadoria yuvrajsinghbhado2030@gmail.com