Repository navigation
Conversation
…49th expert DeepSeek-V4.1-Flash's shared expert can run inside MegaMoE as one more local expert of every EP rank, which each token of the rank takes as a seventh slot with weight 1 (re-quantized to MXFP4 by the caller). That table is 49 experts a rank and topk 7, which no MegaMoE layout covered, so it fell back to the staged route with the generic config everywhere. Make it a layout of its own, V41_FLASH_EP8_SHARED_LAYOUT (8, 49, 5120, 2304) with topk 7: - FUSED_LAYOUTS: the small- and large-input fused routes serve it, at the large-input capacities of the 48-expert EP8 layout. - FIXED_SLOT_EXPERTS_PER_RANK: one place lists the EP8 expert widths that dispatch into fixed slots at the small capacities (48 and 49 experts a rank; the receive capacity is one row a source token and slot either way). The config selectors, the Stage1 geometry check and the small-input kernel read it, and so can a caller that sizes its decode capacities the same way. - Its own tune entry points (staged, small-input, large-input), which start from the 48-expert EP8 tunes; the large-input per-token combine wait stays off for its payload memory. - The narrow final-A Stage1 schedule of the 48-expert layout applies to it. Tests: tests/test_mega_moe_v41_shared_layout.py (layout gate, route for every max_tokens including each capacity's boundary, fixed-slot dispatch and its receive-capacity check, large-input 32-bit offsets with seven slots, the small-input protocol across buckets, the tune selection); op_tests/multigpu_tests/test_mega_moe_v2.py gains --network v41_flash_shared, whose seventh slot is the sender rank's shared expert, for the routes suite and the size suite. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…hared-expert layout With the shared expert as each rank's 49th expert, every rank runs about one more expert's worth of rows, all rank-local. Two things pay off for those rows on the small-input kernel: - en_order (FusedStage1Knobs, default 0): the GEMM1 (bit 1) and GEMM2 (bit 2) units of the run of one expert's m-tiles that lies wholly inside an XCD's slice go in (expert, n)-major order, so the run's m-tiles read each weight tile at about the same time and share it in the L2; bit 4 reads such grouped units' weights through the cache. The remap is a bijection on the slice's units that keeps every unit in its own expert's m-tiles and leaves the m-tiles cut by the slice ends in place, so only the order changes. The GEMM1 order runs on m-tile units, so it is refused together with pair_tiles; it reads the experts from the local plan, so it needs plan_local. - _V41_FLASH_EP8_SHARED_SMALL: the per-bucket knobs on top of the 48-expert EP8 tune (en_order, wider GEMM1 tiles and streamed W1 at the larger buckets, the lean GEMM1 / GEMM2 epilogues, dispatch CUs and waves per EU), searched before the small-input route changes this builds on and to be re-searched on them. None of them changes what ranks and launches exchange. Other layouts keep en_order 0: their kernels and configs are unchanged (the pinned config digests take en_order only when set). Tests: tests/test_mega_moe_v41_shared_layout.py checks each bucket is the 48-expert tune plus exactly its table entry, and that every small-input config with en_order is buildable (plan_local, no GEMM1 order with pair_tiles). Co-Authored-By: Claude Opus 5.5 <[email protected]>
yhl-amd
force-pushed
the
mega-v41-ep8-shared-49th
branch
from
November 25, 2026 08:29
1560e2e to
cbdf0f1
Compare
Contributor
Author
|
GPU validation of this head (
Not covered: end-to-end accuracy (the ATOM side that routes the shared expert into MegaMoE is not part of this PR) and re-searching the per-bucket table on this base. Result: pass at the op level. |
Contributor
Author
|
Closing: for the SemiAnalysis InferenceX submission the shared expert must not be re-quantized to MXFP4, so the 49th-expert FP4 layout is not usable there. The FP8 shared-expert path (in the spirit of #8491 / DeepGEMM's separate shared stage) is being pursued instead. Branch kept for reference. |
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.
Summary
Stacked on #8633 (base branch
ghu/mega_small_m_speedup_20261125, rebased onto its head6420f64ab); only the last two commits are this PR's. It will be rebased onto main once #8633 lands, and CI runs after that.DeepSeek-V4.1-Flash's shared expert can run inside MegaMoE as one more local expert of every EP rank (49 experts a rank, topk 7, the shared slot taken with weight 1). No MegaMoE layout covered that table, so it fell back to the staged route with the generic config.
feat(mega_moe): a layout of its own,V41_FLASH_EP8_SHARED_LAYOUT(8, 49, 5120, 2304), topk 7:FUSED_LAYOUTS: the small- and large-input fused routes serve it, at the large-input capacities of the 48-expert EP8 layout.FIXED_SLOT_EXPERTS_PER_RANK = (48, 49): one place lists the EP8 expert widths that dispatch into fixed slots at the small capacities; selectors, the Stage1 geometry check and the small-input kernel read it (same name as [FlyDSL] [DSV41] MegaMoE improvements for DEP8 #8186 / ATOM#3726 read).tune(mega_moe): per-bucket small-input knobs for that layout, plusFusedStage1Knobs.en_order(default 0): (expert, n)-major order of the GEMM1/GEMM2 units of an expert's m-tile run inside an XCD slice so the run shares weight tiles in L2. The remap is a bijection on the slice's units; GEMM1 order is refused together withpair_tilesand needsplan_local; the expert lookup reuses [FlyDSL] [MoE] MegaMoEV2: faster small-input route (bitwise identical), EP8 V4.1-Flash large-input route at every capacity #8633'sexpert_ballot(). Other layouts keepen_order0 and their pinned config digests do not change.Status (draft)
pair_tilesor the GEMM1 order).tests/test_mega_moe_v41_shared_layout.pyand the route-plan digest tests pass; the en_order remap arithmetic was checked in a Python mirror over random plans.v41_flash_shared(routes and size suites), andv41_flash(48 experts) gives accuracy output identical to the base. End-to-end accuracy is not run yet.FUSED_LAYOUTStable).Performance
All measured on 8x MI355X (gfx950), DeepSeek-V4.1-Flash DEP8, InferenceX AgentX c512, on stacks before #8633 (none on this PR's base). The per-bucket table is a placeholder until it is re-searched on #8633, so the numbers below are indicative only.
Shared expert as the 49th expert (first commit, with the ATOM side that routes the shared expert into MegaMoE, which is not part of this PR; 48-expert tune reused). 900 s, 1 run each, same machine, against the same stack with the shared expert run separately:
GSM8K 0.9249 (0.9257 without the change). MegaMoE gets slower per layer (128 rows 180 -> 192 us, 190 rows 203 -> 213 us, 16384 rows 4805 -> 5403 us), but the separate shared-expert GEMM / activation / quant kernels (about 1.8 ms of GPU time per decode step) go away.
Per-bucket table (second commit). 8-GPU replay of all 40 layers with recorded routing, CUDA-graph timing, median of 7 interleaved rounds, us per layer, against the default path of that stack. The table column is the local table this placeholder comes from (en_order plus per-bucket knobs; the placeholder drops the knobs #8633 no longer has). Outputs bit-identical.
End-to-end was only measured with that table plus three knobs ported from #8360 (
g2_pipe/g1_v2/comb_v2, not in this PR): 900 s per run, runs alternating with / without / without / with, on two machines: total throughput per GPU +2.69% (303,843 vs 295,893 tok/s) and +2.64% (304,654 vs 296,813); interactivity p90 +5.65% (136.5 vs 129.2) and +4.8% (136.5 vs 130.3). GSM8K 0.9181.🤖 Generated with Claude Code