Repository navigation
Conversation
KV cache at q4 and q8 on RDNA4 was getting read up to 8 times a pass, once per query head. This puts a full 32-value K block on one lane and checks all of those query heads in the same pass. On an R9700 (ROCm 10.1), Qwen3-30B-A3B q4_0 at 64k goes from 32.1 to 71.7 tok/s, and Qwen3.6-35B-A3B q8_0 at 128k goes from 36.1 to 66.2 tok/s. Full tables in the PR. FLASH_ATTN_EXT passes 4030/4030.
|
Thank you, these are good changes. However, I'm not sure this is the right way to go about it. The vector kernel suffers from massive register pressure and is very quickly outscaled by the tile kernel beyond 1 or 2 columns. So I would very much assume that rather than adding GQA support to the vector kernel you would get better performance by adding quantized KV cache support to the tile kernel. If you're up for it I would ask you to try implementing that first. There is this PR #30792 that kind of goes in that direction but I would preferably assign this to you instead if you're interested. |
|
Ok I will dig in. Your approach looks better. Parking this as a draft for now. |
|
Tile version is up in #31234 @JohannesGaessler |
|
closing this in favor of #31234 |
Working tree content carried over from the previous b12033-pr2 worktree, whose git objects did not survive the consolidation: upstream 785322d plus the hipCUB on HIP change and PRs ggml-org#30803, ggml-org#25940 and ggml-org#31234, plus the two rdna4 blocks that are also on rocm-gfx1201. Kept as a single commit so the carried changes are visible as one diff against rocm-gfx1201 rather than being mixed into that branch's history.
Overview
KV cache at q4 and q8 on RDNA4 was getting read up to 8 times a pass, once per query head. That meant quantized cache ran slower than f16 once the context got long.
This puts a full 32-value K block on one lane, loads it once, and checks the query heads that share that KV head in the same pass (2, 4, 6, or 8 heads). RDNA4 only, head size 128 and 256. f16 KV is unchanged, and other GPUs and head sizes stay on the old path.
R9700 (gfx1201), ROCm 10.1, 300 W. llama-bench, master vs this commit, -fa 1:
D = 256 (-n 64)
D = 128 (-n 128)
f16 KV is flat across these rows. test-backend-ops -o FLASH_ATTN_EXT on this GPU: 4030/4030.
Requirements