Repository navigation
fix(metal): the 27B's prompt attention and tf_lane_reg compile on macOS 27 - #573
Conversation
…OS 27 On macOS 27 (Metal 4.1) decltype of a cooperative-tensor local keeps its thread address space, and matmul2d's get_destination_cooperative_tensor rejects that type, so the qwen27 engine refused to load (LibraryLoad): first q27_mma_s/q27_mma_o in attention_prompt.metal, then tf_lane_reg on the first projection. Strip the address space, as nax.h already does.
|
Thank you, @jkuepker. This is in main as 67b80aa, your commit merged as it was, and it fixes #579. We checked it with macOS 27.0.1's own Metal compiler. Compiling the exact sources the 27B builds at startup, with the engine's options, main's prompt attention fails at lines 535 and 549 and the lane projection's register kernel at line 243, the errors in #579, and your versions compile. At Metal 4.0, the version macOS 26 compiles with, both versions compile. We also looked for any other call that passes a cooperative tensor's own type to |
… and ashhart#576's line in the file's style
… and ashhart#576's line in the file's style
On macOS 27 the 27B engine (
qwen27) cannot load. Two of its Metal kernels fail to compile at startup, and the load stops withLibraryLoad:Under Metal 4.1,
decltypeof a cooperative-tensor local keeps itsthreadaddress space, andmatmul2d::get_destination_cooperative_tensorrejects that type. Three call sites pass such a type:q27_mma_sandq27_mma_oinzig/kernels/metal/qwen27/attention_prompt.metal. These fail first.tf_lane_reginzig/kernels/metal/core/lane_projection.metal. This fails next, at the first projection, once attention compiles.The fix wraps those template arguments in
metal::remove_addrspace_t, asnax.halready does. It changes template arguments only. There is no arithmetic, layout or dispatch change.Receipt
Setup: M5 Max, macOS 27.0 (26A428), Xcode 27.0 (27A266a), Metal 32023.921, Zig 0.17.0, Qwen3.8-27B MLX 4-bit, 2,048-token prompt. Both columns were built the same way (
-Dcpu=apple_m1); "before" is this branch with main's two kernel files restored.0d83398bbc93801dtf-core-lane-reg-checkLibraryLoad(tf_lane_reg, line 243)REG CHECK PASS cases=352tf-qwen27-syntheticLibraryLoadtf-qwen27-run --max-tokens 32 --compare-chunk 16LibraryLoad(attention, lines 535/549)prompt_state_byte_equal: true,prompt_sha256 c89730be…TF_ANE_COLUMNS=0prompt_state_byte_equal: true,prompt_sha256 1ae7ce8f…Host gates on the branch:
zig build native -Dcpu=apple_m1 -Dversion=1.0.0: builds.zig build test test-golden -Dcpu=apple_m1: exit 0. The golden corpus reports 309/319 equal and 0 unexpected differences; the other 10 are known differences.python3 tools/zig/lean_check.py: 509 problems on main and 509 on the branch, so the fix adds none. All 509 are inherited and none is in the two files touched.I could not test macOS 26 here.
nax.halready usesremove_addrspace_tthe same way and ships today, so the wrapped form should still compile there.