Skip to content

[TRTLLM-16624][fix] Compile the gated RMSNorm kernel's one-token variants up front (#22576 back-port) - #22772

Merged
zhaoyuanh-nvidia merged 1 commit into
NVIDIA:feat/helix-aggfrom
zhaoyuanh-nvidia:zhaoyuanh/gated-rmsnorm-sync-22576
Nov 23, 2026
Merged

zhaoyuanh-nvidia merged 1 commit into
NVIDIA:feat/helix-aggfrom
zhaoyuanh-nvidia:zhaoyuanh/gated-rmsnorm-sync-22576

Conversation

@zhaoyuanh-nvidia

Copy link
Copy Markdown
Collaborator

Description

Brings over what #22576 (the main port 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:

  • One-token batches. The kernel's row strides (of x, the output and the gate) are compile keys too: Triton specializes integer arguments on == 1 and % 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 whose x is a column slice on the RMSNorm module 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.
  • Bookkeeping. The variants compiled ahead of time are recorded too, so launching one later does not repeat the work, and one info line per newly launched variant names what was compiled (N, heads per token, row strides). As on main, the sibling compile is the helper _compile_multirow_siblings, and the set is named _multirow_variants_with_siblings.
  • Test. test_multirow_kernel_reuses_the_compiled_variant_across_batches now 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 makes x a 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 EVEN and CONTIG compile flags (#20916) and the GROUPS tiling (#21997) that main's launch helper also handles, with #22576's sibling compiles for them and the helper's grouped= signature; and #22576's change to _direct_launch in main's qwen4_exp op, which this branch's qwen4_exp op does not have. These come with the next mass merge from main, where main's versions of both files replace this branch's.

Tracks TRTLLM-16624.

Test Coverage

On a GB300 (SM103) node, using a feat/helix-agg build at 338b563 (its layernorm_gated.py differs 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-Next rms_norm_gated_token_major catalog tests (all but test_layernorm_gated.py at the build's revision): 178 passed with this PR, 174 on this branch without it. The reuse test went from 2 cases to 6.
  • The new test against this branch's source without the change: the dense and aligned cases pass on both paths, and both sliced cases fail. After warmup the kernel has 2 variants (the launched one and its PDL twin), and the one-token batch compiles 2 more.

Pre-commit passes on the changed files.

PR Checklist

  • Please check this after reviewing the above items as appropriate for this PR.

…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>
@zhaoyuanh-nvidia
zhaoyuanh-nvidia requested a review from a team as a code owner November 23, 2026 04:28
@zhaoyuanh-nvidia
zhaoyuanh-nvidia merged commit d36eeba into NVIDIA:feat/helix-agg Nov 23, 2026
9 checks passed
@zhaoyuanh-nvidia
zhaoyuanh-nvidia deleted the zhaoyuanh/gated-rmsnorm-sync-22576 branch November 23, 2026 04:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant