Skip to content

[Triton/Gluon] [Config] [Perf] Retune gfx950 preshuffled AFP4WFP4 config for N=4096, K=14336 - #6521

Merged
azaidy merged 1 commit into
ROCm:mainfrom
reger-men:mxfp4-presh-llama8b-down-retune
Oct 16, 2026
Merged

azaidy merged 1 commit into
ROCm:mainfrom
reger-men:mxfp4-presh-llama8b-down-retune

Conversation

@reger-men

@reger-men reger-men commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

Retuned GEMM-AFP4WFP4_PRESHUFFLED-N=4096-K=14336.json on gfx950, which is the down_proj of Llama-3.1-8B. Config only, one file, same keys and bucket layout as before. The shipped file runs NUM_KSPLIT=1 on a 64 wide N tile in every bucket except M_LEQ_31, so at decode sizes the 29 MB weight read gets split over just 64 workgroups and the kernel takes 46-49 us at M=1-8 and at M=32-64 alike. M_LEQ_31 already splits K 14 ways and was the only bucket that was close.

I found this through vLLM. With VLLM_ROCM_USE_AITER_FP4_ASM_GEMM=1 vLLM sends M <= 64 to gemm_afp4wfp4_preshuffle when this file exists, but its tuned-config probe used 4 * K_bytes instead of 2 * K_bytes, so it looked for K=28672 and down_proj went to the ASM gemm_a4w4. With the probe fixed (vllm-project/vllm#61637), down_proj starts loading this file and decode gets up to 20% slower than before the fix. With this retune the same path is 11-17% faster than before the fix.

How I tuned it: AITER's own sweep_configs.py (rocprofv3 kernel trace, L2 flushed between calls) per bucket, first over BLOCK_SIZE_M / N / K, num_warps, cache_modifier and NUM_KSPLIT, then waves_per_eu / num_stages / num_warps / GROUP_SIZE_M on the best 4 tile shapes (3 for any). M_LEQ_8 was scored over M=1, 2, 4, 8, any over M=512, 2048, 8192, M_LEQ_31 at M=16 since the sweep script wants a power of two, the other buckets at their bound. Each of the 9096 timed candidates was run on the test_gemm_afp4wfp4.py inputs against its torch reference, and every one passed assert_close and came out bit identical, so the pick is just the fastest.

Then I checked the picked file against the shipped one on its own: per-call time inside a captured cudagraph with the weights rotated over 12 copies (~352 MB, past the cache) so each call reads them from HBM, activation quant not included, one process per file, order shipped / new / new / shipped, mean of the two. MI355X, clock pinned with perf_determinism (sclk CV 0.045% under load), GPU idle checked first. ASM gemm_a4w4 with the same inputs for reference, us per call:

M shipped this PR new / shipped ASM gemm_a4w4
1 48.13 12.07 0.25 23.84
2 47.90 13.36 0.28 24.03
4 47.97 13.53 0.28 24.25
8 49.16 13.64 0.28 24.59
16 16.79 14.50 0.86 25.33
24 23.07 19.44 0.84 26.26
32 46.46 13.55 0.29 27.06
48 46.17 16.94 0.37 25.28
64 46.32 18.09 0.39 26.24
128 46.35 19.40 0.42 25.86
256 46.16 26.20 0.57 25.95
512 88.65 65.42 0.74 31.18
2048 313.54 87.36 0.28 57.76
8192 1155.68 361.57 0.31 213.15

It's faster than shipped at every M I measured (also 12, 31, 96, 192, 1024, 4096, not listed). In the same runs the output was bit identical to the op_tests reference and to plain gemm_afp4wfp4 on the same quantized bytes at every M. Above M=256 the ASM kernel is still well ahead, but vLLM only routes M <= 64 here and I didnt chase the big buckets further than the sweep.

End to end: amd/Llama-3.1-8B-Instruct-MXFP4-W4A4-MLCAL-C1000-GPTQ under vLLM, TP=1 on one MI355X, VLLM_ROCM_USE_AITER=1 VLLM_ROCM_USE_AITER_FP4_ASM_GEMM=1, same clock pin and idle check, one process per run, compile caches off, arms interleaved, 2 runs each. Decode ms/token (p50 wall of a 128 token run minus p50 wall of a 1 token run, over 127 tokens):

  • bs1: before the probe fix 3.532, probe fix + shipped file 4.233, probe fix + this PR 3.082
  • bs8: 3.790, 4.469, 3.360
  • bs16: 3.872, 3.541, 3.434
  • bs32: 4.101, 4.623, 3.573
  • bs64: 4.606, 4.737, 3.812

Token ids are identical across all three at every batch and on 84 greedy prompts, and GSM8K (1319 questions, 4-shot greedy) is 706/1319 for all three with the same token ids on every question.

For reference, the default vLLM path on the same model (no env var, plain gemm_afp4wfp4) is 2.664 / 2.923 / 2.948 / 3.220 / 3.915, so for this model the env var path is still slower at bs1-32 and about 2.6% faster at bs64. That part is outside this file.

…fig for N=4096, K=14336

This is the down_proj of Llama-3.1-8B. The shipped file runs NUM_KSPLIT=1
on a 64 wide N tile in every bucket except M_LEQ_31, so at decode sizes
the whole 29 MB weight read is spread over only 64 workgroups. All seven
buckets are retuned, same keys and bucket layout as before.

Per call on MI355X, cudagraph replay with the weights rotated past the
cache, shipped -> new, us: M=1 48.1 -> 12.1, M=8 49.2 -> 13.6,
M=16 16.8 -> 14.5, M=32 46.5 -> 13.6, M=64 46.3 -> 18.1,
M=256 46.2 -> 26.2, M=2048 313.5 -> 87.4, M=8192 1155.7 -> 361.6.
Faster at every M I measured from 1 to 8192, and the output is bit
identical to the op_tests reference and to gemm_afp4wfp4 at every M.

Signed-off-by: adlashab <[email protected]>
@reger-men
reger-men requested a review from a team October 14, 2026 07:44
@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
ci:windows Windows JIT op smoke test on the gfx1201 ROCm runner
ci:multi-gpu 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: DeepSeek-V4-Pro, MiniMax-M3-MXFP4
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 6521 --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.

🔵 Needs a closer look

The hardware-specific correctness and performance results require final human validation on gfx950.

0 open findings

What changed in this PR

Retunes the gfx950 preshuffled AFP4WFP4 GEMM configuration for the Llama 3.1 8B down-projection shape.

Changes:

  • Updates tiling, split-K, staging, cache, warp, and wave settings across all M buckets.
  • Preserves the existing bucket layout and required configuration keys.
File Description
aiter/​ops/​triton/​configs/​gfx950/​triton/​gemm/​gemm_afp4wfp4_preshuffled/​GEMM-AFP4WFP4_PRESHUFFLED-N=4096-K=14336.json Retunes the specialized gfx950 GEMM configuration.

🧠 Review effort: Balanced


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

@azaidy

azaidy commented Oct 14, 2026

Copy link
Copy Markdown
Contributor

@reger-men what triton version did you use?

@reger-men

Copy link
Copy Markdown
Contributor Author

@azaidy triton 3.8.0, the build that ships in the rocm/vllm-dev:base image (torch 2.13.0+git733fca1), on MI355X. Thats the same version CI pins (triton==3.8.0 from the release_0914 index) but not the same wheel. The sweep_configs.py tuning, the bit-equality check of every candidate against run_torch on the op_tests inputs, and the served Llama-3.1-8B A/B all ran in that one container.

I havent rerun the picks on the CI wheel. If you want that, I can do the standalone check there and post the numbers.

@nidal567 nidal567 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.

Thank you for the detailed write-up, the split-k explanation for decode buckets makes sense. As I had the same concerns as @azaidy, I re-ran shipped vs this PR on MI35X with the exact wheel CI pins (triton 3.8.0 + amd.rocm7.2.0.gitcb7b059).

M shipped (µs) this PR (µs)
1 40.2 10.6
8 41.2 11.3
16 11.9 10.9
31 20.5 18.0
64 39.5 14.6
256 39.5 23.4
512 75.4 57.2
2048 255.5 90.9
8192 906.5 309.3

It's also faster at all 16 M values. My absolute numbers are a bit lower dsince this is kernel time only). Also outputs are bit-identical to the op_tests reference as you specified.

One small, non-blocking suggestion though: test_gemm_afp4wfp4.py has no coverage for N = 4096, K = 14336 shape, so CI never runs these new split-k tiles unless we add a couple of entries to get_x_vals (like M = 1 and M = 64) to cover them. Otherwise, LGTM!

@azaidy azaidy 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.

LGTM!

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