Repository navigation
[Triton/Gluon] : (GEMM) Add rotating buffers and do_bench_aiter_triton support - #6551
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
Parser conflicts and incomplete conversions prevent benchmark execution, while graph capture omits entries from larger buffer pools.
4 open findings
What changed in this PR
This PR moves GEMM benchmarks toward rotating input buffers and shared GPU graph timing to reduce repeated-buffer cache effects.
Changes:
- Adds buffer-pool generation and graph-based timing helpers.
- Migrates standard, batched, and fused GEMM benchmarks.
- Adds a shared backend option and removes AFP8WFP8’s optional graph flag.
| File | Description |
|---|---|
| op_tests/op_benchmarks/triton/utils/benchmark_utils.py | Adds rotating pools and graph timing. |
| op_tests/op_benchmarks/triton/utils/argparse.py | Adds shared backend selection. |
| op_tests/op_benchmarks/triton/bench_gemm_afp8wfp8.py | Migrates FP8 timing and retains reference checks. |
| op_tests/op_benchmarks/triton/bench_gemm_afp4wfp4.py | Rotates plain and preshuffled FP4 inputs. |
| op_tests/op_benchmarks/triton/bench_gemm_a8wfp4.py | Migrates mixed-precision timing. |
| op_tests/op_benchmarks/triton/bench_gemm_a8w8.py | Begins rotating-pool integration. |
| op_tests/op_benchmarks/triton/bench_gemm_a8w8_per_token_scale.py | Rotates per-token-scale inputs. |
| op_tests/op_benchmarks/triton/bench_gemm_a8w8_blockscale.py | Rotates selected weight and scale layouts. |
| op_tests/op_benchmarks/triton/bench_gemm_a16w8_blockscale.py | Migrates block-scale timing. |
| op_tests/op_benchmarks/triton/bench_gemm_a16w16.py | Begins pooled-input conversion. |
| op_tests/op_benchmarks/triton/bench_gemm_a16w16_gating.py | Migrates gating benchmark timing. |
| op_tests/op_benchmarks/triton/bench_gemm_a16w16_gated.py | Migrates gated GEMM timing. |
| op_tests/op_benchmarks/triton/bench_fused_gemm_afp4wfp4_mul_add.py | Pools FP4 and elementwise operands. |
| op_tests/op_benchmarks/triton/bench_fused_gemm_afp4wfp4_a16w16.py | Pools both fused GEMM branches. |
| op_tests/op_benchmarks/triton/bench_fused_gemm_a8w8_blockscale_mul_add.py | Pools block-scale and elementwise operands. |
| op_tests/op_benchmarks/triton/bench_fused_gemm_a8w8_blockscale_a16w16.py | Pools FP8 and BF16 branches. |
| op_tests/op_benchmarks/triton/bench_batched_gemm_bf16.py | Migrates batched BF16 timing. |
| op_tests/op_benchmarks/triton/bench_batched_gemm_afp4wfp4.py | Migrates batched FP4 timing. |
| op_tests/op_benchmarks/triton/bench_batched_gemm_a8w8.py | Migrates batched A8W8 timing. |
| op_tests/op_benchmarks/triton/bench_batched_gemm_a8w8_a_per_token_group_prequant_w_per_batched_tensor_quant.py | Pools inputs while retaining dispatch options. |
| op_tests/op_benchmarks/triton/bench_batched_gemm_a16wfp4.py | Migrates batched mixed-precision timing. |
🧠 Review effort: Balanced
💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
2ba7552 to
309f78b
Compare
309f78b to
2bd5236
Compare
ca6f8e6 to
dec7d6f
Compare
dec7d6f to
108f499
Compare
108f499 to
6733c8c
Compare
brunomazzottiamd
left a comment
There was a problem hiding this comment.
LGTM!
I think I've found an existing issue, not sure if it should be addressed in this PR:
bench_gemm_a16w16.py initializes each atomic output buffer once, then do_bench_aiter_triton replays the graph repeatedly without clearing it. gemm_a16w16_atomic uses atomic_add, so --atomic timings can accumulate prior outputs and cease to represent valid GEMMs. This behavior appears pre-existing, but the new rotating-buffer path preserves it.
…urrent main - bench_gemm_model_shapes: ROCm#6551 put (kwargs_rot_bufs, kwargs_do_bench_graph) in front of the upstream bench_gemm_fn arguments, so the old call failed with "bench_gemm_fn() missing 2 required positional arguments: 'layout' and 'backend'". Pass them, at the upstream CLI defaults, when the helper takes them; the perf-daily nightly rebases this tree onto main, so both forms occur. - bench_pa_decode: override_parser_action looks actions up by option string, so "backend" raised KeyError: 'backend' before any bench ran; use "--backend". Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…nch API (ROCm#7121) ROCm#7121 replaced the (kwargs_rot_bufs, kwargs_do_bench_graph) prefix of the upstream bench_gemm_fn with a single RotatingBufferBench, so perf-daily night ROCm#55 failed with "bench_gemm_fn() missing 1 required positional argument: 'backend'" (the shim passed nothing and every argument shifted by one). _lead_args now keys on the helper's first parameter: none (M), the ROCm#6551 dict pair, or a ROCm#7121 bencher built with RotatingBufferBench.from_dict from the same CLI defaults. Any other prefix raises a TypeError naming it, instead of a shifted-argument error from inside the bench. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…urrent main - bench_gemm_model_shapes: ROCm#6551 put (kwargs_rot_bufs, kwargs_do_bench_graph) in front of the upstream bench_gemm_fn arguments, so the old call failed with "bench_gemm_fn() missing 2 required positional arguments: 'layout' and 'backend'". Pass them, at the upstream CLI defaults, when the helper takes them; the perf-daily nightly rebases this tree onto main, so both forms occur. - bench_pa_decode: override_parser_action looks actions up by option string, so "backend" raised KeyError: 'backend' before any bench ran; use "--backend". Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…nch API (ROCm#7121) ROCm#7121 replaced the (kwargs_rot_bufs, kwargs_do_bench_graph) prefix of the upstream bench_gemm_fn with a single RotatingBufferBench, so perf-daily night ROCm#55 failed with "bench_gemm_fn() missing 1 required positional argument: 'backend'" (the shim passed nothing and every argument shifted by one). _lead_args now keys on the helper's first parameter: none (M), the ROCm#6551 dict pair, or a ROCm#7121 bencher built with RotatingBufferBench.from_dict from the same CLI defaults. Any other prefix raises a TypeError naming it, instead of a shifted-argument error from inside the bench. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>


Motivation
Cache-warm inputs. Most AITER Triton benchmarks reuse a single set of inputs across benchmark iterations. Depending on their size, those inputs can stay resident in L2, so later iterations read from cache instead of HBM. This overstates performance, especially for memory-bound and small-shape kernels, and can make autotuning pick the wrong configs. In real workloads, other layers’ weights and activations pass through the cache between calls to a kernel, so its inputs usually have to be read from HBM. This PR allocates multiple input sets whose combined size is larger than the L2 cache and rotates through them, so each launch sees cold-cache behavior.
triton.testing.do_bench approximates this by flushing L2 before each run. However, the flush can’t be placed inside a captured graph without being timed along with the kernel, and it adds gaps between launches. Rotating buffers avoid both problems.
Graph capture. Most benchmarks launch kernels eagerly, which includes CPU launch overhead in the measurement. That overhead can dominate for small kernels. Production inference stacks (e.g. vLLM and SGLang decode paths) typically run under HIP graphs. The new do_bench captures the rotated launches in a graph, which makes the measured time closer to what these kernels see in deployment.
Comparison of results with default shapes for each benchmarks with old method vs new method
gemm_old_vs_new.xlsx