Repository navigation
[Triton/Gluon] [Config] [Perf] [gfx950] Tune afp4wfp4 decode configs for Llama-3.1-8B dense shapes - #6015
Conversation
🏷️ CI GuideRuns automatically on every PR:
Extended tests (opt-in via labels):
One backend per PR: PR title tags & labels: |
There was a problem hiding this comment.
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
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.
8178f7b to
e50f6bc
Compare
|
@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: The red MI35X shard 0 on the old head was |
…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]>
e50f6bc to
cac6bf6
Compare
cac6bf6 to
05d7ff7
Compare
|
@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. |

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