Skip to content

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

Merged
ggerganov merged 3 commits into
masterfrom
pascal/fattn-tile-576-gqa2
Nov 26, 2026
Merged

ggerganov merged 3 commits into
masterfrom
pascal/fattn-tile-576-gqa2

Conversation

@ServeurpersoCom

@ServeurpersoCom ServeurpersoCom commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Overview

Fixes the ROCm CI, red on master since #32960.

The flash attention tile kernel for DKQ 576 / DV 512 (the MLA shape) only has variants for GQA ratios that are multiples of 4, but the kernel selection accepts any ratio from 2. On GPUs that use the tile kernel for this shape, such as RDNA, a ratio of 2 hits GGML_ABORT in fattn-tile.cuh. The hy_v4_flash fixture of test-llama-context has such a ratio, so the test aborts on both ROCm runners.

The selection now only picks the tile kernel for 576 when the GQA ratio is a multiple of 4. Other ratios are reported unsupported and fall back like any unsupported op. No template is added, and the MMA path is unchanged.

Additional information

No released model uses these ratios: they are 16 to 128 for this shape (Hy4 flash itself has 32 and 64), so real models keep the same kernels on every backend.

test-backend-ops now covers 576/512 with GQA ratios 2 and 3. Tested with ROCm 7.13 on a Radeon AI PRO R9700 (gfx1201): ratios 2 and 3 are reported unsupported instead of aborting, the whole FLASH_ATTN_EXT set passes (4371 OK, 0 failures), and the hy_v4_flash fixture passes test-llama-context. On CUDA (RTX PRO 6000), both ratios still run through the MMA path.

Requirements

@ServeurpersoCom
ServeurpersoCom requested review from a team and ggerganov as code owners November 25, 2026 15:42
@github-actions github-actions Bot added testing Everything test related ggml changes relating to the ggml tensor library for machine learning CUDA Related to the CUDA backend labels Nov 25, 2026
@JohannesGaessler

Copy link
Copy Markdown
Contributor

If we don't have any models actually using that configuration, either return false in supports_op for the problematic cases or use the template specialization with ncols2 == 4 as a fallback after gqa_ratio % 8 != 0. We should not compile extra template specializations if if can be avoided.

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.
@ServeurpersoCom
ServeurpersoCom force-pushed the pascal/fattn-tile-576-gqa2 branch from 14a89da to 70ccc89 Compare November 25, 2026 19:32
…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.
…ed 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.
@ServeurpersoCom

Copy link
Copy Markdown
Contributor Author

If we don't have any models actually using that configuration, either return false in supports_op for the problematic cases or use the template specialization with ncols2 == 4 as a fallback after gqa_ratio % 8 != 0. We should not compile extra template specializations if if can be avoided.

Thanks. I tried the ncols2 == 4 fallback first, but on an R9700 it hits an illegal memory access for a ratio of 2: a tile block reads a single K/V head (head0 / gqa_ratio), and with 2 Q heads ne02 / ncols2 is 0. So I went with supports_op: the 2 column variant is gone, and the tile kernel is only picked for 576 when gqa_ratio is a multiple of 4. The other cases fall back like any unsupported op, and the MMA path is unchanged.

No model uses that configuration, Hy4 flash itself has ratios of 32 and 64, so nothing real changes path. The ratio of 2 comes from the hy_v4_flash fixture in test-llama-context, which has made the ROCm CI red on master since #32960, so this is now a ROCm CI fix. On the R9700, the whole FLASH_ATTN_EXT set passes (4371 OK, 0 failures) and so does that fixture.

@ServeurpersoCom ServeurpersoCom changed the title CUDA: flash attention tile kernel for DKQ 576 with a GQA ratio of 2 CUDA: fix ROCm CI, do not pick the tile FA kernel for DKQ 576 with a GQA ratio not divisible by 4 Nov 25, 2026
@ggerganov
ggerganov merged commit e38ea71 into master Nov 26, 2026
31 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CUDA Related to the CUDA backend ggml changes relating to the ggml tensor library for machine learning testing Everything test related

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants