You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 351ee54
Browse filesBrowse the repository at this point in the historyBrowse files
[MLX] Isolate submodule build with ExternalProject
MLX was pulled into ExecuTorch's build via add_subdirectory, dropping MLX's
whole CMake project into ET's target/option namespace. That shared scope
collides with deps MLX fetches (today nlohmann_json), worked around by patching
MLX's own CMakeLists.txt at configure time. Patching a submodule is fragile: the
patch is pinned to specific lines and silently stops applying when an MLX bump
touches that region, at which point the json collision returns with no clear
signal. It also dirties the submodule and leaks MLX's MLX_BUILD_* options into
ET's cache.
Build MLX in its own isolated CMake scope via ExternalProject and consume it as
a prebuilt static lib + metallib through an imported `mlx` target. MLX then runs
its FetchContent in its own namespace, so the json collision cannot happen and
the patch is deleted. The imported target re-adds the Metal/Foundation/
QuartzCore frameworks a static libmlx.a does not carry (matching the imported
mlx target already in tools/cmake/executorch-config.cmake), and mlxdelegate
depends on mlx_external directly since add_dependencies on an imported target
does not order the build.
The ExternalProject BINARY_DIR is kept at the same location add_subdirectory
used, so libmlx.a and mlx.metallib land at their existing paths; downstream
consumers (package config, metallib copy helper, the pybindings wheel in
setup.py) need no changes.
- Replace MLX_BUILD_* options + patch loop + add_subdirectory with
ExternalProject_Add(mlx_external) and an imported `mlx` target.
- install(TARGETS mlx) -> install(FILES ${_mlx_static_lib}), since an imported
target cannot be installed via install(TARGETS).
- Point the metallib install and MLX_METALLIB_PATH at ${_mlx_metallib}.
- Delete backends/mlx/patches/mlx_json.patch and the patch-apply loop.
Verified: cmake --preset mlx-release configures, builds, and installs;
libmlx.a, libmlxdelegate.a, and mlx.metallib land in cmake-out/lib/; the MLX
submodule stays pristine through configure/build/install; the delegate tests
(op_test_runner, multi_thread_test_runner, mlx_mutable_state_test) build and
link mlx directly, and mlx_mutable_state_test passes.
Fixes#20556.
Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
0 commit comments