Skip to content

[Triton/Gluon] [Perf] [gfx1250] gluon UA2D: BLOCK_M 256 only when the batch has <= 8 sequences - #7745

Draft
akao-amd wants to merge 10 commits into
ROCm:mainfrom
akao-amd:pr-gfx1250-ua2d-bf16-blockm
Draft

akao-amd wants to merge 10 commits into
ROCm:mainfrom
akao-amd:pr-gfx1250-ua2d-bf16-blockm

Conversation

@akao-amd

@akao-amd akao-amd commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

The gfx1250 Gluon attn_2d catch-all uses BLOCK_M 128. This change adds DT_bf16_bf16.NS_LEQ_8 with BLOCK_M 256 for eligible full-attention launches with at most eight sequence slots. Larger tiles are intended for a few long sequences; many one-token decodes waste more rows in each tile.

NS counts the launch's sequence slots, including padding. It is the table's last axis, so the new row overrides only any. Existing decode, sliding-window, short-context and head-256-or-larger rows retain their selection. FP16 shares the BF16 tag; FP8 KV cannot match the BF16/BF16 entry. FP8 and NVFP4 selections are unchanged.

Lookup and explain include NS only for tables declaring it. Missing num_seqs on such a table is an explicit metadata error. _uses_ns now respects USE_LRU_CACHE, allowing live schema edits when tuning with caches disabled. Config and review documentation describe the new axis.

This PR is independent of the unified-attention stack and merges main ecfa616d80a17b4030feccb18da47df59dbca720.

The base1130_v3 stack (MI450 gpt-oss measurements, December 1, 2026) carried an earlier version, c30b303d7. Its config and sequence gate match this PR; the runtime difference is the schema-cache fix, with added CPU coverage. The stack's v1/v3 A/B contains the change in both arms and does not measure this PR alone. Its FP8-KV recipe cannot select this BF16/BF16 row.

Earlier gpt-oss reports for D64/GQA8 gave TP1 70k +2.8%, TP1 8k +0.2%, TP2 70k c4 +2.9%, and TP2 1k c16 -2.5%. The original isolated measurement setup is unverified. Performance, including the TP2 1k c16 regression, has not been re-measured on this head.

PR Self-Review

Reviewed revision

f6d6dae17e5a71f130db4c0869ddf4e5a76d453f

Behavior and intent

Use BLOCK_M 256 for eligible gfx1250 Gluon BF16/BF16 full-attention launches with NS<=8, retaining BLOCK_M 128 above that boundary and higher-priority selections. The cache fix supports live tuning; kernel arithmetic and head-size support are unchanged.

Validation and unverified scope

CPU command, with torch 2.12+ROCm 10.1 and Triton 3.8:

AITER_TRITON_ONLY=1 PYTHONPATH=. python3 op_tests/triton_tests/attention/test_unified_attention_gluon_config.py -v

Seven tests pass; Black, Ruff and whitespace checks pass. These tests validate config behavior without GPU execution.

GPU setup: MI455X (gfx1250) 96-CU partition, image rocm/sgl-dev:v1.0.0-rocm101-mi45x-20261202, torch 2.12.0+rocm10.1.0, Triton 3.9.0. Main was compared with runtime revision 3397036e8f2307434fe79578995fd7b3602fb07d; the reviewed head adds only CPU-test changes and has identical runtime/config files.

Public-wrapper parity against the existing test reference passes on both arms:

  • Shuffled page-64 BF16 KV: 36 cases per arm, D64/128 x GQA1/4/8 x six prefill/padded/mixed scenarios. A second run repeats these same cases. Main selects BLOCK_M128 throughout; head selects 256 for the 12 eight-slot cases and 128 for the other 24.
  • Unshuffled page-64 KV: 72 cases per arm, the same matrix with both FP16 and BF16. Main selects BLOCK_M128 throughout; head selects 256 only for prefill8 and mixed8 (24 cases), and 128 for all 48 larger-slot cases. All 12 padded9 cases retain 128.

The broad command pytest -q op_tests/triton_tests/attention/test_unified_attention.py -k "gluon or bf16" aborts on both arms. Isolation identifies a shared D512/32768-block mixed case whose reference runs out of memory converting the value cache to FP32, before output comparison. The following case passes alone; running the pair without synchronization triggers an HSA memory fault and timeout. Synchronizing after each attention removes the pair's fault but leaves the reference OOM. The corresponding 2048-block controls pass. These cases use existing head-size rows outside the new tuning entry; the fault mechanism remains unverified, and the broad suite is incomplete.

D192 compilation fails on both arms because gl.arange requires a power-of-two width. Shuffled FP16 setup is not supported by the existing BF16/FP8-only helper. Unshuffled FP16 parity is verified at D64/128; other widths/layouts and current performance remain unverified.

PR-specific question

The main boundary is the actual launch slot count, including zero-length padding. CPU tests cover 8/9, dtype and head-size precedence, and tables without NS. GPU cases verify numerical parity and real wrapper selection at eight slots, nine slots including padding, and mixed sixteen-slot launches. These checks do not explain the historical mixed-chunk serving regression.

Changed op tests

  • test_unified_attention.py: supplies launch num_seqs to config metadata, satisfying the new schema contract used by the production wrapper.
  • test_unified_attention_gluon_config.py: checks selection and fallback without a GPU, scopes architecture detection during imports, and verifies live JSON edits with caches disabled and errors on missing required num_seqs. Output-only parity would not detect these lookup contracts.

@github-actions

Copy link
Copy Markdown
Contributor

🏷️ CI Guide

Runs automatically on every PR:

  • ✅ Pre-checks (submodule verification, code formatting)
  • ✅ Aiter standard tests on MI35X
  • ✅ Triton tests on MI35X (only when aiter/ops/triton/** or related paths are changed)

Extended tests (opt-in via labels):

Label Tests
ci:mi300x Run Aiter standard tests on MI300X in PRs; main branch always runs them
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 Radeon R9700 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 7745 --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.

Reviews:
A reviewer is usually assigned within one working day after the PR is ready for review (see Code Review Process). If nobody has responded for about a week, mention the area contact listed in CONTACTS.md. Want to help review? See REVIEWERS.md.

bf16 full attention on the gfx1250 catch-all entry was BLOCK_M 128. 256 is faster for a few long sequences and slower when mixed chunks put many 1-token decodes in one batch, since each pads a 256-row block. Add a num_seqs (NS) lookup axis, last in the schema, and key the entry DT_bf16_bf16.NS_LEQ_8 so fp8 and NVFP4 keep the catch-all. Only the gfx1250 gluon 2D table lists NS.
@akao-amd
akao-amd force-pushed the pr-gfx1250-ua2d-bf16-blockm branch from c03cb7b to a3081a9 Compare November 11, 2026 08:51
@akao-amd
akao-amd marked this pull request as ready for review November 11, 2026 08:54
@akao-amd
akao-amd requested a review from a team November 11, 2026 08:54
@github-actions github-actions Bot changed the title [Perf] [gfx1250] gluon UA2D: BLOCK_M 256 only when the batch has <= 8 sequences [Triton/Gluon] [Perf] [gfx1250] gluon UA2D: BLOCK_M 256 only when the batch has <= 8 sequences Nov 11, 2026
@aiter-bot

aiter-bot commented Nov 11, 2026 •

Copy link
Copy Markdown

WAITING ON AUTHOR

PR Self-Review

Revision 23772fdf9d9e · 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 permissions and untrusted-input boundary does this CI change have, and can fork PR code or text reach a privileged execution path?
  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/triton_tests/attention/test_unified_attention.py
  • FAIL — changed op test not explained in Changed op tests: op_tests/triton_tests/attention/test_unified_attention_gluon_config.py
  • 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.

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 CPU test fails during import on GPU-less hosts, and stale schema caching with USE_LRU_CACHE=False can select the wrong sequence-count configuration during live tuning.

2 open issues
What changed in this PR

This PR makes gfx1250 Gluon 2D attention tuning depend on sequence count, using larger blocks for small bf16/fp16 batches while keeping existing specialized entries unchanged.

Changes:

  • Adds an NS lookup axis and selects BLOCK_M=256 for eligible batches with at most eight sequences.
  • Adds lookup tests for the threshold, dtype behavior, and specialized-entry precedence.
  • Documents the axis and its required position in the schema.
File Description
op_tests/​triton_tests/​attention/​test_unified_attention_gluon_config.py Adds sequence-count lookup regression tests.
aiter/​ops/​triton/​utils/​unified_attention_utils.py Passes sequence count into config selection and diagnostics.
aiter/​ops/​triton/​README.md Introduces the optional NS axis.
aiter/​ops/​triton/​configs/​gfx1250/​gluon/​attention/​unified_attention/​DEFAULT.json Adds the small-batch bf16 tuning entry.
aiter/​ops/​triton/​configs/​AGENTS.md Documents sequence-count semantics and lookup precedence.
.github/​instructions/​aiter-ops-triton.instructions.md Adds the rule requiring NS to be the last axis.

Review effort: Balanced

return compute_tile_params(config, block_size)


@functools.lru_cache(maxsize=64)

import torch

from aiter.ops.triton.utils.types import e4m3_dtype
@zufayu
zufayu requested review from a team and vgokhale November 12, 2026 01:12
@akao-amd

Copy link
Copy Markdown
Contributor Author

Triton shard 7 on 5c209f58 hit the 60-minute step limit while tests were still running. The last test to pass was in test_batched_gemm_a16wfp4, and the log has no pytest failures. The other seven Triton shards and all Standard shards pass.

Could a maintainer re-run shard 7, or raise its step limit, or move the slow gemm_a8w8 file to another shard? I haven't pushed to this branch since 5c209f58.

@akao-amd
akao-amd marked this pull request as draft December 3, 2026 02:38

This branch has not been deployed

No deployments
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