Repository navigation
[Triton/Gluon] [Config] [Perf] Retune gfx950 preshuffled AFP4WFP4 config for N=4096, K=14336 - #6521
Conversation
…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]>
🏷️ 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.
🔵 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.
|
@reger-men what triton version did you use? |
|
@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
left a comment
There was a problem hiding this comment.
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!
Retuned
GEMM-AFP4WFP4_PRESHUFFLED-N=4096-K=14336.jsonon 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=1vLLM sends M <= 64 togemm_afp4wfp4_preshufflewhen 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 ASMgemm_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 forany). M_LEQ_8 was scored over M=1, 2, 4, 8,anyover 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 thetest_gemm_afp4wfp4.pyinputs against its torch reference, and every one passedassert_closeand 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_a4w4with the same inputs for reference, us per call: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_afp4wfp4on 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):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.