name: 'Build and Test on macOS' description: 'Build and test MLX on macOS' runs: using: "composite" steps: - name: Install dependencies shell: sh env: DEBUG: 1 CMAKE_ARGS: "-DCMAKE_COMPILE_WARNING_AS_ERROR=ON" run: | uv pip install --upgrade pip uv pip install cmake setuptools nanobind==2.4.0 uv pip install -e . -v - name: Generate package stubs shell: bash run: | uv pip install typing_extensions uv run --no-project setup.py generate_stubs - name: Install tests dependencies shell: sh run: | uv pip install numpy torch tensorflow unittest-xml-reporting - name: Run Python tests shell: bash env: LOW_MEMORY: 1 run: | DEVICE=cpu uv run -m xmlrunner discover -v python/tests -o test-results/cpu DEVICE=gpu METAL_DEVICE_WRAPPER_TYPE=1 METAL_DEBUG_ERROR_MODE=0 uv run -m xmlrunner discover -v python/tests -o test-results/gpu 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 - name: Build example extension shell: bash run: | cd examples/extensions uv pip install -r requirements.txt uv run --no-project setup.py build_ext --inplace uv run --no-project test.py - name: Build CPP only shell: bash run: | mkdir -p build cd build cmake .. make -j $(sysctl -n hw.ncpu) - name: Run CPP tests shell: bash env: DEVICE: gpu METAL_DEVICE_WRAPPER_TYPE: 1 METAL_DEBUG_ERROR_MODE: 0 run: ./build/tests/tests - name: Build small binary with JIT shell: bash run: | mkdir -p build cd build cmake .. -DCMAKE_BUILD_TYPE=MinSizeRel \ -DBUILD_SHARED_LIBS=ON \ -DMLX_BUILD_CPU=OFF \ -DMLX_BUILD_SAFETENSORS=OFF \ -DMLX_BUILD_GGUF=OFF \ -DMLX_METAL_JIT=ON make -j $(sysctl -n hw.ncpu) - name: Run Python tests with JIT shell: bash env: LOW_MEMORY: 1 DEVICE: gpu METAL_DEVICE_WRAPPER_TYPE: 1 METAL_DEBUG_ERROR_MODE: 0 run: | CMAKE_ARGS="-DMLX_METAL_JIT=ON" \ uv pip install -e . -v uv run -m xmlrunner discover \ -v python/tests \ -o test-results/gpu_jit