Skip to content
Closed
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
4 changes: 3 additions & 1 deletion .github/actions/build-cuda-release/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,12 @@ runs:
MLX_BUILD_STAGE: 2
CMAKE_ARGS: -DMLX_BUILD_CUDA=ON -DCMAKE_CUDA_COMPILER=${{ inputs.nvcc-location }}
run: |
echo "::group::Build packages"
pip install auditwheel build patchelf setuptools
python setup.py clean --all
python -m build -w

if [ -f "python/scripts/repair_cuda.sh" ]; then
bash python/scripts/repair_cuda.sh
fi
fi
echo "::endgroup::"
22 changes: 18 additions & 4 deletions .github/actions/build-cuda/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,38 +24,52 @@ runs:
env:
DEBUG: 1
CMAKE_ARGS: -DMLX_BUILD_CUDA=ON -DCMAKE_COMPILE_WARNING_AS_ERROR=ON -DCMAKE_CUDA_COMPILER=${{ inputs.nvcc-location }}
run: pip install -e ".[dev]" -v
run: |
echo "::group::Install Python Package"
pip install -e ".[dev]" -v
echo "::endgroup::"

- name: Run Python tests - CPU
if: inputs.run-tests == 'true'
shell: bash
env:
LOW_MEMORY: 1
DEVICE: cpu
run: python -m unittest discover python/tests -v
run: |
echo "::group::Run Python tests - CPU"
python -m unittest discover python/tests -v
echo "::endgroup::"

- name: Run Python tests - GPU
if: inputs.run-tests == 'true'
shell: bash
env:
LOW_MEMORY: 1
DEVICE: gpu
run: python -m tests discover python/tests -v
run: |
echo "::group::Run Python tests - GPU"
python -m tests discover python/tests -v
echo "::endgroup::"

- name: Build CPP only
if: inputs.build-type == 'debug'
shell: bash
run: |
echo "::group::Build CPP"
cmake . -B build \
-DMLX_BUILD_CUDA=ON \
-DCMAKE_CUDA_COMPILER=${{ inputs.nvcc-location }} \
-DCMAKE_BUILD_TYPE=DEBUG
cmake --build build -j $(nproc)
echo "::endgroup::"

- name: Run CPP tests
if: ${{ inputs.build-type == 'debug' && inputs.run-tests == 'true' }}
shell: bash
run: ./build/tests/tests -sfe="*fft_tests.cpp,*linalg_tests.cpp"
run: |
echo "::group::Run CPP Tests"
./build/tests/tests -sfe="*fft_tests.cpp,*linalg_tests.cpp"
echo "::endgroup::"

- name: Build Python package
if: inputs.build-type == 'release'
Expand Down
4 changes: 4 additions & 0 deletions .github/actions/build-docs/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,22 @@ runs:
- name: Install dependencies
shell: sh
run: |
echo "::group::Install dependencies"
brew install doxygen
uv pip install --upgrade pip cmake
uv pip install -r docs/requirements.txt
uv pip install . -v
echo "::endgroup::"

- name: Build documentation
shell: bash
run: |
echo "::group::Build documentation"
source .venv/bin/activate
cd docs
doxygen
make html O=-W
echo "::endgroup::"

- name: Create artifact tar
shell: sh
Expand Down
24 changes: 19 additions & 5 deletions .github/actions/build-linux/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,24 @@ runs:
shell: sh
env:
CMAKE_ARGS: "-DCMAKE_COMPILE_WARNING_AS_ERROR=ON"
run: pip install -e ".[dev]" -v
run: |
echo "::group::Install Python Package"
pip install -e ".[dev]" -v
echo "::endgroup::"

- name: Generate package stubs
shell: sh
run: |
echo "::group::Generate package stubs"
pip install typing_extensions
python setup.py generate_stubs

echo "::endgroup::"

- name: Run Python tests
if: inputs.run-tests == 'true'
shell: bash
run: |
echo "::group::Run Python tests"
python -m unittest discover python/tests -v
mpirun --bind-to none --allow-run-as-root -host localhost:8 -np 8 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)
Expand All @@ -48,24 +54,31 @@ runs:
echo "Distributed ring test failed";
exit 1;
fi

echo "::endgroup::"

- name: Build CPP only
if: inputs.build-type == 'debug'
shell: bash
run: |
echo "::group::Build CPP"
mkdir -p build && cd build
cmake .. -DMLX_BUILD_METAL=OFF -DCMAKE_BUILD_TYPE=DEBUG
make -j $(nproc)

echo "::endgroup::"

- name: Run CPP tests
if: ${{ inputs.build-type == 'debug' && inputs.run-tests == 'true' }}
shell: sh
run: ./build/tests/tests
run: |
echo "::group::Run CPP Tests"
./build/tests/tests
echo "::endgroup::"

- name: Build Python package
if: inputs.build-type == 'release'
shell: bash
run: |
echo "::group::Build Python Package"
pip install auditwheel patchelf build
python setup.py clean --all
MLX_BUILD_STAGE=1 python -m build -w
Expand All @@ -76,3 +89,4 @@ runs:
python setup.py clean --all
MLX_BUILD_STAGE=2 python -m build -w
auditwheel repair dist/mlx_cpu*.whl --plat manylinux_2_35_x86_64
echo "::endgroup::"
2 changes: 2 additions & 0 deletions .github/actions/build-macos-release/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@ runs:
env:
MACOSX_DEPLOYMENT_TARGET: ${{ inputs.macos-target }}
run: |
echo "::group::Build packages (target: $MACOSX_DEPLOYMENT_TARGET)"
uv pip install build
uv run --no-project setup.py clean --all
MLX_BUILD_STAGE=1 uv run -m build -w
uv run --no-project setup.py clean --all
MLX_BUILD_STAGE=2 uv run -m build -w
echo "::endgroup::"
27 changes: 23 additions & 4 deletions .github/actions/build-macos/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,65 +24,81 @@ runs:
DEBUG: 1
DEV_RELEASE: 1
run: |
echo "::group::Install dependencies"
uv pip install --upgrade pip
uv pip install cmake setuptools nanobind==2.4.0
uv pip install -e . -v
echo "::endgroup::"

- name: Generate package stubs
shell: bash
run: |
echo "::group::Generate package stubs"
uv pip install typing_extensions
uv run --no-project setup.py generate_stubs
echo "::endgroup::"

- name: Install tests dependencies
if: inputs.run-tests == 'true'
shell: sh
run: |
echo "::group::Install test dependencies"
uv pip install numpy torch tensorflow unittest-xml-reporting
echo "::endgroup::"

- name: Run Python tests
if: inputs.run-tests == 'true'
shell: bash
env:
LOW_MEMORY: 1
run: |
echo "::group::Run Python tests"
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
echo "::endgroup::"

- name: Build example extension
if: inputs.run-tests == 'true'
shell: bash
run: |
echo "::group::Build example extension"
cd examples/extensions
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
if: inputs.run-tests == 'true'
shell: bash
run: |
echo "::group::Build CPP"
mkdir -p build
cd build
cmake ..
make -j $(sysctl -n hw.ncpu)
echo "::endgroup::"

- name: Run CPP tests
- name: Run CPP Tests
if: inputs.run-tests == 'true'
shell: bash
env:
DEVICE: gpu
METAL_DEVICE_WRAPPER_TYPE: 1
METAL_DEBUG_ERROR_MODE: 0
run: ./build/tests/tests
run: |
echo "::group::Run CPP Tests"
./build/tests/tests
echo "::endgroup::"

- name: Build small binary with JIT
if: inputs.run-tests == 'true'
shell: bash
run: |
echo "::group::Build JIT Binary"
mkdir -p build
cd build
cmake .. -DCMAKE_BUILD_TYPE=MinSizeRel \
Expand All @@ -92,7 +108,8 @@ runs:
-DMLX_BUILD_GGUF=OFF \
-DMLX_METAL_JIT=ON
make -j $(sysctl -n hw.ncpu)

echo "::endgroup::"

- name: Run Python tests with JIT
if: inputs.run-tests == 'true'
shell: bash
Expand All @@ -102,11 +119,13 @@ runs:
METAL_DEVICE_WRAPPER_TYPE: 1
METAL_DEBUG_ERROR_MODE: 0
run: |
echo "::group::Test JIT Binary"
CMAKE_ARGS="-DMLX_METAL_JIT=ON" \
uv pip install -e . -v
uv run -m xmlrunner discover \
-v python/tests \
-o test-results/gpu_jit
echo "::endgroup::"

- name: Build macOS 14 package
if: inputs.build-type == 'release'
Expand Down
2 changes: 2 additions & 0 deletions .github/actions/setup-linux/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,11 @@ runs:
TZ: Etc/UTC
shell: bash
run: |
echo "::group::Install dependencies"
sudo apt-get update
sudo apt-get install -y libblas-dev liblapack-dev liblapacke-dev tzdata zip
sudo apt autoremove -y
echo "::endgroup::"

- uses: actions/setup-python@v6
with:
Expand Down