Repository navigation
[w2] fattn-mma: spill-free RDNA3 D256 config for ncols2 up to 8 (Qwen4 GQA8) - #163
Merged
Merged
Conversation
…on RDNA3 flash_attn_ext_f16<256,256,8,8> (D256, GQA8, full 64-column tile) spilled with the default RDNA config: 256 VGPR, 932 B scratch (1344 B for the sparse variant). Widening the existing streaming-Q config condition from ncols2 2..4 to 2..8 gives 206 VGPR and no scratch. Prototype measurement (variant A): D256 GQA8 kernel 11437 -> 8559 us, pp512@d32768 +10.2% on Qwen3.6 (same shape as Qwen4 full attention: 16 Q / 2 KV heads). Assisted-by: Claude Sonnet 5.5
Owner
Author
|
Reverted from master on 2026-12-04 (w2 build crashed Qwen4-single at >20k ctx; no measured gain). Commit preserved on branch archive/w2-25f0def; will be re-landed individually after GPU validation. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
One-line widening in
ggml_cuda_fattn_mma_get_config_rdna3(ggml/src/ggml-cuda/fattn-mma-f16.cuh): the streaming-Q D256 configCONFIG(256,256,64,256,2,32,128,128,64,1,false)now applies forncols2 2..8instead of2..4. The stale comment ("with 8 this config is not faster") is replaced with the measured numbers. D512, Gemma and all other rows are untouched. The D128ncols2==1line of survey variant A is intentionally NOT ported (seeinkling-kld-config).Why
flash_attn_ext_f16<256,256,*,8>spilled on RDNA3 with the default config. Qwen4 full-attention layers are exactly D256 GQA8 (16 Q / 2 KV heads), the case Qwen3.6 used to cover.Spill check (CPU, HIP gfx1100 device asm of the four
fattn-mma-f16-instance-f16-f16-ncols1_{1,2,4,8}-ncols2_8.cu, master 928d721 vs this branch)Flags:
flash_attn_ext_f16<256,256,ncols1,8,softcap,V_is_K_view,sparse,...>; fields vgpr / sgpr / private_segment (B) / group_segment (B) / vgpr_spill.__LINE__-derived constant in a trap/assert path (0x812 vs 0x814) caused by the comment growing by 2 lines.ncols12 and 4 with ncols2 8 (ncols 16/32, i.e. decode-ish batches such as MTP verify) still spill (808/868 B) because the streaming config exists only for the 64-column tile. Not changed here (the task says leave other rows untouched); a possible follow-up is a 16/32-column streaming config for D256 ncols2 8.fattn.cu.obuilds on the branch (host-side config queries OK); no new warnings.Sparse 8x8 note (qwen4-qsa-sparse-fa)
The config lookup depends only on (DKQ, DV, ncols=ncols1*ncols2, ncols2), not on
use_sparse. The sparse 8x8 D256 kernel therefore uses this same (256,256,64,ncols2=8) config, and its spill also drops (1344 B scratch / 548 spilled VGPRs -> 32 B / 0 VGPR spill). No code change needed for that PR.Expected gain (ESTIMATE from prototype variant A, not yet measured on this tree)
D256 GQA8 FA kernel 11437 -> 8559 us (-25%); pp512 at d=32768 +10.2% on Qwen3.6 (same shape). Qwen4 prompt at depth expected similar while dense FA is used. Short context was neutral in the prototype.
Env switch
None: compile-time config table. Isolated tonight by B0 vs BA with ALL_OFF (or the optional spill-only build BS).
Files
ggml/src/ggml-cuda/fattn-mma-f16.cuhRisks
Rules followed: no GPU used, no production/homelab changes, nothing touched in ggml-org/llama.cpp, build only under the build lock (nice 19, -j6) and build trees deleted.
GPU validation tonight (NOT YET RUN)
Assisted-by: Claude Sonnet 5.5