Repository navigation
fix(kernel): strip the address space from the pair-code table field - #5
Merged
Merged
Conversation
From Metal 4.1 (macOS 27), decltype(pairs) keeps the variable's own thread address space, and a struct field may not carry one, so the pair-code gather qmv and down-combine kernels failed to build. Metal 3.1 to 4.0 are unaffected.
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.
On macOS 27, any checkpoint with pair-coded experts (e.g. Ornith-1.5-35B-A3B-4bit) fails at startup:
MLX compiles these kernels at runtime at the newest Metal language version the OS supports, which is 4.1 on macOS 27. From 4.1,
decltype(pairs)keeps the variable's ownthreadaddress space, and a struct field may not carry one.PairCodeScalesnow strips it withmetal::remove_addrspace_t, which keeps the pointee'sdevice/constantspace, so bothdecltype(pairs)call sites (gather qmv, down-combine) are fixed unchanged.A standalone repro of the pattern, compiled with
MTLCompileOptions.languageVersionon macOS 27:Holder<decltype(pairs)>(main)remove_addrspace_tfield (this PR)Tested on M4 (24 GB), macOS 27.2.1:
uv run pytest tests/kernel/moe/affine/test_affine_{gather_qmv_pair_codes,down_combine,glu_pending}.py: 65 failed / 54 passed on main, 119 passed hereuv run pytest tests/: 1923 passed, 5 skipped (FTMETAL_TEST_MODEL_PATH unset)uv run ftm serve --model <ckpt> --port 18997for Ornith-1.5-35B-A3B-4bit, Qwen3.6-35B-A3B-4bit and Flint-40B-A2.5B-int4: each starts and answers "What is 17 * 23?" with 391; Ornith on main exits at CommandGraph captureNot run on a macOS 15 machine: the 3.1/3.2 results use macOS 27's own Metal headers.