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>
jonathan308
added a commit
to Layr-Labs/d-inference
that referenced
this pull request
Oct 28, 2026
…ares Layr-Labs/mlx-swift-lm#368 was squash-merged as 2beb401f, so this branch's former SDK pin 76ff231b (#368's head) is not on SDK main. Every gitlink now points at a commit on its fork's main: - libs/mlx-swift-lm 76ff231b -> 2beb401f, the tip of SDK main and the #368 squash. Merging 76ff231b into the previous main (25bcd63f) gives exactly 2beb401f's tree, so #368 (demandedLatestCheckpointMinimumTokens) is unchanged. The pin also brings what SDK main gained since master's aee6ebb6: the tensor-parallel engine (#308), Qwen tensor batching (#352) and the optional stop-string scope (#369). - libs/mlx-swift 4926d3d9 -> c633d221, the revision 2beb401f's Package.swift declares; mlx-swift main (52c36f86) has the same tree. SDK main calls mlx-swift APIs that 4926d3d9 lacks (MLXArray.sharingArray, the fencedInputs argument of MLXFast.metalKernel). The nested mlx-c moves from 004c735f to 2ac897e3 with it. - libs/mlx 31f550af -> 72dffa2d, the nested copy that Cmlx compiles at c633d221 (Source/Cmlx/mlx); mlx main (f24d7e63) has the same tree. 72dffa2d keeps the 0.10.3 M5 NAX head-dim split JIT fix: 31f550af is not its ancestor, but that fix's squash on mlx main (6bc9de5b, Layr-Labs/mlx#48, identical patch ID) is, and its jit_kernels.cpp change is intact. #1645 pins the same mlx-swift and mlx commits. Provider follow-ups for the SDK's new enum cases, identical to #1645's (46f7ae9 and 2185dfe) so the two branches merge without conflicts: - MLXServerGenerationEvent.logprobs is token metadata. The GLM and JSON answer-format observers and seven test helpers treat it like .info. No SDK engine or provider bridge emits it today; the provider sends logprobs through EngineV2LogprobsChannel. - MLXOpenAIServiceError.responseFormatCutOffByMaxTokens, which the SDK split from invalidResponseFormatOutput for a structured answer cut off by max_tokens, keeps that case's 422 and retryable classification. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
11 of 16 tasks
Gajesh2007
pushed a commit
to Layr-Labs/d-inference
that referenced
this pull request
Oct 29, 2026
…prompt end (−16.5% follow-up TTFT) (#1643) * perf(provider): restore dense Qwen conversations from just below the prompt end A dense Qwen 3.5/3.8 request served alone prefills in 4,096-token stripes, so its deepest SSD checkpoint was the last full stripe end, up to 4,095 tokens before the prompt end. The next turn of the conversation re-prefilled that gap. With its paged complete store, the engine now sets the SDK's demandedLatestCheckpointMinimumTokens to the store floor. A request the store would write then also ends a prefill range at the deepest 256-aligned boundary at least 64 tokens below its prompt end, when that saves at least the floor. Busy providers, which prefill in 512-token chunks beside decoding requests, keep the ordinary geometry. Six-turn conversation from 30K to 55K tokens, Qwen3.5-9B, M3 Ultra, two runs per arm: the mean summed time to first token of the five follow-up turns fell from 57.38 s to 47.88 s (-16.5%), with outputs identical to master on every turn. SSD bytes rose 2.6% (2.71 GB to 2.78 GB) for the same 7 files. Requires mlx-swift-lm 05c7ca7e (feat/demanded-latest-checkpoint). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * chore(provider): pin mlx-swift-lm 76ff231b (docs for the end-of-prompt boundary) The SDK change adds demandedLatestCheckpointMinimumTokens to the retention doc and shortens its code comments. No code changes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Repin the SDK to the merged #368 (2beb401f) and the MLX stack it declares Layr-Labs/mlx-swift-lm#368 was squash-merged as 2beb401f, so this branch's former SDK pin 76ff231b (#368's head) is not on SDK main. Every gitlink now points at a commit on its fork's main: - libs/mlx-swift-lm 76ff231b -> 2beb401f, the tip of SDK main and the #368 squash. Merging 76ff231b into the previous main (25bcd63f) gives exactly 2beb401f's tree, so #368 (demandedLatestCheckpointMinimumTokens) is unchanged. The pin also brings what SDK main gained since master's aee6ebb6: the tensor-parallel engine (#308), Qwen tensor batching (#352) and the optional stop-string scope (#369). - libs/mlx-swift 4926d3d9 -> c633d221, the revision 2beb401f's Package.swift declares; mlx-swift main (52c36f86) has the same tree. SDK main calls mlx-swift APIs that 4926d3d9 lacks (MLXArray.sharingArray, the fencedInputs argument of MLXFast.metalKernel). The nested mlx-c moves from 004c735f to 2ac897e3 with it. - libs/mlx 31f550af -> 72dffa2d, the nested copy that Cmlx compiles at c633d221 (Source/Cmlx/mlx); mlx main (f24d7e63) has the same tree. 72dffa2d keeps the 0.10.3 M5 NAX head-dim split JIT fix: 31f550af is not its ancestor, but that fix's squash on mlx main (6bc9de5b, Layr-Labs/mlx#48, identical patch ID) is, and its jit_kernels.cpp change is intact. #1645 pins the same mlx-swift and mlx commits. Provider follow-ups for the SDK's new enum cases, identical to #1645's (46f7ae9 and 2185dfe) so the two branches merge without conflicts: - MLXServerGenerationEvent.logprobs is token metadata. The GLM and JSON answer-format observers and seven test helpers treat it like .info. No SDK engine or provider bridge emits it today; the provider sends logprobs through EngineV2LogprobsChannel. - MLXOpenAIServiceError.responseFormatCutOffByMaxTokens, which the SDK split from invalidResponseFormatOutput for a structured answer cut off by max_tokens, keeps that case's 422 and retryable classification. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: jonathan308 <5055076+jonathan308@users.noreply.github.com> 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.