Repository navigation
Fix the JIT instantiation of the NAX head-dim split attention kernel - #48
Merged
Merged
Conversation
get_steel_attention_nax_kernel passed bv to both attention_nax and attention_nax_dsplit. attention_nax gained a BV parameter in the upstream merge (#38); attention_nax_dsplit has none (its value head dim is BD). With bv in the list, every later argument shifts by one, an integer lands in the MaskType slot, and the library fails to compile: explicit instantiation of 'attention_nax_dsplit' does not refer to a function template ... JIT builds (mlx-swift) compile this kernel at runtime for full attention with head dim 256 or 512 and at least 1,024 query tokens on NAX GPUs, so the compile error surfaced as "Unable to build metal library from source" and the caller's process exited. Builds that use the precompiled metallib were unaffected, because steel_attention_nax.metal instantiates the split kernel without bv. Pass the split kernel the same arguments as its metallib instantiation. The non-split kernel is unchanged.
Gajesh2007
approved these changes
Oct 26, 2026
jonathan308
added a commit
that referenced
this pull request
Oct 27, 2026
…nto the JACCL guard branch Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
jonathan308
added a commit
that referenced
this pull request
Oct 27, 2026
…ce-ordering branch Main's head-dim split NAX attention JIT fix (#48) and this branch's ce21a37 fix the same bug; get_steel_attention_nax_kernel now reads exactly as main's (main's comment and argument list), so the branch no longer differs from main there. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
jonathan308
added a commit
that referenced
this pull request
Oct 27, 2026
main's #48 changed mlx/backend/metal/jit_kernels.cpp without a fork.yaml section, so the fork.yaml gate failed on main and on every PR based on it. The new section explains the change: the JIT source passes attention_nax_dsplit the same template arguments as its metallib instantiation. Co-Authored-By: Claude Opus 5.5 <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.
Summary
get_steel_attention_nax_kernelpassedbvto bothattention_naxandattention_nax_dsplit.attention_naxgained aBVtemplate parameter in the upstream merge (#38);attention_nax_dsplithas none (its value head dim isBD). Withbvin the list, every later argument shifts by one, an integer lands in theMaskTypeslot, and the runtime compile always fails:JIT builds (mlx-swift, and so Darkbloom provider 0.10.2) compile this kernel at runtime on NAX GPUs (M5) for full attention with head dim 256 or 512 and at least 1,024 query tokens. The error trapped the process, and provider 0.10.2 crashed on M5 Macs serving Gemma 4 and Qwen 3.5/3.6/3.8. Builds that use the precompiled metallib were unaffected, because
steel_attention_nax.metalinstantiates the split kernel withoutbv.The fix passes the split kernel the same arguments as its metallib instantiation. The non-split kernel is unchanged.
Before and after
flowchart LR subgraph Before A1["get_steel_attention_nax_kernel(split_d)"] --> B1["attention_nax_dsplit<T, bq, bk, bd, bv, wm, wn, mask>"] --> C1["compile error -> throw -> process trap"] end subgraph After A2["get_steel_attention_nax_kernel(split_d)"] --> B2["attention_nax_dsplit<T, bq, bk, bd, wm, wn, mask>"] --> C2["library + pipeline built"] endValidation
metal::utils()+metal::steel_attention_nax()+ template definition, language 4.1), on an M3 Ultra and an M5 Ultra: the shipped dsplit instantiations for head dim 256 and 512 fail with the error above; the fixed ones compile, and on the M5 their pipelines build (256 threads, 16 KB threadgroup memory).eedca444, realMLXFast.scaledDotProductAttention, bf16, against a float32 reference):Trace/BPT trap: 5with the error above on the first head-dim-256 call;jit_kernels.cpp; mlx-swift and d-inference CI do.Pinned for the provider hotfix from branch
hotfix/0.10.2-jit-nax-dsplit(31f550af, onff4bb35b); this PR brings the same commit tomain.