You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
aiter-sage-attention: SageAttention for AMD RDNA4 (gfx1201) #1222
Hi! I'd like to propose hosting a SageAttention kernel for AMD Radeon RDNA4 GPUs (gfx1201: Radeon AI PRO R9700 / R9600D, RX 9070 series) here, and I'd be grateful for your thoughts.
The kernel
It computes QK^T in INT8 and PV in FP8, with FP32 accumulation. Q/K are quantized per 32-row block and V per channel inside the kernel. The source is in ROCm/aiter (HIP, MIT): ROCm/aiter#6390. That PR is still under review.
Why it could be useful here
As far as I can tell, diffusers doesn't have a quantized attention backend for these GPUs yet. SAGE/SAGE_HUB are CUDA builds, and kernels-community/aiter-flash-attn ships tuning configs for gfx942 / gfx950 / gfx1250. In huggingface/diffusers#15014, @sayakpaul suggested packaging the kernel with Kernels before adding a diffusers backend, and @Abdennacer-Badaoui kindly offered to help with the build.
What I have so far
A package laid out like aiter-flash-attn-ck (edition 5, rocm-archs = ["gfx1201"]):
The two aiter kernel sources (prepare and attention) are vendored unchanged from aiter#6390 at 62019a49. aiter_tensor.h is trimmed to the fields the kernels use, so ck_tile isn't needed.
It exposes sageattn(q, k, v, tensor_layout, is_causal, sm_scale, return_lse) for diffusers, plus gfx1201_sage_attention(query, key, value, softmax_scale, ...). Unsupported inputs (causal, LSE, non-BF16, head dim other than 128, unequal Q/K/V shapes, non-gfx1201) raise an error rather than falling back silently.
tests/ loads the kernel via get_kernel.
I don't have Nix on my machine, so I built it locally with kernel-builder create-pyproject + setup.py build_kernel (PyTorch 2.11, ROCm 7.15). On an R9700:
All 22 tests pass.
Outputs are bit-identical to aiter.gfx1201_sage_attention built from the same commit.
Compared with SDPA (BF16, 28 heads, head dim 128; cosine similarity 0.9992 to SDPA):
Sequence
SDPA
aiter-sage-attention
Speedup
4096
3.4 ms
1.7 ms
1.98x
16384
54.8 ms
23.6 ms
2.33x
57330
676.3 ms
275.2 ms
2.46x
114660
2775.2 ms
1109.0 ms
2.50x
I also tried it end to end in diffusers, through a local aiter_sage_hub backend (loaded via LOCAL_KERNELS), with MiniMax-H3 text-to-video+audio (960x544, 124 frames, 9 steps, one R9700, group offload). Compared with the native backend:
Each transformer call took 12.0 s instead of 16.5 s (1.37x), and the pipeline call took 130 s instead of 171 s.
Video PSNR to the native output was 26.1 dB (worst frame 22.0 dB), and the two videos look the same to me.
The VAE's attention (head dim 64) also follows the active backend, so the diffusers backend sends calls the kernel can't take to SDPA.
My question
Would you be open to hosting this as kernels-community/aiter-sage-attention? If so, could I be vouched so that I can open a PR? I'd open it as a draft and re-sync the vendored sources once aiter#6390 is merged. I'm also happy to adjust the layout or naming to whatever you prefer.
For transparency: I wrote the package with help from an AI coding assistant (GitHub Copilot). I reviewed the code and ran the tests and measurements above myself.
Whenever it's convenient, could I be added to .github/VOUCHED.td so that I can open the PR? I'll open it as a draft first, and keep the vendored sources in sync with ROCm/aiter#6390 as that PR evolves. Thanks again!
Activity
Abdennacer-Badaoui commentedon Oct 13, 2026
Hi @Shan2L,
Amazing work!
If it’s going to be used in Diffusers, then yes, we can host it in
kernels-community/aiter-sage-attention(cc @sayakpaul).Shan2L commentedon Oct 13, 2026
Thank you, @Abdennacer-Badaoui! Yes, it's for the diffusers
aiter_sage_hubbackend in huggingface/diffusers#15014. I'll follow up here soon.sayakpaul commentedon Oct 14, 2026
Looking forward to it.
Shan2L commentedon Oct 14, 2026
Thank you both, @Abdennacer-Badaoui and @sayakpaul!
Whenever it's convenient, could I be added to
.github/VOUCHED.tdso that I can open the PR? I'll open it as a draft first, and keep the vendored sources in sync with ROCm/aiter#6390 as that PR evolves. Thanks again!Add Shan2L to the VOUCHED (#1224)
aiter-sage-attention: add gfx1201 SageAttention kernel (huggingface#1229