Repository navigation
[FlyDSL] [MoE] MegaMoEV2: EP8 V4.1-Flash DSpark draft MoE on the small-input route, BF16 return on every draft route (on #8758) - #8759
Conversation
|
GPU validation on top of #8758 / #8633 (head 6420f64), gfx950 / MI355X, 8 GPUs; details in the description.
Stays draft until #8758 merges. |
504bc7b to
0b4d003
Compare
|
Updated (force-pushed 0b4d003): the draft MoE now returns BF16 rows on every route, no longer FP8.
Still a draft until #8758 merges. |
|
Update (ac81354): extend the BF16 return to the V4.1-Flash DSpark draft MoE on every EP width.
Checks:
V4-Pro draft and target share the (8, 48, 7168, 3072) layout and cannot be told apart by layout; that needs an instance-level flag from the caller and is not covered here. |
…ute, BF16 return DeepSeek-V4.1-Flash's DSpark draft layer with the shared expert computed apart runs a MegaMoE of 16 routed experts a rank and topk 3 on 8 ranks. No fused layout covered it, so every draft call took the staged route. Make it a small-input-only fused layout, V41_FLASH_EP8_DRAFT_LAYOUT (8, 16, 5120, 2304) with topk 3, the default (no switch): - FUSED_LAYOUTS takes it; SMALL_M_ONLY_LAYOUTS keeps it off the large-input kernel: large_m_mtprs_for() takes the experts a rank and gives such a layout no capacity, so calls above SMALL_M_MAX_MTPR rows a rank stay on the staged route (MegaMoEV2 and LargeMRuntime pass experts_per_rank). - The small-input kernel dispatches it into fixed slots, as the 48-expert layout (one receive row a source token and slot either way). - Its tune (_tune_v41_flash_ep8_draft_small) is the 48-expert EP8 small-input tune without its per-bucket table. Every route of the layout returns BF16 rows (BF16_RETURN_LAYOUTS), the precision of the default MoE backend, whose MoRI combine returns BF16: - small-input route: bf16_rows_always (FusedStage1Knobs, default off) makes every rank send BF16 GEMM2 rows instead of the rows-received choice of FP8 or BF16 rows (a hot expert or many received rows picked FP8). - staged route: p2p_quant "auto" resolves to "none" at every MTPR for the layout (it picked fp8_blockwise_1x32 from P2P_FP8_MIN_MTPR, i.e. at the 16384-token draft instance), and the FP8-only aligned-pair Stage2 gives way to the plain Stage2 of the same bucket. An explicit p2p_quant is kept. Every other layout, the 48-expert target layout included, keeps its configs (the pinned digests take bf16_rows_always only when set). Tests: - tests/test_mega_moe_v41_ep8_draft_layout.py: layout gate, no large-input capacity, the route for every max_tokens, each bucket's config (the EP8 tune with the BF16 return), one launch protocol, the staged route's BF16 return at every capacity, the other layouts' returns unchanged, fixed-slot dispatch. - op_tests/multigpu_tests/test_mega_moe_v2.py gains --network v41_flash_draft for the routes suite, --staged-rtol (the relL2 gate against the staged route) and, for a BF16_RETURN_LAYOUTS layout, the [BF16RET] checks: the instance's return configs, skewed routes (whose hot rank picked FP8 rows before) against the staged route, staged calls above the small-input capacity against the fp32 reference. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ry EP width BF16_RETURN_LAYOUTS held only the EP8 draft layout (8, 16, 5120, 2304). The draft MoE (128 routed experts, topk 3) on 4 ranks is (4, 32, 5120, 2304), on 2 ranks (2, 64, ...), on 1 rank (1, 128, ...): none of them is a fused layout, so every draft call takes the staged route, and at the draft instance's 16384-token capacity p2p_quant "auto" picked fp8_blockwise_1x32 (P2P_FP8_MIN_MTPR) -- a DEP4 draft MoE returned FP8 rows. - V41_FLASH_DRAFT_LAYOUTS: the draft MoE on 1, 2, 4 and 8 ranks; BF16_RETURN_LAYOUTS is that set. The staged route's "auto" resolves to "none" for each (the FP8-only aligned-pair Stage2 gives way to the plain Stage2), an explicit p2p_quant is kept. - _fused_config gives any BF16_RETURN_LAYOUTS layout bf16_rows_always, not only the EP8 one (the EP1/2/4 drafts have no fused route today). - Target-model layouts (V4-Pro, V4.1-Flash EP8/EP4/EP2, EPLB profiles, R1, Kimi-K3, GLM-5.2) keep every config field. Tests: tests/test_mega_moe_v41_ep8_draft_layout.py checks the EP1/EP2/EP4 draft staged returns at every capacity and the target layouts' returns; test_mega_moe_v2.py --suite routes --network v41_flash_draft on 4 or 2 ranks runs the staged-only BF16 check (configs, fp32 reference, FP8-return instance told apart by --staged-rtol). Co-Authored-By: Claude Opus 5.5 <[email protected]>
ac81354 to
045f0bd
Compare
Summary
DeepSeek-V4.1-Flash's DSpark draft MoE with the shared expert computed apart (EP8: 16 routed experts a rank, topk 3) takes MegaMoE's fused small-input route instead of the staged route, and every route of this layout returns BF16 rows. Default behaviour (no switch, no environment variable).
V41_FLASH_EP8_DRAFT_LAYOUT(8, 16, 5120, 2304) / topk 3 joinsFUSED_LAYOUTS;SMALL_M_ONLY_LAYOUTSkeeps it off the large-input kernel (large_m_mtprs_for(..., experts_per_rank=)gives it no capacity), so calls above 512 rows a rank stay staged.bf16_rows_always(newFusedStage1Knobsfield, default off): every rank sends BF16 GEMM2 rows instead of the rows-received FP8/BF16 choice.BF16_RETURN_LAYOUTS(the draft layout only): the staged route'sp2p_quant="auto"resolves to"none"(BF16) at every MTPR, including the 16384-token draft instance, whereautopickedfp8_blockwise_1x32before. The FP8-only aligned-pair Stage2 gives way to the plain Stage2 of the same bucket. An explicitp2p_quantis kept.bf16_rows_alwaysenters them only when set).Why BF16 (SemiAnalysis InferenceX Check 13)
The first version of this PR forced an FP8 (1x32 E8M0) return to match the staged route. That FP8 return is not the draft's shipped precision:
standard. Its MoRI combine returns BF16, and the signed-off DeepSeek-V4.1 recipe says "combine stays BF16". The mega backend is opt-in.P2P_FP8_MIN_MTPR. A draft MoE that returns FP8 where the default path returns BF16 runs the draft at a lower activation precision than the default, and Check 13 can flag that.This version returns BF16 on both draft routes, small-input and staged. Without it, the mega backend's draft (staged, FP8 return) has the same problem, so this PR fixes main's draft path as well.
Numerics
--suite routes --network v41_flash_draft --staged-rtol 0.005(8 GPUs, gfx950):[BF16RET]checks:p2p_quant=noneand every small-input config hasbf16_rows_always.autois FP8 elsewhere) are within --rtol of the fp32 reference (0.0519).Performance
DeepSeek-V4.1-Flash, MI355X DEP8, InferenceX AgentX c512, 900 s per run after a 900 s warm-up, SA-compliant serving config on the mega MoE backend (48 routed experts a rank / topk 6, FP8 shared expert computed apart, draft not fused, dynamic EPLB), one machine, order A, B, B, A. The arms run the same stack and differ only in the draft MoE return. A: fused small-input route with FP8 return (previous version of this PR) and staged FP8 return. B: this version, BF16 on every draft route.
p2p_quant=none.fp8_blockwise_1x32at MTPR 16384 and its small-input configs are unchanged.Accuracy of B (GSM8K 5-shot, no golden acceptance length): 0.9363 ± 0.0067. Draft acceptance 0.4884 (78,144 / 160,000), 3.44 tokens/forward. In the earlier run: FP8 return 0.9310 / 0.4901, staged as in main 0.9325 / 0.4895. All within noise.
Dependencies / merge order
AITER_MEGA_FUSED_DRAFT_LAYOUT(rows-received FP8/BF16 return). Whichever merges second keeps one draft layout. That layout should readSMALL_M_ONLY_LAYOUTSandBF16_RETURN_LAYOUTS.Tests
tests/test_mega_moe_v41_ep8_draft_layout.py(CPU) covers:bf16_rows_always) and one launch protocol;p2p_quantkept;tests/test_mega_moe_gfx950_route_plan.py(pinned digests) andtests/test_mega_moe_v41_ep8_small_knobs.py: 139 passed.op_tests/multigpu_tests/test_mega_moe_v2.py --suite routes --network v41_flash_draft --staged-rtol 0.005(8 GPUs): ALL PASS.--suite routes --network v41_flash --compare-untunedon this branch: ALL PASS (48-expert layout unchanged; its hot ranks still pick FP8 rows by rows received).🤖 Generated with Claude Code