Skip to content

[Trition] Add chunk_delta_attn triton kernels - #4568

Merged
Liang-jianhao97 merged 1 commit into
mainfrom
feature/chunk_delta_attn
Aug 10, 2026
Merged

Liang-jianhao97 merged 1 commit into
mainfrom
feature/chunk_delta_attn

Conversation

@Liang-jianhao97

@Liang-jianhao97 Liang-jianhao97 commented Aug 5, 2026 •

Copy link
Copy Markdown
Contributor

Motivation

Add chunk_delta_attn (chunked delta-attention operator with gated recurrence) as a first-class Triton op in aiter.

Technical Details

Triton dispatch layer (aiter/ops/triton/_triton_kernels/chunk_delta_attn/) ported from flash-linear-attention v0.5.2 commit 9c8e42e.

  • chunk_fwd.py — top-level entry point
  • gate.py — beta sigmoid preprocessing
  • intra_attn.py — intra-chunk attention (sub-chunk diagonal + inter-solve + W/U recompute)
  • wy_fast.py — recompute W and U tensors from Akk inverse
  • gla_output.py — GLA output computation
  • utils/cumsum.py — fused gate + chunk-local prefix sum
  • utils/index.py — variable-length sequence chunk index preparation
  • utils/l2norm.py — L2 normalization (forward only)
  • utils/utils.py — shared constants, autotune helpers, input_guard decorator

Test Plan

  • Correctness:
    pytest op_tests/triton_tests/chunk_delta_attn/ -v
  • Performance:
   python op_tests/op_benchmarks/triton/bench_chunk_delta_attn.py

Test Result

All correctness tests pass (bfloat16, atol=1e-2, rtol=1e-2). KDA E2E Precision verification passed on GFX1250/GFX950 with Triton 3.7.0 + commit efbae9a33c.
AMD MI350X:

B T H K V Time(ms) TFLOPS BW(GB/s)
1 512 16 64 64 0.2923 0.92 18.0
1 1024 16 64 64 0.2805 1.91 37.5
1 2048 16 64 64 0.2862 3.75 73.5
1 4096 16 64 64 0.2927 7.34 143.8
1 8192 16 64 64 0.3403 12.62 247.3
1 16384 16 64 64 0.7183 11.96 234.3
2 2048 16 64 64 0.2898 7.41 145.2
2 4096 16 64 64 0.2994 14.35 281.1
4 2048 16 64 64 0.2995 14.34 280.9
4 4096 16 64 64 0.4492 19.12 374.6
1 8192 32 128 128 0.9621 26.78 349.3
1 8192 64 128 128 1.5373 33.53 437.2
1 8192 96 128 128 2.2912 33.74 440.0
1 8192 128 128 128 2.9169 35.34 460.9
1 16384 32 128 128 1.7696 29.13 379.8
1 16384 64 128 128 3.0030 34.33 447.6
1 16384 96 128 128 4.5886 33.70 439.4
1 16384 128 128 128 5.6478 36.50 476.0

@Liang-jianhao97
Liang-jianhao97 requested a review from a team August 5, 2026 05:40
@github-actions

github-actions Bot commented Aug 5, 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 4568 --add-label <label>

@github-actions github-actions Bot 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.

Remaining comments which cannot be posted as a review comment to avoid GitHub Rate Limit

ruff

⚠️ [ruff] <B023> reported by reviewdog 🐶
Function definition does not bind loop variable k

https://github.com/ROCm/aiter/blob/3f3f61caf3dbdf6d3ea91e91096fdd408b7a1940/op_tests/op_benchmarks/triton/bench_chunk_delta_attn.py#L137-L137


⚠️ [ruff] <B023> reported by reviewdog 🐶
Function definition does not bind loop variable beta

https://github.com/ROCm/aiter/blob/3f3f61caf3dbdf6d3ea91e91096fdd408b7a1940/op_tests/op_benchmarks/triton/bench_chunk_delta_attn.py#L138-L138


⚠️ [ruff] <B023> reported by reviewdog 🐶
Function definition does not bind loop variable v

https://github.com/ROCm/aiter/blob/3f3f61caf3dbdf6d3ea91e91096fdd408b7a1940/op_tests/op_benchmarks/triton/bench_chunk_delta_attn.py#L140-L140


⚠️ [ruff] <B023> reported by reviewdog 🐶
Function definition does not bind loop variable g

https://github.com/ROCm/aiter/blob/3f3f61caf3dbdf6d3ea91e91096fdd408b7a1940/op_tests/op_benchmarks/triton/bench_chunk_delta_attn.py#L140-L140


⚠️ [ruff] <B023> reported by reviewdog 🐶
Function definition does not bind loop variable scale

https://github.com/ROCm/aiter/blob/3f3f61caf3dbdf6d3ea91e91096fdd408b7a1940/op_tests/op_benchmarks/triton/bench_chunk_delta_attn.py#L141-L141


⚠️ [ruff] <B023> reported by reviewdog 🐶
Function definition does not bind loop variable A_log

https://github.com/ROCm/aiter/blob/3f3f61caf3dbdf6d3ea91e91096fdd408b7a1940/op_tests/op_benchmarks/triton/bench_chunk_delta_attn.py#L146-L146


⚠️ [ruff] <B023> reported by reviewdog 🐶
Function definition does not bind loop variable dt_bias

https://github.com/ROCm/aiter/blob/3f3f61caf3dbdf6d3ea91e91096fdd408b7a1940/op_tests/op_benchmarks/triton/bench_chunk_delta_attn.py#L147-L147


⚠️ [ruff] <F401> reported by reviewdog 🐶
torch.nn.functional imported but unused

https://github.com/ROCm/aiter/blob/3f3f61caf3dbdf6d3ea91e91096fdd408b7a1940/op_tests/triton_tests/chunk_delta_attn/test_chunk_delta_attn_fwd.py#L22-L22


⚠️ [ruff] <BLE001> reported by reviewdog 🐶
Do not catch blind exception: Exception

https://github.com/ROCm/aiter/blob/3f3f61caf3dbdf6d3ea91e91096fdd408b7a1940/op_tests/triton_tests/chunk_delta_attn/test_chunk_delta_attn_fwd.py#L35-L35


⚠️ [ruff] <RUF059> reported by reviewdog 🐶
Unpacked variable A_log is never used

https://github.com/ROCm/aiter/blob/3f3f61caf3dbdf6d3ea91e91096fdd408b7a1940/op_tests/triton_tests/chunk_delta_attn/test_chunk_delta_attn_fwd.py#L95-L95


⚠️ [ruff] <RUF059> reported by reviewdog 🐶
Unpacked variable dt_bias is never used

https://github.com/ROCm/aiter/blob/3f3f61caf3dbdf6d3ea91e91096fdd408b7a1940/op_tests/triton_tests/chunk_delta_attn/test_chunk_delta_attn_fwd.py#L95-L95


⚠️ [ruff] <I001> reported by reviewdog 🐶
Import block is un-sorted or un-formatted

https://github.com/ROCm/aiter/blob/3f3f61caf3dbdf6d3ea91e91096fdd408b7a1940/op_tests/triton_tests/chunk_delta_attn/test_chunk_gate_cumsum.py#L15-L19


⚠️ [ruff] <RUF059> reported by reviewdog 🐶
Unpacked variable B is never used

https://github.com/ROCm/aiter/blob/3f3f61caf3dbdf6d3ea91e91096fdd408b7a1940/op_tests/triton_tests/chunk_delta_attn/test_chunk_gate_cumsum.py#L92-L92


⚠️ [ruff] <RUF059> reported by reviewdog 🐶
Unpacked variable T is never used

https://github.com/ROCm/aiter/blob/3f3f61caf3dbdf6d3ea91e91096fdd408b7a1940/op_tests/triton_tests/chunk_delta_attn/test_chunk_gate_cumsum.py#L92-L92


⚠️ [ruff] <RUF059> reported by reviewdog 🐶
Unpacked variable B is never used

https://github.com/ROCm/aiter/blob/3f3f61caf3dbdf6d3ea91e91096fdd408b7a1940/op_tests/triton_tests/chunk_delta_attn/test_chunk_gate_cumsum.py#L102-L102


⚠️ [ruff] <RUF059> reported by reviewdog 🐶
Unpacked variable T is never used

https://github.com/ROCm/aiter/blob/3f3f61caf3dbdf6d3ea91e91096fdd408b7a1940/op_tests/triton_tests/chunk_delta_attn/test_chunk_gate_cumsum.py#L102-L102


⚠️ [ruff] <RUF059> reported by reviewdog 🐶
Unpacked variable H is never used

https://github.com/ROCm/aiter/blob/3f3f61caf3dbdf6d3ea91e91096fdd408b7a1940/op_tests/triton_tests/chunk_delta_attn/test_chunk_gate_cumsum.py#L102-L102


⚠️ [ruff] <RUF059> reported by reviewdog 🐶
Unpacked variable S is never used

https://github.com/ROCm/aiter/blob/3f3f61caf3dbdf6d3ea91e91096fdd408b7a1940/op_tests/triton_tests/chunk_delta_attn/test_chunk_gate_cumsum.py#L102-L102


⚠️ [ruff] <RUF059> reported by reviewdog 🐶
Unpacked variable B is never used

https://github.com/ROCm/aiter/blob/3f3f61caf3dbdf6d3ea91e91096fdd408b7a1940/op_tests/triton_tests/chunk_delta_attn/test_chunk_gate_cumsum.py#L112-L112


⚠️ [ruff] <RUF059> reported by reviewdog 🐶
Unpacked variable T is never used

https://github.com/ROCm/aiter/blob/3f3f61caf3dbdf6d3ea91e91096fdd408b7a1940/op_tests/triton_tests/chunk_delta_attn/test_chunk_gate_cumsum.py#L112-L112


⚠️ [ruff] <RUF059> reported by reviewdog 🐶
Unpacked variable H is never used

https://github.com/ROCm/aiter/blob/3f3f61caf3dbdf6d3ea91e91096fdd408b7a1940/op_tests/triton_tests/chunk_delta_attn/test_chunk_gate_cumsum.py#L112-L112


⚠️ [ruff] <RUF059> reported by reviewdog 🐶
Unpacked variable S is never used

https://github.com/ROCm/aiter/blob/3f3f61caf3dbdf6d3ea91e91096fdd408b7a1940/op_tests/triton_tests/chunk_delta_attn/test_chunk_gate_cumsum.py#L112-L112


⚠️ [ruff] <RUF059> reported by reviewdog 🐶
Unpacked variable B is never used

https://github.com/ROCm/aiter/blob/3f3f61caf3dbdf6d3ea91e91096fdd408b7a1940/op_tests/triton_tests/chunk_delta_attn/test_chunk_gate_cumsum.py#L132-L132


⚠️ [ruff] <RUF059> reported by reviewdog 🐶
Unpacked variable T is never used

https://github.com/ROCm/aiter/blob/3f3f61caf3dbdf6d3ea91e91096fdd408b7a1940/op_tests/triton_tests/chunk_delta_attn/test_chunk_gate_cumsum.py#L132-L132


⚠️ [ruff] <RUF059> reported by reviewdog 🐶
Unpacked variable H is never used

https://github.com/ROCm/aiter/blob/3f3f61caf3dbdf6d3ea91e91096fdd408b7a1940/op_tests/triton_tests/chunk_delta_attn/test_chunk_gate_cumsum.py#L132-L132


⚠️ [ruff] <RUF059> reported by reviewdog 🐶
Unpacked variable S is never used

https://github.com/ROCm/aiter/blob/3f3f61caf3dbdf6d3ea91e91096fdd408b7a1940/op_tests/triton_tests/chunk_delta_attn/test_chunk_gate_cumsum.py#L132-L132


⚠️ [ruff] <RUF059> reported by reviewdog 🐶
Unpacked variable B is never used

https://github.com/ROCm/aiter/blob/3f3f61caf3dbdf6d3ea91e91096fdd408b7a1940/op_tests/triton_tests/chunk_delta_attn/test_chunk_gate_cumsum.py#L137-L137


⚠️ [ruff] <RUF059> reported by reviewdog 🐶
Unpacked variable T is never used

https://github.com/ROCm/aiter/blob/3f3f61caf3dbdf6d3ea91e91096fdd408b7a1940/op_tests/triton_tests/chunk_delta_attn/test_chunk_gate_cumsum.py#L137-L137


⚠️ [ruff] <RUF059> reported by reviewdog 🐶
Unpacked variable H is never used

https://github.com/ROCm/aiter/blob/3f3f61caf3dbdf6d3ea91e91096fdd408b7a1940/op_tests/triton_tests/chunk_delta_attn/test_chunk_gate_cumsum.py#L137-L137


⚠️ [ruff] <RUF059> reported by reviewdog 🐶
Unpacked variable S is never used

https://github.com/ROCm/aiter/blob/3f3f61caf3dbdf6d3ea91e91096fdd408b7a1940/op_tests/triton_tests/chunk_delta_attn/test_chunk_gate_cumsum.py#L137-L137


⚠️ [ruff] <RUF059> reported by reviewdog 🐶
Unpacked variable B is never used

https://github.com/ROCm/aiter/blob/3f3f61caf3dbdf6d3ea91e91096fdd408b7a1940/op_tests/triton_tests/chunk_delta_attn/test_chunk_gate_cumsum.py#L144-L144


⚠️ [ruff] <RUF059> reported by reviewdog 🐶
Unpacked variable T is never used

https://github.com/ROCm/aiter/blob/3f3f61caf3dbdf6d3ea91e91096fdd408b7a1940/op_tests/triton_tests/chunk_delta_attn/test_chunk_gate_cumsum.py#L144-L144


⚠️ [ruff] <RUF059> reported by reviewdog 🐶
Unpacked variable H is never used

https://github.com/ROCm/aiter/blob/3f3f61caf3dbdf6d3ea91e91096fdd408b7a1940/op_tests/triton_tests/chunk_delta_attn/test_chunk_gate_cumsum.py#L144-L144


⚠️ [ruff] <RUF059> reported by reviewdog 🐶
Unpacked variable S is never used

https://github.com/ROCm/aiter/blob/3f3f61caf3dbdf6d3ea91e91096fdd408b7a1940/op_tests/triton_tests/chunk_delta_attn/test_chunk_gate_cumsum.py#L144-L144

@Liang-jianhao97 Liang-jianhao97 changed the title [chunk_delta_attn] Add Gluon kernels + self-contained triton ops for … [chunk_delta_attn] Add triton and gluon kernels Aug 5, 2026
@Liang-jianhao97 Liang-jianhao97 changed the title [chunk_delta_attn] Add triton and gluon kernels [Trition] Add chunk_delta_attn triton and gluon kernels Aug 5, 2026
@Liang-jianhao97
Liang-jianhao97 force-pushed the feature/chunk_delta_attn branch 19 times, most recently from 00bf965 to 8311db1 Compare August 5, 2026 11:04

@Dewei-Wang-sh Dewei-Wang-sh 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.

can you make it 2 PRs?
first, specify the original porting files
second, add our gfx950 optimization.

@Liang-jianhao97

Copy link
Copy Markdown
Contributor Author

can you make it 2 PRs? first, specify the original porting files second, add our gfx950 optimization.

sure

@zufayu
zufayu requested a review from vgokhale August 6, 2026 02:34
@Liang-jianhao97
Liang-jianhao97 force-pushed the feature/chunk_delta_attn branch 3 times, most recently from 055a754 to 586ac07 Compare August 6, 2026 03:59
@Liang-jianhao97
Liang-jianhao97 force-pushed the feature/chunk_delta_attn branch from 586ac07 to 41d7936 Compare August 6, 2026 04:03
@Liang-jianhao97 Liang-jianhao97 changed the title [Trition] Add chunk_delta_attn triton and gluon kernels [Trition] Add chunk_delta_attn triton kernels Aug 6, 2026
@Liang-jianhao97
Liang-jianhao97 force-pushed the feature/chunk_delta_attn branch 13 times, most recently from 1750a5a to d639aad Compare August 8, 2026 15:07
…rd pass

Ported from flash-linear-attention v0.5.2

Co-Authored-By: Claude Opus 4.6 <[email protected]>
@Liang-jianhao97
Liang-jianhao97 force-pushed the feature/chunk_delta_attn branch from d639aad to 99ad604 Compare August 8, 2026 15:14

@Dewei-Wang-sh Dewei-Wang-sh 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.

overall lgtm, but need to specifiy

  1. what is the original source and commit id
  2. does it pass on gfx1250?

@Liang-jianhao97
Liang-jianhao97 merged commit 01ddb01 into main Aug 10, 2026
54 of 56 checks passed
@Liang-jianhao97
Liang-jianhao97 deleted the feature/chunk_delta_attn branch August 10, 2026 03:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants