Skip to content

[Triton/Gluon] bench_pa_decode: report the real KV bandwidth and time with CUDA graphs - #6690

Merged
azaidy merged 3 commits into
mainfrom
bench-pa-decode-bandwidth
Oct 21, 2026
Merged

azaidy merged 3 commits into
mainfrom
bench-pa-decode-bandwidth

Conversation

@NimitPtl

@NimitPtl NimitPtl commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor
  • Count the K and V bytes of every attended token (BS * SEQ_LEN * kv_heads * head_size * dtype bytes * 2) in the bandwidth number.
  • Use one page per sequence block slot by default. The pool is capped at 4 GB for each cache tensor. Add -num_blocks to set the pool size. When the pool is large enough, the block table uses distinct pages.
  • Time with do_bench_cudagraph, after one warm-up call.
  • Make max_context_len a Python int. The Triton wrapper no longer syncs on a device tensor, so it can be captured in a CUDA graph.

Test Result

MI355X, bf16, 64 query heads, 8 kv heads, head size 128, 8 × 8192:

Backend Old script (GB/s) New script (GB/s)
triton 12.2 5819
gluon 10.3 5420

MI450-MC

Backend Old script (GB/s) New script (GB/s)
triton 3.2 3440
gluon 7.3 3180

Can observe realistic numbers now

Motivation

bench_pa_decode.py printed bandwidth numbers that were far too low. For batch 8 and 8192 tokens it printed 12 GB/s (Triton) and 10 GB/s (Gluon). The real values are in the TB/s range.

There were two causes:

  • The script used only 4 physical KV blocks. Every sequence read the same 4 pages, so the data stayed in cache and the run was not limited by HBM.
  • The script counted the bytes of those 4 blocks (about 2 MB). The decode reads K and V for every attended token (268 MB for this shape).

The script also timed each call with do_bench, which includes launch overhead and, for the Triton backend, a device sync on every call.

Technical Details

Test Plan

Submission Checklist

… with CUDA graphs

The benchmark used 4 physical KV blocks and counted the bytes of those 4
blocks, so it printed about 10 GB/s for a decode that reads 268 MB. Count the
K and V bytes of every attended token. Use one page per block slot (capped at
4 GB per cache tensor) with distinct pages, and add -num_blocks. Time with
do_bench_cudagraph. Make max_context_len a Python int so the Triton wrapper
does not sync on a device tensor and can be captured.
@NimitPtl
NimitPtl requested a review from a team October 20, 2026 00:14
@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 6690 --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

The enlarged FP8 cache pool can overflow Triton’s signed 32-bit offsets and produce invalid memory addresses.

1 open issue
What changed in this PR

This PR improves paged-attention decode benchmark bandwidth accounting and timing for Triton and Gluon.

Changes:

  • Count K and V bytes for every attended token.
  • Size the page pool by workload, with a cap and CLI override.
  • Use CUDA graph timing and a Python integer for maximum context length.
File Description
op_tests/​op_benchmarks/​triton/​bench_pa_decode.py Updates page allocation, bandwidth accounting, and graph-based timing.

Review effort: Balanced

NimitPtl and others added 2 commits October 19, 2026 19:07
Add validation for num_blocks in Triton backend to ensure it does not exceed max_blocks.

Co-authored-by: Copilot Autofix powered by AI <[email protected]>
@NimitPtl
NimitPtl requested a review from azaidy October 20, 2026 18:00
@azaidy azaidy self-assigned this Oct 20, 2026

@scxiao scxiao 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

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

@azaidy
azaidy merged commit e52cac3 into main Oct 21, 2026
@azaidy
azaidy deleted the bench-pa-decode-bandwidth branch October 21, 2026 17:58
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