CUDA: add GGML_OP_LIGHTNING_INDEXER kernel (F16/F32 K)#25632
Closed
Dorijan10 wants to merge 1 commit into
Closed
Conversation
Implements the CUDA backend for the lightning indexer op (added in ggml-org#24231, CPU-only). Naive one-thread-per-KV kernel; validated against the CPU reference via test-backend-ops at all tested shapes on sm_120 (RTX 5090). Supports F16/F32 K; quantized K to follow.
|
Hi @Dorijan10, thanks for your contribution! Per our contribution guidelines, the automated PR checker found the following issue(s) that need your attention:
Please note that maintainers reserve the right to make final decisions on PRs. If you believe there is a mistake, please comment below. |
|
You know that #25545 exists, right? |
Author
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.
What
Adds the CUDA backend for
GGML_OP_LIGHTNING_INDEXER, introduced in #24231with a CPU implementation only. On GPU-resident DeepSeek-V3.2 / GLM-5.2 models
the fused lightning-indexer path currently has no CUDA kernel.
Implementation
Naive one-thread-per-KV-position kernel: each thread computes
sum_h relu(dot(q_h, k)) * w_h + maskover the indexer heads, matching theCPU reference in
ggml_compute_forward_lightning_indexer. Supports F16 andF32 K; quantized K (Q8_0 etc.) to follow in a subsequent change.
Validation
Passes the existing
test-backend-opsLIGHTNING_INDEXERcase at the test's1e-6 NMSE tolerance across all tested shapes (varying heads, KV, batch,
streams, mask broadcast), on an RTX 5090 (sm_120):
Quantized K types report
not supportedviasupports_opand are skipped.Notes
This is a correctness-first implementation; optimization (shared-memory
q/w staging, coalesced K reads) can follow. Happy to iterate.