Repository navigation
CUDA: refactor & deduplicate FA data loading - #32901
Conversation
|
HIP quality check was failing. This seems to in part be due to changed kernel names. But also the tile kernel started spilling for CDNA for |
|
Could you measure the vgpr use for the other specializations? if pressure increased generally this bodes poorly for future optimizations. |
|
Sorry, I'm not familiar with how to do this. Do we have tooling for this? |
IMbackK
left a comment
There was a problem hiding this comment.
there is -DGGML_HIP_EXPORT_METRICS=1 also rocprofv3 will tell you in its output.
anyhow i dont think its worth delaying over this.
|
btw ci will detect this kind of thing soon: #32365 (occupancy drops) |
pwilkin
left a comment
There was a problem hiding this comment.
Let's do it so we can merge the Inkling 2 changes.
…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.
…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.
…d-tile refactor: a new file, fattn-fused-load.cuh, now holds the fused load tags and the flash_attn_load_tile_impl specializations, merging the branch's dequant definitions into upstream's new loader definitions. Assisted-by: OpenCode
This PR refactors and deduplicates the CUDA FlashAttention code for loading data. The purpose is to provide a clean and extensible interface for further work by other contributors. In summary this PR:
fattn-mma-f16.cuhandfattn-tile.cuhtofattn-common.cuh. The mma and tile kernels now use the same code where applicable.half2 *rather thanchar *.Performance
Table generated with
scripts/compare-llama-bench.pyPerformance improves on average though some cases also got a few % slower. There are multiple effects causing the changes. One is a reduction in GPU anti-patterns such as
char *with a later cast though this is only a few %. Another one is that this PR includes a fix to a performance regression introduced with #29510 . I coordinated with @am17an off-site and we agreed that I would be rolling a fix into this PR; I followed his suggestion and am essentially for now disabling support forKV_rows_ptron the problematic GPUs (NVIDIA older than Turing + AMD).Requirements