Repository navigation
[Fix] deepseek-v4: Keep the draft MoE out of the target's expert placement - #45299
Conversation
3e03efa to
ba04baf
Compare
Root cause: DeepSeek-V4 draft MoE layers (DSpark stages and NextN) are
DeepseekV2MoE layers with is_nextn=True and zero-based layer ids; DSpark
stages also own a smaller expert set (128 vs the target's 384). EPLB only
ever rebalances the target, yet the draft was sized with the target's
redundant slots, loaded its experts through the target's logical-to-physical
map, and the MegaMoE paths (CUDA and AMD flydsl) built dispatch info for
layer_id 0..2 from the target's metadata. With redundant experts, DSpark
top-k ids were remapped to physical slots the draft MegaMoE does not own
and the kernel hung in its grid barrier ("Grid sync timeout") during draft
CUDA graph capture.
Fix: FusedMoE takes uses_expert_location (default True); DeepseekV2MoE
passes False for DeepSeek-V4 nextn layers, which then get no redundant
slots, load with the plain global-to-local mapping, and get no MegaMoE
dispatch info; moe_wna16 places their qzeros the same way. The DSpark
loader numbers the fused shared expert after the stage's own routed experts,
matching the plain mapping.
Validation: GB300, DeepSeek-V4.1-Flash, EP4/attention-DP4, MegaMoE, DSpark,
--enable-eplb --ep-num-redundant-experts 16: main dies in draft decode-graph
capture; with the fix all graphs capture and the server serves. GSM8K
(sgl-eval, 400 questions, native acceptance): no EPLB 97.50%, EPLB16 with
two rebalances during the eval 98.00%.
ba04baf to
222744a
Compare
|
The per-layer opt-out is the right size for this bug. The underlying issue is that the expert-location metadata is a process singleton keyed by (from Claude) |
|
/rerun-test test/registered/e2e/models/test_deepseek_v4_flash_fp4_megamoe_b200.py test/registered/ep/test_eplb_no_a2a.py test/registered/moe/test_fused_append_remap_per_rank_shared_slots.py test/registered/unit/models/test_deepseek_v4_shared_expert_fusion.py |
|
🚀 🚀 🚀 🚀 |
Same sgl-project#45299 fallout, one file over: _layer() mocks moe.experts for the flydsl path, which now reads uses_expert_location at mega_moe_flydsl.py:317. Signed-off-by: Xinyuan Tong <[email protected]>
Motivation
DeepSeek-V4.1 with DSpark and MegaMoE cannot run EPLB. With
--enable-eplb --ep-num-redundant-experts 16, the server dies while capturing the draft decode CUDA graphs: DeepGEMM's MegaMoE kernel times out in its grid barrier (Grid sync timeout,barrier.cuh), which later surfaces asunspecified launch failure.DeepSeek-V4 draft MoE layers (DSpark stages and NextN) are
DeepseekV2MoElayers built withis_nextn=Trueand zero-based layer ids. DSpark stages also own a smaller expert set: 128 routed experts, against the target's 384 over 40 layers.EPLB only rebalances the target. The draft never gets an EPLB manager and exposes no
routed_experts_weights_of_layer, yet the target's expert placement leaked into the draft in three ways:FusedMoE.weight_loaderindexed the draft's own expert tensors through the target's logical-to-physical map for layer 0..2;mega_moeand AMDmega_moe_flydsl) builtExpertLocationDispatchInfoforlayer_id0..2 from the target's metadata.With redundant experts, DSpark draft top-k ids were remapped to physical slots the draft MegaMoE does not own, and the kernel hung. For NextN MTP with the target's expert count, the same leak routed draft tokens by the live target map after a rebalance, while the draft weights stayed at the startup placement.
#34846 (closed) opted DSpark draft layers into dispatch instead. That cannot work for DeepSeek-V4.1, where the draft's expert count differs from the target's.
Modifications
FusedMoEtakesuses_expert_location: bool = True. When it is False,weight_loaderignores the global expert-location metadata and uses the plain global-to-local mapping.DeepseekV2MoEpassesuses_expert_location=Falsefor DeepSeek-V4 nextn layers. Those layers get no redundant expert slots.mega_moe._run_mega_routedandmega_moe_flydsl._run_mega_routedpass no dispatch info for such layers. The other MoE paths indeepseek_v2.pyalready skip nextn layers.moe_wna16places qzeros with the same plain mapping for such layers, matching the weight loader.Target layers and non-DeepSeek-V4 models are unchanged. With redundant experts, a DeepSeek-V4 NextN layer on MegaMoE now gets its own MegaMoE buffer, since its expert count no longer matches the target's.
Out of scope, left for a follow-up:
--enable-waterfill, which sizes the draft's balancer from the target's expert count plus redundant slots.Accuracy Tests
GB300, DeepSeek-V4.1-Flash, EP4 with attention DP 4, MegaMoE, DSpark,
--enable-eplb --ep-num-redundant-experts 16:GSM8K (sgl-eval, 400 questions, native speculative acceptance) shows no accuracy loss:
Only DSpark was run on GPU; DeepSeek-V4 NextN MTP with EPLB was not. The isolated draft paths were also checked: on main, the MegaMoE draft path builds target dispatch info, and the draft weight loader indexes its experts through the target's map. Neither happens with this change.
Speed Tests and Profiling
Unchanged for target layers. For DeepSeek-V4 draft layers, behavior changes only when the target's placement is non-trivial (
--enable-eplb, redundant experts, or a non-trivial--init-expert-location). This makes EPLB usable on DeepSeek-V4.1 DSpark + MegaMoE decode.Checklist
CI States
Latest PR Test (Base): ❌ Run #39365705959
Latest PR Test (Extra): ❌ Run #39365706063
Latest PR Test (AMD ROCm 10): ❌ Run #39365707455