Skip to content

[Triton/Gluon] [Config] [Perf] [gfx950] Tune afp4wfp4 decode configs for Llama-3.1-8B dense shapes - #6015

Merged
azaidy merged 2 commits into
ROCm:mainfrom
reger-men:mxfp4-llama8b-decode-configs
Oct 8, 2026
Merged

azaidy merged 2 commits into
ROCm:mainfrom
reger-men:mxfp4-llama8b-decode-configs

Conversation

@reger-men

Copy link
Copy Markdown
Contributor

Tuned gemm_afp4wfp4 configs on gfx950 for the four Llama-3.1-8B dense projections at decode sizes, M_LEQ_1 up to M_LEQ_64. Config only, no kernel change. qkv (N=6144, K=4096) and o_proj (N=4096, K=4096) get their own files, before this they fell back to DEFAULT.json. gate_up (N=28672, K=4096) and down_proj (N=4096, K=14336) get their M<=64 buckets replaced. Everything above M_LEQ_64 is left as it was.

I kept it as two commits so the M<=8 half and the M 9-64 half can be reviewed on their own, the per-bucket reasoning is in each commit message. Short version: none of the four had an M_LEQ_1 bucket, so batch 1 resolved to M_LEQ_8. There qkv, o_proj and gate_up run matrix_instr_nonkdim=32 with NUM_KSPLIT=4 (down_proj is already nonkdim=16 but NUM_KSPLIT=8), so a 1-8 row batch wastes most of the 32-wide MFMA and pays for a second reduce kernel. The new M_LEQ_1 and M_LEQ_8 entries use nonkdim=16 and no split-K, except down_proj M_LEQ_1 which keeps 4. At M_LEQ_64 all four shapes were on BM=32 BN=32 BK=512, so a 48 or 64 row batch gets split over two M tiles and every weight tile is read twice.

Each candidate was timed inside a captured cudagraph with cold weights (a set of weight copies bigger than the MALL), since batch-1 decode streams all the weights every token and a cache-hot microbench picks the wrong tile. Every picked tile gives the same GEMM output bytes as the shipped one. Isolated GEMM, new vs shipped, at M_LEQ_1: qkv 0.62x, o_proj 0.57x, gate_up 0.53x, down_proj 0.84x. At M_LEQ_64: 0.79x, 0.71x, 0.46x, 0.52x.

End to end I served Llama-3.1-8B-Instruct MXFP4 (W4A4) under vLLM on one MI355X, GPU idle-checked before every run, clock pinned with perf_determinism at 1700 MHz (sclk under load CV below 0.6%), one config per process, compiled + cudagraph, in128/out128. p50 ms/tok decode, shipped configs -> this PR, with the FP8 build of the same model as reference:

  • bs1 3.331 -> 2.671 (-19.8%), FP8 2.955
  • bs8 3.680 -> 2.928 (-20.4%), FP8 3.823
  • bs16 3.319 -> 2.963 (-10.7%), FP8 3.917
  • bs32 3.634 -> 3.415 (-6.0%), FP8 4.137
  • bs64 5.135 -> 4.123 (-19.7%), FP8 4.633

So MXFP4 goes from 12.7% slower than FP8 at bs1 (and 10.8% slower at bs64) to faster than FP8 at every batch size I tested, -9.6% at bs1 and -11.0% at bs64. Shipped is the mean of 2 runs, FP8 of 6, this PR is 1 run, and later runs with these configs gave bs1/8/16 within 0.02 ms of it.

Output doesnt change. Greedy token ids are identical to the shipped configs for every sequence at bs1/8/16/32/64 and for 84 diverse prompts at batch 1, 16 and 64. At full size, with these configs plus the separate quant launch change below, GSM8K 1319/1319 generations are token-identical to shipped, and ARC-Challenge 1172/1172 and MMLU 14042/14042 pick the same answer on every item.

I also have a dynamic_mxfp4_quant launch fix for 16 < M <= 64 that helps bs32/64 further. It's independent of this PR (different file, either can go first) and I'll send it on its own, the numbers above are configs only.

@reger-men
reger-men requested a review from a team September 30, 2026 17:06
@github-actions

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 6015 --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.

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

🔵 Needs a closer look

The reported GPU results need final human validation, and the new specialized decode buckets lack automated correctness coverage.

Review effort: Balanced
Findings: 1 Low severity

Open (1)
What changed in this PR

This PR tunes gfx950 MXFP4 GEMM configurations for Llama-3.1-8B decode projections without changing the kernel.

Changes:

  • Adds shape-specific configurations for QKV and output projections.
  • Retunes decode buckets through M=64 for gate/up and down projections; larger buckets remain unchanged.
File Description
aiter/​ops/​triton/​configs/​gfx950/​triton/​gemm/​gemm_afp4wfp4/​GEMM-AFP4WFP4-N=6144-K=4096.json Adds QKV projection tuning.
aiter/​ops/​triton/​configs/​gfx950/​triton/​gemm/​gemm_afp4wfp4/​GEMM-AFP4WFP4-N=4096-K=4096.json Adds output projection tuning.
aiter/​ops/​triton/​configs/​gfx950/​triton/​gemm/​gemm_afp4wfp4/​GEMM-AFP4WFP4-N=4096-K=14336.json Retunes down projection decode buckets.
aiter/​ops/​triton/​configs/​gfx950/​triton/​gemm/​gemm_afp4wfp4/​GEMM-AFP4WFP4-N=28672-K=4096.json Retunes gate/up projection decode buckets.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@reger-men

Copy link
Copy Markdown
Contributor Author

@azaidy could you take a look when you have a moment? its config only, four gfx950 afp4wfp4 files for the Llama-3.1-8B dense shapes.

I pushed one more commit for the review comment on test coverage: get_x_vals() now has M 1/8/16/32/64 for all four tuned N/K pairs, (6144, 4096) included, so every new M_LEQ_* entry gets checked against the torch reference on both the plain and preshuffled path. On MI355X that selection is 170 passed (gluon cases skip like the rest of the file), and each of those M/N/K pairs resolves to its tuned entry.

The red MI35X shard 0 on the old head was op_tests/test_jit_dir_with_enum.py (fmoe asm output came back all zeros). That test doesn't touch these files and it didnt fail in any of the later main and PR runs of the same workflow I checked, so I'm reading it as a flake. I also rebased on main, so CI runs fresh on the new head.

@github-actions github-actions Bot changed the title [Triton/Gluon] [Config] [Perf] [gfx950] Tune afp4wfp4 decode configs for Llama-3.1-8B dense shapes [Triton/Gluon] [Perf] [gfx950] Tune afp4wfp4 decode configs for Llama-3.1-8B dense shapes Oct 2, 2026
@github-actions github-actions Bot removed the Config label Oct 2, 2026
…s for Llama-3.1-8B dense shapes

The afp4wfp4 M<=8 decode configs for the Llama-3.1-8B dense projections
fall back to DEFAULT.json for qkv and o_proj, and the shipped gate_up
entry is the same shape of config: BM=8 BN=64 BK=512 with
matrix_instr_nonkdim=32 and NUM_KSPLIT=4. At batch 1-8 that 32-wide MFMA
tile is fed 1-8 rows and wastes most of the matrix unit, and the split-K
adds a second reduce kernel. down_proj (K=14336) already ships nonkdim=16
but with NUM_KSPLIT=8.

New entries use nonkdim=16 everywhere and drop split-K except for
down_proj at M_LEQ_1 (4 instead of 8). qkv, o_proj and down_proj M_LEQ_8
also move to BK=1024 with small BM/BN tiles and 2 warps.

The candidates were timed inside a captured cudagraph with cold weights
(a set of weight copies bigger than the MALL, per-call median), since
batch-1 decode streams all 3.7 GB of weights every token and a cache-hot
microbench picks the wrong tile. Isolated GEMM at M=1, new vs shipped:
qkv 0.62x, o_proj 0.57x, gate_up 0.53x, down_proj 0.84x.

Batch-1 decode runs the GEMM at M=1, so it reads M_LEQ_1. M_LEQ_8 is what
batch 2-8 reads.

Served, Llama-3.1-8B-Instruct-MXFP4-W4A4 under vLLM on MI355X, GPU
idle, clock pinned (perf_determinism), p50 ms/tok:

- bs1  3.331 -> 2.671 (-19.8%), FP8 build of the same model is 2.955
- bs8  3.680 -> 2.928 (-20.4%), FP8 3.823

Greedy output is byte-identical to the shipped configs (same kernel,
only the tile changes). Every bucket above M_LEQ_8 is left as shipped in
this commit.

Signed-off-by: adlashab <[email protected]>
… for Llama-3.1-8B dense shapes

Follow-up to the M<=8 change, same four shapes, now for the buckets that
batch 9-64 decode hits (vLLM captures cudagraphs at 16/24/32/48/64, so
those land in M_LEQ_16, M_LEQ_32 and M_LEQ_64). All four shapes were
running BM=32 there, and at M_LEQ_64 the fallback is BM=32 BN=32 BK=512,
so a 48/64 row batch gets split over two M tiles and every weight tile is
read twice. gate_up and down_proj suffer the most because they are the
big ones.

Same method as the M<=8 commit: each candidate timed inside a captured
cudagraph with cold weights, summed over the batch sizes that map to the
bucket. Split-K and nonkdim=32 were in the search space. Only down_proj
keeps split-K (2 at M_LEQ_32, 4 at M_LEQ_64). Isolated GEMM, new vs
shipped, M_LEQ_16 / M_LEQ_32 / M_LEQ_64:

- qkv       0.97x / 0.97x / 0.79x
- o_proj    0.87x / 0.95x / 0.71x
- gate_up   0.64x / 0.71x / 0.46x
- down_proj 0.81x / 0.87x / 0.52x

Served, Llama-3.1-8B-Instruct-MXFP4-W4A4 under vLLM on MI355X, GPU
idle, clock pinned (perf_determinism), p50 ms/tok, M<=8 buckets tuned in
both arms:

- bs16  3.320 -> 2.966 (-10.7%)
- bs32  3.640 -> 3.408 (-6.4%)
- bs64  5.128 -> 4.096 (-20.1%)

bs1 and bs8 do not change (they resolve to M_LEQ_1/M_LEQ_8). With both
commits the MXFP4 model beats the FP8 build of the same model at every
batch size tested: bs1 -9.6%, bs8 -23.4%, bs16 -24.3%, bs32 -17.4%,
bs64 -11.0%. With the shipped configs it was 12.7% behind at bs1 and
10.8% behind at bs64.

Greedy output is byte-identical to the shipped configs at every batch
size tested (bs1/8/16/32/64 plus 84 diverse prompts at batch 1, 16 and
64). Buckets above M_LEQ_64 are left as they were.

Signed-off-by: adlashab <[email protected]>
@reger-men
reger-men force-pushed the mxfp4-llama8b-decode-configs branch from e50f6bc to cac6bf6 Compare October 5, 2026 16:12
@azaidy
azaidy requested a review from Boss2002n October 5, 2026 22:23
@azaidy azaidy assigned Boss2002n and unassigned Boss2002n Oct 5, 2026
@reger-men
reger-men force-pushed the mxfp4-llama8b-decode-configs branch from cac6bf6 to 05d7ff7 Compare October 6, 2026 16:06
@reger-men

Copy link
Copy Markdown
Contributor Author

@Boss2002n done, I took the extra (M, N, K) cases back out of get_x_vals, so the PR is config only again. I had run all 20 of those shapes on MI355X before and each one picked its tuned M_LEQ entry and passed, so dropping them from CI doesnt lose anything.

@github-actions github-actions Bot changed the title [Triton/Gluon] [Perf] [gfx950] Tune afp4wfp4 decode configs for Llama-3.1-8B dense shapes [Triton/Gluon] [Config] [Perf] [gfx950] Tune afp4wfp4 decode configs for Llama-3.1-8B dense shapes Oct 6, 2026
@github-actions github-actions Bot added the Config label Oct 6, 2026
@azaidy
azaidy merged commit 5ea05ef into ROCm:main Oct 8, 2026
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.

4 participants