Repository navigation
Nax Refactor - #3271
Merged
Merged
Nax Refactor#3271
Conversation
Member
Author
|
No major performance implications with this PR Attention numbers for example After: |
angeloskath
approved these changes
Mar 18, 2026
angeloskath
left a comment
Member
There was a problem hiding this comment.
Awesome!
I may be reading too much the tea leaves but it looks like there is a small but consistent improvement for unfused and a tiny but fairly consistent regression for fused 🤷♂️
1 task done
3 of 4 tasks
rabbitson87
added a commit
to rabbitson87/mlx
that referenced
this pull request
Oct 3, 2026
…plore#3271) Both steel attention kernels applied the causal mask only to the last ceil(BQ/BK) K blocks (plus one when K was unaligned). When the query offset (kL - qL) is not a multiple of BK while kL is, the diagonal starts one block earlier, and rows saw up to BK - 1 future keys. Upstream fixed this in ml-explore/mlx ml-explore#3271 ("Nax Refactor") by masking from the block holding the tile's first row (`kb_min_causal = q_min / BK`); this ports that rule to both kernels here. Found by lumen-rs's load-time check of the windowed kernel, which exercises causal + window together: 60 queries over 2,000 keys gave max abs diff 0.046 against explicit-mask attention. Checked on random Q/K/V: causal-only at head_dim 128 (60 over 2,000 keys was 0.028 off, now bit-identical to the explicit mask) and windowed at head_dim 256 (now within one bf16 step at every shape). The NAX variant compiles; it was not run (no NAX device here).
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.
Proposed changes
Checklist
Put an
xin the boxes that apply.pre-commit run --all-filesto format my code / installed pre-commit prior to committing changes