From 765ebd7ef260f0f267c3c0e16c6fc303b7328efa Mon Sep 17 00:00:00 2001 From: electron-rare <108685187+electron-rare@users.noreply.github.com> Date: Sun, 10 May 2026 13:13:24 +0200 Subject: [PATCH] ci: add macOS arm64 wheel build workflow Builds mlx wheels for Python 3.11 and 3.12 on macos-14 (arm64) on push to main, metal-*, q-*, attn-mask-fix, fix-rope branches or via workflow_dispatch. Wheels uploaded as artifacts (30d retention). Tagged commits (v*) also publish a GitHub Release. --- .github/workflows/build-wheels.yml | 81 ++++++++++++++++++++++++++++++ 1 file changed, 81 insertions(+) create mode 100644 .github/workflows/build-wheels.yml diff --git a/.github/workflows/build-wheels.yml b/.github/workflows/build-wheels.yml new file mode 100644 index 00000000..31032cff --- /dev/null +++ b/.github/workflows/build-wheels.yml @@ -0,0 +1,81 @@ +name: Build macOS arm64 wheels + +on: + push: + branches: + - main + - 'metal-*' + - 'q-*' + - attn-mask-fix + - fix-rope + workflow_dispatch: + inputs: + branch_to_build: + description: 'Branch to build (optional, defaults to current ref)' + required: false + default: '' + +concurrency: + group: build-${{ github.ref }} + cancel-in-progress: true + +jobs: + build: + name: Build wheel (Python ${{ matrix.python }}) + runs-on: macos-14 + timeout-minutes: 60 + strategy: + fail-fast: false + matrix: + python: ['3.11', '3.12'] + env: + CMAKE_BUILD_PARALLEL_LEVEL: '4' + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + ref: ${{ github.event.inputs.branch_to_build || github.ref }} + submodules: recursive + + - name: Set up Python ${{ matrix.python }} + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python }} + + - name: Cache pip + uses: actions/cache@v4 + with: + path: | + ~/.cache/pip + ~/Library/Caches/pip + key: pip-${{ runner.os }}-py${{ matrix.python }}-${{ hashFiles('CMakeLists.txt', 'setup.py', 'pyproject.toml') }} + restore-keys: | + pip-${{ runner.os }}-py${{ matrix.python }}- + + - name: Install build dependencies + run: | + python -m pip install -U pip wheel build setuptools cmake nanobind + + - name: Build wheel + run: | + mkdir -p ./wheels + pip wheel --no-deps . -w ./wheels + + - name: List built wheels + run: ls -lh ./wheels + + - name: Upload wheel artifact + uses: actions/upload-artifact@v4 + with: + name: mlx-${{ github.ref_name }}-py${{ matrix.python }}-wheels + path: ./wheels/*.whl + retention-days: 30 + if-no-files-found: error + + - name: Create GitHub Release (on tag) + if: startsWith(github.ref, 'refs/tags/v') + uses: softprops/action-gh-release@v2 + with: + files: ./wheels/*.whl + fail_on_unmatched_files: false + generate_release_notes: true