Repository navigation
perf(cake_rmsnorm_silu_gate_train): L2-prefetching extra-long forward on SM107 - #8701
Conversation
…the long forward on SM107 With deterministic=False, on sm_107a from 1740 rows per SM (the long forward's start there) the forward runs the long forward's program 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: the extra-long tier (role fwd_xlong) that sm_103a runs from 3000 rows per SM, in place of the long forward on sm_107a. Every other route, grid, threshold and architecture is unchanged, and y stays bitwise equal to the deterministic forward (a prefetch writes no register and no memory). cake_jit: the extra-long forward record on sm_103a and sm_107a (from 3000 and 1740 rows per SM), its sm_107a route in place of the long forward's, and the long forward record without sm_107a. The tests cover the extra-long tier's start, routes, grid and stall behavior on both architectures; the docs name it.
|
@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 |
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
yzh119
left a comment
There was a problem hiding this comment.
LGTM, one nit: LONG_FORWARD_ROWS_PER_SM in test_cake_rmsnorm_silu_gate_train_api.py still lists sm_107a: 1740 though that arch has no long forward now. Check that nothing still reads it for sm_107a.
flashinfer-bot
left a comment
There was a problem hiding this comment.
CODEOWNERS gap attestation (not a code review).
A code owner of a changed path has approved this PR:
- @yzh119 -> tests/norm/test_cake_rmsnorm_silu_gate_train_api.py
- @yzh119 -> tests/norm/test_cake_rmsnorm_silu_gate_train.py
- @yzh119 -> tests/norm/test_cake_rmsnorm_silu_gate_train_stall.py
The following files match only the catch-all rule; this approval covers that technical gap under the one-approval policy. GitHub still requires each owned path's own owner.
- 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/init.py
Head: 10c6017
This PR changes which module runs the sm_107a forward in the non-deterministic package of Cake's SiLU-gated RMSNorm training kernel (
flashinfer.cake_rmsnorm_silu_gate_trainwithdeterministic=False). From 1740 rows per SM, the sm_107a forward now runscake_rmsnorm_silu_gate_train_7f014401d5cc855ab883. This is the L2-prefetching 256-thread forward with the packed gate, which PR #8673 added for sm_103a from 3000 rows per SM. On sm_107a, the new route takes over the whole range the long forward used to serve, so the long forward no longer runs on that architecture. All eight changed shapes in Table 1 are at or above 1740 rows per SM on the 212-SM R200.The previous Cake baseline below is the long forward,
cake_rmsnorm_silu_gate_train_7b7fac905aff1ddaa258, which ran these inputs on sm_107a before this PR. This PR adds no kernel source. It builds the existing module for sm_107a and drops the long forward's sm_107a build, which no sm_107a input reaches any more. The long forward still ships on sm_100a and sm_103a. Every other module and route runs the same code as before, including the backward, every sm_107a forward below 1740 rows per SM, and every sm_100a and sm_103a route.The PR is one commit on FlashInfer main after PR #8673. The A/B compared two FlashInfer trees. In the first, the long forward serves sm_107a from 1740 rows per SM. The second is the same tree plus this PR's sm_107a route. On sm_107a, this PR's routes, library entries and kernel sources are identical to those of the measured second tree.
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 eight changed shapes of Table 1 on R200 (VR200 node; nvidia-smi name NVIDIA Graphics Device), sm_107a, 212 SMs, CUDA 13.4.
In the pre-registered A/B, the code changes in 32 cells (fwd, fwdg, ckptg and stepg_f32 at the eight shapes), and new is faster than the previous Cake route in all 32. bwdg and bwdg_f32 run the same code in both trees. The strongest non-Cake kernel is not faster than new on any row of Table 1. The deterministic Cake kernel is faster than new in one cell: 1031x48 fwdg in Table 2 (det / new 0.996). That shape is below 1740 rows per SM, and this PR does not change its forward. Every cell below 1x against the previous Cake route is in a cell that runs the same code in both trees. "Cells below 1x" lists each one.
The kernel has two other Cake variants: the deterministic package
flashinfer.cake_rmsnorm_silu_gate_det_train(the same API withdeterministic=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_107a from 1740 rows per SM.How the tables were measured
flashinfer.testing. Inputs are BF16, and all times are in us.rms_norm_gated.rms_norm_gated(fla.modules.fused_norm_gate).rmsnorm_fn(layernorm_gated).flashinfer.cake_rmsnorm_silu_gate_det_train, unchanged by this PR.fwdis one eager forward call, andfwdgis the forward replayed from a CUDA graph.bwdgis the backward replayed from a CUDA graph, andbwdg_f32is the same backward with an FP32 dw.ckptgis the checkpointed step (2 x forward + backward) in one CUDA graph, andstepg_f32is the same step with an FP32 dw.fwd + bwdis fwdg + bwdg, derived.Cells below 1x
Results on R200 (sm_107a, 212 SMs)
Table 1 (R200, VR200 node, sm_107a, CUDA 13.4): new vs the deterministic Cake kernel, the strongest non-Cake kernel and the previous Cake route
Rows where the strongest non-Cake kernel beats new: none.
Table 2 (R200, VR200 node, sm_107a, CUDA 13.4): full step, previous Cake route vs new (A/B medians)
Summary by CodeRabbit
Performance Improvements
Documentation
Tests