Skip to content

perf(cake_mxfp8_megamoe_ep16): sm_107a CuTe-DSL fused programs read the peer tables from shared memory - #8971

Merged
yyihuang merged 1 commit into
flashinfer-ai:mainfrom
yyihuang:cake-6032-s17-sm107-peer-smem
Nov 6, 2026
Merged

yyihuang merged 1 commit into
flashinfer-ai:mainfrom
yyihuang:cake-6032-s17-sm107-peer-smem

Conversation

@yyihuang

@yyihuang yyihuang commented Nov 6, 2026

Copy link
Copy Markdown
Collaborator

cake_mxfp8_megamoe_ep16 is the fused MoE kernel with BF16 activations and MXFP8 weights for 16-way expert parallelism (EP16). It has a CUDA backend and a CuTe-DSL backend. Each backend has three programs per architecture: the fused kernel, the fused kernel with the return-all-CTA config, and the top-k reduce. This PR changes only the two sm_107a CuTe-DSL fused programs (CTA-0 and return-all-CTA).

Compared with the CuTe-DSL backend on current main (the previous Cake version), EP16 on VR200 runs 1.010–1.013× faster in both launch modes.

Table. NVIDIA Vera Rubin NVL72 (VR200, sm_107a, 212 SMs per GPU), 16 GPUs (4 nodes × 4 GPUs in one NVLink rack, IMEX), driver 620.62, CUDA 13.0, PyTorch 2.14.1+cu130, CuTe-DSL (nvidia-cutlass-dsl) 4.8.1. Latency is one eager EP16 forward with a cold (flushed) L2, timed with CUDA events. A round value is the maximum over ranks of the per-rank median of 40 iterations. Each table value is the median over 32 rounds: 16 rounds load the baseline first, 16 load this PR first, and sessions are recreated each round. The baseline is the CuTe-DSL backend on current main, and Speedup = baseline / this PR. In "Pre-sleep" mode, a GPU sleep of 1e6 cycles precedes each launch. In "Back-to-back" mode, launches run with no sleep. T is tokens per rank. balanced routing spreads routes evenly across experts, and hotset50 sends half of the routes to a hot set of experts. p is an exact one-sided Mann-Whitney U test on the per-round results, with "this PR faster" as the alternative. With 32 vs 32 rounds, 5.46e-19 is the smallest possible value; it means this PR was faster in every round.

Launch mode T Routing Baseline (µs) This PR (µs) Speedup p (one-sided MWU)
Pre-sleep 16 balanced 181.51 179.54 1.011× 1.09e-18
Pre-sleep 16 hotset50 181.44 179.35 1.012× 5.46e-19
Pre-sleep 32 balanced 182.26 180.46 1.010× 5.46e-19
Pre-sleep 32 hotset50 183.34 180.93 1.013× 5.46e-19
Pre-sleep 64 balanced 183.26 181.31 1.011× 5.46e-19
Pre-sleep 64 hotset50 185.04 182.59 1.013× 5.46e-19
Back-to-back 16 balanced 181.34 179.48 1.010× 5.46e-19
Back-to-back 16 hotset50 181.55 179.14 1.013× 3.98e-15
Back-to-back 32 balanced 181.85 180.13 1.010× 9.82e-18
Back-to-back 32 hotset50 182.93 180.90 1.011× 7.59e-14
Back-to-back 64 balanced 183.05 181.18 1.010× 5.46e-19
Back-to-back 64 hotset50 184.88 182.42 1.013× 2.18e-18

The CUDA backend, the sm_100a and sm_103a CuTe-DSL programs, and the top-k reduce programs are unchanged; the family ships on sm_100a, sm_103a and sm_107a.

…he peer tables from shared memory

The sm_107a fused programs (CTA-0 and return-all-CTA) read five by-value
peer-pointer tables at a runtime rank. CuTe-DSL lowers each such read to a
31-deep select chain over the table slots, which ptxas turns into long runs
of predicated constant loads on the publication critical path.

As on sm_103a (flashinfer-ai#8735), each CTA now copies the 16 slots of these tables
into 640 bytes of shared memory during setup, before the existing CTA
barrier, and the route push, row push, rank flags and FC2 route-term
lookups read the slot from shared memory. Pointer values and outputs are
unchanged (bitwise identical to the CUDA backend). The sm_100a and sm_103a
programs, the top-k reduce programs and the CUDA backend are unchanged.
@yyihuang

yyihuang commented Nov 6, 2026

Copy link
Copy Markdown
Collaborator Author

@flashinfer-bot run tests/experimental/test_cake_mxfp8_megamoe_ep16.py

@coderabbitai

coderabbitai Bot commented Nov 6, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Review was skipped because the changed files are too large to review.

📏 Files whose diffs exceed the per-file size limit: 2

  • flashinfer/experimental/cake_mxfp8_megamoe_ep16/csrc/cake_mxfp8_megamoe_ep16/cute/cake_mxfp8_megamoe_ep16_fused_sm_107a.py
  • flashinfer/experimental/cake_mxfp8_megamoe_ep16/csrc/cake_mxfp8_megamoe_ep16/cute/cake_mxfp8_megamoe_ep16_fused_return_all_cta_sm_107a.py

Retrying the review will skip these files again. If they are generated content such as fixtures or snapshots, exclude them with reviews.path_filters (for example !**/fixtures/**).

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: a1c6c0e8-a0d7-4e27-b3cb-5baa0da56e10
Commits

Reviewing files that changed from the base of the PR and between 4c2b8a7 and 67814de.

Files selected for processing: 2

  • flashinfer/experimental/cake_mxfp8_megamoe_ep16/csrc/cake_mxfp8_megamoe_ep16/cute/cake_mxfp8_megamoe_ep16_fused_return_all_cta_sm_107a.py
  • flashinfer/experimental/cake_mxfp8_megamoe_ep16/csrc/cake_mxfp8_megamoe_ep16/cute/cake_mxfp8_megamoe_ep16_fused_sm_107a.py

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

  • 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

@yzh119 yzh119 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Worth a quick check that the smem allocation covers 160768 + 640 bytes, and that a barrier sits between the table fill and the first read.

@yyihuang
yyihuang enabled auto-merge (squash) November 6, 2026 13:41
@yyihuang
yyihuang merged commit d52713e into flashinfer-ai:main Nov 6, 2026
24 of 33 checks passed
yyihuang pushed a commit to yyihuang/flashinfer that referenced this pull request Nov 6, 2026
…ashinfer-ai#8972, mega_moe_v3) into cake-lm-head-nondet-train

Resolve tests/test_helpers/cake_package.py: keep this branch's LM-head
det/nondet PACKAGES rows and the dense GEMM det/nondet rows from flashinfer-ai#8926.
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