Skip to content

[Triton/Gluon] [HIP] gemm_a16w16: gfx950 config for MiniMax-M3 lm_head (N=50016, K=6144) at small M - #6079

Merged
valarLip merged 2 commits into
mainfrom
minimax-m3-lm-head-a16w16-small-m
Oct 2, 2026
Merged

valarLip merged 2 commits into
mainfrom
minimax-m3-lm-head-a16w16-small-m

Conversation

@valarLip

@valarLip valarLip commented Oct 2, 2026 •

Copy link
Copy Markdown
Collaborator

Motivation

The MiniMax-M3 lm_head GEMM (TP4 vocab shard: [M, 6144] x [50016, 6144]^T, bf16 out) has tuned rows in minimax_m3_eagle_bf16_tuned_gemm.csv only at M = 1/2/4/8/16/... . For M = 3/5/6/7 the exact lookup misses and get_padded_m (gl=0) pads to the M = 16 row, a Triton "auto" entry. Triton's DEFAULT M_LEQ_8 config (8 warps, waves_per_eu 8) 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

  • New aiter/ops/triton/configs/gfx950/triton/gemm/gemm_a16w16/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). 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.mm on MI355X (gfx950, 256 CUs), this shape, median of 50 iterations:

M before after
1, 2, 4 115.8–117.2 us 95.2–95.9 us
3, 5 561.8–565.2 us 96.1–96.8 us
8 118.9 us 99.2 us
9–16 100.3–116.0 us unchanged (same Triton path)

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 = 0 now pads 0 < M < 16 to nextPow2(M):

M gl=0 before gl=0 after gl=1
3 16 4 4
5, 7 16 8 8
0, 1, 2, 4, 8, 9..15, >= 16 unchanged unchanged unchanged

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.

…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.
@valarLip
valarLip requested a review from a team October 2, 2026 05:50
@github-actions

github-actions Bot commented Oct 2, 2026

Copy link
Copy Markdown
Contributor

🏷️ CI Guide

Runs automatically on every PR:

  • ✅ Pre-checks (submodule verification, code formatting)
  • ✅ Aiter op tests (gfx942 + gfx950)
  • ✅ Triton tests on MI35X (only when aiter/ops/triton/** or related paths are changed)

Extended tests (opt-in via labels):

Label Tests
ci:gfx1250-ffm-triton Run the five-shard gfx1250 FFM Triton test suite
ci:triton-300x Run an additional Triton test job on MI300X in PRs (added automatically when gfx942 configs change); main branch always runs both MI35X and MI300X
ci:triton-355 Run the full Triton test suite on MI35X, not only the tests the change affects
multigpu Aiter multi-GPU tests on the 8-GPU runner
ci:sglang SGLang integration tests: DeepSeek-R1-MXFP4 accuracy, Qwen 3.5 accuracy
ci:atom ATOM benchmark: DeepSeek-R1-0528, GPT-OSS-120B
ci:atom_full ATOM accuracy suite for PR and main models from ATOM models_accuracy.json
ci:vllm vLLM benchmark: GPT-OSS-120B, DeepSeek-R1-0528, Kimi-K2.5
ci:all All standard extended tests (excludes ci:atom_full)

Only add ci:atom_full for FlyDSL or Triton upgrades.
Add labels via the sidebar or gh pr edit 6079 --add-label <label>

One backend per PR:
A PR changes one kernel backend: [Triton/Gluon] (Triton and Gluon count as one), [HIP], [ASM], [CK], [OPUS] or [FlyDSL]. If the title ends up with two backend tags, split the PR -- as stacked pull requests when one part cannot merge without the other.

PR title tags & labels:
Component tags ([Triton/Gluon], [HIP], [CK], [ASM], ...) are added to the PR title and as PR labels automatically from the changed files and re-synced on every push — change-type tags like [fix]/[Perf], op tags like [MLA], and human labels (ci:*) are left untouched. Add the no-auto-title label to stop the title rewrites; labels stay in sync either way.

@github-actions github-actions Bot changed the title gemm_a16w16: gfx950 config for MiniMax-M3 lm_head (N=50016, K=6144) at small M [Triton/Gluon] [Config] gemm_a16w16: gfx950 config for MiniMax-M3 lm_head (N=50016, K=6144) at small M Oct 2, 2026
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.
@valarLip valarLip changed the title [Triton/Gluon] [Config] gemm_a16w16: gfx950 config for MiniMax-M3 lm_head (N=50016, K=6144) at small M gemm_a16w16: MiniMax-M3 lm_head config at small M; getPaddedM fine-grained M < 16 Oct 2, 2026
@github-actions github-actions Bot changed the title gemm_a16w16: MiniMax-M3 lm_head config at small M; getPaddedM fine-grained M < 16 [Triton/Gluon] [HIP] gemm_a16w16: gfx950 config for MiniMax-M3 lm_head (N=50016, K=6144) at small M Oct 2, 2026
@github-actions github-actions Bot added HIP and removed Config labels Oct 2, 2026
@Boss2002n
Boss2002n requested a balanced review from Copilot October 2, 2026 09:33

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 Low severity

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.

Comment on lines +19 to +21
if(M > 0 && M < 16)
{
padded_m = nextPow2(M);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants