CUDA: fix ROCm CI, do not pick the tile FA kernel for DKQ 576 with a GQA ratio not divisible by 4 (#33045)

* CUDA: flash attention tile kernel for DKQ 576 with a GQA ratio of 2

The tile kernel for 576/512 only had variants for GQA ratios that are
multiples of 4, while the kernel selection accepts any ratio from 2,
so an MLA attention with a ratio of 2 aborted on GPUs that use the
tile kernel, such as RDNA. Add the 2 column configuration, copied from
the 512/512 one of each table, and dispatch even ratios to it. Odd
ratios have no tile variant: the selection now reports them as
unsupported instead of picking the tile kernel. Cover the ratios 2
and 3 in test-backend-ops.

* CUDA: pass the K/V types to the tile kernel for 576 with a GQA ratio of 2

#32901 added the K and V types as template parameters of the tile kernel,
the ratio 2 dispatch for DKQ 576 still used the old parameter list.

* CUDA: report DKQ 576 with a GQA ratio not divisible by 4 as unsupported by the tile kernel

Use the selection instead of a new tile specialization, as suggested in
review: drop the 2 column variant and only pick the tile kernel for
576/512 when the GQA ratio is a multiple of 4, the ncols2 = 4 and 16
variants it has. The ncols2 = 4 variant cannot serve a ratio of 2, a
block reads a single K/V head.
This commit is contained in:
Pascal 2026-11-26 10:25:33 +01:00 • committed by GitHub
parent 074f1f3f73
commit e38ea719bd
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 7 additions and 3 deletions

View file

@ -749,12 +749,15 @@ static best_fattn_kernel ggml_cuda_get_best_fattn_kernel(const int device, const
gqa_ratio_eff *= 2;
}
// the tile kernel for DKQ=576 only has the ncols2 = 4 and 16 variants
const best_fattn_kernel tile_kernel = Q->ne[0] == 576 && gqa_ratio % 4 != 0 ? BEST_FATTN_KERNEL_NONE : BEST_FATTN_KERNEL_TILE;
if (volta_mma_available(cc) && Q->ne[0] != 40 && Q->ne[0] != 72) {
if (can_use_vector_kernel && Q->ne[1] * gqa_ratio_eff <= 2) {
return BEST_FATTN_KERNEL_VEC;
}
if (Q->ne[1] * gqa_ratio_eff <= 16) {
return BEST_FATTN_KERNEL_TILE; // On Volta tensor cores are only faster for sufficiently large matrices.
return tile_kernel; // On Volta tensor cores are only faster for sufficiently large matrices.
}
return BEST_FATTN_KERNEL_MMA_F16;
}
@ -800,7 +803,7 @@ static best_fattn_kernel ggml_cuda_get_best_fattn_kernel(const int device, const
}
}
}
return BEST_FATTN_KERNEL_TILE;
return tile_kernel;
}
size_t ggml_cuda_flash_attn_ext_get_alloc_size(int device, const ggml_tensor * dst) {

View file

@ -14336,7 +14336,8 @@ static std::vector<std::unique_ptr<test_case>> make_test_cases_eval() {
if (nh == 1 && hsk != 320 && hsk != 576) continue;
for (int nr3 : { 1, 3, }) {
if (hsk > 64 && nr3 > 1) continue; // skip broadcast for large head sizes
for (int nr2 : { 1, 4, 8, 12, 16, 20, 32 }) {
for (int nr2 : { 1, 2, 3, 4, 8, 12, 16, 20, 32 }) {
if ((nr2 == 2 || nr2 == 3) && hsk != 576) continue; // MLA with a GQA ratio below 4
if (nr2 == 8 && hsk != 192) continue;
if (nr2 == 12 && hsk != 128) continue;
if (nr2 == 16 && hsk != 192) continue;