diff --git a/ggml/src/ggml-cuda/fattn-mma-f16.cuh b/ggml/src/ggml-cuda/fattn-mma-f16.cuh index 7aaf89da0c52..e9dd9fd3e93d 100644 --- a/ggml/src/ggml-cuda/fattn-mma-f16.cuh +++ b/ggml/src/ggml-cuda/fattn-mma-f16.cuh @@ -276,8 +276,10 @@ static constexpr __host__ __device__ fattn_mma_config ggml_cuda_fattn_mma_get_co // RDNA3 WMMA operands are mirrored, so keeping Q in registers for head size 256 spills heavily. // Stream Q from shared memory and use a smaller KV batch to reduce register pressure. K and V are loaded in one // batch each: with several batches some compilers move the WMMAs of a batch past the loads of the next one and spill. - // Only for 2-4 Q heads per KV head: with 8 this config is not faster than the default one. - if (ncols2 >= 2 && ncols2 <= 4) { + // Also used for 8 Q heads per KV head (Qwen3.6/Qwen4 full attention, 16 Q / 2 KV heads): the default config spills there + // (flash_attn_ext_f16<256,256,*,8>: 256 VGPR + 1196 B scratch, 529 spilled VGPRs). With this config the spill is gone + // (207 VGPR, no scratch); measured on a D256 GQA8 kernel 11437 -> 8559 us, pp512@d32768 +10.2% on Qwen3.6. + if (ncols2 >= 2 && ncols2 <= 8) { GGML_CUDA_FATTN_MMA_CONFIG_CASE(256, 256, 64, 256, 2, 32, 128, 128, 64, 1, false); }