Repository navigation
[FlyDSL] MegaMoEV2: MiniMax-M3.1 EP4 layout on the fused small-input route - #8917
MengqingCao wants to merge 2 commits into
Conversation
MiniMax-M3.1's experts use SwiGLU-OAI: the gate clamped above and the up projection to +-swiglu_limit, then gate * sigmoid(1.702 * gate) * (up + 1). MegaMoEV2 accepts act="swigluoai" (with a positive swiglu_limit) and applies it in both GEMM1 epilogues through one helper, gated_act_f32: the shared SiluQuantEpilogue (staged route) and the ring GEMM1 of the fused small-input kernel, which takes act and keys its kernel name on it. The test reference gains the activation, an "m31" network and an MX rounding emulation (_reference(quantize=(input, hidden))) for an error check against the op's own quantization. Co-Authored-By: Claude <[email protected]>
…route Adds the MiniMax-M3.1 EP4 layout (4 ranks, 128 experts, top-4, hidden 6144, inter 3072) to the fused small-input kernel, both quants, with its SwiGLU-OAI activation clamped at 7. FUSED_LAYOUTS now maps each layout to the one (act, swiglu_limit) it is built for, and fused_layout_supported checks that pair instead of SiLU at 10. M3.1 is in SMALL_M_ONLY_LAYOUTS: the large-input kernel's epilogue is SiLU only and it combines over FP8, so a call above the small-input capacity takes the staged route. The fixed-slot dispatch admits 4 ranks x 32 experts. _tune_m31_ep4_small starts from the EP4 DeepSeek-V4.1-Flash tune, sends BF16 combine rows at every row count (new FusedStage1Knobs.bf16_wire, the M3.1 numerics) and, at bucket 128 (the decode points), caches W1 and starts GEMM2 early. Tests: the routes suite takes --network m31 and checks a call one row above the small-input capacity; a CPU test pins the M3.1 layout gate and its BF16 wire; bench_mega_moe_m31.py times M3.1 decode points on captured routing. Co-Authored-By: Claude <[email protected]>
🏷️ CI GuideRuns automatically on every PR:
Extended tests (opt-in via labels):
One backend per PR: PR title tags & labels: Reviews: |
|
Superseded by #8921: the same commit, reopened from a ROCm/aiter branch so the three PRs form a stack (stack #8923) and each shows only its own diff. |
Ready for review. No blocking issues. Stacked on #8916; review only the last commit (
20258e647). A cross-repo PR cannot target a fork branch, so this branch carries #8916's commit too.Why
On main, a MiniMax-M3.1 EP4 call (128 experts, top-4, hidden 6144, inter 3072) always takes the staged route. At 128 decode rows a rank, one MoE layer takes 269 us (a8w4) and 297 us (a4w4). The fused small-input kernel serves only DeepSeek layouts at SiLU 10.
What changed
FUSED_LAYOUTSmaps each layout to the one (act, swiglu_limit) it is built for, and adds M3.1 EP4 at SwiGLU-OAI 7, both quants.fused_layout_supportedchecks that pair.SMALL_M_ONLY_LAYOUTS: the large-input kernel is SiLU and FP8-wire only, so a call above 512 rows a rank takes the staged route._tune_m31_ep4_small: the V4.1-Flash EP4 tune plus BF16 combine rows always (newFusedStage1Knobs.bf16_wire); bucket 128 caches the GEMM1 weights.--network m31, a CPU test of the M3.1 gate, andbench_mega_moe_m31.pyfor captured routing.Review focus
Testing
At DP-group rows 8-512 the fused route is 1.55-2.07x (a8w4) and 1.70-2.10x (a4w4) faster than main's staged route, with every routes-suite check passing.
mengqing/main-megamoe-combine-wire @ ef6599c43: routes suite m31 a8w4 and a4w4 64 PASS, 0 FAIL each; V4.1-Flash EP4 57 PASS. CPU route-plan tests 218 passed. ruff, black clean.Follow-ups
combine_wire, honoured by every route: [FlyDSL] MegaMoEV2: combine_wire option that every route honours #8918.aiter/aot/flydsl/mega_moe.py); today its kernels trace on the JIT path.Dev record
Found. The fused a4w4 GEMM1 output is MXFP8 (#8623's design), so a4w4 fused differs from staged by relL2 0.15 but is closer to fp32 (0.196 vs 0.23).
Decided.
_use_direct_fixed_slot); the ring kernel needs no other change for it.bf16_wireis on in M3.1's tune at every bucket, so M3.1 never sends FP8 combine rows, whatever the caller asks.b_nt=0, early GEMM2 2/2) comes from a sweep on [FlyDSL] [CI] [MoE] MegaMoEV2: fully fused A4W4 routes, A8W4 performance optimizations, capacity 32768, rank-shared AOT #8623's pre-merge head; other buckets keep the V4.1-Flash EP4 tune, unmeasured on M3.1. The ring kernel is unchanged since then._LATE_KNOBSintests/test_mega_moe_gfx950_route_plan.pygainsbf16_wire, so the pinned DeepSeek config digests stay as they were.Surprised. none
Left undone. Not run: EP8 layouts, MI300X, MI250X. This commit alone was not run on GPU; the stack head was.
Evidence
4 x MI355X (gfx950), gpool lease on pit2-p03-g07 GPUs 4-7, image
mengqing-108/agx:c2f06e01-mega-a40489a9e(FlyDSL 0.5.3), each tree'saiter/ops/flydsl,aiter/aot,aiter/utility,op_tests/multigpu_testsandtestsover the image's aiter.One M3.1 layer, MTPR 512, routed, random top-4 routing and MXFP4 weights, R/4 rows a rank, max_tokens = R/4. Time is the median of 15 replays of a 20-call graph, max over ranks. Main runs
act="silu"(it rejects SwiGLU-OAI; same staged kernels and time), branchact="swigluoai", combine_wire="bf16".Branch relL2 vs fp32 SwiGLU-OAI reference: a8w4 0.053-0.054, a4w4 0.195-0.197. Captured-routing results (c140/c150 points, layers 3/20/40/59, error vs own-quant emulation no worse than staged) are in MengqingCao#5 on #8623's pre-merge head.
🤖 Generated with Claude Code