Repository navigation
[Config] [Tuning] [gfx950] Add MiniMax-M3.1 MXFP4 MoE configs (E=128, top-4, TP2/TP4); fix A16W4 tuner checks - #6942
Conversation
…hared-expert fusion (E=128, top-4, TP4)
Without shared-expert fusion, MiniMax-M3 runs its routed experts as an
E=128, top-4 fused MoE (the shared expert stays a separate MXFP8 MLP).
main only covers the fused E=129, top-5 shapes.
- Register (128, 6144, 768, 4) in moe_aux gen_instances.py SHAPES and in
MXFP4_MOE_SUPPORTED_SHAPES. Without the codegen line, candidates that
need mxfp4_moe_scatter_reduce crash with "no codegen'd instance for
aux_scatter_H6144_TOPK4_NT1"; without the Python line, fused_moe
rejects the MXMOE path for this shape.
- Add 16 A4W4 rows (tokens 1..32768, inter_dim 768) to
minimax_m3_fp4_{untuned,tuned}_fmoe.csv. Tuned with the default
(flydslv2) tuner, then --mxfp4-flydsl --compare --update_improved;
7 shapes (tokens 256, 1024..32768) took the MXMOE kernels, improving
the production op by 3.8% to 26.3% over the first pass.
Swiglu MXFP4 MoE runs A4W4 only from 256 tokens up; below that it runs
A16W4, whose E=128 rows follow separately.
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…16w4 tuner checks - Add 9 A16W4 rows (bf16 A x MXFP4 W, tokens 1..256, E=128, top-4, model_dim 6144, inter_dim 768) to minimax_m3_a16w4_tuned_fmoe.csv, tuned with the FlyDSL a16w4 kernels. Against main's default kernel choice, the production fused_moe op is 9.0% to 18.2% faster for tokens 1..128 and its relative L2 error vs the torch reference drops from 0.53-0.66% to 0.35%. - gemm_moe_tune.py, a16w4 FlyDSL stage2: the launcher always atomic-scatters into moe_buf and ignores the kernelName's reduce mode and persist (as fused_moe.stage2_uses_route_reduce already assumes), but the tuner zeroed moe_buf only for mode == "atomic". reduce-named candidates accumulated across timed iterations and were all rejected as catastrophic errors (max abs delta 97). Zero moe_buf for every a16w4 stage2 candidate, and skip the reduce/persist names, which launch the same kernel as the plain atomic one (stage2 candidates per shape 240 -> 60). - gemm_moe_tune.py, --run_config: shuffle the a16w4 W1 with the standard GGUU layout (gate_up=False) as op_tests/test_moe_2stage.py and the tuning path do; only a8w4 (fp8 A) uses the interleaved GUGU layout. With GUGU every a16w4 shape reported MISMATCH (logits_diff ~0.89) for any kernel, including main's CK-Tile path. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…P2 (E=128, top-4, inter_dim 1536)
- Register (128, 6144, 1536, 4) in MXFP4_MOE_SUPPORTED_SHAPES so fused_moe
takes the MXMOE path at TP2, and list it in gen_instances.py next to the
TP4 entry (the aux instances are keyed by NE/TOPK/H, so none are added).
- A4W4 rows, tokens 1..32768, in minimax_m3_fp4_{untuned,tuned}_fmoe.csv.
- A16W4 rows, tokens 1..256, in minimax_m3_a16w4_tuned_fmoe.csv.
Production fused_moe via gemm_moe_tune.py --run_config on one gfx950 GPU,
main's tables vs these rows: tokens 1..192 (A16W4) take 3.9% to 16.8% less
time, 256..32768 (A4W4) 5.3% to 24.7% less; all 17 shapes match the torch
reference.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
🏷️ CI GuideRuns automatically on every PR:
Extended tests (opt-in via labels):
One backend per PR: PR title tags & labels: |
…6 a4w4/a8w4, a8w8 block-scale TP4 shapes incl. split-K)
Extends the TP8 tables with the TP4 shapes of Mistral Large 4 on MI350X (gfx950,
256 CUs), tuned with the in-tree tuners of aiter 0.1.26 (--mxfp4-flydsl
--mxfp4-search-mode prune for a4w4, --mp 3, default errRatio):
- mistral_large4_{a8w4,a4w4}_tuned_fmoe.csv: +14 rows each, 128 experts top-4,
inter_dim 1536, M = 1..8192. The a4w4 winners are 1-stage flydsl_mxmoe_g1_*
kernels and need the (128, 6144, 1536, 4) MXFP4 aux shape (on main since ROCm#6942).
- a8w8_blockscale_tuned_gemm_mistral_large4.csv: +31 rows for N x K = 2048x6144
and 12288x6144 (M = 1..16384) and 6144x2048 (M = 16384), with a split-K pass
for M <= 256; 4096x6144 and 6144x6144 re-tuned on 0.1.26. The other TP4 shapes
(3072x6144, 6144x1536, 6144x2048 below M = 16384) are already covered by the
bundled ds_v3 / qwen3_next / glm5.2 tables and are left out.
- mistral_large4_bf16_tuned_gemm.csv: one duplicate (M=4, 512x6144) row removed.
- Untuned shape lists extended accordingly.
End to end (vLLM, TP4, a4w4 experts, bf16 KV, 8k in / 1k out): TPOT -14 / -9 / -8 %
and output throughput +16 / +9 / +9 % at concurrency 1 / 4 / 8 over the heuristic
configs; gsm8k unchanged.
Signed-off-by: Hongxia Yang <[email protected]>
Co-Authored-By: Claude Fable 5.1 <[email protected]>
* [Config] Mistral Large 4: gfx950 TP8 tuned tables (fused MoE a8w4/a4w4, a8w8 block-scale, bf16 GEMM) Tuned on MI350X (gfx950, 256 CUs) for Mistral Large 4 (hidden 6144, 128 experts top-4, MLA ranks 512/64/128, vocab 204800) served at TP8, with the in-tree tuners (--mp 8, default errRatio). Files go under aiter/configs/model_configs/ and are named so the existing *tuned_fmoe* / *a8w8_blockscale_tuned_gemm* / *bf16_tuned_gemm* globs merge them with the bundled tables; no shape overlaps the bundled rows. - mistral_large4_a8w4_tuned_fmoe.csv (14 rows) and mistral_large4_a4w4_tuned_fmoe.csv (9 rows): 2-stage fused MoE, 128 experts, top-4, inter_dim 768, SiLU, per_1x32 MXFP4 weights; fp8 activations (a8w4) for M = 1..8192 and MXFP4 activations (a4w4, --mxfp4-flydsl prune search) for M = 32..8192 (no candidates below M=32 in that port). - a8w8_blockscale_tuned_gemm_mistral_large4.csv (91 rows): 128x128 block-scale fp8 GEMMs, N x K = 1024x6144, 1536x6144, 4096x6144, 6144x768/1024/3072/6144, M = 1..16384, --libtype all, plus a split-K pass for M <= 256 that takes the K=6144 small-M shapes from ~19.6 us to 6-10 us. - mistral_large4_bf16_tuned_gemm.csv (45 rows): bf16 GEMMs 512x6144, 576x6144, 25600x6144, M = 1..16384. The two opus rows use the local kernel IDs introduced by #6937 (resolved with kid_for_name; same kernels as tuned). The untuned inputs are added next to each tuned file for retuning. Measured end to end (vLLM, TP8, 8k in / 1k out): +14-22% output throughput over the heuristic configs across concurrency 1-64, accuracy unchanged. Signed-off-by: Hongxia Yang <[email protected]> Co-Authored-By: Claude Fable 5.1 <[email protected]> * [Config] Mistral Large 4: gfx950 TP4 tunings (fused MoE inter_dim 1536 a4w4/a8w4, a8w8 block-scale TP4 shapes incl. split-K) Extends the TP8 tables with the TP4 shapes of Mistral Large 4 on MI350X (gfx950, 256 CUs), tuned with the in-tree tuners of aiter 0.1.26 (--mxfp4-flydsl --mxfp4-search-mode prune for a4w4, --mp 3, default errRatio): - mistral_large4_{a8w4,a4w4}_tuned_fmoe.csv: +14 rows each, 128 experts top-4, inter_dim 1536, M = 1..8192. The a4w4 winners are 1-stage flydsl_mxmoe_g1_* kernels and need the (128, 6144, 1536, 4) MXFP4 aux shape (on main since #6942). - a8w8_blockscale_tuned_gemm_mistral_large4.csv: +31 rows for N x K = 2048x6144 and 12288x6144 (M = 1..16384) and 6144x2048 (M = 16384), with a split-K pass for M <= 256; 4096x6144 and 6144x6144 re-tuned on 0.1.26. The other TP4 shapes (3072x6144, 6144x1536, 6144x2048 below M = 16384) are already covered by the bundled ds_v3 / qwen3_next / glm5.2 tables and are left out. - mistral_large4_bf16_tuned_gemm.csv: one duplicate (M=4, 512x6144) row removed. - Untuned shape lists extended accordingly. End to end (vLLM, TP4, a4w4 experts, bf16 KV, 8k in / 1k out): TPOT -14 / -9 / -8 % and output throughput +16 / +9 / +9 % at concurrency 1 / 4 / 8 over the heuristic configs; gsm8k unchanged. Signed-off-by: Hongxia Yang <[email protected]> Co-Authored-By: Claude Fable 5.1 <[email protected]> --------- Signed-off-by: Hongxia Yang <[email protected]> Co-authored-by: Claude Fable 5.1 <[email protected]>
…=128, top-4) for 8/16/32/64/128 tokens (#7414) Replace the FlyDSL a16w4 kernel pair of the E=128/topk=4/inter_dim=768 rows for tokens 8, 16, 32, 64 and 128 in minimax_m3_a16w4_tuned_fmoe.csv (rows 1, 2, 4, 256 and all A4W4 rows are unchanged). The rows added in #6942 were tuned under uniformly random routing. Real MiniMax-M3.1 AgentX decode routing touches 46/53/64/71/89 distinct experts per layer at 24/32/40/64/96 tokens (uniform random: 68/82/92/111/122), and there the token=64 row of #6942 is slower than the CK-tile default. Rows were swept over the FlyDSL a16w4 registry (tile_m=16, 304 stage-1 and 64 stage-2 kernels) with `fused_moe` end to end, replaying the real per-layer top-k ids dumped from a live AgentX c16 run (57 layers per CUDA graph, 6 weight copies). Per layer, us, vs #6942 rows: bucket 32 82.0 -> 77.8, 64 103.5 -> 91.2, 128 95.7 -> 89.3, 8 43.1 -> 40.2, 16 60.0 -> 56.2; default CK-tile path: 79.9 / 92.3 / 92.8 / 43.2 / 60.0. us1/us2/us/err2 are measured with uniform random routing at token=T (err2: max-abs error of the whole fused op vs a bf16 reference of the dequantised weights, in % of max|ref|). Signed-off-by: Fangzhou Ai <[email protected]> Co-authored-by: lirui927 <[email protected]> Co-authored-by: Claude Sonnet 5.5 <[email protected]>
…=128, top-4) for 8/16/32/64/128 tokens (#7414) Replace the FlyDSL a16w4 kernel pair of the E=128/topk=4/inter_dim=768 rows for tokens 8, 16, 32, 64 and 128 in minimax_m3_a16w4_tuned_fmoe.csv (rows 1, 2, 4, 256 and all A4W4 rows are unchanged). The rows added in #6942 were tuned under uniformly random routing. Real MiniMax-M3.1 AgentX decode routing touches 46/53/64/71/89 distinct experts per layer at 24/32/40/64/96 tokens (uniform random: 68/82/92/111/122), and there the token=64 row of #6942 is slower than the CK-tile default. Rows were swept over the FlyDSL a16w4 registry (tile_m=16, 304 stage-1 and 64 stage-2 kernels) with `fused_moe` end to end, replaying the real per-layer top-k ids dumped from a live AgentX c16 run (57 layers per CUDA graph, 6 weight copies). Per layer, us, vs #6942 rows: bucket 32 82.0 -> 77.8, 64 103.5 -> 91.2, 128 95.7 -> 89.3, 8 43.1 -> 40.2, 16 60.0 -> 56.2; default CK-tile path: 79.9 / 92.3 / 92.8 / 43.2 / 60.0. us1/us2/us/err2 are measured with uniform random routing at token=T (err2: max-abs error of the whole fused op vs a bf16 reference of the dequantised weights, in % of max|ref|). Signed-off-by: Fangzhou Ai <[email protected]> Co-authored-by: lirui927 <[email protected]> Co-authored-by: Claude Sonnet 5.5 <[email protected]>
…ge 2 When main was merged in, the MiniMax-M3.1 TP4 A16W4 rows at 8-128 tokens went back to #6942's kernels and undid #7414's retune for every caller. They now use #7414's stage-1 kernels and its 16-token row. Only stage 2 at 8, 32, 64 and 128 tokens changes from the reduce to the atomic epilogue (the fused shared expert needs it), and the rows carry shared-expert tiles (_sh), which do not change the routed kernels. Real routing (top-4 ids of all 57 MoE layers from an AgentX c16 replay, 114 layer routings per token count, cold weights, MI355X), wall us a call: tokens #7414 this, routed only this + shared expert before + shared 8 39.4 37.1 37.5 39.6 16 56.1 56.1 58.0 61.5 32 80.1 78.2 89.0 84.9 64 114.5 109.8 112.8 120.3 128 142.7 136.9 142.6 150.7 CSV values: us1 = #7414's (the same stage-1 kernel); us2 and us = #7414's plus the measured change of the whole op (uniform routing, same process); err2 measured against the FP32 reference. Signed-off-by: Vinayak Gokhale <[email protected]>
* [FlyDSL] [Perf] A16W4 MoE: optional fused bf16 shared expert
The moe_2stage_a16wmix gemm1/gemm2 kernels can now compute a dense bf16
shared expert in the same launches as the routed experts. The shared
tiles take the first program ids. The routed tiles and the sort do not
change. Without shared weights, the kernels, names and launch signatures
do not change.
- gemm1/gemm2: dense=True body mode and *_shared kernel variants
(compile parameters shared_tile_n/_m/_k and shared_k_wave).
- moe_kernels: parse the "_sh{M}x{N}x{K}[kw{W}]" kernel-name suffix;
forward shared_w1_bf16/shared_w2_bf16/shared_inter_bf16.
- fused_moe: the FlyDSL stage wrappers forward the shared tensors.
- MiniMax-M3.1 TP4 A16W4 rows: shared tiles on the 32-256 rows and
measured exact-width decode rows (40-168).
- Tests in op_tests/test_flydsl_moe_a16wfp4.py.
Signed-off-by: Vinayak Gokhale <[email protected]>
* [FlyDSL] [Perf] A16W4 MoE: MXFP8 weights for the fused shared expert
The dense shared expert of the moe_2stage_a16wmix gemm1/gemm2 kernels can
now read MXFP8 weights (fp8 e4m3 codes + E8M0 1x32 scales) instead of a
bf16 copy, at half the weight bytes. The format follows the dtype of the
shared weight the caller passes; bf16 weights run as before.
- utils.make_b_loader: w_dtype "fp8". Codes in the shuffle_weight (16, 16)
layout (two dwordx4 per lane and 128-K block, whole-line runs per load
instruction), scales in the shuffle_scale layout (the routed MXFP4 scale
path, reused). The codes are scaled to bf16 in registers right before the
MFMA (v_cvt_scalef32_pk_bf16_fp8). An e4m3 value times a power of two is a
bf16 value and the K order and MFMA sequence are the bf16 path's, so the
output is bitwise that of the bf16 weights. gfx950 only.
- gemm1/gemm2: compile parameter shared_w_dtype ("bf16" or "fp8", kernel
name suffix _mxfp8); the shared kernels take a scale pointer. gemm2
asserts a power-of-two shared_tile_k (its A-LDS swizzle needs it).
- API: shared_w1 / shared_w1_scale and shared_w2 / shared_w2_scale
(fused_moe naming) replace shared_w1_bf16 / shared_w2_bf16 in the FlyDSL
stage wrappers and moe_kernels.
- MiniMax-M3.1 TP4 rows: shared tiles retuned for MXFP8 at the same shared
k_wave (so bitwise to the bf16 path): g1 rows 32, 48-56, 72-168, g2 rows
72-80.
- Tests: MXFP8 shared vs bf16 shared bitwise at every M3.1 TP4 decode row
(1-256; stage 1 and stage-2 shared tiles), MXFP8 in the shared-expert
correctness tests and the fused_moe_2stages test, argument checks.
MI355X, M3.1 TP4 rows, skewed routing, cold weights, CUDA graph, us per
layer (gemm1 + gemm2), bf16 shared at the previous tiles -> MXFP8 shared:
8 46.1 -> 43.0, 16 68.6 -> 60.2, 32 89.5 -> 86.1, 64 118.7 -> 117.1,
128 160.4 -> 152.4, 160 178.0 -> 161.4, 256 202.9 -> 195.9.
Signed-off-by: Vinayak Gokhale <[email protected]>
* [FlyDSL] A16W4 shared expert: LDS checks and a bounded default tile width
- a16w4_default_shared_tile_n raises ValueError when N is not a positive
multiple of step, and starts its search at N or below. Before, the
search did not stop for such an N, or when tile_n / 4 was above N.
- The shared-expert builds of gemm1 and gemm2 compare their LDS size with
get_lds_capacity_bytes and raise NotImplementedError above it, as the
gemm2 reuse_lds build does. The shipped _sh tiles use at most 64 KB
(gemm1) and 32 KB (gemm2).
- New tests: test_default_shared_tile_n_bounds,
test_stage1_shared_rejects_oversized_lds and
test_stage2_shared_rejects_oversized_lds.
Signed-off-by: Vinayak Gokhale <[email protected]>
* [FlyDSL] A16W4 shared expert: name the arguments fused_shared_w*
op_tests/test_fhmoe.py::test_heterogeneous_moe_uses_a_separate_custom_op_schema
keeps FHMoE's argument names (shared_w1, shared_w2, shared_w1_scale,
shared_w2_scale, shared_expert_id, clamp_shared) off the ordinary MoE APIs,
so that the heterogeneous MoE keeps its own custom-op schema. The A16W4
shared expert used shared_w1 / shared_w1_scale / shared_w2 /
shared_w2_scale on flydsl_moe_stage1/2 and the FlyDSL stage wrappers, and
that test failed in CI. They are now fused_shared_w1, fused_shared_w1_scale,
fused_shared_w2 and fused_shared_w2_scale (the shared expert fused into the
routed launches); shared_inter_bf16 and shared_tile do not change.
FHMoE's own arguments in fused_moe do not change.
Signed-off-by: Vinayak Gokhale <[email protected]>
* [Config] M3.1 A16W4 rows at 8-128 tokens: #7414's kernels, atomic stage 2
When main was merged in, the MiniMax-M3.1 TP4 A16W4 rows at 8-128 tokens
went back to #6942's kernels and undid #7414's retune for every caller.
They now use #7414's stage-1 kernels and its 16-token row. Only stage 2 at
8, 32, 64 and 128 tokens changes from the reduce to the atomic epilogue
(the fused shared expert needs it), and the rows carry shared-expert tiles
(_sh), which do not change the routed kernels.
Real routing (top-4 ids of all 57 MoE layers from an AgentX c16 replay,
114 layer routings per token count, cold weights, MI355X), wall us a call:
tokens #7414 this, routed only this + shared expert before + shared
8 39.4 37.1 37.5 39.6
16 56.1 56.1 58.0 61.5
32 80.1 78.2 89.0 84.9
64 114.5 109.8 112.8 120.3
128 142.7 136.9 142.6 150.7
CSV values: us1 = #7414's (the same stage-1 kernel); us2 and us = #7414's
plus the measured change of the whole op (uniform routing, same process);
err2 measured against the FP32 reference.
Signed-off-by: Vinayak Gokhale <[email protected]>
---------
Signed-off-by: Vinayak Gokhale <[email protected]>
MiniMax-M3.1 with MXFP4 experts and the shared expert not fused into the routed experts runs a fused MoE with E=128, top-4. main tunes only the fused shape (E=129, top-5), so E=128 falls back to the default kernel choice, and the MXFP4 aux kernels have no instance for it. This adds TP4 (inter_dim 768 per GPU) and TP2 (inter_dim 1536).
Changes
moe_aux/codegen/gen_instances.pyandMXFP4_MOE_SUPPORTED_SHAPES. Without them, tuning and inference fail withno codegen'd instance for shape key 'aux_scatter_H6144_TOPK4_NT1'.minimax_m3_fp4_{untuned,tuned}_fmoe.csv.minimax_m3_a16w4_tuned_fmoe.csv.fused_moetakes this path for M < 256; the key rounds M up to a power of two, so M in 129..255 reads the 256 row.gemm_moe_tune.py, A16W4 only: stage2 always atomic-scatters intomoe_buf, so the tuner zeroes it for every candidate and skips the reduce/persist names, which launch the same kernel. Before, reduce-named candidates accumulated and were rejected as errors.--run_configshuffles the stage-1 weight as GGUU, like the tuning path andop_tests/test_moe_2stage.py; with GUGU every A16W4 shape reported MISMATCH.The config files only gain lines.
Op-level result
Production
fused_moeviagemm_moe_tune.py --run_config, one gfx950 GPU. main uses onlyaiter/configs/tuned_fmoe.csv, which has no E=128 rows; PR uses this PR's rows. Each token uses the pathfused_moepicks for it. All shapes match the torch reference on both.Token 192 exercises the A16W4 row keyed 256.
End-to-end result
MiniMax-M3
ATOM, MiniMax-M3-MXFP4 on gfx950 GPUs. This checkpoint's shared expert is MXFP4, so ATOM's fusion check was patched to return False to run the E=128, top-4 path; main and PR differ only in the MoE table, as above. In the server logs every E=128 lookup under PR hit a tuned row (TP2: 148 lookups, 0 default, 0 "no tuned FlyDSL config" warnings); under main all took the default.
GSM8K (5-shot, 1319 questions), mean of two runs: TP4 main 0.9420, PR 0.9416; TP2 main 0.9394, PR 0.9394. The gaps are within run-to-run noise.
benchmark_serving, ISL 8192 / OSL 1024, one run each: output throughput +3.5% (TP4) and +5.0% (TP2) at concurrency 4, +1.7% and +3.5% at 64.
MiniMax-M3.1
ATOM-m3, MiniMax-M3.1-preview2 Quark MXFP4 on gfx950 GPUs. This checkpoint's shared expert is MXFP8, so ATOM keeps it out of the routed MoE without any patch and the routed MoE runs E=128, top-4; main and PR differ only in the MoE table. Under PR every E=128 lookup hit a tuned row (per GSM8K run 88 at TP4 and 44 at TP2, per benchmark run 104 and 52; 0 default); under main all took the default.
GSM8K (5-shot, 1319 questions): TP4 main 0.9510 (mean of three runs), PR 0.9522 (mean of four runs); TP2 main 0.9484, PR 0.9481 (mean of two runs).
benchmark_serving, ISL 8192 / OSL 1024, mean of two runs (one with PR first, one with main first):