Repository navigation
[Spec] Support MegaMoE for DSpark under dp attention - #34844
Merged
Merged
Conversation
_handle_dspark rejected every non-'none' moe_a2a_backend when dp attention is on, forcing DSpark deployments onto the built-in TP MoE. The restriction predates the DSV4-MoE draft path, which already runs the cross-DP lockstep an EP a2a dispatch needs: DraftBlockProposer all-gathers global_num_tokens through _fill_dp_moe_sync_metadata, and a rank with no local generation requests still enters the draft forward via run_idle_participation, so every EP rank calls the MoE the same number of times per step. MegaMoE's fused kernel already accommodates a zero-token rank (empty topk tensors, y allocated with max(num_tokens, 1) rows), which is exactly the shape an idle DP rank produces. Admit 'megamoe' alongside 'none', gated on SGLANG_RAGGED_VERIFY_MODE=static (the default). Compact ragged verify stays rejected: it agrees on a per-rank graph tier only when _dp_tier_gather_enabled holds, which rests on require_mlp_tp_gather -- config-dependent under an a2a backend (false once moe_dense_tp_size <= tp_size // dp_size, true for flashinfer or moe_dense_tp_size=None), so ranks can disagree on the token-keyed tier and replay different graph shapes. Only the uniform static layout is admitted until that gather gets an a2a-independent sync. deepep and every other a2a backend keep raising, now naming the value; deepep needs its own runner-backend pairing and is not covered by the validation below. Validation: Unit -- 7/7 pass in test/registered/spec/dspark/ test_dspark_draft_path_default.py (5 pre-existing + 2 new): one pinning both sides of the a2a allowlist, one pinning the compact-mode rejection. Serving -- DeepSeek-V4-Pro fp8 with its bundled DSpark draft (DeepseekV4ForCausalLMDSpark, gamma=5), aggregated on 8x GB300 over 2 nodes, TP8/DP8/EP8 with --enable-dp-attention --enable-dp-lm-head --moe-a2a-backend megamoe. This is the MoE-draft path, so the draft itself joins the EP collectives. Target-verify and draft-verify CUDA graphs captured on all 8 EP ranks (identical 25.6 s per rank -- a phase-flip barrier desync would hang or raise "unspecified launch failure" here). ISL 8192 / OSL 1024 at concurrency 64 ran to completion: 640/640 successful requests over 615 s, 8642 tok/s total throughput, mean TPOT 63 ms, and DSpark accept length averaging 5.21 of 6 across 471 decode batches (p10 4.65, p50 5.40) -- speculative decoding stayed active rather than silently degrading. No CUDA, NCCL, or barrier errors during the run. Accuracy -- gsm8k 400 questions, 5-shot, same serving config with only the MoE backend varied: 0.9775 on both the megamoe and the built-in TP MoE arm (391/400 each), so no accuracy regression.
weireweire
force-pushed
the
dspark-megamoe-ep
branch
from
August 14, 2026 12:42
ec40fae to
ddeadcc
Compare
Collaborator
Author
|
/tag-and-rerun-ci |
hnyls2002
approved these changes
Aug 15, 2026
saturn-acc
pushed a commit
to saturn-acc/sglang
that referenced
this pull request
Aug 16, 2026
Co-authored-by: weireweire <[email protected]>
shiyu7
pushed a commit
to shiyu7/sglang
that referenced
this pull request
Aug 18, 2026
Backport sgl-project#34844 while preserving the DeepEP + DeepGemm combination supported by this branch.
3 of 5 tasks
shiyu7
pushed a commit
to bytedance-iaas/sglang
that referenced
this pull request
Aug 21, 2026
Backport sgl-project#34844 while preserving the DeepEP + DeepGemm combination supported by this branch.
Atituiset
pushed a commit
to Atituiset/sglang
that referenced
this pull request
Sep 10, 2026
Co-authored-by: weireweire <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
_handle_dsparkrejected every non-none--moe-a2a-backendwhen--enable-dp-attentionis on, so DSpark could not run alongside an EP all-to-all dispatch.The lockstep an EP dispatch needs was already in place. The DSV4-MoE draft path all-gathers
global_num_tokensin_fill_dp_moe_sync_metadata, and a rank with no local generation requests still enters the draft forward viarun_idle_participation, so every EP rank calls the MoE the same number of times per step. MegaMoE's fused kernel already accommodates the zero-token rank that produces.Modifications
arg_groups/speculative_hook.py: admitmegamoealongsidenone, restricted toSGLANG_RAGGED_VERIFY_MODE=static.Compact ragged verify stays rejected. It agrees on a per-rank graph tier only when
_dp_tier_gather_enabledholds, which rests onrequire_mlp_tp_gather— config-dependent under an a2a backend — so ranks could disagree on the token-keyed tier and replay different graph shapes.deepepand the other backends keep raising, now naming the value.Two tests: one pins both sides of the a2a allowlist, one pins the compact-mode rejection.
Accuracy Tests
gsm8k, 400 questions, 5-shot. Same serving config as below with only the MoE backend varied.
none(built-in TP MoE,flashinfer_mxfp4)megamoe(deep_gemm)Identical score, 391/400 on both arms — no accuracy regression.
Speed Tests and Profiling
DeepSeek-V4-Pro fp8 with its bundled DSpark draft (
DeepseekV4ForCausalLMDSpark, gamma=5), aggregated on 8x GB300 across 2 nodes, TP8/DP8/EP8,--enable-dp-attention --enable-dp-lm-head --moe-a2a-backend megamoe. This is the MoE-draft path, so the draft itself joins the EP collectives.Target-verify and draft-verify CUDA graphs captured on all 8 EP ranks, 25.6 s each and identical across ranks — a phase-flip barrier desync would hang or raise
unspecified launch failurehere.ISL 8192 / OSL 1024 at concurrency 64:
No CUDA, NCCL, or barrier errors during the run. There is no baseline arm, so these are absolute numbers rather than a comparison.
Checklist
CI States
Latest PR Test (Base): ✅ Run #31801506657
Latest PR Test (Extra): ❌ Run #31801506455