Repository navigation
[TRTLLM-16624][fix] Compile the gated RMSNorm kernel's one-token variants up front (#22576 back-port) - #22772
Merged
zhaoyuanh-nvidia merged 1 commit intoNov 23, 2026
Conversation
…ants up front (NVIDIA#22576 back-port) A one-token batch can key another variant of the multi-row gated RMSNorm kernel. PyTorch gives a dimension of size 1 the dense stride, so a gate viewed in a wider projection, or a column-sliced x, arrives with other row strides when it holds one token, and Triton specializes them on == 1 and % 16. The first launch of a variant now also compiles the one-token launches when their strides differ, registers every variant it compiles, and logs once which variants it compiled. The reuse test covers dense, aligned and sliced layouts and starts from an empty kernel cache. Back-port of what review added to NVIDIA#22576 (merged to main as 13aae0e) after NVIDIA#22202 had merged here, written for this branch's kernel, which does not have main's EVEN, CONTIG and GROUPS keys yet. Signed-off-by: Zhaoyuan He <195028209+zhaoyuanh-nvidia@users.noreply.github.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.
Description
Brings over what #22576 (the
mainport of #22202, merged there as 13aae0e) has beyond #22202, which merged here on 11-13 as caf6dc4. Review on #22576 added three things that apply to this branch's kernel:x, the output and the gate) are compile keys too: Triton specializes integer arguments on== 1and% 16 == 0. PyTorch gives a dimension of size 1 the dense stride, so a one-token batch whose gate is a column slice of a wider projection, or whosexis a column slice on theRMSNormmodule path, arrives with other strides than every larger batch. When the projection's row stride is not a multiple of 16, that one-token batch compiled a new variant mid-serving. The first launch of a variant now also compiles the one-token launches (both PDL settings) when their strides differ.N, heads per token, row strides). As onmain, the sibling compile is the helper_compile_multirow_siblings, and the set is named_multirow_variants_with_siblings.test_multirow_kernel_reuses_the_compiled_variant_across_batchesnow gives the gate whole (dense) or as a column slice of a wider projection whose row stride is a multiple of 16 (aligned) or not (sliced); sliced also makesxa column slice on the module path. It first clears the kernel's compiled variants, as a server process starts with none, so variants compiled by earlier tests in the same process cannot stand in for the ones warmup compiles. The sweep adds 4,095 tokens.Not brought over, because this branch's kernel does not have them yet: the
EVENandCONTIGcompile flags (#20916) and theGROUPStiling (#21997) thatmain's launch helper also handles, with #22576's sibling compiles for them and the helper'sgrouped=signature; and #22576's change to_direct_launchinmain's qwen4_exp op, which this branch's qwen4_exp op does not have. These come with the next mass merge frommain, wheremain's versions of both files replace this branch's.Tracks TRTLLM-16624.
Test Coverage
On a GB300 (SM103) node, using a
feat/helix-aggbuild at 338b563 (itslayernorm_gated.pydiffers from this branch's only by #22202) with both files taken from the tree under test:test_layernorm_gated.py,test_gdn_kernel_optimizations.py,test_traced_triton_op_wrappers.py, and the K3 and Qwen3.8-Flash-Nextrms_norm_gated_token_majorcatalog tests (all buttest_layernorm_gated.pyat the build's revision): 178 passed with this PR, 174 on this branch without it. The reuse test went from 2 cases to 6.Pre-commit passes on the changed files.
PR Checklist