Repository navigation
feat: Support flashinfer_cutedsl MoE runner with flashinfer alltoall backend - #22669
Conversation
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
ad51fab to
59c2c2a
Compare
…backend Enable CuteDSL FP4 MoE runner (--moe-runner-backend flashinfer_cutedsl) to work with FlashInfer one-sided alltoall dispatch (--moe-a2a-backend flashinfer) for DP attention + EP configurations. Changes: - server_args.py: whitelist cutedsl + flashinfer a2a, force-disable NVFP4_DISPATCH - qwen2_moe.py: M=0 guard, skip allreduce for a2a, shared_expert tp_size=1 - flashinfer.py: remove dummy token, pass 0-size tensors, add invalid_token_expert_id - flashinfer_cutedsl.py: register fused func, scale max_num_tokens by dp_size - test_cutedsl_a2a.py: E2E test on B200x4 with GSM8K Tested: Qwen3.5-397B-A17B-NVFP4, B200x4, EP=4 DP=4 - GSM8K: 97.56% (baseline 97.64%) - GPQA: 86.2% (8 repeats)
59c2c2a to
91e1434
Compare
|
/tag-and-rerun-ci |
01ea5d1 to
6eac935
Compare
| payloads, | ||
| self.runtime_max_tokens_per_rank, | ||
| invalid_token_expert_id=self.num_experts, |
There was a problem hiding this comment.
This will trigger moe_a2a_sanitize_expert_ids kernel, we should confirm if it's necessary otherwise it will reduce the perf
There was a problem hiding this comment.
This is necessary, the recv_buffer of A2A is allocated redundantly. If the invalid slots are not sanitized, they will be sent for useless MoE computation.
|
@samuellees Could you ping me on slack when this PR is ready? Also, I removed the |
# Conflicts: # python/sglang/srt/layers/moe/moe_runner/flashinfer_cutedsl.py # python/sglang/srt/layers/moe/token_dispatcher/flashinfer.py # python/sglang/srt/layers/quantization/modelopt_quant.py
| popen_launch_server, | ||
| ) | ||
|
|
||
| register_cuda_ci(est_time=600, stage="base-c", runner_config="4-gpu-b200") |
There was a problem hiding this comment.
let's move it to stage="extra-b"
Adds an investigation report for the nightly-test-perf-4-gpu-b200 failure of test_a_gsm8k under TestDeepseekV3FP4CuteDSLMoE. The regression is traced to commit 044649c (PR sgl-project#22669) which under-sizes the CuteDslMoEWrapper buffer for the EP=1, TP=4, no-DP-attention DeepSeek V3 FP4 configuration. The report includes: - pass/fail boundary (run sgl-project#624 pass -> sgl-project#625 fail on main) - bisection across the 50 commits in 7f154ba..c4a7d12 - root-cause diff in flashinfer_cutedsl.py:ensure_cutedsl_wrapper - direct repro at offending and parent SHAs (GPU 4 only) - a four-line recommended patch and short-term workarounds Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
sgl-project#22669 changed ensure_cutedsl_wrapper to size the CuteDslMoEWrapper CUDA-graph buffers from the first forward's token count (max(num_tokens, 1)), which during startup is a small capture batch. A larger real forward then trips FlashInfer's `num_tokens exceeds max_num_tokens` guard and crashes the scheduler (repros on DeepSeek-V3-0324-FP4, tp4/ep1/flashinfer_cutedsl, no dp-attention). Size the buffer from the server config instead, via a shared ServerArgs.cutedsl_moe_max_num_tokens() helper covering the prefill, piecewise-prefill-capture, and decode/spec-verify bounds; scale by dp_size on the allgather path. Reuse the helper in the A2A startup guard and drop the unused num_tokens parameter.
sgl-project#22669 changed ensure_cutedsl_wrapper to size the CuteDslMoEWrapper CUDA-graph buffers from the first forward's token count (max(num_tokens, 1)), which during startup is a small capture batch. A larger real forward then trips FlashInfer's `num_tokens exceeds max_num_tokens` guard and crashes the scheduler (repros on DeepSeek-V3-0324-FP4, tp4/ep1/flashinfer_cutedsl, no dp-attention). Add ServerArgs.cutedsl_moe_max_num_tokens() as a single source of truth for the per-forward token bound: max over the prefill (max_prefill_tokens), piecewise-prefill-capture, and decode/spec-verify (cuda_graph_max_bs * num_tokens_per_bs) bounds. Use it both for the standard-allgather wrapper buffers (* dp_size) and the FlashInfer A2A dispatcher budget check -- the latter moved after speculative resolution so it sees the final num_tokens_per_bs, replacing its weaker max_prefill_tokens-only check. Drop the unused num_tokens parameter.
…backend (sgl-project#22669) Co-authored-by: Trevor Morris <[email protected]> Co-authored-by: Claude Opus 4.7 <[email protected]>
Depends on flashinfer-ai/flashinfer#3021 for topk=10.
Summary
--moe-runner-backend flashinfer_cutedsl) to work with FlashInfer one-sided alltoall dispatch (--moe-a2a-backend flashinfer) for DP attention + EP configurationsChanges
server_args.py"flashinfer"to cutedsl'smoe_a2a_backendwhitelist"flashinfer_cutedsl"to flashinfer a2a'smoe_runner_backendwhitelistSGLANG_MOE_NVFP4_DISPATCHfor cutedsl + flashinfer a2a (FP4 dispatch path not yet validated with cutedsl's scale factor layout)qwen2_moe.pyshared_expertandgate(FP4 GEMM cannot handle empty tensors), but still callself.experts()to participate in alltoall collectivetensor_model_parallel_all_reducecauses NCCL size mismatch between active/idle rankstp_size=1: In a2a mode, shared_expert must not be TP-sharded (same as deepep), because TP allreduce on shared_expert output fails when idle DP ranks have 0 tokensflashinfer.py(token dispatcher)local_num_tokens=0. Removed unused dummy tensor allocationshas_dummy_token→is_idle_rankfor clarityinvalid_token_expert_id: Mark padding slots with invalid expert ID so MoE kernels skip themflashinfer_cutedsl.py(MoE runner)("flashinfer", "flashinfer_cutedsl")for flashinfer alltoall dispatchermax_num_tokensbydp_sizein DP attention mode, since wrapper receivesdp_size * local_tokensafter allgather/dispatchtest_cutedsl_a2a.py(unit test)Reproduce
Hardware: B200 × 4
Baseline (cutedsl + DP, no a2a)
This PR (cutedsl + DP + flashinfer a2a)
GSM8K eval
GPQA eval
Accuracy
Test plan
test/registered/moe/test_cutedsl_a2a.py— GSM8K > 90% on B200×4The capital of France is→Paris.CI States
Latest PR Test (Base): 🚫 Run #26144561324
Latest PR Test (Extra): ❌ Run #26144561265