Skip to content

HIP/CUDA: enable sparse attn on CDNA - #31259

Merged
ggerganov merged 3 commits into
ggml-org:masterfrom
IMbackK:cdna_sparse_fattn
Oct 29, 2026
Merged

ggerganov merged 3 commits into
ggml-org:masterfrom
IMbackK:cdna_sparse_fattn

Conversation

@IMbackK

@IMbackK IMbackK commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

Overview

This enables the sparse fattn path on cdna

Additional information

This is perf postive in synthetics and with an additional patch to enable sparse fattn for qwen4exp i get these nummbers:

model size params backend ngl lazy_mode test t/s
qwen4exp A3B Q4_K - Medium 103.68 GiB 176.94 B ROCm -1 off pp512 @ d16384 760.52 ± 55.29
qwen4exp A3B Q4_K - Medium 103.68 GiB 176.94 B ROCm -1 off tg64 @ d16384 35.81 ± 3.04
qwen4exp A3B Q4_K - Medium 103.68 GiB 176.94 B ROCm -1 off pp512 @ d32768 633.18 ± 99.63
qwen4exp A3B Q4_K - Medium 103.68 GiB 176.94 B ROCm -1 off tg64 @ d32768 30.78 ± 5.79
model size params backend ngl lazy_mode test t/s
qwen4exp A3B Q4_K - Medium 103.68 GiB 176.94 B ROCm -1 off pp512 @ d16384 782.11 ± 11.73
qwen4exp A3B Q4_K - Medium 103.68 GiB 176.94 B ROCm -1 off tg64 @ d16384 36.43 ± 2.43
qwen4exp A3B Q4_K - Medium 103.68 GiB 176.94 B ROCm -1 off pp512 @ d32768 736.58 ± 62.15
qwen4exp A3B Q4_K - Medium 103.68 GiB 176.94 B ROCm -1 off tg64 @ d32768 35.20 ± 2.19

The numbers are pretty noisy (the above is with -r 50) but there is a definite improvement. Note that this is with the model loaded on 2x mi100s 1x r9700 and 1x rx7900xtx so this undersells i since half the model is not on architectures affected.

The other arches will get a followup.

Requirements

  • I have read and agree with the contributing guidelines
  • AI usage disclosure: YES, host side dispatch code was written by Qwen3.8-flash-next

@IMbackK
IMbackK requested a review from a team as a code owner October 27, 2026 16:36
@am17an

am17an commented Oct 27, 2026

Copy link
Copy Markdown
Contributor

You need to do higher depth, also why not enable it for RDNA?

@am17an

am17an commented Oct 27, 2026

Copy link
Copy Markdown
Contributor

The other arches will get a followup.

Sorry I didn't read the whole thing

Comment thread ggml/src/ggml-cuda/fattn.cu Resolved
@github-actions github-actions Bot added ggml changes relating to the ggml tensor library for machine learning CUDA Related to the CUDA backend labels Oct 27, 2026
@IMbackK

IMbackK commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor Author

will followup with the __ballot_sync use in the other file, there the mask is actively used on warp 64 devices. so this makes it incorrect for wave64 on rocm == 6.3-6.4

@IMbackK IMbackK added the merge ready A maintainer can use this label to indicate that they consider the changes final and ready to merge. label Oct 28, 2026
@ggerganov
ggerganov merged commit 78febba into ggml-org:master Oct 29, 2026
27 of 30 checks passed
dzannotti added a commit to halo-box/strix-llama.cpp that referenced this pull request Nov 15, 2026
…sparse D256 kernel

Restore the master FA budgets and symbol names (the renamed baseline is not needed after the signature fix), keep the diagmask unit removed, and add a budget for the sparse-gather D256 8x8 kernel that upstream enabled on HIP (ggml-org#31259). Master has no such kernel.

Assisted-by: Claude Opus 5.5

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01YKmjzcT1LTvKtbw9EzBVGE
dzannotti added a commit to halo-box/strix-llama.cpp that referenced this pull request Nov 15, 2026
Upstream builds the sparse MMA flash-attention kernels on HIP since ggml-org#31259, but ggml_cuda_flash_attn_ext_mma_f16_shall_use_sparse selects them only on NVIDIA (Turing and newer) and CDNA, so gfx1151 never runs them. Skip them in the gfx1151 device code like D40 / D72 / D192; the D256 8x8 one had 26 SGPR spills.

Assisted-by: Claude Opus 5.5

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01YKmjzcT1LTvKtbw9EzBVGE
amangupta-tether added a commit to tetherto/qvac-fabric-llm.cpp that referenced this pull request Nov 18, 2026
…end-ops

The radix top-k (ggml-org#31084) and the QSA row lists (ggml-org#32247) use __ballot_sync, which
the HIP headers do not provide before 7.0 with HIP_DISABLE_WARP_SYNC_BUILTINS:
the hip CI job failed to compile top-k-mask.cu and top-k.cu. Take the mapping
upstream added in ggml-org#31259. Compiled on ROCm 7.2 with and
without the mapping (gfx1151, gfx90a).

test-backend-ops uses std::iota for the row-list indexer cases, which needs
<numeric> on MSVC (windows / x64-cpu-static).

Assisted-by: Claude Opus 5.5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CUDA Related to the CUDA backend ggml changes relating to the ggml tensor library for machine learning merge ready A maintainer can use this label to indicate that they consider the changes final and ready to merge.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants