Skip to content

Commit 31e134b

Browse files
authored
Build for macOS 15 (#1208)
* Build for macos 15 * metal32 as well * comment --------- Co-authored-by: Awni Hannun <Awni Hannun>
1 parent e84ba80 commit 31e134b

File tree

6 files changed

+9
-81
lines changed

6 files changed

+9
-81
lines changed

CMakeLists.txt

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -85,13 +85,12 @@ elseif (MLX_BUILD_METAL)
8585

8686
message(STATUS "Building with SDK for macOS version ${MACOS_VERSION}")
8787

88-
if (${MACOS_VERSION} GREATER_EQUAL 14.2)
89-
set(METAL_CPP_PATCH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/metal.14.2.diff)
90-
set(METAL_CPP_URL https://developer.apple.com/metal/cpp/files/metal-cpp_macOS14.2_iOS17.2.zip)
88+
set(METAL_CPP_URL https://developer.apple.com/metal/cpp/files/metal-cpp_macOS15_iOS18-beta.zip)
89+
if (${MACOS_VERSION} GREATER_EQUAL 15.0)
90+
set(MLX_METAL_VERSION METAL_3_2)
91+
elseif (${MACOS_VERSION} GREATER_EQUAL 14.2)
9192
set(MLX_METAL_VERSION METAL_3_1)
9293
elseif (${MACOS_VERSION} GREATER_EQUAL 14.0)
93-
set(METAL_CPP_PATCH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/metal.14.0.diff)
94-
set(METAL_CPP_URL https://developer.apple.com/metal/cpp/files/metal-cpp_macOS14_iOS17-beta.zip)
9594
set(MLX_METAL_VERSION METAL_3_0)
9695
else()
9796
message(FATAL_ERROR "MLX requires macOS SDK >= 14.0 to be built with MLX_BUILD_METAL=ON" )
@@ -100,7 +99,6 @@ elseif (MLX_BUILD_METAL)
10099
FetchContent_Declare(
101100
metal_cpp
102101
URL ${METAL_CPP_URL}
103-
PATCH_COMMAND /usr/bin/patch -N -i ${METAL_CPP_PATCH} || true
104102
)
105103

106104
FetchContent_MakeAvailable(metal_cpp)

cmake/metal.14.0.diff

Lines changed: 0 additions & 36 deletions
This file was deleted.

cmake/metal.14.2.diff

Lines changed: 0 additions & 36 deletions
This file was deleted.

mlx/backend/metal/device.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,9 @@ constexpr int MAX_DISPATCHES_PER_ENCODER = 2;
3030
constexpr const char* default_mtllib_path = METAL_PATH;
3131

3232
constexpr auto get_metal_version() {
33-
#if defined METAL_3_1
33+
#if defined METAL_3_2
34+
return MTL::LanguageVersion3_2;
35+
#elif defined METAL_3_1
3436
return MTL::LanguageVersion3_1;
3537
#else
3638
return MTL::LanguageVersion3_0;

mlx/backend/metal/kernels/bf16.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
using namespace metal;
88

9-
#if defined METAL_3_1 || (__METAL_VERSION__ >= 310)
9+
#if defined METAL_3_1 || defined METAL_3_2 || (__METAL_VERSION__ >= 310)
1010

1111
typedef bfloat bfloat16_t;
1212

mlx/backend/metal/kernels/bf16_math.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,7 @@ instantiate_metal_math_funcs(
369369
return static_cast<otype>(__metal_simd_xor(static_cast<ctype>(data))); \
370370
}
371371

372-
#if defined METAL_3_1 || (__METAL_VERSION__ >= 310)
372+
#if defined METAL_3_1 || defined METAL_3_2 || (__METAL_VERSION__ >= 310)
373373

374374
#define bfloat16_to_uint16(x) as_type<uint16_t>(x)
375375
#define uint16_to_bfloat16(x) as_type<bfloat16_t>(x)

0 commit comments

Comments
 (0)