Revamp CUDA extension based on new cuDNN wrappers#738
Draft
maleadt wants to merge 10 commits into
Draft
Conversation
Introduce `scaled_dot_product_attention` and `scaled_dot_product_attention_scores` taking inputs shaped `(head_dim, nheads, seq_len, batch...)`, PyTorch-style, with the number of heads inferred from the tensor shape rather than a `nheads` keyword. - `scaled_dot_product_attention` returns only the attention output; the scores are available separately via `scaled_dot_product_attention_scores`. - Grouped-query attention (GQA): key/value may have fewer heads than the query. - New `scale` and `is_causal` keywords; `make_causal_mask` now defaults to `dims=3`. - Deprecate the old packed-head `dot_product_attention` / `dot_product_attention_scores`, forwarding through the new implementation. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.
JuliaGPU/CUDA.jl#3191 modernizes CUDA.jl's cuDNN wrappers, deprecating the old imperative interface, instead adding one based on the new back-end API, with a higher-level interface on top. This PR builds off of #719 and reworks the extension here to be built on top of that new API.
Since I'm not actually a user of these interfaces, I'd appreciate if people would take a look and suggest any changes to make to the cuDNN wrappers to facilitate use here (I already had LLMs do as much as possible, taking into account what NNlib.jl and LuxLib.jl require, and how NVIDIA's high-level wrappers are implemented).
cc @CarloLucibello