Skip to content

perf(cake_rmsnorm_silu_gate): L2-prefetching mid forward on SM107 - #8656

Merged
yyihuang merged 1 commit into
flashinfer-ai:mainfrom
yyihuang:cake-rmsnorm-silu-gate-sm107-mid-l2-prefetch
Nov 4, 2026
Merged

yyihuang merged 1 commit into
flashinfer-ai:mainfrom
yyihuang:cake-rmsnorm-silu-gate-sm107-mid-l2-prefetch

Conversation

@yyihuang

@yyihuang yyihuang commented Nov 4, 2026 •

Copy link
Copy Markdown
Collaborator

This PR switches the sm_107a mid forward of the non-deterministic package of Cake's SiLU-gated RMSNorm training kernel (flashinfer.cake_rmsnorm_silu_gate_train with deterministic=False) to cake_rmsnorm_silu_gate_train_87f0173e9583ad4fdd2a. That is the L2-prefetching module sm_100a and sm_103a already run. In it, thread 0 also warms two later row blocks in L2, with one bulk prefetch per tensor, wherever the inputs x and z hold their rows packed. The two blocks are the CTA's next block and the CTA's first block one resident wave later. The sm_107a routing thresholds and grid do not change: the mid forward serves inputs from 800 rows per SM up to the long forward's 1740. The five shapes in Table 1 fall in that range.

The module this replaces, cake_rmsnorm_silu_gate_train_b0eb3df9844d5b734850, is the same 128-thread build without the prefetch. Nothing routes to it anymore, so this PR removes it. It is the "previous Cake" baseline below. Every other module and route is FlashInfer main's code: the backward, the short and long forwards, and every sm_100a and sm_103a route run the same code as before.

The PR is one commit on FlashInfer main after PR #8622. The A/B compared two FlashInfer trees: one whose sm_107a mid forward runs without the prefetch, and the same tree plus this PR's sm_107a route. In the measured tree, the new module's sources are byte-identical to this PR's.

A speedup is baseline us / new us, so a value above 1 means this PR is faster. The table gives ranges (min-max) over the five shapes of Table 1 on R200 (sm_107a, 212 SMs), CUDA 13.4. For stepg_f32 and fwd + bwd, the ranges cover the twelve shapes of Table 2: those five, plus seven shapes that run the same code in both trees.

op det Cake / new strongest non-Cake / new previous Cake / new (A/B)
fwd 1.119-1.141 1.071-1.080 1.113-1.136
fwdg 1.131-1.142 1.047-1.077 1.111-1.136
bwdg 1.081-1.163 1.097-1.119 0.9998-1.0002
ckptg 1.115-1.151 1.070-1.084 1.046-1.060
stepg_f32 (12 shapes) 1.068-1.218 - 0.9996-1.061
fwd + bwd (12 shapes) 1.062-1.197 - 0.998-1.045

In the pre-registered A/B, all 20 cells whose code changes (fwd, fwdg, ckptg and stepg_f32 at the five shapes) are faster than the previous Cake route. bwdg runs the same code in both trees. Neither the strongest non-Cake kernel (Table 1) nor the deterministic Cake kernel (Tables 1 and 2) is faster than new on any row. Every cell below 1x is a same-code cell against the previous Cake route, each by less than 0.3 %, and every one is listed under "Cells below 1x".

The kernel's other Cake variants are the deterministic package flashinfer.cake_rmsnorm_silu_gate_det_train (the same API with deterministic=True) and the FP32 weight-gradient output of the non-deterministic package. Both packages ship on sm_100a, sm_103a and sm_107a. sm_100a and sm_103a have run this mid forward since PR #8622, and this PR changes only the non-deterministic package's mid forward on sm_107a.

How the tables were measured

  • Latency: CUPTI kernel time with cold L2, taken with FlashInfer's GPU timer in flashinfer.testing. Inputs are BF16, and all times are in us.
  • Table 1: the deterministic Cake kernel, the strongest non-Cake kernel and new were measured in the same process. Each value is the median of the per-round medians over 10 rounds.
  • A/B values: the previous Cake and new (A/B) columns and all of Table 2 are medians of the pre-registered interleaved A/B, which ran 16 sequences and 160 processes. stepg_f32 has no same-process measurement, so its deterministic Cake values also come from the A/B.
  • Strongest non-Cake kernel per row: the fastest of the following, with torch 2.14.1+cu130 and Triton 3.8.0.
    • FLA 0.6.0 rms_norm_gated (fla.modules.fused_norm_gate).
    • mamba_ssm v2.3.2 rmsnorm_fn (layernorm_gated).
    • torch.compile in default and max-autotune-no-cudagraphs modes, best of 5 fresh compiles each. #k names the fastest compile.
    • The inductor-generated persistent-reduction Triton kernel of the FP32 formula, launched directly.
  • Deterministic Cake: flashinfer.cake_rmsnorm_silu_gate_det_train, unchanged by this PR.
  • Operations:
    • fwd is one eager forward call, and fwdg is the forward replayed from a CUDA graph.
    • bwdg is the backward replayed from a CUDA graph.
    • ckptg is the checkpointed step (2 x forward + backward) in one CUDA graph, and stepg_f32 is the same step with an FP32 dw.
    • fwd + bwd is fwdg + bwdg, derived.
  • In Table 2, the first five shapes run the new module. 260x48, 1031x48, 2048x48, 3533x48, 7685x48, 10600x48 and 16384x48 run the same code in both trees.

Cells below 1x

  • vs the strongest non-Cake kernel (Table 1): none.
  • vs the deterministic Cake kernel: none.
  • vs the previous Cake route (A/B), only at cells that run the same code in both trees:
    • bwdg (Table 1): 8192x32 0.9998, 7684x48 0.99999
    • Table 2: 1031x48 stepg_f32 0.9997, 1031x48 fwd + bwd 0.998, 2048x48 stepg_f32 0.9996, 3533x48 ckptg 0.9996, 3533x48 stepg_f32 0.9999, 7685x48 stepg_f32 0.9999, 7685x48 fwd + bwd 0.9998, 10600x48 stepg_f32 0.99996, 16384x48 fwd + bwd 0.9999

Results on R200 (sm_107a, 212 SMs)

  • GPU: R200 (VR200 node; nvidia-smi name 'NVIDIA Graphics Device'), sm_107a, compute capability 10.7, 212 SMs, driver 620.43.
  • CUDA: 13.4 (nvcc Build cuda_13.4.r13.4/compiler.38855100_0); PyTorch 2.14.1+cu130 (CUDA 13.0); Triton 3.8.0; Python 3.14.8.

Table 1 (R200, sm_107a, CUDA 13.4): new vs the deterministic Cake kernel, the strongest non-Cake kernel and the previous Cake route

T x H op det Cake us strongest non-Cake us strongest non-Cake kernel new us previous Cake us (A/B) new us (A/B) det / new non-Cake / new previous / new (A/B)
3534x48 fwd 18.192 17.408 torch.compile default #1 16.256 18.272 16.241 1.119 1.071 1.125
3534x48 fwdg 18.256 16.896 torch.compile default #3 16.144 18.088 16.096 1.131 1.047 1.124
3534x48 bwdg 38.528 37.072 FLA rms_norm_gated 33.136 33.088 33.088 1.163 1.119 1.00001
3534x48 ckptg 72.831 68.273 FLA rms_norm_gated 63.264 66.264 63.048 1.151 1.079 1.051
3534x48 stepg_f32 72.576 (A/B) not measured - - 66.392 63.392 1.145 (A/B) n/a 1.047
4097x48 fwd 20.416 19.328 FLA rms_norm_gated 17.889 19.904 17.888 1.141 1.080 1.113
4097x48 fwdg 20.192 19.104 torch.compile max-autotune-no-cudagraphs #2 17.825 19.872 17.880 1.133 1.072 1.111
4097x48 bwdg 40.064 40.689 FLA rms_norm_gated 37.057 37.128 37.120 1.081 1.098 1.0002
4097x48 ckptg 78.544 75.376 FLA rms_norm_gated 70.464 73.808 70.536 1.115 1.070 1.046
4097x48 stepg_f32 78.440 (A/B) not measured - - 73.816 70.849 1.107 (A/B) n/a 1.042
8192x32 fwd 26.304 24.928 FLA rms_norm_gated 23.072 25.961 22.944 1.140 1.080 1.131
8192x32 fwdg 26.272 24.784 FLA rms_norm_gated 23.009 25.961 22.928 1.142 1.077 1.132
8192x32 bwdg 50.352 50.608 FLA rms_norm_gated 46.048 45.992 46.000 1.093 1.099 0.9998
8192x32 ckptg 100.273 96.256 FLA rms_norm_gated 89.616 94.256 89.256 1.119 1.074 1.056
8192x32 stepg_f32 99.885 (A/B) not measured - - 94.256 89.425 1.117 (A/B) n/a 1.054
6000x48 fwd 28.096 26.624 torch.compile default #1 24.673 28.064 24.704 1.139 1.079 1.136
6000x48 fwdg 28.048 26.417 torch.compile default #3 24.640 27.872 24.544 1.138 1.072 1.136
6000x48 bwdg 54.928 54.529 FLA rms_norm_gated 49.328 49.184 49.184 1.114 1.105 1.000003
6000x48 ckptg 108.096 103.552 FLA rms_norm_gated 95.904 101.608 95.824 1.127 1.080 1.060
6000x48 stepg_f32 108.769 (A/B) not measured - - 101.760 95.945 1.134 (A/B) n/a 1.061
7684x48 fwd 35.008 33.168 FLA rms_norm_gated 30.720 34.712 30.816 1.140 1.080 1.126
7684x48 fwdg 35.008 32.961 torch.compile default #5 30.688 34.537 30.656 1.141 1.074 1.127
7684x48 bwdg 66.208 65.648 FLA rms_norm_gated 59.824 59.720 59.720 1.107 1.097 0.99999
7684x48 ckptg 133.120 128.496 FLA rms_norm_gated 118.560 125.296 118.361 1.123 1.084 1.059
7684x48 stepg_f32 132.496 (A/B) not measured - - 125.569 118.705 1.116 (A/B) n/a 1.058

Table 2 (R200, sm_107a, CUDA 13.4): full step, previous Cake route vs new (A/B medians)

T x H rows op previous Cake us new us previous / new det Cake us det / new
3534x48 169632 ckptg 66.264 63.048 1.051 72.609 1.152
3534x48 169632 stepg_f32 66.392 63.392 1.047 72.576 1.145
3534x48 169632 fwd + bwd 51.176 49.184 1.041 56.833 1.156
4097x48 196656 ckptg 73.808 70.536 1.046 78.449 1.112
4097x48 196656 stepg_f32 73.816 70.849 1.042 78.440 1.107
4097x48 196656 fwd + bwd 57.000 55.000 1.036 60.368 1.098
8192x32 262144 ckptg 94.256 89.256 1.056 100.032 1.121
8192x32 262144 stepg_f32 94.256 89.425 1.054 99.885 1.117
8192x32 262144 fwd + bwd 71.953 68.929 1.044 76.656 1.112
6000x48 288000 ckptg 101.608 95.824 1.060 108.872 1.136
6000x48 288000 stepg_f32 101.760 95.945 1.061 108.769 1.134
6000x48 288000 fwd + bwd 77.056 73.728 1.045 83.328 1.130
7684x48 368832 ckptg 125.296 118.361 1.059 132.564 1.120
7684x48 368832 stepg_f32 125.569 118.705 1.058 132.496 1.116
7684x48 368832 fwd + bwd 94.257 90.376 1.043 100.800 1.115
260x48 12480 ckptg 14.704 14.704 1.000 18.064 1.229
260x48 12480 stepg_f32 14.352 14.344 1.001 17.472 1.218
260x48 12480 fwd + bwd 12.664 12.664 1.00002 15.160 1.197
1031x48 49488 ckptg 26.592 26.584 1.0003 29.768 1.120
1031x48 49488 stepg_f32 26.624 26.632 0.9997 29.656 1.114
1031x48 49488 fwd + bwd 22.224 22.272 0.998 26.624 1.195
2048x48 98304 ckptg 43.328 43.328 1.000 46.537 1.074
2048x48 98304 stepg_f32 42.832 42.848 0.9996 45.896 1.071
2048x48 98304 fwd + bwd 33.952 33.952 1.00001 37.968 1.118
3533x48 169584 ckptg 67.192 67.216 0.9996 72.520 1.079
3533x48 169584 stepg_f32 67.152 67.156 0.9999 72.496 1.080
3533x48 169584 fwd + bwd 51.280 51.272 1.0002 56.736 1.107
7685x48 368880 ckptg 121.057 121.009 1.0004 132.776 1.097
7685x48 368880 stepg_f32 121.136 121.152 0.9999 132.832 1.096
7685x48 368880 fwd + bwd 92.017 92.032 0.9998 100.688 1.094
10600x48 508800 ckptg 162.752 162.692 1.0004 173.993 1.069
10600x48 508800 stepg_f32 162.858 162.865 0.99996 173.985 1.068
10600x48 508800 fwd + bwd 123.296 123.280 1.0001 131.025 1.063
16384x48 786432 ckptg 236.545 236.453 1.0004 254.433 1.076
16384x48 786432 stepg_f32 236.737 236.643 1.0004 254.441 1.075
16384x48 786432 fwd + bwd 177.737 177.761 0.9999 188.721 1.062

Summary by CodeRabbit

  • Performance
    • Updated RMSNorm-SiLU-gate training execution for newer GPU architectures, including sm_107a. The revised path supports a lower minimum workload threshold on that architecture and applies bulk L2 prefetching across supported architectures.
  • Documentation
    • Clarified the description of mid-forward L2 prefetching.

…e mid forward on SM107

With deterministic=False, on sm_107a the mid forward (from 800 rows per
SM up to the long forward's) now runs the program sm_100a and sm_103a
run there, whose thread 0 also warms in L2, with one bulk prefetch per
tensor where x and z hold their rows packed, the CTA's next row block and
the first row block of the CTA one wave later.  The sm_107a grid and
threshold, every other route and every other program are unchanged, and
y stays bitwise equal to the deterministic forward (a prefetch writes no
register and no memory).

cake_jit: the mid forward record ships on sm_107a too (from 800 rows per
SM there) and the sm_107a mid forward program without the prefetch is
removed; the docs name the prefetch on every architecture.
@yyihuang

yyihuang commented Nov 4, 2026

Copy link
Copy Markdown
Collaborator Author

@flashinfer-bot run tests/norm/test_cake_rmsnorm_silu_gate_det_train.py tests/norm/test_cake_rmsnorm_silu_gate_det_train_aliases.py tests/norm/test_cake_rmsnorm_silu_gate_det_train_api.py tests/norm/test_cake_rmsnorm_silu_gate_det_train_stall.py tests/norm/test_cake_rmsnorm_silu_gate_train.py tests/norm/test_cake_rmsnorm_silu_gate_train_api.py tests/norm/test_cake_rmsnorm_silu_gate_train_stall.py

@coderabbitai

coderabbitai Bot commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The sm_107a mid-forward route now uses the shared module for sm_100a, sm_103a, and sm_107a. The module adds bulk L2 prefetching and an sm_107a row threshold. Build metadata and generated CUDA sources reflect the module change.

Changes: Mid-forward module consolidation

Layer / File(s) Summary
Shared mid-forward behavior and routing
flashinfer/cake_rmsnorm_silu_gate_train_backend/cake_jit.py, flashinfer/cake_rmsnorm_silu_gate_train_backend/__init__.py
The shared mid-forward module now covers sm_100a, sm_103a, and sm_107a. It prefetches the CTA’s next packed-row block and a block one wave later. The row threshold is 976 for sm_100a and sm_103a, and 800 for sm_107a. The sm_107a route selects this module.
sm_107a artifact transition
flashinfer/cake_rmsnorm_silu_gate_train_backend/build.json, flashinfer/cake_rmsnorm_silu_gate_train_backend/csrc/...
Build metadata adds the shared module’s sm_107a artifact and removes the previous artifact record. The previous module’s generated binding and kernel source files are deleted.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Refactor

Merge Risk: Minimal · up to 80acb

No actionable merge-blocking issue was identified in the SM107 module consolidation. Merge readiness remains subject to normal build and test checks.

Pre-merge checks: Passed 5
Check name Status Explanation
Description check Passed The description follows the repository template in substance. It has a clear Description section that explains the change, the reason for it, and the measured results. It covers the removed module and…
Docstring Coverage Passed No eligible functions found in the changed files. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentat…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Title check Passed The title names the main change: the SM107 mid-forward path of the Cake RMSNorm-SiLU-gate training kernel now uses the L2-prefetching module, as the raw summary (cake_jit.py now serves sm_107a from th…
Full details: Description check

Explanation

The description follows the repository template in substance. It has a clear Description section that explains the change, the reason for it, and the measured results. It covers the removed module and the unchanged routes. It includes tables of measurements, a list of cells below 1x, and the hardware and software versions. The template's checklist items (pre-commit, tests) are not ticked, and the Related Issues section is empty. The author did request specific test targets in the PR comments, but the description does not state whether the tests were run or passed. The experimental section is correctly left untouched because this is not an experimental PR. The description is mostly complete, so the check passes, though the missing Related Issues link and the unchecked test and pre-commit items are noted for the author.

Full details: Docstring Coverage

Explanation

No eligible functions found in the changed files. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 0 functions across 2 files. (1 skipped: 1 unsupported.)

Full details: Title check

Explanation

The title names the main change: the SM107 mid-forward path of the Cake RMSNorm-SiLU-gate training kernel now uses the L2-prefetching module, as the raw summary (cake_jit.py now serves sm_107a from the shared module, and the old sm_107a-only module is removed) and the PR objectives both describe. The 'perf' type prefix matches the stated goal of faster measured timings. The title is specific and short, and it does not describe anything missing from the changeset.

Finishing Touches
Generate unit tests (beta)
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share
Recent review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 3fb69628-d646-4d68-861d-fc7c73e18de7
Commits

Reviewing files that changed from the base of the PR and between bc4e12b and 80acbaf.

Files selected for processing: 5
  • flashinfer/cake_rmsnorm_silu_gate_train_backend/__init__.py
  • flashinfer/cake_rmsnorm_silu_gate_train_backend/build.json
  • flashinfer/cake_rmsnorm_silu_gate_train_backend/cake_jit.py
  • flashinfer/cake_rmsnorm_silu_gate_train_backend/csrc/cake_rmsnorm_silu_gate_train_b0eb3df9844d5b734850_binding.cu
  • flashinfer/cake_rmsnorm_silu_gate_train_backend/csrc/cake_rmsnorm_silu_gate_train_b0eb3df9844d5b734850_kernel.cu
Files with no reviewable changes: 2
  • flashinfer/cake_rmsnorm_silu_gate_train_backend/csrc/cake_rmsnorm_silu_gate_train_b0eb3df9844d5b734850_binding.cu
  • flashinfer/cake_rmsnorm_silu_gate_train_backend/csrc/cake_rmsnorm_silu_gate_train_b0eb3df9844d5b734850_kernel.cu

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 2 remain after this review.

@yyihuang yyihuang changed the title perf(cake_rmsnorm_silu_gate_train): L2-prefetching mid forward on SM107 perf(cake_rmsnorm_silu_gate): L2-prefetching mid forward on SM107 Nov 4, 2026
@yyihuang
yyihuang merged commit 9e97780 into flashinfer-ai:main Nov 4, 2026
28 of 29 checks passed
yyihuang added a commit that referenced this pull request Nov 4, 2026
… on SM103 (#8673)

This PR adds an extra-long forward tier on sm_103a to the
non-deterministic package of Cake's SiLU-gated RMSNorm training kernel
(`flashinfer.cake_rmsnorm_silu_gate_train` with `deterministic=False`).
From 3000 rows per SM, the sm_103a forward now runs
`cake_rmsnorm_silu_gate_train_7f014401d5cc855ab883`, and this route is
tried before the long forward's. The new module is a 256-thread forward
with the packed gate. In it, thread 0 also warms the CTA's next row
block in L2, the same way the mid forward warms its later blocks: one
bulk prefetch per tensor wherever the inputs x and z hold their rows
packed. All nine changed shapes in Table 1 are at or above 3000 rows per
SM on the 152-SM GB300.

The previous Cake baseline below is the long forward,
`cake_rmsnorm_silu_gate_train_7b7fac905aff1ddaa258`. It ran these inputs
before this PR, and it still runs sm_103a inputs from 2400 up to 3000
rows per SM. This PR removes no module. Every other module and route
runs the same code as before, including the backward, the short, mid and
long forwards, and every sm_100a and sm_107a route.

The PR is one commit on FlashInfer main after PR #8656. The A/B compared
two FlashInfer trees. In the first, there is no extra-long route, so the
long forward also serves 3000 rows per SM and up. The second is the same
tree plus this PR's sm_103a route. Both trees predate PR #8656, which
changed only the sm_107a mid forward. In the measured tree, the new
module's sources are byte-identical to this PR's.

A speedup is baseline us / new us, so a value above 1 means this PR is
faster. The table gives ranges (min-max) over the nine changed shapes of
Table 1 on GB300 (sm_103a, 152 SMs), CUDA 13.4.

| op | det Cake / new | strongest non-Cake / new | previous Cake / new
(A/B) |
|---|---|---|---|
| fwd | 1.134-1.164 | 1.061-1.133 | 1.039-1.050 |
| fwdg | 1.134-1.165 | 1.053-1.134 | 1.039-1.049 |
| bwdg | 1.114-1.147 | 1.091-1.115 | 0.9999-1.0002 |
| ckptg | 1.123-1.144 | 1.093-1.121 | 1.017-1.022 |
| stepg_f32 | 1.125-1.145 (A/B) | - | 1.017-1.021 |
| fwd + bwd | 1.129-1.143 (A/B) | - | 1.014-1.018 |

In the pre-registered A/B, the code changes in 36 cells (fwd, fwdg,
ckptg and stepg_f32 at the nine shapes), and new is faster than the
previous Cake route in all 36. bwdg and bwdg_f32 run the same code in
both trees. Neither the strongest non-Cake kernel (Table 1) nor the
deterministic Cake kernel (Tables 1 and 2) is faster than new on any
row. Every cell below 1x is a same-code cell against the previous Cake
route and is within 0.1 % of parity. "Cells below 1x" lists each one.

The kernel's other Cake variants are the deterministic package
`flashinfer.cake_rmsnorm_silu_gate_det_train` (the same API with
`deterministic=True`) and the FP32 weight-gradient output of the
non-deterministic package; both packages ship on sm_100a, sm_103a and
sm_107a, and this PR changes only the non-deterministic package's
forward on sm_103a from 3000 rows per SM.

## How the tables were measured

- Latency: CUPTI kernel time with cold L2, taken with FlashInfer's GPU
timer in `flashinfer.testing`. Inputs are BF16, and all times are in us.
- Table 1: the deterministic Cake kernel, the strongest non-Cake kernel
and new were measured in the same process. Each value is the median of
the per-round medians over 10 rounds.
- A/B values: the previous Cake and new (A/B) columns and all of Table 2
are medians of the pre-registered interleaved A/B, which ran 16
sequences and 160 processes. stepg_f32 has no same-process measurement,
so its deterministic Cake values also come from the A/B.
- Strongest non-Cake kernel per row: the fastest of the following, with
torch 2.14.1+cu130 and Triton 3.8.0.
  - FLA 0.6.0 `rms_norm_gated` (`fla.modules.fused_norm_gate`).
  - mamba_ssm v2.3.2 `rmsnorm_fn` (`layernorm_gated`).
- torch.compile in default and max-autotune-no-cudagraphs modes, best of
5 fresh compiles each. `#k` names the fastest compile.
- The inductor-generated persistent-reduction Triton kernel of the FP32
formula, launched directly.
- Deterministic Cake: `flashinfer.cake_rmsnorm_silu_gate_det_train`,
unchanged by this PR.
- Operations:
- `fwd` is one eager forward call, and `fwdg` is the forward replayed
from a CUDA graph.
- `bwdg` is the backward replayed from a CUDA graph, and `bwdg_f32` is
the same backward with an FP32 dw.
- `ckptg` is the checkpointed step (2 x forward + backward) in one CUDA
graph, and `stepg_f32` is the same step with an FP32 dw.
  - `fwd + bwd` is fwdg + bwdg, derived.
- In Table 2, the forward at the first nine shapes runs the new module.
7600x48, 9120x48 and 9499x48 are below 3000 rows per SM and run the same
code in both trees.

## Cells below 1x

- vs the strongest non-Cake kernel (Table 1): none.
- vs the deterministic Cake kernel (Tables 1 and 2): none.
- vs the previous Cake route (A/B), only at cells that run the same code
in both trees:
  - Table 1, bwdg: 9500x48 0.99996, 9975x48 0.9999
- Table 2, changed shapes (backward cells): 9500x48 bwdg 0.99996,
9975x48 bwdg 0.9999, 9975x48 bwdg_f32 0.9998, 19000x48 bwdg_f32 0.99996
- Table 2, same-code shapes: 7600x48 fwd 0.9999, 7600x48 ckptg 0.9995,
7600x48 bwdg_f32 0.9998, 7600x48 stepg_f32 0.9998, 9120x48 fwd 0.9999,
9120x48 ckptg 0.99996, 9120x48 stepg_f32 0.9998, 9499x48 fwdg 0.99999,
9499x48 bwdg_f32 0.9999
- The same-process run behind Table 1 also timed the previous Cake
route. Those times are not in the tables. Its bwdg previous / new, where
both routes run the same backward module, is below 1 at 9975x48 0.9997
(107.361 / 107.392 us), 11400x48 0.999 (118.688 / 118.752 us), 14250x48
0.9998 (146.497 / 146.529 us), 19000x48 0.999 (189.217 / 189.312 us) and
32737x48 0.9999 (316.057 / 316.097 us).

## Results on GB300 (sm_103a, 152 SMs)

- GPU: NVIDIA GB300, sm_103a, compute capability 10.3, 152 SMs, driver
580.159.03.
- CUDA: 13.4 (nvcc Build cuda_13.4.r13.4/compiler.38855100_0); PyTorch
2.14.1+cu130 (CUDA 13.0); Triton 3.8.0; Python 3.14.8.

### Table 1 (GB300, sm_103a, CUDA 13.4): new vs the deterministic Cake
kernel, the strongest non-Cake kernel and the previous Cake route

| T x H | op | det Cake us | strongest non-Cake us | strongest non-Cake
kernel | new us | previous Cake us (A/B) | new us (A/B) | det / new |
non-Cake / new | previous / new (A/B) |
|---|---|---|---|---|---|---|---|---|---|---|
| 9500x48 | fwd | 63.937 | 59.712 | torch.compile
max-autotune-no-cudagraphs #1 | 56.256 | 59.088 | 56.592 | 1.137 | 1.061
| 1.044 |
| 9500x48 | fwdg | 64.001 | 59.328 | torch.compile
max-autotune-no-cudagraphs #1 | 56.320 | 59.177 | 56.608 | 1.136 | 1.053
| 1.045 |
| 9500x48 | bwdg | 116.144 | 111.921 | FLA rms_norm_gated | 101.873 |
102.476 | 102.481 | 1.140 | 1.099 | 0.99996 |
| 9500x48 | ckptg | 238.009 | 231.377 | FLA rms_norm_gated | 211.617 |
215.305 | 211.424 | 1.125 | 1.093 | 1.018 |
| 9500x48 | stepg_f32 | 239.080 (A/B) | not measured | - | - | 215.240 |
211.644 | 1.130 (A/B) | n/a | 1.017 |
| 9975x48 | fwd | 68.000 | 63.856 | torch.compile
max-autotune-no-cudagraphs #2 | 59.008 | 61.489 | 58.817 | 1.152 | 1.082
| 1.045 |
| 9975x48 | fwdg | 68.216 | 63.840 | torch.compile
max-autotune-no-cudagraphs #2 | 59.145 | 61.569 | 58.964 | 1.153 | 1.079
| 1.044 |
| 9975x48 | bwdg | 121.408 | 117.809 | FLA rms_norm_gated | 107.392 |
107.409 | 107.417 | 1.131 | 1.097 | 0.9999 |
| 9975x48 | ckptg | 250.129 | 242.209 | FLA rms_norm_gated | 221.313 |
225.312 | 221.624 | 1.130 | 1.094 | 1.017 |
| 9975x48 | stepg_f32 | 249.065 (A/B) | not measured | - | - | 224.568 |
220.272 | 1.131 (A/B) | n/a | 1.020 |
| 10450x48 | fwd | 69.600 | 65.872 | torch.compile default #4 | 61.184 |
63.804 | 61.064 | 1.138 | 1.077 | 1.045 |
| 10450x48 | fwdg | 69.696 | 66.272 | torch.compile default #4 | 61.408
| 63.873 | 61.232 | 1.135 | 1.079 | 1.043 |
| 10450x48 | bwdg | 126.016 | 122.081 | FLA rms_norm_gated | 110.880 |
111.280 | 111.264 | 1.137 | 1.101 | 1.0001 |
| 10450x48 | ckptg | 259.129 | 253.009 | FLA rms_norm_gated | 230.737 |
234.784 | 230.616 | 1.123 | 1.097 | 1.018 |
| 10450x48 | stepg_f32 | 260.468 (A/B) | not measured | - | - | 235.060
| 231.064 | 1.127 (A/B) | n/a | 1.017 |
| 11400x48 | fwd | 75.841 | 71.649 | torch.compile default #1 | 66.624 |
69.601 | 66.608 | 1.138 | 1.075 | 1.045 |
| 11400x48 | fwdg | 75.873 | 72.097 | torch.compile default #1 | 66.736
| 69.712 | 66.840 | 1.137 | 1.080 | 1.043 |
| 11400x48 | bwdg | 136.161 | 132.464 | FLA rms_norm_gated | 118.752 |
118.656 | 118.656 | 1.147 | 1.115 | 1.000 |
| 11400x48 | ckptg | 281.393 | 274.785 | FLA rms_norm_gated | 247.633 |
252.912 | 247.816 | 1.136 | 1.110 | 1.021 |
| 11400x48 | stepg_f32 | 281.760 (A/B) | not measured | - | - | 252.896
| 247.976 | 1.136 (A/B) | n/a | 1.020 |
| 14250x48 | fwd | 93.856 | 87.329 | torch.compile
max-autotune-no-cudagraphs #1 | 80.624 | 84.385 | 80.384 | 1.164 | 1.083
| 1.050 |
| 14250x48 | fwdg | 94.000 | 87.889 | torch.compile
max-autotune-no-cudagraphs #1 | 80.704 | 84.481 | 80.496 | 1.165 | 1.089
| 1.049 |
| 14250x48 | bwdg | 166.017 | 161.336 | FLA rms_norm_gated | 146.529 |
146.320 | 146.320 | 1.133 | 1.101 | 1.000 |
| 14250x48 | ckptg | 346.897 | 337.257 | FLA rms_norm_gated | 303.441 |
309.408 | 303.016 | 1.143 | 1.111 | 1.021 |
| 14250x48 | stepg_f32 | 345.600 (A/B) | not measured | - | - | 309.401
| 303.148 | 1.140 (A/B) | n/a | 1.021 |
| 16384x48 | fwd | 106.257 | 103.825 | FLA rms_norm_gated | 91.617 |
95.752 | 91.384 | 1.160 | 1.133 | 1.048 |
| 16384x48 | fwdg | 106.368 | 103.968 | FLA rms_norm_gated | 91.713 |
95.849 | 91.488 | 1.160 | 1.134 | 1.048 |
| 16384x48 | bwdg | 184.561 | 181.889 | FLA rms_norm_gated | 165.473 |
165.861 | 165.853 | 1.115 | 1.099 | 1.00005 |
| 16384x48 | ckptg | 390.258 | 383.401 | FLA rms_norm_gated | 344.001 |
350.948 | 343.357 | 1.134 | 1.115 | 1.022 |
| 16384x48 | stepg_f32 | 391.796 (A/B) | not measured | - | - | 350.737
| 343.433 | 1.141 (A/B) | n/a | 1.021 |
| 19000x48 | fwd | 122.529 | 114.848 | torch.compile
max-autotune-no-cudagraphs #2 | 105.600 | 110.257 | 105.569 | 1.160 |
1.088 | 1.044 |
| 19000x48 | fwdg | 122.577 | 114.689 | torch.compile
max-autotune-no-cudagraphs #2 | 105.632 | 110.400 | 105.689 | 1.160 |
1.086 | 1.045 |
| 19000x48 | bwdg | 214.337 | 209.449 | FLA rms_norm_gated | 189.312 |
189.176 | 189.144 | 1.132 | 1.106 | 1.0002 |
| 19000x48 | ckptg | 453.474 | 440.353 | FLA rms_norm_gated | 396.322 |
404.440 | 396.276 | 1.144 | 1.111 | 1.021 |
| 19000x48 | stepg_f32 | 452.042 (A/B) | not measured | - | - | 404.200
| 396.216 | 1.141 (A/B) | n/a | 1.020 |
| 32737x48 | fwd | 205.408 | 192.161 | torch.compile
max-autotune-no-cudagraphs #5 | 176.511 | 183.425 | 176.529 | 1.164 |
1.089 | 1.039 |
| 32737x48 | fwdg | 205.441 | 192.217 | torch.compile
max-autotune-no-cudagraphs #3 | 176.544 | 183.601 | 176.656 | 1.164 |
1.089 | 1.039 |
| 32737x48 | bwdg | 354.705 | 348.737 | FLA rms_norm_gated | 316.097 |
316.376 | 316.360 | 1.122 | 1.103 | 1.0001 |
| 32737x48 | ckptg | 759.283 | 743.979 | FLA rms_norm_gated | 663.666 |
677.643 | 664.382 | 1.144 | 1.121 | 1.020 |
| 32737x48 | stepg_f32 | 760.154 (A/B) | not measured | - | - | 677.238
| 663.723 | 1.145 (A/B) | n/a | 1.020 |
| 16384x32 | fwd | 73.216 | 70.288 | torch.compile
max-autotune-no-cudagraphs #1 | 64.544 | 65.601 | 62.816 | 1.134 | 1.089
| 1.044 |
| 16384x32 | fwdg | 73.312 | 70.416 | torch.compile
max-autotune-no-cudagraphs #1 | 64.656 | 65.660 | 62.888 | 1.134 | 1.089
| 1.044 |
| 16384x32 | bwdg | 128.641 | 125.937 | FLA rms_norm_gated | 115.424 |
115.448 | 115.441 | 1.114 | 1.091 | 1.0001 |
| 16384x32 | ckptg | 268.505 | 262.737 | FLA rms_norm_gated | 238.816 |
242.144 | 238.000 | 1.124 | 1.100 | 1.017 |
| 16384x32 | stepg_f32 | 267.669 (A/B) | not measured | - | - | 242.037
| 237.872 | 1.125 (A/B) | n/a | 1.018 |

### Table 2 (GB300, sm_103a, CUDA 13.4): full step, previous Cake route
vs new (A/B medians)

| T x H | rows | op | previous Cake us | new us | previous / new | det
Cake us | det / new |
|---|---|---|---|---|---|---|---|
| 9500x48 | 456000 | fwd | 59.088 | 56.592 | 1.044 | 64.288 | 1.136 |
| 9500x48 | 456000 | fwdg | 59.177 | 56.608 | 1.045 | 64.416 | 1.138 |
| 9500x48 | 456000 | bwdg | 102.476 | 102.481 | 0.99996 | 116.784 |
1.140 |
| 9500x48 | 456000 | ckptg | 215.305 | 211.424 | 1.018 | 239.224 | 1.131
|
| 9500x48 | 456000 | bwdg_f32 | 102.444 | 102.433 | 1.0001 | 116.888 |
1.141 |
| 9500x48 | 456000 | stepg_f32 | 215.240 | 211.644 | 1.017 | 239.080 |
1.130 |
| 9500x48 | 456000 | fwd + bwd | 161.653 | 159.089 | 1.016 | 181.200 |
1.139 |
| 9975x48 | 478800 | fwd | 61.489 | 58.817 | 1.045 | 67.008 | 1.139 |
| 9975x48 | 478800 | fwdg | 61.569 | 58.964 | 1.044 | 67.072 | 1.138 |
| 9975x48 | 478800 | bwdg | 107.409 | 107.417 | 0.9999 | 121.312 | 1.129
|
| 9975x48 | 478800 | ckptg | 225.312 | 221.624 | 1.017 | 248.973 | 1.123
|
| 9975x48 | 478800 | bwdg_f32 | 107.380 | 107.400 | 0.9998 | 121.337 |
1.130 |
| 9975x48 | 478800 | stepg_f32 | 224.568 | 220.272 | 1.020 | 249.065 |
1.131 |
| 9975x48 | 478800 | fwd + bwd | 168.977 | 166.381 | 1.016 | 188.385 |
1.132 |
| 10450x48 | 501600 | fwd | 63.804 | 61.064 | 1.045 | 70.304 | 1.151 |
| 10450x48 | 501600 | fwdg | 63.873 | 61.232 | 1.043 | 70.368 | 1.149 |
| 10450x48 | 501600 | bwdg | 111.280 | 111.264 | 1.0001 | 126.480 |
1.137 |
| 10450x48 | 501600 | ckptg | 234.784 | 230.616 | 1.018 | 260.496 |
1.130 |
| 10450x48 | 501600 | bwdg_f32 | 111.216 | 111.208 | 1.0001 | 126.400 |
1.137 |
| 10450x48 | 501600 | stepg_f32 | 235.060 | 231.064 | 1.017 | 260.468 |
1.127 |
| 10450x48 | 501600 | fwd + bwd | 175.153 | 172.496 | 1.015 | 196.848 |
1.141 |
| 16384x32 | 524288 | fwd | 65.601 | 62.816 | 1.044 | 72.704 | 1.157 |
| 16384x32 | 524288 | fwdg | 65.660 | 62.888 | 1.044 | 72.769 | 1.157 |
| 16384x32 | 524288 | bwdg | 115.448 | 115.441 | 1.0001 | 128.564 |
1.114 |
| 16384x32 | 524288 | ckptg | 242.144 | 238.000 | 1.017 | 267.521 |
1.124 |
| 16384x32 | 524288 | bwdg_f32 | 115.468 | 115.464 | 1.00003 | 128.392 |
1.112 |
| 16384x32 | 524288 | stepg_f32 | 242.037 | 237.872 | 1.018 | 267.669 |
1.125 |
| 16384x32 | 524288 | fwd + bwd | 181.108 | 178.329 | 1.016 | 201.333 |
1.129 |
| 11400x48 | 547200 | fwd | 69.601 | 66.608 | 1.045 | 75.904 | 1.140 |
| 11400x48 | 547200 | fwdg | 69.712 | 66.840 | 1.043 | 75.976 | 1.137 |
| 11400x48 | 547200 | bwdg | 118.656 | 118.656 | 1.000 | 136.092 | 1.147
|
| 11400x48 | 547200 | ckptg | 252.912 | 247.816 | 1.021 | 281.797 |
1.137 |
| 11400x48 | 547200 | bwdg_f32 | 118.672 | 118.672 | 1.00001 | 136.136 |
1.147 |
| 11400x48 | 547200 | stepg_f32 | 252.896 | 247.976 | 1.020 | 281.760 |
1.136 |
| 11400x48 | 547200 | fwd + bwd | 188.369 | 185.496 | 1.015 | 212.068 |
1.143 |
| 14250x48 | 684000 | fwd | 84.385 | 80.384 | 1.050 | 93.344 | 1.161 |
| 14250x48 | 684000 | fwdg | 84.481 | 80.496 | 1.049 | 93.472 | 1.161 |
| 14250x48 | 684000 | bwdg | 146.320 | 146.320 | 1.000 | 165.857 | 1.134
|
| 14250x48 | 684000 | ckptg | 309.408 | 303.016 | 1.021 | 345.804 |
1.141 |
| 14250x48 | 684000 | bwdg_f32 | 146.176 | 146.168 | 1.0001 | 165.848 |
1.135 |
| 14250x48 | 684000 | stepg_f32 | 309.401 | 303.148 | 1.021 | 345.600 |
1.140 |
| 14250x48 | 684000 | fwd + bwd | 230.801 | 226.816 | 1.018 | 259.329 |
1.143 |
| 16384x48 | 786432 | fwd | 95.752 | 91.384 | 1.048 | 106.769 | 1.168 |
| 16384x48 | 786432 | fwdg | 95.849 | 91.488 | 1.048 | 106.904 | 1.169 |
| 16384x48 | 786432 | bwdg | 165.861 | 165.853 | 1.00005 | 184.792 |
1.114 |
| 16384x48 | 786432 | ckptg | 350.948 | 343.357 | 1.022 | 391.417 |
1.140 |
| 16384x48 | 786432 | bwdg_f32 | 165.744 | 165.721 | 1.0001 | 184.824 |
1.115 |
| 16384x48 | 786432 | stepg_f32 | 350.737 | 343.433 | 1.021 | 391.796 |
1.141 |
| 16384x48 | 786432 | fwd + bwd | 261.709 | 257.341 | 1.017 | 291.696 |
1.134 |
| 19000x48 | 912000 | fwd | 110.257 | 105.569 | 1.044 | 121.984 | 1.156
|
| 19000x48 | 912000 | fwdg | 110.400 | 105.689 | 1.045 | 122.048 | 1.155
|
| 19000x48 | 912000 | bwdg | 189.176 | 189.144 | 1.0002 | 214.192 |
1.132 |
| 19000x48 | 912000 | ckptg | 404.440 | 396.276 | 1.021 | 452.058 |
1.141 |
| 19000x48 | 912000 | bwdg_f32 | 189.128 | 189.136 | 0.99996 | 214.016 |
1.132 |
| 19000x48 | 912000 | stepg_f32 | 404.200 | 396.216 | 1.020 | 452.042 |
1.141 |
| 19000x48 | 912000 | fwd + bwd | 299.576 | 294.832 | 1.016 | 336.240 |
1.140 |
| 32737x48 | 1571376 | fwd | 183.425 | 176.529 | 1.039 | 206.593 | 1.170
|
| 32737x48 | 1571376 | fwdg | 183.601 | 176.656 | 1.039 | 206.609 |
1.170 |
| 32737x48 | 1571376 | bwdg | 316.376 | 316.360 | 1.0001 | 354.253 |
1.120 |
| 32737x48 | 1571376 | ckptg | 677.643 | 664.382 | 1.020 | 760.275 |
1.144 |
| 32737x48 | 1571376 | bwdg_f32 | 316.552 | 316.536 | 1.0001 | 354.101 |
1.119 |
| 32737x48 | 1571376 | stepg_f32 | 677.238 | 663.723 | 1.020 | 760.154 |
1.145 |
| 32737x48 | 1571376 | fwd + bwd | 499.977 | 493.017 | 1.014 | 560.862 |
1.138 |
| 7600x48 | 364800 | fwd | 48.416 | 48.421 | 0.9999 | 52.320 | 1.081 |
| 7600x48 | 364800 | fwdg | 48.448 | 48.448 | 1.000 | 52.448 | 1.083 |
| 7600x48 | 364800 | bwdg | 82.784 | 82.784 | 1.000003 | 97.112 | 1.173
|
| 7600x48 | 364800 | ckptg | 175.881 | 175.969 | 0.9995 | 195.777 |
1.113 |
| 7600x48 | 364800 | bwdg_f32 | 82.849 | 82.868 | 0.9998 | 97.148 |
1.172 |
| 7600x48 | 364800 | stepg_f32 | 175.988 | 176.024 | 0.9998 | 195.824 |
1.112 |
| 7600x48 | 364800 | fwd + bwd | 131.232 | 131.232 | 1.000002 | 149.560
| 1.140 |
| 9120x48 | 437760 | fwd | 56.528 | 56.536 | 0.9999 | 62.016 | 1.097 |
| 9120x48 | 437760 | fwdg | 56.496 | 56.496 | 1.000 | 62.208 | 1.101 |
| 9120x48 | 437760 | bwdg | 97.480 | 97.480 | 1.000003 | 112.860 | 1.158
|
| 9120x48 | 437760 | ckptg | 207.985 | 207.993 | 0.99996 | 230.096 |
1.106 |
| 9120x48 | 437760 | bwdg_f32 | 97.552 | 97.544 | 1.0001 | 112.752 |
1.156 |
| 9120x48 | 437760 | stepg_f32 | 207.868 | 207.904 | 0.9998 | 230.137 |
1.107 |
| 9120x48 | 437760 | fwd + bwd | 153.977 | 153.977 | 1.000002 | 175.067
| 1.137 |
| 9499x48 | 455952 | fwd | 59.344 | 59.320 | 1.0004 | 63.952 | 1.078 |
| 9499x48 | 455952 | fwdg | 59.424 | 59.424 | 0.99999 | 64.128 | 1.079 |
| 9499x48 | 455952 | bwdg | 102.336 | 102.320 | 1.0002 | 116.840 | 1.142
|
| 9499x48 | 455952 | ckptg | 215.769 | 215.741 | 1.0001 | 238.488 |
1.105 |
| 9499x48 | 455952 | bwdg_f32 | 102.328 | 102.336 | 0.9999 | 116.664 |
1.140 |
| 9499x48 | 455952 | stepg_f32 | 214.561 | 214.540 | 1.0001 | 238.336 |
1.111 |
| 9499x48 | 455952 | fwd + bwd | 161.760 | 161.745 | 1.0001 | 180.968 |
1.119 |


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

<!-- coderabbit-ai-generated:v1 -->

## Summary by CodeRabbit

* **New Features**
  * Added support for RMSNorm with SiLU gating in training workflows.
* On sm_103a, large inputs with at least 3,000 rows per SM now use an
extra-long forward path. This path follows the same launch-grid behavior
as the long forward path and can prefetch the next row block.
* **Bug Fixes**
* Improved handling of forward-path selection around the extra-long
threshold.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->

Co-authored-by: Yingyi Huang <averyh@nvidia.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants