Skip to content

[Spec] Support MegaMoE for DSpark under dp attention - #34844

Merged
hnyls2002 merged 1 commit into
sgl-project:mainfrom
weireweire:dspark-megamoe-ep
Aug 15, 2026
Merged

hnyls2002 merged 1 commit into
sgl-project:mainfrom
weireweire:dspark-megamoe-ep

Conversation

@weireweire

@weireweire weireweire commented Aug 14, 2026 •

Copy link
Copy Markdown
Collaborator

Motivation

_handle_dspark rejected every non-none --moe-a2a-backend when --enable-dp-attention is 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_tokens in _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 the zero-token rank that produces.

Modifications

arg_groups/speculative_hook.py: admit megamoe alongside none, restricted to SGLANG_RAGGED_VERIFY_MODE=static.

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 — so ranks could disagree on the token-keyed tier and replay different graph shapes. deepep and 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.

arm gsm8k
none (built-in TP MoE, flashinfer_mxfp4) 0.9775
megamoe (deep_gemm) 0.9775

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 failure here.

ISL 8192 / OSL 1024 at concurrency 64:

metric value
successful requests 640 / 640 in 615.3 s
total token throughput 8642 tok/s
output token throughput 959 tok/s (peak 4679)
TTFT mean / p50 / p99 3107 / 2457 / 14218 ms
TPOT mean / p50 / p99 63.0 / 67.1 / 142.4 ms
DSpark accept length mean 5.21 of 6 (p10 4.65, p50 5.40, n=471)

No CUDA, NCCL, or barrier errors during the run. There is no baseline arm, so these are absolute numbers rather than a comparison.

Checklist

  • Format your code according to the Format code with pre-commit
  • Add unit tests
  • Update documentation — no user-facing interface change
  • Provide accuracy and speed benchmark results
  • Follow the SGLang code style guidance

CI States

Latest PR Test (Base): ✅ Run #31801506657
Latest PR Test (Extra): ❌ Run #31801506455

_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

Copy link
Copy Markdown
Collaborator Author

/tag-and-rerun-ci

@github-actions github-actions Bot added the run-ci CI: run the baseline test suite on this PR label Aug 14, 2026
@hnyls2002
hnyls2002 merged commit 6eb941a into sgl-project:main Aug 15, 2026
246 of 281 checks passed
saturn-acc pushed a commit to saturn-acc/sglang that referenced this pull request Aug 16, 2026
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.
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

deepseek run-ci CI: run the baseline test suite on this PR speculative-decoding

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants