Repository navigation
[Triton/Gluon] [HIP] gemm_a16w16: gfx950 config for MiniMax-M3 lm_head (N=50016, K=6144) at small M - #6079
Conversation
…t small M The MiniMax-M3 lm_head GEMM (TP4 vocab shard, [M, 6144] x [50016, 6144]^T, bf16 out) had tuned rows only at M = 1/2/4/8/16/... . M = 3/5/6/7 missed the exact lookup and padded to the M = 16 row (Triton "auto"), whose DEFAULT M_LEQ_8 config (8 warps, waves_per_eu 8) takes ~550 us on this shape, vs ~115 us for M = 4/8. A decode step of 3, 5, 6 or 7 sequences paid ~450 us extra. - Add GEMM-A16W16-N=50016-K=6144.json: DEFAULT with M_LEQ_8 set to the M_LEQ_16 config (4 warps, waves_per_eu 6). - Point the M = 1/2/4/8 rows of minimax_m3_eagle_bf16_tuned_gemm.csv at Triton (they were flydsl hgemm at ~115 us). tgemm.mm on MI355X, this shape: M = 1..16 all 95-111 us (before: 116 us at M = 1/2/4/8, ~550 us at M = 3/5/6/7; M = 9..16 unchanged). In an ATOM MiniMax-M3 TP4 server trace the lm_head kernel per decode step went from 553-560 us to 93-96 us at bs 3/5/6/7 and from ~116 us to ~93 us at bs 1/2/4/8.
🏷️ CI GuideRuns automatically on every PR:
Extended tests (opt-in via labels):
One backend per PR: PR title tags & labels: |
The tuned-config walk is exact M -> getPaddedM(gl=0, "fine") -> getPaddedM(gl=1, "coarse"), used by tgemm, a8w8 / a4w4 / batched, opus and the CK / cktile a8w8 C++ lookups. For M < 16 the "fine" level (round up to a multiple of 16) is coarser than the "coarse" one (next power of two): M = 3 padded to 16 before 4, M = 5..7 to 16 before 8, so a tuned M = 4 / 8 row was skipped whenever an M = 16 row existed (the MiniMax-M3 lm_head took the M = 16 Triton row at M = 3 / 5..7). gl = 0 now pads 0 < M < 16 to nextPow2(M): M = 3 -> 4, M = 5..7 -> 8. M = 0, M = 9..15 (-> 16) and every M >= 16 are unchanged.
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
The HIP padding change must be separated from the Triton tuning changes per the one-backend-per-PR rule.
Review effort: Balanced
Findings: 1
Open (1)
What changed in this PR
Optimizes MiniMax-M3 lm_head GEMM dispatch on gfx950 for small M values.
Changes:
- Adds shape-specific Triton tuning for N=50016, K=6144.
- Routes selected model rows from FlyDSL to Triton.
- Refines sub-16 padded-M lookup behavior.
| File | Description |
|---|---|
csrc/py_itfs_cu/gemm_common.cu |
Uses power-of-two padding below M=16. |
aiter/ops/triton/configs/gfx950/triton/gemm/gemm_a16w16/GEMM-A16W16-N=50016-K=6144.json |
Adds gfx950 shape-specific tuning. |
aiter/configs/model_configs/minimax_m3_eagle_bf16_tuned_gemm.csv |
Selects Triton for small-M lm_head rows. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| if(M > 0 && M < 16) | ||
| { | ||
| padded_m = nextPow2(M); |

Motivation
The MiniMax-M3 lm_head GEMM (TP4 vocab shard:
[M, 6144] x [50016, 6144]^T, bf16 out) has tuned rows inminimax_m3_eagle_bf16_tuned_gemm.csvonly at M = 1/2/4/8/16/... . For M = 3/5/6/7 the exact lookup misses andget_padded_m(gl=0) pads to the M = 16 row, a Triton "auto" entry. Triton's DEFAULTM_LEQ_8config (8 warps,waves_per_eu8) takes ~550 us on this shape, vs ~115 us for M = 4/8, so every decode step with 3, 5, 6 or 7 sequences paid ~450 us extra.Changes
aiter/ops/triton/configs/gfx950/triton/gemm/gemm_a16w16/GEMM-A16W16-N=50016-K=6144.json: DEFAULT withM_LEQ_8set to theM_LEQ_16config (4 warps,waves_per_eu6). Every other bucket is DEFAULT's.minimax_m3_eagle_bf16_tuned_gemm.csv: the M = 1/2/4/8 rows of this shape (outdtype bf16) now select Triton (were flydsl hgemm, ~115 us).Test results
tgemm.mmon MI355X (gfx950, 256 CUs), this shape, median of 50 iterations:M = 1 reaches ~6.45 TB/s (615 MB of weight). Outputs checked against the previous path (rel l2 < 1e-2, bf16 GEMM).
In an ATOM MiniMax-M3-MXFP4 TP4 server trace (ISL 3000 / OSL 256), the lm_head kernel per decode step went from 553–560 us to 93–96 us at bs 3/5/6/7 and from ~116 us to ~93 us at bs 1/2/4/8 (decode step −8% to −13.5% at bs 3/5/6/7).
getPaddedM: fine-grained lookup for M < 16
The tuned-config walk (tgemm, a8w8 / a4w4 / batched, opus, CK / cktile a8w8) is exact M ->
getPaddedM(gl=0)("fine") ->getPaddedM(gl=1)("coarse"). For M < 16 the fine level (round up to a multiple of 16) is coarser than the coarse one (next power of two), so M = 3 padded to 16 before 4 and M = 5..7 to 16 before 8: a tuned M = 4 / 8 row was skipped whenever an M = 16 row existed. That is how the lm_head above landed on the M = 16 Triton row at M = 3 / 5..7.gl = 0now pads0 < M < 16tonextPow2(M):Tests:
op_tests/tuning_tests/test_a6w6_tuning.py,test_mixed_mxfp_tuning.py,test_opus_a8w8_interface.py: 38 passed;test_mixed_mxfp_tuning.py::test_bare_run_config_retains_canonical_untuned_shapes(a6w4 / a4w6) fails the same way on unmodified main and does not use padded lookups.