Skip to content

[Triton/Gluon] : (GEMM) Add rotating buffers and do_bench_aiter_triton support - #6551

Merged
rahulbatra85 merged 1 commit into
mainfrom
triton_benchmark_gemm_rework
Oct 27, 2026
Merged

rahulbatra85 merged 1 commit into
mainfrom
triton_benchmark_gemm_rework

Conversation

@rahulbatra85

@rahulbatra85 rahulbatra85 commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

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

@rahulbatra85
rahulbatra85 requested a review from a team October 14, 2026 22:58
@github-actions github-actions Bot changed the title [Triton/Gluon]: Use rotating buffers and do_aiter_bench for GEMM Triton Benchmark [Triton/Gluon] : Use rotating buffers and do_aiter_bench for GEMM Triton Benchmark Oct 14, 2026
@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 6551 --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.

@rahulbatra85
rahulbatra85 marked this pull request as draft October 14, 2026 22:59
@Boss2002n
Boss2002n requested a balanced review from Copilot October 15, 2026 01:33

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.

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

@rahulbatra85
rahulbatra85 force-pushed the triton_benchmark_gemm_rework branch from 2ba7552 to 309f78b Compare October 21, 2026 22:38
@rahulbatra85
rahulbatra85 marked this pull request as ready for review October 21, 2026 22:39
@rahulbatra85 rahulbatra85 changed the title [Triton/Gluon] : Use rotating buffers and do_aiter_bench for GEMM Triton Benchmark [Triton/Gluon] : (GEMM benchmarks)Add rotating buffers and do_bench_aiter_triton support Oct 21, 2026
@rahulbatra85
rahulbatra85 force-pushed the triton_benchmark_gemm_rework branch from 309f78b to 2bd5236 Compare October 21, 2026 22:58
@zufayu
zufayu requested review from a team, TennyWang1223 and vgokhale October 22, 2026 01:17
@zufayu
zufayu removed the request for review from TennyWang1223 October 22, 2026 01:20
@rahulbatra85 rahulbatra85 changed the title [Triton/Gluon] : (GEMM benchmarks)Add rotating buffers and do_bench_aiter_triton support [Triton/Gluon] : (GEMM) Add rotating buffers and do_bench_aiter_triton support Oct 22, 2026
@rahulbatra85
rahulbatra85 force-pushed the triton_benchmark_gemm_rework branch 4 times, most recently from ca6f8e6 to dec7d6f Compare October 24, 2026 18:17
@Boss2002n Boss2002n assigned rahulbatra85 and unassigned vgokhale Oct 26, 2026
@rahulbatra85
rahulbatra85 force-pushed the triton_benchmark_gemm_rework branch from dec7d6f to 108f499 Compare October 26, 2026 18:53
@rahulbatra85
rahulbatra85 force-pushed the triton_benchmark_gemm_rework branch from 108f499 to 6733c8c Compare October 26, 2026 18:59

@brunomazzottiamd brunomazzottiamd 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!

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.

@rahulbatra85
rahulbatra85 merged commit 52e6484 into main Oct 27, 2026
61 checks passed
@rahulbatra85
rahulbatra85 deleted the triton_benchmark_gemm_rework branch October 27, 2026 01:40
yanxuer-999 added a commit to yanxuer-999/aiter that referenced this pull request Oct 28, 2026
…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]>
yanxuer-999 added a commit to yanxuer-999/aiter that referenced this pull request Nov 5, 2026
…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]>
yanxuer-999 added a commit to yanxuer-999/aiter that referenced this pull request Nov 13, 2026
…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]>
yanxuer-999 added a commit to yanxuer-999/aiter that referenced this pull request Nov 13, 2026
…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]>
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