Skip to content

ggml-cuda: tune D=256 tile flash-attn config for RDNA3.5 - #41

Merged
mgehre-amd merged 1 commit into
gfx11from
rogarcia.fattn-tile-d256
Jul 10, 2026
Merged

ggml-cuda: tune D=256 tile flash-attn config for RDNA3.5#41
mgehre-amd merged 1 commit into
gfx11from
rogarcia.fattn-tile-d256

Conversation

@roberteg16

Copy link
Copy Markdown

What this changes

A tile flash-attn tuning for RDNA3.5. With rocWMMA FlashAttention off (-DGGML_HIP_ROCWMMA_FATTN=OFF), D=256 prefill runs on the tile kernel, and the shared RDNA tile config is not optimal on RDNA3.5 for the D=256, ncols=32 case. This adds ggml_cuda_fattn_tile_get_config_amd_rdna3_5, which overrides just that row with a smaller K tile and higher occupancy (nbatch_K 128->64, occupancy 3->4) and falls back to the shared RDNA table for every other case.

Selection is matched consistently on both sides: the host path checks GGML_CUDA_CC_IS_RDNA3_5(cc) before the generic RDNA branch, and the device path uses the RDNA3_5 macro ahead of RDNA. Only RDNA3.5 sees the new config; all other architectures are unchanged.

Benchmarks

Measured on gfx1151 (Radeon 8060S), Qwen3.6-35B-A3B Q4_K_M, -ngl 999 -r 1, built with -DGGML_HIP_ROCWMMA_FATTN=OFF. Baseline is gfx11 at the same commit base.

test baseline t/s this PR t/s delta
pp128 549.01 563.88 +2.7%
pp1024 1133.77 1137.63 +0.3% (noise)
tg128 53.31 53.28 -0.1% (noise)

On this model the effect is small - Qwen3.6-35B-A3B does not lean heavily on the D=256 tile path - so most of the movement is within run-to-run noise at -r 1. The change is a targeted config override that only affects the D=256 tile kernel, which is exercised more directly by models with a 256-wide head dim.

With rocWMMA FlashAttention off, D=256 prefill runs on the tile kernel. Add an
RDNA3.5 config that overrides the D=256, ncols=32 row with a smaller K tile and
higher occupancy (nbatch_K 128->64, occupancy 3->4); other cases fall back to the
shared RDNA table. Selection is matched on host (cc) and device (RDNA3_5 macro).

Assisted-by: Claude Opus 4 (1M context)
@mgehre-amd

Copy link
Copy Markdown
Collaborator

Does llama.cpp repo provide a way to just test this kernel on various shapes instead of testing the whole model?

@mgehre-amd
mgehre-amd merged commit 38a8ff8 into gfx11 Jul 10, 2026
6 checks passed
@mgehre-amd
mgehre-amd deleted the rogarcia.fattn-tile-d256 branch July 10, 2026 23:02
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