Skip to content

[Triton/Gluon] [GFX950] Add Unified Attention Gluon Kernel - #4614

Merged
cagrikymk merged 42 commits into
mainfrom
cagri/unif_2d_gfx950_clean
Sep 25, 2026
Merged

cagrikymk merged 42 commits into
mainfrom
cagri/unif_2d_gfx950_clean

Conversation

@cagrikymk

@cagrikymk cagrikymk commented Aug 6, 2026 •

Copy link
Copy Markdown
Contributor

Motivation

This PR adds gfx950 gluon kernel for unified attention. It uses single kernel that supports both 2d and 3d grid.

Performance is tuned for head sizes [64, 128, 256], dtype fp8 x fp8 and bf16 x bf16.

Remaining Steps

  • Test e2e performance, at least for GPT-OSS-120b
  • Extend the gluon routing to make it more bullet-proof

Technical Details

Performance numbers are collected using Triton 3.7.1.

Geomean speedup by head_size against Triton

This is the geomean speedup of various run configs with varrying concurrency, kv/seq. length, number of KV/Q heads,

head_size decode bf16 decode fp8 prefill bf16 prefill fp8 mixed bf16 mixed fp8
256 1.58x 1.02x 2.17x 2.22x 1.90x 1.81x
128 1.10x 1.08x 1.19x 1.38x 1.23x 1.41x
64 1.11x 1.24x 1.51x 1.55x 1.54x 1.62x

Detailed performance report:
gluon_gfx950_perf_report.md

Test Plan

Existing tests are routed to the gluon kernel if conditions are met

Test Result

Tests pass

@github-actions

github-actions Bot commented Aug 6, 2026

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:triton-300x Run an additional Triton test job on MI300X in PRs; main branch always runs both MI35X and MI300X
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: GPT-OSS-120B, DeepSeek-R1-0528, Kimi-K2.5
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 4614 --add-label <label>

@cagrikymk

Copy link
Copy Markdown
Contributor Author

GPT-OSS 120b benchmark, bf16 kv cache:

ISL/OSL 1024/1024

C gluon tok/s triton tok/s delta
8 1979 1958 +1.1%
16 3937 3921 +0.4%
32 7014 6941 +1.1%
64 12090 11960 +1.1%
128 19208 19003 +1.1%

ISL/OSL 8192/1024

C gluon tok/s triton tok/s delta
8 1836 1816 +1.1%
16 3419 3384 +1.0%
32 5528 5434 +1.7%
64 8306 8144 +2.0%
128 11189 10945 +2.2%

@cagrikymk
cagrikymk marked this pull request as ready for review August 7, 2026 15:57
@cagrikymk
cagrikymk requested a review from a team August 7, 2026 15:57
vgokhale
vgokhale previously approved these changes Aug 7, 2026
@cagrikymk

Copy link
Copy Markdown
Contributor Author

@vgokhale Due to triton version difference between CI and my local setup (both are 3.7 but at different commits), I was getting LLVM compilation error when using waves_per_eu=3 with sliding window in CI:

llvm/ADT/Sequence.h:275  llvm::iota_range<unsigned>::iota_range(T, T, bool):
  Assertion `Begin <= End && "Begin must be less or equal to End."' failed.
 (anonymous namespace)::SIInsertWaitcnts::run()
translateLLVMIRToASM   (python/src/llvm.cc:399)

I changed occupancy to 0 for that case, and it compiles to a kernel with occupancy 3 without any error in CI triton now.

@cagrikymk
cagrikymk requested a review from vgokhale August 7, 2026 19:20
vgokhale
vgokhale previously approved these changes Aug 7, 2026
@github-actions github-actions Bot changed the title [TRITON][GLUON][GFX950] Add Unified Attention Gluon Kernel [Triton/Gluon] [GFX950] Add Unified Attention Gluon Kernel Aug 19, 2026
@cagrikymk
cagrikymk marked this pull request as ready for review September 15, 2026 15:38
@Boss2002n
Boss2002n requested a lite review from Copilot September 15, 2026 17:45

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.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

cagrikymk and others added 2 commits September 22, 2026 14:15
Chunked serving rebuilds padded block tables with changing strides, so storing the stride in `AttentionConfig` creates per-width Gluon binaries during live requests. Pass it as runtime `tl.int32` state through both KV loaders while retaining the cache-layout strides as compile-time constants.
azaidy
azaidy previously approved these changes Sep 25, 2026

@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! Please address the following in a separate PR:

  1. Need a repr. Both gfx1250 unified-attention Gluon kernels have one.
  2. Several helpers are copies of code already in the tree. elementwise_max_prop_nan, reduce_max_prop_nan and _MAX_PROPAGATE_NAN_ALL are byte-identical to the gfx1250 versions.
  3. test_triton_unified_attn never reaches the 3d grid, because both its seq_lens sets contain a prefill. The only decode test is test_triton_unified_attn_3d, and it is parametrized head_size=[64], sliding_window=[None]. That leaves 6 of the 8 attn_3d keys in the new DEFAULT.json unreachable, including every WIDE_BLOCK_M_MULT entry. Please address test coverage in a followup PR.

@azaidy
azaidy self-requested a review September 25, 2026 14:39

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

@cagrikymk
cagrikymk merged commit faa117e into main Sep 25, 2026
77 of 85 checks passed
@cagrikymk
cagrikymk deleted the cagri/unif_2d_gfx950_clean branch September 25, 2026 19:28
@Boss2002n
Boss2002n requested a lite review from Copilot September 25, 2026 20:11

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.

Copilot review overview

🟡 Changes recommended

Unresolved routing and kernel safety issues block approval, with portability and coverage fixes also needed.

Get a fresh assessment by requesting another Copilot review.

Review effort: Lite
Findings: 2 High severity · 1 Medium severity

Open (3)

Comment on lines +752 to +756
# clamp to the last column so the loop's j+2 prefetch
# never reads past the (padded) block table
if self.cfg.ALL_DECODE:
i = gl.minimum(i, self.block_table_stride - 1)
blk = gl.load(self.block_tables_ptr_shifted + i)
Comment on lines +142 to +145
and params.head_size <= 256
and triton.next_power_of_2(params.head_size) == params.head_size
and params.head_size_v == params.head_size
and params.q_dtype in (e4m3_dtype, torch.bfloat16)
@@ -0,0 +1,2001 @@
import torch
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.

5 participants