Skip to content
Merged
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
10 changes: 2 additions & 8 deletions .github/actions/build-macos-release/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,15 @@ runs:
using: "composite"
steps:
- name: Build Python package
shell: bash
env:
MACOSX_DEPLOYMENT_TARGET: ${{ inputs.macos-target }}
shell: bash -l {0}
run: |
conda activate env
pip install build
python setup.py clean --all
MLX_BUILD_STAGE=1 python -m build -w

- name: Build backend package
if: ${{ inputs.build-backend }}
shell: bash
env:
MACOSX_DEPLOYMENT_TARGET: ${{ inputs.macos-target }}
shell: bash -l {0}
run: |
conda activate env
python setup.py clean --all
MLX_BUILD_STAGE=2 python -m build -w
69 changes: 22 additions & 47 deletions .github/actions/build-macos/action.yml
Original file line number Diff line number Diff line change
@@ -1,91 +1,67 @@
name: 'Build and Test on macOS'
description: 'Build and test MLX on macOS'

inputs:
python-version:
description: 'Python version to use'
required: false
default: '3.10'
macos-target:
description: 'macOS target to build and test for'
required: false
default: '14.0'

runs:
using: "composite"
steps:
- name: Setup uv
uses: astral-sh/setup-uv@v6
with:
python-version: ${{ inputs.python-version }}
activate-environment: true

- name: Install dependencies
shell: sh
env:
DEBUG: 1
CMAKE_ARGS: "-DCMAKE_COMPILE_WARNING_AS_ERROR=ON"
MACOSX_DEPLOYMENT_TARGET: ${{ inputs.macos-target }}
shell: bash -l {0}
run: |
uv pip install --upgrade pip
uv pip install cmake setuptools nanobind==2.4.0
uv pip install -e . -v
pip install --upgrade pip
pip install cmake setuptools nanobind==2.4.0
pip install -e . -v

- name: Generate package stubs
shell: bash
shell: bash -l {0}
run: |
uv pip install typing_extensions
uv run --no-project setup.py generate_stubs
pip install typing_extensions
python setup.py generate_stubs

- name: Install tests dependencies
shell: sh
shell: bash -l {0}
run: |
uv pip install numpy torch tensorflow unittest-xml-reporting
pip install numpy torch tensorflow unittest-xml-reporting

- name: Run Python tests
shell: bash
shell: bash -l {0}
env:
LOW_MEMORY: 1
MACOSX_DEPLOYMENT_TARGET: ${{ inputs.macos-target }}
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
DEVICE=cpu python -m xmlrunner discover -v python/tests -o test-results/cpu
DEVICE=gpu METAL_DEVICE_WRAPPER_TYPE=1 METAL_DEBUG_ERROR_MODE=0 python -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
env:
MACOSX_DEPLOYMENT_TARGET: ${{ inputs.macos-target }}
shell: bash -l {0}
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
pip install -r requirements.txt
python setup.py build_ext --inplace
python test.py

- name: Build CPP only
shell: bash
env:
MACOSX_DEPLOYMENT_TARGET: ${{ inputs.macos-target }}
shell: bash -l {0}
run: |
mkdir -p build
cd build
cmake ..
make -j $(sysctl -n hw.ncpu)

- name: Run CPP tests
shell: bash
shell: bash -l {0}
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
env:
MACOSX_DEPLOYMENT_TARGET: ${{ inputs.macos-target }}
shell: bash -l {0}
run: |
mkdir -p build
cd build
Expand All @@ -98,16 +74,15 @@ runs:
make -j $(sysctl -n hw.ncpu)

- name: Run Python tests with JIT
shell: bash
shell: bash -l {0}
env:
LOW_MEMORY: 1
DEVICE: gpu
METAL_DEVICE_WRAPPER_TYPE: 1
METAL_DEBUG_ERROR_MODE: 0
MACOSX_DEPLOYMENT_TARGET: ${{ inputs.macos-target }}
run: |
CMAKE_ARGS="-DMLX_METAL_JIT=ON" \
uv pip install -e . -v
uv run -m xmlrunner discover \
pip install -e . -v
python -m xmlrunner discover \
-v python/tests \
-o test-results/gpu_jit
11 changes: 11 additions & 0 deletions .github/actions/setup-macos/action.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
name: 'Setup macOS Environment'
description: 'Install dependencies for macOS builds'

inputs:
python-version:
description: 'Python version to use'
required: false
default: '3.10'

runs:
using: "composite"
steps:
Expand All @@ -11,3 +17,8 @@ runs:
- 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 }}
1 change: 0 additions & 1 deletion .github/workflows/nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ jobs:
with:
python-version: ${{ matrix.python-version }}
- uses: ./.github/actions/build-macos

- name: Build macOS 15 package
uses: ./.github/actions/build-macos-release
with:
Expand Down
8 changes: 6 additions & 2 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ on: pull_request
permissions:
contents: read

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
check_lint:
runs-on: ubuntu-22.04
Expand Down Expand Up @@ -32,13 +36,13 @@ jobs:
matrix:
macos-target: ["14.0", "15.0"]
runs-on: [self-hosted, macos]
env:
MACOSX_DEPLOYMENT_TARGET: ${{ matrix.macos-target }}
needs: check_lint
steps:
- uses: actions/checkout@v5
- uses: ./.github/actions/setup-macos
- uses: ./.github/actions/build-macos
with:
macos-target: ${{ matrix.macos-target }}

cuda_build_and_test:
if: github.repository == 'ml-explore/mlx'
Expand Down
19 changes: 9 additions & 10 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,8 @@ jobs:
strategy:
matrix:
python_version: ["3.10", "3.11", "3.12", "3.13", "3.14"]
include:
- runner: ubuntu-24.04
arch: x64
- runner: ubuntu-24.04-arm64
arch: arm64
runs-on: ${{ matrix.runner }}
arch: ['x86_64', 'aarch64']
runs-on: ${{ matrix.arch == 'x86_64' && 'ubuntu-22.04' || 'ubuntu-22.04-arm' }}
env:
PYPI_RELEASE: 1
DEV_RELEASE: ${{ github.event.inputs.dev_release == 'true' && 1 || 0 }}
Expand All @@ -68,12 +64,14 @@ jobs:
- name: Upload MLX artifacts
uses: actions/upload-artifact@v5
with:
overwrite: true
name: linux-wheels-${{ matrix.python_version }}
path: wheelhouse/mlx-*.whl
- name: Upload CPU artifacts
if: matrix.python_version == '3.10'
uses: actions/upload-artifact@v5
with:
overwrite: true
name: mlx-cpu
path: wheelhouse/mlx_cpu-*.whl

Expand All @@ -90,19 +88,17 @@ jobs:
steps:
- uses: actions/checkout@v5
- uses: ./.github/actions/setup-macos
- uses: conda-incubator/setup-miniconda@v3
with:
miniconda-version: "latest"
python-version: ${{ matrix.python-version }}

- name: Install dependencies
shell: sh
shell: bash -l {0}
run: |
pip install --upgrade pip
pip install cmake setuptools nanobind==2.4.0
pip install -e . -v
- name: Generate package stubs
shell: bash
shell: bash -l {0}
run: |
pip install typing_extensions
python setup.py generate_stubs
Expand All @@ -119,12 +115,14 @@ jobs:
- name: Upload MLX artifacts
uses: actions/upload-artifact@v5
with:
overwrite: true
name: mac-wheels-${{ matrix.python-version }}
path: dist/mlx-*.whl
- name: Upload Metal artifacts
if: matrix.python-version == '3.10'
uses: actions/upload-artifact@v5
with:
overwrite: true
name: mlx-metal
path: dist/mlx_metal-*.whl

Expand All @@ -146,6 +144,7 @@ jobs:
- name: Upload artifacts
uses: actions/upload-artifact@v5
with:
overwrite: true
name: mlx-cuda
path: wheelhouse/mlx_cuda-*.whl

Expand Down
Loading