Skip to content

Commit 60fa2af

Browse files
committed
Stub NAX JIT source providers when gated out
CI JIT=1 on macos-14 got past cmake configure but hit a linker error: symbol not found in flat namespace '__ZN3mlx4core5metal13quantized_naxEv' jit_kernels.cpp references mlx::core::metal::{gemm_nax, quantized_nax, fp_quantized_nax, steel_gemm_fused_nax, …} as strong external symbols. Those symbols are normally supplied by the auto-generated jit/<name>.cpp files that make_jit_source() creates; when we gate those out for old SDKs, nothing provides them and the NIF fails to link. Extend the patch to emit an nax_stubs.cpp with empty-string returns under the gated-out branch. The stubs are never exercised because is_nax_available() returns false when MLX_METAL_NO_NAX is defined.
1 parent bd3566d commit 60fa2af

1 file changed

Lines changed: 19 additions & 2 deletions

File tree

patches/mlx-jit-nax-gate.patch

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
diff --git a/mlx/backend/metal/CMakeLists.txt b/mlx/backend/metal/CMakeLists.txt
2-
index 67c69579..5dfa56c1 100644
2+
index 67c69579..a3d575ed 100644
33
--- a/mlx/backend/metal/CMakeLists.txt
44
+++ b/mlx/backend/metal/CMakeLists.txt
5-
@@ -83,18 +83,26 @@ if(MLX_METAL_JIT)
5+
@@ -83,18 +83,43 @@ if(MLX_METAL_JIT)
66

77
make_jit_source(steel/attn/kernels/steel_attention)
88

@@ -15,6 +15,10 @@ index 67c69579..5dfa56c1 100644
1515
+ # NAX JIT sources #include <MetalPerformancePrimitives/...>, which only
1616
+ # exists in the macOS 26.2+ SDK. Mirror the AOT gate from
1717
+ # kernels/CMakeLists.txt so older SDKs can still build with JIT on.
18+
+ # When gated out we supply empty stubs for the NAX JIT source
19+
+ # providers so jit_kernels.cpp still links; is_nax_available()
20+
+ # returns false at runtime under MLX_METAL_NO_NAX so the stubs are
21+
+ # never exercised.
1822
+ if((MLX_METAL_VERSION GREATER_EQUAL 400) AND (MACOS_SDK_VERSION GREATER_EQUAL
1923
+ 26.2))
2024
+ make_jit_source(
@@ -35,6 +39,19 @@ index 67c69579..5dfa56c1 100644
3539
+ make_jit_source(steel/attn/kernels/steel_attention_nax)
3640
+ else()
3741
+ target_compile_definitions(mlx PRIVATE MLX_METAL_NO_NAX)
42+
+ set(_nax_stub_cpp "${CMAKE_CURRENT_BINARY_DIR}/jit/nax_stubs.cpp")
43+
+ file(
44+
+ WRITE "${_nax_stub_cpp}"
45+
+ "namespace mlx::core::metal {\n"
46+
+ "const char* gemm_nax() { return \"\"; }\n"
47+
+ "const char* steel_gemm_fused_nax() { return \"\"; }\n"
48+
+ "const char* steel_gemm_gather_nax() { return \"\"; }\n"
49+
+ "const char* steel_gemm_splitk_nax() { return \"\"; }\n"
50+
+ "const char* quantized_nax() { return \"\"; }\n"
51+
+ "const char* fp_quantized_nax() { return \"\"; }\n"
52+
+ "const char* steel_attention_nax() { return \"\"; }\n"
53+
+ "}\n")
54+
+ target_sources(mlx PRIVATE "${_nax_stub_cpp}")
3855
+ endif()
3956

4057
else()

0 commit comments

Comments
 (0)