Conversation
…ber functions) Metal 4.1 (Xcode 27, metalfe-32023) makes the implicit address space of `this` in member functions `__metal_generic` instead of `thread`. Returning `thread T&` to a member then no longer compiles, which broke 17 of 40 kernels, including every quantized matmul (quantized, quantized_nax, fp_quantized*) and all steel GEMM/attention kernels. - Backport ml-explore/mlx#3963 (ef5fc0fab2) to the vendored mlx 0.30.6. Hunks for code that has since diverged upstream (sort.h LessThan, the newer NAXFrag-based nax.h, the Conv3D loaders) do not apply and are not needed here. - Apply the same rule to the older NAXSubTile/NAXTile structs in steel/gemm/nax.h and steel/attn/nax.h (32 signatures each), which #3963 does not cover because upstream rewrote them. - Regenerate mlx-generated/ (JIT sources and metal/ headers) from the patched kernels. Only the patched-vs-unpatched delta is applied, so existing hand edits in mlx-generated/ are kept. All 39 kernels in the metallib build list compile with Metal 32023.921. The change is a no-op on older toolchains (the qualifier was already the implicit default there). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
3 tasks
solderzzc
marked this pull request as ready for review
September 24, 2026 03:22
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.
Problem
Xcode 27 ships Metal 4.1 (metalfe-32023.921). In Metal 4.1,
thisinside a member function no longer defaults to thethreadaddress space; it now defaults to__metal_generic. As a result, a member function that returnsthread T&to one of its members fails to compile:17 of the 40 kernels fail. That includes every quantized matmul kernel (
quantized,quantized_nax,fp_quantized*) and all steel GEMM and attention kernels../build.shin SwiftLM stops atmlx-metallib, so nothing can be built with Xcode 27. Found while setting up an M6 Mac mini on macOS 27.0.Fix
ef5fc0fab2), the upstream fix for this exact issue, into the vendored mlx 0.30.6. Some of its hunks don't apply because upstream has since rewritten that code (sort.hLessThan, the NAXFrag-basednax.h, the Conv3D loaders). Those hunks aren't needed here.NAXSubTile/NAXTilestructs insteel/gemm/nax.handsteel/attn/nax.h: add an explicitthreadqualifier to each member function signature (32 per file). #3963 doesn't cover these because upstream replaced them.mlx-generated/. Both the JIT.cppsources and themetal/header copies are regenerated from the patched kernels. I ran the generator twice, on unpatched and on patched sources, and applied only the difference between the two runs. The existing hand edits inmlx-generated/(thecompiled_preamblebool fix,conv.cpp, and the hand-writtensteel_conv_3d.cppstub) are left as they were.On older toolchains this changes nothing, because
threadwas already the implicit default forthis.Verification
steel_conv_3dstill fails on its own, but it isn't in the build list and it failed before this change too../build.shcompletes: a 128 MBmlx.metallib, and the Swift 6.4 build succeeds.mlx-community/Qwen3.8-27B-4bit(it runs the quantized, GEMM, attention and NAX kernels). Results: correct answers on a short factual question and on arithmetic, and a planted code word retrieved correctly from a 7.9K-token prompt; decode 9.0 tok/s; no Metal errors.🤖 Generated with Claude Code