Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/actions/build-macos-release/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ runs:
DEVELOPER_DIR: /Applications/Xcode-latest.app
MACOSX_DEPLOYMENT_TARGET: ${{ inputs.macos-target }}
run: |
pip install build
uv pip install build
python setup.py clean --all
MLX_BUILD_STAGE=1 python -m build -w

Expand Down
54 changes: 34 additions & 20 deletions .github/actions/build-macos/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,61 +4,72 @@ description: 'Build and test MLX on macOS'
runs:
using: "composite"
steps:
- name: Install dependencies
- name: Install Python package
env:
DEBUG: 1
CMAKE_ARGS: "-DCMAKE_COMPILE_WARNING_AS_ERROR=ON"
shell: bash -l {0}
shell: bash
run: |
pip install --upgrade pip
pip install cmake setuptools typing_extensions
pip install -e ".[dev]" -v
echo "::group::Install Python package"
uv pip install -e ".[dev]" -v
echo "::endgroup::"

- name: Install tests dependencies
shell: bash -l {0}
shell: bash
run: |
pip install tensorflow
echo "::group::Install tests dependencies"
uv pip install tensorflow
echo "::endgroup::"

- name: Run Python tests
shell: bash -l {0}
shell: bash
env:
LOW_MEMORY: 1
run: |
echo "::group::Run Python tests"
DEVICE=cpu python -m unittest discover -v python/tests
DEVICE=gpu METAL_DEVICE_WRAPPER_TYPE=1 METAL_DEBUG_ERROR_MODE=0 python -m unittest discover -v python/tests
mpirun --bind-to none -host localhost:8 -np 8 -x DYLD_LIBRARY_PATH=/opt/homebrew/lib/ python python/tests/mpi_test_distributed.py
mlx.launch --verbose -n 8 python/tests/ring_test_distributed.py -v 2> >(tee -a stderr.log >&2)
if $(grep "\[WARN\]" stderr.log); then echo "Distributed ring test failed"; exit 1; fi

echo "::endgroup::"

- name: Build example extension
shell: bash -l {0}
shell: bash
run: |
echo "::group::Build example extension"
cd examples/extensions
pip install -r requirements.txt
python setup.py build_ext --inplace
python test.py

uv pip install -r requirements.txt
uv run --no-project setup.py build_ext --inplace
uv run --no-project test.py
echo "::endgroup::"

- name: Build CPP only
shell: bash -l {0}
shell: bash
run: |
echo "::group::Build CPP only"
mkdir -p build
cd build
cmake ..
make -j $(sysctl -n hw.ncpu)
echo "::endgroup::"

- name: Run CPP tests
shell: bash -l {0}
shell: bash
env:
DEVICE: gpu
METAL_DEVICE_WRAPPER_TYPE: 1
METAL_DEBUG_ERROR_MODE: 0
run: |
echo "::group::Run CPP tests"
./build/tests/tests
./build/tests/test_teardown
echo "::endgroup::"

- name: Build small binary with JIT
shell: bash -l {0}
shell: bash
run: |
echo "::group::Build small binary with JIT"
mkdir -p build
cd build
cmake .. -DCMAKE_BUILD_TYPE=MinSizeRel \
Expand All @@ -68,15 +79,18 @@ runs:
-DMLX_BUILD_GGUF=OFF \
-DMLX_METAL_JIT=ON
make -j $(sysctl -n hw.ncpu)

echo "::endgroup::"

- name: Run Python tests with JIT
shell: bash -l {0}
shell: bash
env:
LOW_MEMORY: 1
DEVICE: gpu
METAL_DEVICE_WRAPPER_TYPE: 1
METAL_DEBUG_ERROR_MODE: 0
run: |
echo "::group::Run Python tests with JIT"
CMAKE_ARGS="-DMLX_METAL_JIT=ON" \
pip install -e . -v
uv pip install -e . -v
python -m unittest discover -v python/tests
echo "::endgroup::"
18 changes: 13 additions & 5 deletions .github/actions/setup-macos/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,20 @@ runs:
- name: Install Homebrew packages
shell: sh
run: /opt/homebrew/bin/brew install openmpi

- name: Verify MetalToolchain installed
shell: bash
run: xcodebuild -showComponent MetalToolchain

- uses: conda-incubator/setup-miniconda@v3
with:
miniconda-version: "latest"
python-version: ${{ inputs.python-version }}
- uses: astral-sh/setup-uv@v7

- name: Setup Python venv
shell: bash
run: |
echo "::group::Setup Python venv"
uv venv --python ${{ inputs.python-version }}
source .venv/bin/activate
echo PATH=$PATH >> $GITHUB_ENV
# Search python packages in .venv
echo PYTHONPATH=`python -c 'import sys; print(sys.path[-1])'` >> $GITHUB_ENV
echo "::endgroup::"
9 changes: 2 additions & 7 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -93,13 +93,8 @@ jobs:
- uses: ./.github/actions/setup-macos
with:
python-version: ${{ matrix.python-version }}

- name: Install dependencies
shell: bash -l {0}
run: |
pip install --upgrade pip
pip install cmake setuptools typing_extensions
pip install -e . -v
- name: Install Python package
run: uv pip install -e . -v
- name: Build macOS 14 package
uses: ./.github/actions/build-macos-release
with:
Expand Down
2 changes: 1 addition & 1 deletion examples/extensions/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
setuptools>=42
cmake>=3.25
mlx>=0.21.0
mlx>=0.31.2
nanobind==2.12.0
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ def get_tag(self) -> tuple[str, str, str]:
"ml_dtypes",
"numpy>=2",
"pre-commit",
"psutil",
"psutil>=7.2",
"torch>=2.9",
"typing_extensions",
],
Expand Down
Loading