Repository navigation
Conversation
b73f63e to
a47909b
Compare
|
@GnohzZ Please solve the conflicts, thanks |
0f09fa4 to
bc3bbb4
Compare
|
@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. |
bc3bbb4 to
c18e299
Compare
| @@ -0,0 +1,51 @@ | |||
| """SM120 (RTX PRO Blackwell) x DeepSeek-V4-Flash. | |||
There was a problem hiding this comment.
Please remove all the changes under test folder, unless it's for fixing
There was a problem hiding this comment.
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 | |||
| ) | |||
There was a problem hiding this comment.
Why changing the logic here? When eplb is not enabled, we shouldn't set a non None value here
There was a problem hiding this comment.
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.
| @@ -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(), | |||
There was a problem hiding this comment.
What if we run flashinfer megamoe on sm100/sm90. Will this change cause incorrect result
There was a problem hiding this comment.
#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()).
|
Please solve the conflict |
c18e299 to
0386d3c
Compare
Preview approval requiredThis pull request comes from a fork, so Mintlify won't build a preview until someone with write access approves commit |
|
@Fridge003 Rebased onto main and resolved the conflict. The PR now only touches the SM120 path ( |
|
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.
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. |
0386d3c to
6945e2c
Compare
|
@xulunfan Thanks for testing this on a single-NUMA host.
If you get a chance, an EP8 run on your host (default table, and |
7241b7c to
4b31d5e
Compare
|
Rebased onto main Re-validated on 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. |
…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.
4b31d5e to
3b8e3b4
Compare
Co-authors: @jychen21 @AichenF
Submitted by: @GnohzZ
Motivation
--moe-a2a-backend flashinfer_megamoecurrently requires SM100. FlashInfer #6346 addedsm120_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 sameflashinfer.moe_ep.MoEEpMegaLayerAPI this backend already uses. This PR wires it into the existingflashinfer_megamoepath 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_mxfp4at 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
flashinfer_megamoe(layers/moe/flashinfer_megamoe.py,arg_groups/moe_hook.py,environ.py); SM100 code paths are unchanged:Sm120_Mxfp4_Mxfp8_Bf16_Cake_MegaMoeConfig, i.e. >= 0.7.3 (clear error otherwise).--enable-eplbis rejected (the packed scales are not expert-major); speculative decoding without an explicit--speculative-moe-runner-backendis rejected (the default draft runnerflashinfer_trtllmis SM100-only).NCCL_CUMEM_ENABLE=1by 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 thedeepep_v2branch.preprocess_sm120_mxfp4_mxfp8_cake_mega_weights). FC1 is a gate/up row interleave ofw13and is written back intow13; 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.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.MegaMoeTunedForwardis 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(defaultlsa_where_reachable) selects the peer transport; FlashInfer validates the value.Earlier revisions of this PR also changed
deepseek_v2.py(expert-id remapping under static placement) anddeepseek_v4.py(MoE output finalization forflashinfer_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 mainc269302, where this PR's files andpyproject.tomlare identical. Official imagelmsysorg/sglang:nightly-dev-cu13-20261122-e96e9675: FlashInfer0.7.4with itsflashinfer-cubin/flashinfer-jit-cachepackages, torch 2.14.1+cu130, no FlashInfer source build): pre-commit passed for all changed files (the Cookbook command export leavespython/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:--moe-runner-backend flashinfer_mxfp4(baseline)--moe-a2a-backend flashinfer_megamoe(this PR)--init-expert-location <recording> --ep-num-redundant-experts 32 --ep-dispatch-algorithm staticThe 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 twoflashinfer_megamoerows 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-cu13built 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 of27b68303d0and FlashInfer main399b6c1d(#6346) from source; modeldeepseek-ai/DeepSeek-V4-Flash-0731; sgl-eval 0.1.2. Unless noted:--tp 4 --attn-dp-size 4on 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):--moe-runner-backend flashinfer_mxfp4(baseline)--moe-a2a-backend flashinfer_megamoe(this PR)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, andchat_template_kwargs={"thinking": true}.flashinfer_mxfp4flashinfer_megamoeThese 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 deprecatedsglang.test.run_eval(5-shot), run before upstream moved to sgl-eval:(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_mxfp4decode 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 4places whole experts per rank like this PR: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-cacheand 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)/medianacross 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):
--ep-size 4Hence the prefill positioning. Decode CUDA graphs capture one bucket per batch size: with
--disable-cuda-graphthe 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_TABLEselects the table. Prefill, OSL 1,--max-concurrency 128, input tokens/s for ISL 2048 / 4096:lsa_where_reachable(default)all_ginAt 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.70on 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,
cudaDeviceCanAccessPeertrue 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 againstSGLANG_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
/tag-and-rerun-ci,/tag-run-ci-label,/rerun-failed-ciCI States
Latest PR Test (Base): ⊘ Skipped -- a maintainer comments⚠️ Run #46105564621
/tag-and-rerun-cito run CI tests.Latest PR Test (Extra): ⊘ Skipped -- a maintainer comments
/tag-and-rerun-cito run CI tests.Latest PR Test (AMD ROCm 10):
Tip
Base CI only covers the core cases, and its workload may not exercise your change. Use
/rerun-testto run the tests your change touches, or copy this prompt for an agent: