Repository navigation
Conversation
D=512 VEC decode was added for HIP/RDNA4 (bef3727), dispatched only under GGML_USE_HIP in ggml_cuda_get_best_fattn_kernel. The kernel body and its instantiations were left unguarded, so plain CUDA builds still compiled them. For K=q8_0 with turbo{2,3,4} V, the scaled V_cols_per_iter (nthreads_V/8) at D=512 pushes the shared KQ buffer past 64KB, which ptxas rejects on Turing (sm_75) with 'uses too much shared data'. Since ggml_cuda_get_best_fattn_kernel never routes D=512 decode to this path outside HIP, the CUDA-side instantiation had no runtime benefit. Gate the kernel body in ggml_cuda_flash_attn_ext_vec_case_d512 (aborts on non-HIP builds, matching the unreachable path) and the dispatch call sites in ggml_cuda_flash_attn_ext_vec behind GGML_USE_HIP; keep the template declarations unconditional so the .cu instance files and the extern declarations don't need touching.
Owner
|
Thanks for this. #372 fixed the same break a day earlier and removes the D=512 instances from non-HIP builds entirely instead of keeping an aborting stub, so I merged that one and I'm closing this as a duplicate. For the record, since the comment here says 64 KB: ptxas reports a 0xc000 (48 KiB) static shared cap for both sm_75 and sm_89 with nvcc 13.0, and sm_121 accepts the 65,792-byte kernel, which is why a GB10 build never saw the error. Hosted CI builds sm_89 with nvcc 12.6, which also accepts it, so the break only shows up on CUDA 13 toolchains for pre-Blackwell cards. Your Vulkan PR (#373) is in review separately. |
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.
Summary
The D=512 VEC flash-attention decode path (added for HIP/RDNA4) is only ever dispatched under
GGML_USE_HIPinggml_cuda_get_best_fattn_kernel, but the kernel body and its instantiations were left unguarded, so plain CUDA builds still compiled them.For K=
q8_0combined with V=turbo2_0/turbo3_0/turbo4_0, the scaledV_cols_per_iter(nthreads_V / 8) atD=512pushes the sharedKQbuffer past 64KB.ptxasrejects this on Turing (sm_75) withuses too much shared data, which fails any plain-CUDA build that reaches these template instances, includingGGML_CUDA_ARCHITECTURES=75.Since
ggml_cuda_get_best_fattn_kernelnever routes D=512 decode to this path outside HIP, compiling it on CUDA has no runtime benefit, only a build-time cost.Fix
ggml_cuda_flash_attn_ext_vec_case_d512(fattn-vec.cuh) behindGGML_USE_HIP; on non-HIP builds it aborts, matching the fact that the dispatcher never reaches it there.ggml_cuda_flash_attn_ext_vec(fattn.cu) behind the sameGGML_USE_HIPguard.DECL_FATTN_VEC_CASE_D512and itsexternuses) are left unconditional, so none of the six per-type.cuinstance files undertemplate-instances/needed to change.