Repository navigation
[CUDA] faster window attention - #4927
Merged
Merged
Conversation
Contributor
Author
|
BTW here is the same table with B200
|
zcbenz
marked this pull request as ready for review
November 22, 2026 08:11
Open
2 of 4 tasks
rcfa
pushed a commit
to cubiculum-ai/mlx
that referenced
this pull request
Nov 26, 2026
osaurus-ai/mlx takes only the part of this commit that is independent of the window size: the VJP fallback (gradients of the mask or the sinks, and the fallback's primals) and the gradient test, without windows. The window size needs ml-explore#4734, which osaurus-ai/mlx does not take. Ported: Apple's commit adds `|| other_grads` to an `if (outputs.size() != 2)` that came upstream with ml-explore/mlx PR 4565, which the fork does not have. So this commit also adds that check: without the logsumexp output, the VJP takes the fallback. The fused Metal backward needs that output. (cherry picked from commit 58d91ee)
This was referenced Nov 26, 2026
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.
This allows for faster and more memory efficient window attention in cuda, forward and backward.
Window attention now goes through the CUDA kernels instead of defaulting back to unfused fallback which uses full attention.
headline numbers
Results table (claude produced it)
Measured on one h100, bf16, 16 Q heads, 8 KV heads, dim 128; causal and window attention
Time in ms, peak in GB