Repository navigation
[Triton/Gluon] tune fused_bmm_rope_kv_cache on gfx950, add bench & configs (gfx950/1250) - #6501
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.
🟡 Changes recommended
The corrected FP8 GLM-5 shape lacks a checked-in correctness regression test.
1 open finding
What changed in this PR
Retunes fused FP4/FP8 MLA BMM + RoPE + KV-cache kernels for gfx950, separates FP4 tuning, and adds benchmarking support.
Changes:
- Adds a dedicated FP4 config family for gfx950/gfx1250.
- Retunes affected gfx950 FP8 and FP4 shapes.
- Adds a configurable CUDA-graph benchmark.
| File | Description |
|---|---|
op_tests/op_benchmarks/triton/bench_fused_bmm_rope_kv_cache.py |
Adds FP4/FP8 benchmark CLI. |
aiter/ops/triton/fusions/fused_bmm_rope_kv_cache.py |
Uses the fused kernel’s FP4 config loader. |
aiter/ops/triton/_triton_kernels/fusions/fused_bmm_rope_kv_cache.py |
Defines dedicated FP4 config lookup. |
.../fused_fp8.../FUSED-FP8-...-N=512-K=192.json |
Retunes all M buckets. |
.../fused_fp8.../FUSED-FP8-...-N=512-K=128.json |
Retunes regressed buckets. |
.../fused_fp8.../FUSED-FP8-...-N=128-K=512.json |
Retunes selected buckets. |
.../gfx950/.../fused_fp4.../DEFAULT.json |
Adds the gfx950 FP4 default. |
.../gfx950/.../fused_fp4.../FUSED-FP4-...-N=512-K=128.json |
Adds fused-kernel-specific tuning. |
.../gfx950/.../fused_fp4.../FUSED-FP4-...-N=128-K=512.json |
Preserves prior specialized selection. |
.../gfx950/.../fused_fp4.../FUSED-FP4-...-N=8192-K=8192.json |
Preserves prior large-shape selection. |
.../gfx1250/.../fused_fp4.../DEFAULT.json |
Preserves gfx1250 default behavior. |
🧠 Review effort: Balanced
💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
brunomazzottiamd
left a comment
There was a problem hiding this comment.
Benchmark looks good, I've just shared minor nitpicks.
My main concern lies in aiter/ops/triton/configs/gfx1250/triton/gemm/fused_fp4_bmm_rope_cat_and_cache_mla/DEFAULT.json. Please check the comment.
3655671 to
3f6c94e
Compare

Motivation
On gfx950, the fused MLA BMM + RoPE + KV-cache kernels (
fused_fp4_bmm_rope_cat_and_cache_mla,fused_fp8_bmm_rope_cat_and_cache_mla) are up to 2.1x slower on Triton 3.8 (TOT) compared to golden (Triton 3.4). 75 of 187 measured shapes regress, mostly decode regression near range that sets TPOT (Time per Output Token).This kernel also does not have a benchmark in AITER, which is now added in this PR.
The fp8 kernel is on SGLang's default MLA path for DeepSeek-V3.2 and GLM-5 on MI355X. On the Triton 3.8 build measured here, main's tile for GLM-5's shape at M ≥ 512 also returns wrong results, including with SGLang's default bf16 KV cache; this PR replaces it
Technical Details
All tuning is gfx950-only, as other archs launch exactly as on main.
Since triton-lang/triton#8151 (Triton 3.6),
waves_per_eu=Npins the kernel to exactly N waves per SIMD (Triton 3.4 passed it as a minimum). The shipped values 2 and 4 make LLVM reserve 169 and 97 VGPRs while the regressed tiles use 34-64, so occupancy drops (for example 5 -> 2 waves for fp4's 128x128 tile). One fp8 tile (N=512-K=128, 16 < M <= 256) regresses from Triton 3.8 codegen instead: 86 VGPRs vs 78 on 3.4, so 5 waves instead of 6. 8 warps make this worse, because the same launch also runs one-row RoPE programs (a median 94% of the workgroups), and each gets a 512-thread workgroup.Every changed bucket now uses 4 warps and
waves_per_eu=0:FUSED-FP4-BMM-ROPE-CAT-AND-CACHE-MLA, read by a one-line_get_fp4_configlike_get_fp8_config([Triton/Gluon] stop fused_bmm_rope_kv_cache from using batched_gemm_a8w8_a_per_token… #5877). It used to borrow the standalonebatched_gemm_a16wfp4configs, so tuning there would have retuned that kernel too.DEFAULT.json,-N=128-K=512.json,-N=8192-K=8192.json(gfx950) andDEFAULT.json(gfx1250) are byte-identical copies of the batched files, so every other shape and arch keeps main's picks. Open [Triton/Gluon] Satya/1250 config cleanup #6293 edits the gfx1250 source file; whichever PR lands second should re-copy it.op_tests/op_benchmarks/triton/bench_fused_bmm_rope_kv_cache.pyruns the unit tests' shapes by default (do_bench_cudagraphafter atorch.cuda.synchronize()).Test Plan
rocprofv3 --kernel-trace, trimmed mean; main on 3.4, main on 3.8 and this PR on 3.8. 187 shapes at unit-test and SGLang settings, plus 56 more (SGLang's default bf16 KV cache, GLM-5's QH 8/16/64, T up to 8192), plus 36 on the CI wheel. A regression is aresult > 1.005 × baseline + 0.5 µs, with a baseline ≥ 4 µs.Test Result
Kernel time in µs; percentages in the main and this-PR columns are vs main on Triton 3.4.
Submission Checklist