Skip to content

[Feat] [NVIDIA] flashinfer_megamoe: SM120 prefill support with FlashInfer's cake MegaMoE backend (DeepSeek-V4-Flash) - #44359

Open
GnohzZ wants to merge 2 commits into
sgl-project:mainfrom
GnohzZ:cake-sm120-flashinfer-megamoe
Open

GnohzZ wants to merge 2 commits into
sgl-project:mainfrom
GnohzZ:cake-sm120-flashinfer-megamoe

Conversation

@GnohzZ

@GnohzZ GnohzZ commented Oct 15, 2026 •

Copy link
Copy Markdown

Co-authors: @jychen21 @AichenF
Submitted by: @GnohzZ

Dependency scope: opt-in, experimental SM120 support. It needs FlashInfer 0.7.3 or later, the first release containing flashinfer-ai/flashinfer#6346; main pins flashinfer_python==0.7.4, so no dependency change is needed. With an older FlashInfer, selecting SM120 MegaMoE fails at startup with an explicit error, and the regular SM120 backend remains available. The kernel is JIT-compiled against NCCL's Device API and currently requires NCCL 2.30.7 (nvidia-nccl-cu13==2.30.7); the SGLang Docker images now install a newer NCCL for DeepEP, which this path does not use (see Validation). Rebased onto main 219ca7b082.

Motivation

--moe-a2a-backend flashinfer_megamoe currently requires SM100. FlashInfer #6346 added sm120_mxfp4_mxfp8_bf16_cake, a fused EP all-to-all + MXFP4 x MXFP8 expert-compute kernel for SM120 (RTX PRO Blackwell) that runs through the same flashinfer.moe_ep.MoEEpMegaLayer API this backend already uses. This PR wires it into the existing flashinfer_megamoe path for FP4-expert checkpoints, starting with DeepSeek-V4-Flash.

The kernel targets prefill. On 4x RTX PRO 5000 Blackwell (72 GB, PCIe) it roughly doubles prefill throughput over --moe-runner-backend flashinfer_mxfp4 at the same TP4 / attention-DP4 layout, while decode with a few requests per rank is slower (numbers below). The recommended use is the prefill server of a PD-disaggregated deployment, with decode on the existing SM120 recipe; the server logs this at startup when it is not a PD prefill server.

Modifications

  1. SM120 branch of flashinfer_megamoe (layers/moe/flashinfer_megamoe.py, arg_groups/moe_hook.py, environ.py); SM100 code paths are unchanged:
    • Platform gate: SM120 with compute capability exactly 12.0, FP4 experts, EP >= 2, and a FlashInfer build exporting Sm120_Mxfp4_Mxfp8_Bf16_Cake_MegaMoeConfig, i.e. >= 0.7.3 (clear error otherwise). --enable-eplb is rejected (the packed scales are not expert-major); speculative decoding without an explicit --speculative-moe-runner-backend is rejected (the default draft runner flashinfer_trtllm is SM100-only).
    • NCCL_CUMEM_ENABLE=1 by default on this path: the kernel joins the EP group's NCCL communicator through NCCL's Device API, which needs cuMem buffers (SGLang otherwise sets it to 0). Same pattern as the deepep_v2 branch.
    • Weights: FlashInfer's own preprocessing (preprocess_sm120_mxfp4_mxfp8_cake_mega_weights). FC1 is a gate/up row interleave of w13 and is written back into w13; FC1/FC2 alias the layer weights, so the experts stay resident once. The float32 (E8M0-widened) checkpoint scales are converted exactly to UE8M0 bytes and replaced by the packed kernel scales.
    • Forward: one workspace per layer; each call stages compile_tokens_per_rank = max(get_dp_global_num_tokens()), identical on every EP rank, so there is no per-layer routing all-gather / host sync, and each decode CUDA-graph batch size captures its own bucket. MegaMoeTunedForward is not used on SM120 (it would build one compiled kernel + NCCL window set per profiled capacity). Router ids are widened to int64 for this kernel.
    • SGLANG_FLASHINFER_MEGAMOE_SM120_TRANSPORT_TABLE (default lsa_where_reachable) selects the peer transport; FlashInfer validates the value.
  2. Docs: DeepSeek-V4 cookbook, new "FlashInfer MegaMoE on SM120 for prefill (Experimental)" note.

Earlier revisions of this PR also changed deepseek_v2.py (expert-id remapping under static placement) and deepseek_v4.py (MoE output finalization for flashinfer_megamoe); upstream #44994 and #46365 now cover both, so they were dropped and this PR touches no model code or tests.

Validation of the current revision (on main 219ca7b082, 2026-11-27; the GPU runs used main c269302, where this PR's files and pyproject.toml are identical. Official image lmsysorg/sglang:nightly-dev-cu13-20261122-e96e9675: FlashInfer 0.7.4 with its flashinfer-cubin / flashinfer-jit-cache packages, torch 2.14.1+cu130, no FlashInfer source build): pre-commit passed for all changed files (the Cookbook command export leaves python/sglang/cli/_commands/ unchanged); existing CPU suites (V4 boundary, layer boundary, FlashInfer MegaMoE, server args, model overrides, runtime context, MXFP8 runner backend): 1375 passed. GPU on 4x RTX PRO 5000 Blackwell (TP4 / attention-DP4 on GPUs 0-3, one CPU socket, decode CUDA graphs on), GSM8K-200 (run_eval, 5-shot) after a 4-prompt smoke, no tracebacks in the server logs:

config GSM8K-200
--moe-runner-backend flashinfer_mxfp4 (baseline) 0.990
--moe-a2a-backend flashinfer_megamoe (this PR) 0.985
this PR + --init-expert-location <recording> --ep-num-redundant-experts 32 --ep-dispatch-algorithm static 0.985

The image ships nvidia-nccl-cu13==2.31.2 (for DeepEP), and FlashInfer's SM120 kernel refuses it at startup with an explicit error, so the two flashinfer_megamoe rows ran with the image's NCCL replaced by 2.30.7 (the baseline row used the image as is). Supporting newer NCCL releases is a FlashInfer-side follow-up.

Prefill spot check on the same revision (--disable-radix-cache, ISL 2048, OSL 1, concurrency 64, 256 prompts, seeds 101-103 after a cold run): 23973 / 23994 / 24004 input tok/s, mean TTFT 4.97 s, within about 0.5 % of the 24085 tok/s measured for this point on the earlier revision below.

SM100 was not re-tested (no hardware here); this PR does not change the SM100 code paths.

Earlier measurements. The accuracy, speed and topology results below were collected on an earlier revision of this PR; the SM120 runtime code (weight preprocessing, forward, kernel config) is unchanged since, and later revisions only removed startup checks, tests and model-code changes now covered upstream. Environment: one host, 8x NVIDIA RTX PRO 5000 Blackwell 72 GB (SM120, PCIe, two CPU sockets), driver 580.95.05; image lmsysorg/sglang:dev-cu13 built 2026-10-13 (CUDA 13.0, torch 2.14.1+cu130, NCCL 2.30.7, nvidia-cutlass-dsl 4.8.0) with this branch on top of 27b68303d0 and FlashInfer main 399b6c1d (#6346) from source; model deepseek-ai/DeepSeek-V4-Flash-0731; sgl-eval 0.1.2. Unless noted: --tp 4 --attn-dp-size 4 on GPUs 0-3.

Accuracy Tests

DeepSeek-V4-Flash (0731), 4x RTX PRO 5000 Blackwell 72 GB (PCIe), --tp 4 --attn-dp-size 4.

GSM8K-1319 (sgl-eval run gsm8k --load-preset-from-model-id deepseek-ai/DeepSeek-V4-Flash-0731, sgl-eval 0.1.2: the model's preset, thinking on, temperature 1.0, top-p 0.95, max_tokens 200000, reasoning_effort=max):

config score truncated error
--moe-runner-backend flashinfer_mxfp4 (baseline) 96.59 % 0 % 0 %
--moe-a2a-backend flashinfer_megamoe (this PR) 96.13 % 0 % 0 %

GPQA-diamond (sgl-eval run gpqa --from-dataset <gpqa_diamond.jsonl> --load-preset-from-model-id deepseek-ai/DeepSeek-V4-Flash-0731 --n-repeats 4, sgl-eval 0.1.2, 198 questions x 4 repeats). Both arms used the model preset: temperature 1.0, top-p 0.95, max_tokens 200000, reasoning_effort=max, and chat_template_kwargs={"thinking": true}.

config pass@1 (avg of 4) repeat-level SEM pass@4 majority@4 truncated error
flashinfer_mxfp4 90.28 % 0.56 % 93.94 % 90.15 % 0.00 % 0.00 %
flashinfer_megamoe 90.15 % 0.44 % 93.94 % 90.66 % 0.00 % 0.00 %

These results replace the earlier temperature-0 / 32k-cap run. Scores were independently recomputed from all 792 outputs per arm. The SEM is across four repeats of the same 198 questions; it is not a confidence interval over independently sampled questions or a formal equivalence test.

AIME25 (the fixture shared with the DeepSeek-V4 cookbook tests in test/manual/dsv4/, run locally with the cookbook recipe: sgl-eval, 30 x 16 repeats, thinking on, temperature 1.0, top-p 1.0, --max-tokens 65536): pass@1 = 98.1 % (SEM 0.5 %), pass@16 = 100 %, no truncation, threshold 0.93. The GSM8K smoke of the same fixture passes as well.

Static EPLB (a recording of V4-Flash routing, --init-expert-location <file> --ep-dispatch-algorithm static, no --enable-eplb) on this PR's backend (earlier revision, which carried a remap fix now covered upstream by #44994); GSM8K-200 via the deprecated sglang.test.run_eval (5-shot), run before upstream moved to sgl-eval:

config GSM8K-200 pf1k input tok/s ShareGPT input tok/s
this PR, no EPLB 0.990 26109 1561
this PR, recorded placement, 0 redundant experts 0.990 25013 1507
this PR, recorded placement, 32 redundant experts 0.990 25633 1453

(The no-EPLB reference is the median of three rounds; the recorded-placement rows are single rounds. They demonstrate functional correctness, not a controlled estimate of remapping overhead.) On the current revision, where the remap comes from upstream #44994, the 32-redundant-expert configuration gives GSM8K-200 = 0.990 (validation table above).

PD-disaggregated functional check (cake prefill server on GPUs 0-3 with --disaggregation-mode prefill, flashinfer_mxfp4 decode server on GPUs 4-7, NIXL/UCX KV transfer over RoCE, sglang_router --pd-disaggregation): coherent smoke answers and GSM8K-200 = 0.990 (run_eval) in two separate runs. (In the second run one request hit the 300 s disaggregation bootstrap timeout before its prefill started.) PD throughput was not measured.

Speed Tests and Profiling

Same setup; --chunked-prefill-size 16384 --max-prefill-tokens 4096 (4096 prefill tokens per rank), --mem-fraction-static 0.8, decode CUDA graphs on (prefill CUDA graphs are disabled for DeepSeek-V4 by SGLang's own rule), sglang.benchmark.serving --dataset-name random-ids. Prefill: a dedicated rerun on 2026-10-15 with radix cache disabled, three rounds per point, all three backends on the same production tree. Decode: the earlier c7 session on the same production tree, one round per point; GSM8K-200 (sgl-eval preset) in that session: 96.5 % / 97.0 % / 97.0 %.

Prefill (OSL 1, --max-concurrency 64, --disable-radix-cache), input tokens/s (TTFT mean / median / P99, ms). Both baselines run W4A8 (MXFP4 weights x MXFP8 activations, FlashInfer CUTLASS fused MoE) with the tokens all-gathered over attention DP and reduce-scattered after the MoE; --ep-size 4 places whole experts per rank like this PR:

ISL flashinfer_mxfp4, TP MoE flashinfer_mxfp4, EP4 flashinfer_megamoe vs TP / vs EP4
512 12125 (2669 / 2630 / 3670) 13853 (2334 / 2279 / 3243) 24174 (1336 / 1291 / 1982) 1.99x / 1.75x
1024 12332 (5126 / 5289 / 6301) 14165 (4462 / 4603 / 5483) 25106 (2518 / 2583 / 3121) 2.04x / 1.77x
2048 12101 (9861 / 10774 / 11961) 13854 (8611 / 9411 / 10469) 24085 (4950 / 5367 / 6086) 1.99x / 1.74x
4096 11935 (17502 / 21537 / 23239) 13644 (15287 / 18821 / 20285) 23400 (8923 / 10887 / 11918) 1.96x / 1.72x

In this serving configuration, EP4 improves the baseline by about 1.14-1.15x and the MegaMoE backend is 1.72-1.77x faster than that EP4 baseline (1.96-2.04x over TP MoE). This comparison measures the complete backend, including communication and integration; it does not isolate kernel fusion alone.

Each prefill round has 524288 requested input tokens (num-prompts = 524288 / ISL), request rate infinity, concurrency 64, temperature 0, and client seeds 101, 102 and 103; a separate cold run is excluded. The server uses --disable-radix-cache and each benchmark passes --flush-cache. All 36 measured runs completed every request without errors; all output lengths are one token. The table reports medians of three run-level metrics (including run-level P99s), not pooled request percentiles. The largest per-point throughput range (max-min)/median across the three rounds was 0.8% / 0.6% / 3.1% for TP / EP4 / MegaMoE respectively. The runs were sequential on one host, so these are synthetic serving measurements, not a PD throughput or kernel microbenchmark result.

Decode uses seed 42, concurrency 4/16/64/256 and 32/32/128/512 requests respectively; all measured output lengths are 1024 tokens. These earlier decode runs retained radix caching and did not explicitly flush between cases.

Decode (ISL 128 / OSL 1024, ignore_eos), median TPOT (ms):

concurrency (req/rank) flashinfer_mxfp4, TP MoE flashinfer_mxfp4, --ep-size 4 this PR
4 (1) 15.4 16.0 21.6
16 (4) 21.0 22.0 27.1
64 (16) 33.4 33.4 37.0
256 (64) 61.7 60.9 60.2

Hence the prefill positioning. Decode CUDA graphs capture one bucket per batch size: with --disable-cuda-graph the median TPOT of this PR is 65.1 / 62.6 / 62.9 ms at concurrency 4 / 16 / 64 (mxfp4: 66.3 / 65.4 / 66.6 ms).

Topology (supplementary, historical cache-enabled runs). The kernel picks a per-peer transport, so the mix of transports depends on the host topology: NCCL LSA (CUDA peer access over PCIe/NVLink) where peers can reach each other and NCCL GIN (GPU-initiated RDMA over the NIC) elsewhere. SGLANG_FLASHINFER_MEGAMOE_SM120_TRANSPORT_TABLE selects the table. Prefill, OSL 1, --max-concurrency 128, input tokens/s for ISL 2048 / 4096:

cake layout GPUs flashinfer_mxfp4 (TP MoE, EP=1) this PR, lsa_where_reachable (default) this PR, all_gin
TP4 / attn-DP4 / EP4 0-3, one CPU socket 12126 / 12130 24283 / 23629 (2.00x / 1.95x) 24563 / 23967 (2.03x / 1.98x)
TP8 / attn-DP8 / EP8 0-7, two CPU sockets 13578 / 14855 40690 / 42221 (3.00x / 2.84x) 41629 / 44673 (3.07x / 3.01x)

At EP8 the two sockets have no CUDA peer path between them, so the default table runs LSA for the 24 directed off-diagonal peer pairs inside the sockets and GIN for the 32 directed pairs across sockets (56 off-diagonal pairs in total); an all-LSA table is not possible on this host. At EP8 this PR needed --mem-fraction-static 0.70 on these 72 GB GPUs (at 0.80 the first MegaMoE launch ran out of memory); the EP8 rows of both backends use 0.70. GSM8K-200 (run_eval) was 0.985-0.990 in every layout.

The headline prefill and decode tables above all use GPUs 0-3 on one CPU socket, where every peer pair uses LSA (PCIe P2P) and no pair uses GIN. On a host where all 8 GPUs can reach each other (for example a single NUMA node with every pair under PHB, cudaDeviceCanAccessPeer true for all pairs), the default table runs all 56 EP8 pairs over LSA; that configuration was not measured here. If PCIe peer bandwidth is the bottleneck on a given platform, compare against SGLANG_FLASHINFER_MEGAMOE_SM120_TRANSPORT_TABLE=all_gin; in the table above the two tables are within 1-3 % at both EP4 and EP8.

Checklist

Review and Merge Process

  1. Ping Merge Oncalls to start the process. See the PR Merge Process.
  2. Get approvals from CODEOWNERS and other reviewers.
  3. Trigger CI tests with comments or contact authorized users to do so.
    • Common commands include /tag-and-rerun-ci, /tag-run-ci-label, /rerun-failed-ci
  4. After green CI and required approvals, ask Merge Oncalls or people with Write permission to merge the PR.

CI States

Latest PR Test (Base): ⊘ Skipped -- a maintainer comments /tag-and-rerun-ci to run CI tests.
Latest PR Test (Extra): ⊘ Skipped -- a maintainer comments /tag-and-rerun-ci to run CI tests.
Latest PR Test (AMD ROCm 10): ⚠️ Run #46105564621

Tip

Base CI only covers the core cases, and its workload may not exercise your change. Use /rerun-test to run the tests your change touches, or copy this prompt for an agent:

Find the registered tests this PR affects and run them with /rerun-test, following https://github.com/sgl-project/sglang/blob/main/.agents/skills/rerun-test/SKILL.md

@github-actions github-actions Bot added documentation Improvements or additions to documentation deepseek labels Oct 15, 2026
@GnohzZ
GnohzZ force-pushed the cake-sm120-flashinfer-megamoe branch from b73f63e to a47909b Compare October 15, 2026 11:20
@GnohzZ
GnohzZ marked this pull request as ready for review October 19, 2026 03:28
@Fridge003

Copy link
Copy Markdown
Collaborator

@GnohzZ Please solve the conflicts, thanks

@GnohzZ
GnohzZ force-pushed the cake-sm120-flashinfer-megamoe branch from 0f09fa4 to bc3bbb4 Compare October 20, 2026 14:07
@GnohzZ

GnohzZ commented Oct 20, 2026 •

Copy link
Copy Markdown
Author

@Fridge003 Thanks, rebased and resolved the conflicts.

The branch is now based on main (16eb87c); the conflict with #44036 (W4A16/SiTU) in flashinfer_megamoe.py has been resolved.

While re-validating on GPU, I hit a regression from #43607: the V4 decoder unconditionally passes leave_output_sum=True, but flashinfer_megamoe completes the EP combine inside its kernel and its FFN transport declares no sum group. The normal MoE path therefore returns MoEOutput pieces that the transport rejects during warmup with “transport finalize owes an undeclared sum group”.

The fix (bda748bc06) disables leave_output_sum specifically for flashinfer_megamoe, preserving other backends’ existing behavior. Tests exercise the real decoder and transport finalization, including a DeepGEMM fallback control. That fallback has a separate unresolved reduction-ownership issue and is not fixed here. The FlashInfer regression likely affects SM100 too; I could only verify it on SM120.

Btw, FlashInfer 0.7.2 does not include flashinfer-ai/flashinfer#6346 yet, so the SM120 path remains an opt-in source install, with an explicit startup error under the default pin.

@GnohzZ
GnohzZ force-pushed the cake-sm120-flashinfer-megamoe branch from bc3bbb4 to c18e299 Compare October 20, 2026 15:53
Comment thread test/manual/dsv4/test_sm120_flash.py Outdated
@@ -0,0 +1,51 @@
"""SM120 (RTX PRO Blackwell) x DeepSeek-V4-Flash.

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.

Please remove all the changes under test folder, unless it's for fixing

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Done, removed all changes under test/.

@@ -1162,11 +1168,7 @@ def forward_normal_dual_stream(
has_shared_output = (
hidden_states.shape[0] > 0 and self.num_fused_shared_experts == 0
)

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.

Why changing the logic here? When eplb is not enabled, we shouldn't set a non None value here

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

It was only meant for static placement without --enable-eplb (init_new returns None unless a dispatch algorithm is set), and #44994 now handles that in TopK, so I dropped this change.

Comment thread python/sglang/srt/models/deepseek_v4.py Outdated
@@ -3459,7 +3459,8 @@ def forward(
input_ids_global=transport.input_ids_global,
skip_shared_experts=transport.do_shared_local,
return_moe_output=transport.return_moe_output,
leave_output_sum=True,
# FlashInfer MegaMoE completes the EP sum inside its kernel.
leave_output_sum=not get_moe_a2a_backend().is_flashinfer_megamoe(),

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.

What if we run flashinfer megamoe on sm100/sm90. Will this change cause incorrect result

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

#46365 has since fixed this in MoeTransport, so I dropped this change. It wasn't arch-specific anyway: SM90 can't select flashinfer_megamoe, and on SM100 the kernel's combine also returns complete outputs (post_experts_output_is_complete()).

@Fridge003

Copy link
Copy Markdown
Collaborator

Please solve the conflict

@GnohzZ
GnohzZ force-pushed the cake-sm120-flashinfer-megamoe branch from c18e299 to 0386d3c Compare October 26, 2026 07:05
@mintlify

mintlify Bot commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

Preview approval required

This pull request comes from a fork, so Mintlify won't build a preview until someone with write access approves commit 3b8e3b4.

Approve preview

@GnohzZ

GnohzZ commented Oct 26, 2026

Copy link
Copy Markdown
Author

@Fridge003 Rebased onto main and resolved the conflict. The PR now only touches the SM120 path (flashinfer_megamoe.py, moe_hook.py, environ.py) and the cookbook; the deepseek_v2.py / deepseek_v4.py changes are dropped since #44994 and #46365 cover them.

@xulunfan

xulunfan commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

Two observations from testing the reachability premise on a second SM120 host (8x RTX PRO 5000 Blackwell, 72 GB), in case it helps calibrate the transport-table discussion and the benchmark numbers.

  1. Peer topology. On this host nvidia-smi topo -m reports all 8 GPUs under a single NUMA node with every pair connected via PHB (no NODE/SYS), and cudaDeviceCanAccessPeer returns true for all 56 directed pairs. So with the default lsa_where_reachable, every off-diagonal pair selects LSA here and there is no GIN leg. The EP8 figures in the description (24 in-socket LSA + 32 cross-socket GIN pairs, --mem-fraction-static 0.70 to avoid the first-launch OOM, and the 1.72-1.77x prefill numbers) were measured on a two-socket host where about a third of the pairs ride GIN over the NIC; on a single-NUMA, all-PHB host the communication profile is entirely PCIe peer-to-peer, so those numbers may not transfer as-is. A short note in the PR (or a run on a single-NUMA host) would help adopters on that common topology know what to expect.

  2. Dependency gate. On the current flashinfer release pin, flashinfer.moe_ep exports only the MXFP8 cake entry points (CakeMxfp8MegaMoeEp16 / cake_mxfp8_megamoe_ep16), and Sm120_Mxfp4_Mxfp8_Bf16_Cake_MegaMoeConfig is absent, matching the dependency-scope note that 0.7.2 predates feat(cake_mega_moe): [SM120] MXFP4 x MXFP8 MegaMoE through MoEEpLayer (sm120_mxfp4_mxfp8_bf16_cake) flashinfer-ai/flashinfer#6346. The startup validation errors cleanly, so the backend cannot be selected by accident before a FlashInfer release ships [Bug] sglang v0.4.6 crashed when use response_format params #6346.

Caveat: I could not run the cake kernel itself (the pinned FlashInfer lacks #6346), so the above is a reachability/topology observation on this host, not a performance measurement.

@GnohzZ
GnohzZ force-pushed the cake-sm120-flashinfer-megamoe branch from 0386d3c to 6945e2c Compare November 7, 2026 10:31
@GnohzZ

GnohzZ commented Nov 7, 2026

Copy link
Copy Markdown
Author

@xulunfan Thanks for testing this on a single-NUMA host.

  1. The headline numbers are TP4 / EP4 on one CPU socket, so all pairs already use LSA (our in-socket pairs are PXB/NODE rather than PHB); only the supplementary EP8 row mixes LSA and GIN. EP8 with every pair on LSA, the default on your host, is untested here. I've noted this in the description.
  2. FlashInfer 0.7.3 includes [Bug] sglang v0.4.6 crashed when use response_format params #6346 and main now pins it, so the backend works without a source build. I rebased and re-validated on the official nightly image (GSM8K-200 0.990, prefill unchanged).

If you get a chance, an EP8 run on your host (default table, and all_gin for comparison) would fill that gap.

@GnohzZ
GnohzZ force-pushed the cake-sm120-flashinfer-megamoe branch 2 times, most recently from 7241b7c to 4b31d5e Compare November 27, 2026 16:17
@GnohzZ

GnohzZ commented Nov 28, 2026

Copy link
Copy Markdown
Author

Rebased onto main 219ca7b082 to resolve the conflict with #46213 (MegaMoE decode workspace). I kept its with_decode_workspace argument and the module-level MegaMoeTunedForward; the SM120 bucketed forward is selected before them, and the SM120 path (FP4 experts) never requests the decode workspace. Apart from that, the only change is one Cookbook line about the NCCL requirement (below).

Re-validated on lmsysorg/sglang:nightly-dev-cu13-20261122-e96e9675 (FlashInfer 0.7.4): pre-commit passes, the existing CPU suites pass (1375 tests), GSM8K-200 is 0.985 for this PR and 0.990 for the flashinfer_mxfp4 baseline, and prefill throughput is unchanged (details in the description).

One environment note: the SGLang images now ship NCCL 2.31.2 (for DeepEP). FlashInfer's SM120 kernel is JIT-compiled against NCCL's Device API and currently requires 2.30.7, so on the stock image it stops at startup with an explicit error. pip install nvidia-nccl-cu13==2.30.7 fixes it, since this path doesn't use DeepEP. I added this to the Cookbook note and will follow up on newer NCCL support in FlashInfer.

Zhong Zheng added 2 commits November 28, 2026 11:13
…ake MegaMoE backend

On SM120 (RTX PRO Blackwell), FP4-expert checkpoints such as
DeepSeek-V4-Flash now run --moe-a2a-backend flashinfer_megamoe on FlashInfer's
sm120_mxfp4_mxfp8_bf16_cake backend (flashinfer-ai/flashinfer#6346).

- Platform gate: SM120 (compute capability 12.0) with FP4 experts, EP >= 2 and a
  FlashInfer build that exports the cake config; --enable-eplb and speculative
  decoding without an explicit draft MoE runner are rejected. NCCL_CUMEM_ENABLE
  defaults to 1 on this path (NCCL's Device API needs cuMem).
- Weights: FlashInfer's own cake preprocessing; FC1 is written back into w13 and
  FC1/FC2 alias the layer weights, so experts stay resident once, and the
  float32 checkpoint scales are replaced by the packed UE8M0 scales.
- Forward: one workspace per layer group, staged with the step's largest per-rank
  token count as the row bucket, so there is no per-layer host sync and decode
  CUDA graphs capture one bucket per batch size.
- SGLANG_FLASHINFER_MEGAMOE_SM120_TRANSPORT_TABLE selects the peer transport
  (default lsa_where_reachable).

SM100 paths are unchanged.
Document the SM120 flashinfer_megamoe path (FlashInfer cake backend) as an
experimental prefill option for DeepSeek-V4-Flash, with the FlashInfer
requirement, the per-rank token budget, static-EPLB support and the
transport-table knob. The RTX PRO 6000 note now refers to the DeepGEMM
MegaMoE only.
@GnohzZ
GnohzZ force-pushed the cake-sm120-flashinfer-megamoe branch from 4b31d5e to 3b8e3b4 Compare November 28, 2026 04:01

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

deepseek documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants