CUDA: fix NORM/RMS_NORM/L2_NORM for more than 65535 channels or samples - #28175
Open
edenfunf wants to merge 1 commit into
Open
CUDA: fix NORM/RMS_NORM/L2_NORM for more than 65535 channels or samples#28175edenfunf wants to merge 1 commit into
edenfunf wants to merge 1 commit into
Conversation
|
Hi @edenfunf, thanks for your contribution! Per our contribution guidelines, the automated PR checker found the following issue(s) that need your attention:
Please note that maintainers reserve the right to make final decisions on PRs. If you believe there is a mistake, please comment below. |
edenfunf
marked this pull request as ready for review
September 1, 2026 14:36
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.
Overview
Fixes #27901, refs #27911.
The norm kernels launch with grid
(nrows, nchannels, nsamples), but CUDA limitsgridDim.y/zto 65535. Whenne[2]orne[3]exceeds that, the launch fails with"invalid argument".Affected kernels:
norm_f32rms_norm_f32(plain and fused mul/add)l2_norm_f32rms_norm_mul_rope_f32As in #25103 and #22944, clamp
grid.y/zat launch and loop over the remaining channels/samples inside the kernel. Since the kernels previously derivednchannelsfromgridDim.y, the actual dimensions are now passed explicitly.#27941 avoids one instance on the model side, but the op still fails on master, e.g.
RMS_NORMwithne = [4,1,65536,1].Additional information
__syncthreads()becauseblock_reducereuses the shared buffer, same assoftmax.cu(CUDA: Fix data-races when reusing SMEM in block_reduce #26385).RMS_NORM_MUL_ROPEuses a slightly relaxed NMSE threshold for large positions due to the existing GPU/CPU trig difference (~5e-6 atne2 = 60000).Tested on RTX 5070. The new cases reproduce #27901 before the fix and pass against the CPU backend after it. The full
test-backend-opssuite also passes.A/B performance:
RMS_NORM 4096x512: 15.07 -> 14.63 usRMS_NORM_MUL_ROPE 128x32x512: 16.66 -> 16.69 usRequirements