Repository navigation
vulkan: enable FA shmem staging on AMD RDNA (scalar path) - #28507
MelonUsk1337 wants to merge 1 commit into
Conversation
Staging K/V through shared memory in the scalar flash-attention path was gated to NVIDIA in ggml-org#19625. On AMD RDNA the same staging is a large win, including for head sizes >= 256 which the NVIDIA gate excludes: - gfx1013 (AMD BC-250, RADV, Mesa 25.2.6), gemma-4-26B-A4B IQ3_S (hsk/hsv 256 SWA / 512 global): pp2048 +12% at d0, +34% at d4096, +50% at d8192 vs stock (b10727). In a 5-node RPC cluster running Qwen3.5-122B-A10B: prefill 96 -> 162 t/s, generation 19 -> 29.5 t/s. - RDNA2 V620, 27B dense Q6_K (reported in ggml-org#25207): +30% at d8192, +62% at d16384. GCN is left unchanged (untested). The coopmat1 path is not touched. Ref: ggml-org#25207
|
Hi @MelonUsk1337, thanks for your contribution! Per our contribution guidelines, the automated PR checker found the following issue(s) that need your attention:
Please note that maintainers reserve the right to make final decisions on PRs. If you believe there is a mistake, please comment below. |
|
Hi @MelonUsk1337, nice results! I'm on AMD Vulcan and would love this PR! The bot flagged this PR because the description doesn't follow the PR template. To save you some time, here's your description rearranged into it. You'd just need to edit the PR's first post, paste this in, and fill in the Requirements section (only you can confirm those): OverviewEnables K/V shared-memory staging (
This gives a large prompt-processing speedup on RDNA2, and the gain grows with context depth. Additional informationAMD BC-250 (gfx1013, RDNA2, RADV / Mesa 25.2.6, Debian 13)
AMD V620 (RDNA2), qwen35 27B Q6_K: +29.8 % at d8192, +62.4 % at d16384. Real-world use: running since 2026-09-01 on a 5-node RPC cluster (Qwen3.5-122B-A10B IQ3_S). Prefill went from 96 to 162 t/s (+68 %) and generation from 19.0 to 29.5 t/s (+55 %). Not tested on RDNA3/RDNA4 or GCN. Test results on those from anyone with the hardware would be welcome. Requirements
|
|
Additionally: Here is a quick CR that claude did. Maybe have a look especially on the OTHERS topic that you have touched: The idea makes sense. Shared-memory staging of K/V was an NVIDIA-only tuning choice in #19625. Turning it on for AMD is a small, low-risk tuning change, and the gains on two RDNA2 cards are big. But there are a few things a reviewer would probably raise:
|
Cherry-pick of ggml-org/llama.cpp PR ggml-org#28507 (ggml-org#28507) Author: Melon_USK (@MelonUsk1337) Reason for our setup: Flash-attention shmem staging on AMD RDNA scalar path - measured +12..62% at large decode depths. Applied manually: PR base predated the coopmat1 FA tuning added by PR ggml-org#27952; change targets get_fa_tuning_params_scalar only.
|
Tested this on RDNA2 (RX 6900 XT). The speedup is real, but Setup
Speed:
Generation is unchanged at every depth (d8192 and d16384 too). Output:
Crash 1: SIGSEGV with head size 72
Head size 72 matters in practice: the Qwen3-VL / Qwen3.5 vision encoder ( Crash 2: GPU hang with head size 320/256 To avoid crash 1 I gated the staging to AMD non-GCN only when Kernel log: Since the hang happened with my narrower gate, the cases that fail are reachable with the original diff too (it enables staging for every head size on RDNA). The 256/256 cases pass: So on RDNA2 the gain is there for head size 256. But enabling staging for every head size breaks at least 72/72 (segfault) and 320/256 (device lost), which suggests the shared memory sizing doesn't fit for some head sizes. Happy to rerun Assisted-by: Claude Opus 5.5 (ran the tests and drafted this comment; the numbers are from my machine) |
Summary
Staging K/V through shared memory in the scalar flash-attention path (
get_fa_tuning_params_scalar) was gated to NVIDIA when it was introduced in #19625. On AMD RDNA the same staging is a large win, including for head sizes >= 256 which the NVIDIA gate excludes. This PR enables it for AMD non-GCN devices in the scalar path only; GCN and the coopmat1 path are left unchanged.Ref: #25207
Measurements
AMD BC-250 (gfx1013, RDNA2, RADV / Mesa 25.2.6, Debian 13), b10727 stock vs. the same build with this change.
gemma-4-26B-A4B-it-UD-IQ3_S (MoE; hsk/hsv = 256 on SWA layers, 512 on global layers), FA on,
llama-bench -p 2048:Production use since 2026-09-01 on a 5-node RPC cluster (dirigent + 4 workers over 2.5 GbE) with Qwen3.5-122B-A10B IQ3_S: prefill 96 -> 162 t/s (+68 %), generation 19.0 -> 29.5 t/s (+55 %) on a 16k-token prompt; a daily 20k-token batch job went from 803 s to ~440 s. No correctness or stability regressions observed over ~6 days of continuous use across five gfx1013 devices.
AMD V620 (RDNA2), reported by @draetheus in #25207 with the same change: qwen35 27B Q6_K, +29.8 % at d8192, +62.4 % at d16384.
Notes
hsk < 256 && hsv < 256condition unchanged. The AMD RDNA gate deliberately has no head-size condition, because the measured gains above are on head sizes 256 and 512.!device->coopmat_support) if maintainers prefer.