Skip to content

[Triton/Gluon] : (MoE) Add RotatingBufferBench support - #6728

Merged
azaidy merged 1 commit into
mainfrom
triton_benchmark_moe_rot_bufs
Nov 19, 2026
Merged

azaidy merged 1 commit into
mainfrom
triton_benchmark_moe_rot_bufs

Conversation

@rahulbatra85

Copy link
Copy Markdown
Contributor

Motivation

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

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

Technical Details

Use rotating buffers and do_bench_aiter_triton() functions for MoE benchmarks

@rahulbatra85
rahulbatra85 requested a review from a team October 20, 2026 17:15
@github-actions github-actions Bot changed the title [Triton/Gluon]: Add rotating buffers and do_bench_aiter_triton support(MoE benchmarks) [Triton/Gluon] : Add rotating buffers and do_bench_aiter_triton support(MoE benchmarks) Oct 20, 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 6728 --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.

🟡 Changes recommended

Parser conflicts break existing benchmarks, and cache-rotation and total-measurement issues undermine the reported timings.

8 open issues
What changed in this PR

This PR moves AITER’s MoE benchmarks to rotating input buffers and graph replay to reduce cache bias and CPU launch overhead.

Changes:

  • Add shared buffer-pool and graph-timing helpers.
  • Migrate MoE benchmarks to the new timing method.
  • Update per-layer reports and benchmark arguments.
File Description
op_tests/​op_benchmarks/​triton/​utils/​benchmark_utils.py Add rotating pools and graph timing.
op_tests/​op_benchmarks/​triton/​utils/​argparse.py Add backend selection and argument overrides.
op_tests/​op_benchmarks/​triton/​bench_moe_wgrad.py Rotate gradients and inputs with fixed routing.
op_tests/​op_benchmarks/​triton/​bench_moe_situ_epilogue.py Use rotating-buffer graph timing.
op_tests/​op_benchmarks/​triton/​bench_moe_gemm_int8_smoothquant.py Add rotating inputs and per-layer reports.
op_tests/​op_benchmarks/​triton/​bench_moe_gemm_a8w8.py Migrate FP8/MXFP8 projection measurements.
op_tests/​op_benchmarks/​triton/​bench_moe_gemm_a8w8_blockscale.py Migrate blockscale projection measurements.
op_tests/​op_benchmarks/​triton/​bench_moe_gemm_a8w4_cudagraph.py Replace repeated weight-init runs with pools.
op_tests/​op_benchmarks/​triton/​bench_moe_gemm_a4w4_cudagraph.py Migrate single- and multi-GPU timing.
op_tests/​op_benchmarks/​triton/​bench_moe_gemm_a16w4.py Add rotating inputs and per-layer reports.

Review effort: Balanced

@zufayu
zufayu requested review from a team, Boss2002n and TennyWang1223 October 21, 2026 01:28
@rahulbatra85
rahulbatra85 force-pushed the triton_benchmark_moe_rot_bufs branch from 8703243 to 4c5f007 Compare October 21, 2026 18:41
@rahulbatra85 rahulbatra85 changed the title [Triton/Gluon] : Add rotating buffers and do_bench_aiter_triton support(MoE benchmarks) [Triton/Gluon] : (MoE benchmarks)Add rotating buffers and do_bench_aiter_triton support Oct 21, 2026
@zufayu
zufayu removed the request for review from TennyWang1223 October 22, 2026 01:20
@rahulbatra85 rahulbatra85 changed the title [Triton/Gluon] : (MoE benchmarks)Add rotating buffers and do_bench_aiter_triton support [Triton/Gluon] : (MoE)Add rotating buffers and do_bench_aiter_triton support Oct 22, 2026
@rahulbatra85 rahulbatra85 changed the title [Triton/Gluon] : (MoE)Add rotating buffers and do_bench_aiter_triton support [Triton/Gluon] : (MoE) Add rotating buffers and do_bench_aiter_triton support Oct 22, 2026
@rahulbatra85
rahulbatra85 force-pushed the triton_benchmark_moe_rot_bufs branch from 4c5f007 to c1e2321 Compare October 22, 2026 18:56
@rahulbatra85
rahulbatra85 marked this pull request as draft October 24, 2026 17:51
@zufayu
zufayu removed request for a team and Boss2002n October 25, 2026 00:02
@Boss2002n Boss2002n assigned rahulbatra85 and unassigned Boss2002n Oct 26, 2026
@rahulbatra85
rahulbatra85 force-pushed the triton_benchmark_moe_rot_bufs branch from c1e2321 to 52a9dff Compare November 2, 2026 19:38
@rahulbatra85
rahulbatra85 marked this pull request as ready for review November 2, 2026 19:38
@aiter-bot

aiter-bot commented Nov 2, 2026 •

Copy link
Copy Markdown

WAITING ON AUTHOR

PR Self-Review

Revision 831e5f786491 · mode shadow

Waiting for the PR author. The readiness report will appear after the self-review answers are complete for this revision.

Questions to answer in the PR description

  1. What behavior does this PR change, and why is the existing behavior insufficient?
  2. What did you validate, and what remains unverified? Include commands, hardware/configuration and results.
  3. What behavior would each changed op test fail on before this PR, and why is that coverage not already provided by an existing canonical test?
  4. For every changed op_tests/ file, what behavior does it cover and why is it not redundant? Write None if no op test changed.

Edit the PR Self-Review section in the PR description. Include the current revision SHA; this comment refreshes automatically.

Missing or invalid answers

  • FAIL — missing ### Reviewed revision in the PR description
  • FAIL — missing ### Behavior and intent in the PR description
  • FAIL — missing ### Validation and unverified scope in the PR description
  • FAIL — missing ### PR-specific question in the PR description
  • FAIL — missing ### Changed op tests in the PR description
  • FAIL — Reviewed revision must contain at least the first 7 characters of the current head SHA
  • FAIL — Behavior and intent has no substantive answer
  • FAIL — Validation and unverified scope has no substantive answer
  • FAIL — PR-specific question has no substantive answer
  • FAIL — changed op test not explained in Changed op tests: op_tests/op_benchmarks/triton/bench_moe_gemm_a16w4.py
  • FAIL — changed op test not explained in Changed op tests: op_tests/op_benchmarks/triton/bench_moe_gemm_a4w4.py
  • FAIL — changed op test not explained in Changed op tests: op_tests/op_benchmarks/triton/bench_moe_gemm_a4w4_proton.py
  • FAIL — changed op test not explained in Changed op tests: op_tests/op_benchmarks/triton/bench_moe_gemm_a8w4.py
  • FAIL — changed op test not explained in Changed op tests: op_tests/op_benchmarks/triton/bench_moe_gemm_a8w4_proton.py
  • FAIL — changed op test not explained in Changed op tests: op_tests/op_benchmarks/triton/bench_moe_gemm_a8w8.py
  • FAIL — changed op test not explained in Changed op tests: op_tests/op_benchmarks/triton/bench_moe_gemm_a8w8_blockscale.py
  • FAIL — changed op test not explained in Changed op tests: op_tests/op_benchmarks/triton/bench_moe_gemm_int8_smoothquant.py
  • FAIL — 4 additional changed op test(s) are not explained
  • FAIL — Changed op tests must explain why each changed op test is necessary and non-redundant

Shadow mode reports what would block but keeps the status successful. Set AITER_PR_SELF_REVIEW_MODE=enforce only after reviewing real false positives.

@rahulbatra85 rahulbatra85 changed the title [Triton/Gluon] : (MoE) Add rotating buffers and do_bench_aiter_triton support [Triton/Gluon] : (MoE) Add RotatingBufferBench support Nov 2, 2026
@zufayu
zufayu requested review from a team and azaidy November 3, 2026 01:17

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

The move to RotatingBufferBench and the new cudagraph MoE benchmarks are good, but a few things must change before merge.

Must fix before merge

  1. The topk benchmark is gone (bench_topk.py:1-14): the file is now a copy of bench_moe_situ_epilogue.py, so no benchmark runs the Triton topk op. Fix: restore it from main, then move its timing.
  2. The MoE GEMM pools do not rotate (bench_moe_gemm_a8w8_cudagraph.py:455-462): with the default --num-weight-inits 1, all 1000 calls read the same weights, and M=1 latencies are 15–33% lower than with 8 weight sets. Fix: size the pool from the bytes that one call reads.
  3. The smoke test fails for the four new scripts (bench_moe_gemm_a8w8_cudagraph.py:608-630): they need --shape and --experts, but _CUSTOM_ARGS has no entry for them, so each one exits with code 2. Fix: add them with _MOE_SHAPE_ARGS.

Nice to fix

Merge order

Merge #7121 first, then rebase so that 83cf2b96 drops out; merged first, this PR breaks 35 benchmarks at import.

@rahulbatra85
rahulbatra85 marked this pull request as draft November 6, 2026 00:49
@zufayu
zufayu removed the request for review from azaidy November 7, 2026 00:03
@brunomazzottiamd

Copy link
Copy Markdown
Contributor

Hi guys. Do you still see any blockers on this PR? Do you have a ETA for merging it? Thanks!

FYI: @rahulbatra85 + @Boss2002n

@azaidy
azaidy merged commit 1dd04e9 into main Nov 19, 2026
@azaidy
azaidy deleted the triton_benchmark_moe_rot_bufs branch November 19, 2026 14:25
menglcai-amd added a commit to menglcai-amd/aiter that referenced this pull request Nov 19, 2026
- pre-checks.yaml: pin black to 26.10.1 (the version that
  psf/black@stable installs now) with the action `version` input.
- pre-checks.yaml: replace the deprecated -fail-on-error with
  -fail-level=any. For the github-check reporter (push to main),
  -fail-on-error maps to error level, and ruff reports every finding as
  WARNING, so the job never failed on main.
- aiter/aot/flydsl/gemm.py: restore mode 100755 (lost in ROCm#7439). The file
  has a shebang, and ruff EXE001 reports it on main.
- bench_models.py: fix ruff I001 (import order). ROCm#6728 added the
  bench_moe_gemm_a4w4 and bench_moe_gemm_a8w4 modules, so ruff now sorts
  their imports as first-party. Move only these 6 lines (ruff autofix).
- CONTRIBUTE.md: install the CI versions (black 26.10.1, ruff 0.16.0).

Refs ROCm#4423
zufayu pushed a commit that referenced this pull request Nov 27, 2026
- pre-checks.yaml: pin black to 26.10.1 (the version that
  psf/black@stable installs now) with the action `version` input.
- pre-checks.yaml: replace the deprecated -fail-on-error with
  -fail-level=any. For the github-check reporter (push to main),
  -fail-on-error maps to error level, and ruff reports every finding as
  WARNING, so the job never failed on main.
- aiter/aot/flydsl/gemm.py: restore mode 100755 (lost in #7439). The file
  has a shebang, and ruff EXE001 reports it on main.
- bench_models.py: fix ruff I001 (import order). #6728 added the
  bench_moe_gemm_a4w4 and bench_moe_gemm_a8w4 modules, so ruff now sorts
  their imports as first-party. Move only these 6 lines (ruff autofix).
- CONTRIBUTE.md: install the CI versions (black 26.10.1, ruff 0.16.0).

Refs #4423
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.

8 participants