cuda : CUDA GGML_OP_LIGHTNING_INDEXER implementation (generic vector kernel + wmma kernel)#25545
Conversation
…kernel + wmma kernel)
including: - ggml-org/master at `4f37f51` - ggml-org#24231 at `428831b` - ggml-org#25545 at `50c49c83`
JohannesGaessler
left a comment
There was a problem hiding this comment.
From a cursory look at the code I get the impression that it would benefit from the use of the primitives in mma.cuh. The interface in nvcuda::wmma does not have a defined memory layout in registers so any non-scalar operations need to go through shared memory. To be clear: from my side this is advice regarding the implementation, not a requirement for a review/merge.
|
Tested PR #25545 at e624d0f on an RTX 5070 under Windows 11. Environment:
Correctness: Both kernel paths were covered on sm_120: the nh=64 cases with F16/quantized K types used the WMMA kernel, while the remaining cases used the vector kernel. I also observed approximately 14.5–15.0 TFLOPS for the larger nh=64 q4_0 test cases: |
@JohannesGaessler I'm aware of that, but I haven't gotten that far down the CUDA matrix multiplication rabbit hole yet. Leaving that as something for the future. |
am17an
left a comment
There was a problem hiding this comment.
I agree with @JohannesGaessler that mma would be much faster but this that can addressed in a later PR.
|
To clarify my position: the only thing that I consider a hard requirement for my approval is a check of the compilation time since that can potentially lead to a stall. Other than that I would consider my comments to only be suggestions. |
@JohannesGaessler On my machine (Epyc 9374F): |
…n lightning indexer kernels to avoid duplication of constants.
…exer implementation
In case anyone wants to use it in the meantime it's currently broken. Good job indeed, me. Edit: should be OK now |
|
Just wanted to share that that this PR works on Mi50 using ROCm and P40 CUDA. Model is fully in VRAM. Pulled and compiled just before the merge |
…kernel + wmma kernel) (ggml-org#25545) * cuda : CUDA GGML_OP_LIGHTNING_INDEXER implementation (generic vector kernel + wmma kernel) * chore : remove indentation of #pragma unroll * cuda : remove unnecessary kernel template declarations * cuda : add WARPS_PER_BLOCK and K_VECS_PER_BLOCK template parameters in lightning indexer kernels to avoid duplication of constants. * cuda : relax MMA architecture requirements to Turing in lightning indexer implementation * chore : renamed variables * chore : rename ggml_cuda_op_lightning_indexer() to ggml_cuda_lightning_indexer() * chore : TODO for AMD rocWMMA * chore : whitespace formatting * chore : another variable rename to fix problems caused by shadowing * chore : yet another rename, this time uppercased all constants * cuda : added alignment checks for Q and K tensors in lightning indexer implementation --------- Co-authored-by: Stanisław Szymczyk <sszymczy@gmail.com>
Overview
This PR adds CUDA implementation of
GGML_OP_LIGHTNING_INDEXER. It contains two kernels: generic portable vector kernel and second faster optimized kernel using WMMA.Requires #24231 (Edit: already merged) to work.
Additional information
I originally wrote this months ago for #21149, now only updated it to match the CPU implementation (scales removed, added mask).
Requirements