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
8 changes: 7 additions & 1 deletion .github/actions/build-docs/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ runs:
- name: Setup machine
uses: ./.github/actions/setup-macos

- name: Setup uv
uses: astral-sh/setup-uv@v6
with:
python-version: "3.10"
activate-environment: true

- name: Install dependencies
shell: sh
run: |
Expand Down Expand Up @@ -35,4 +41,4 @@ runs:
name: github-pages
path: artifact.tar
retention-days: 1
if-no-files-found: error
if-no-files-found: error
13 changes: 8 additions & 5 deletions .github/actions/build-macos-release/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,17 @@ runs:
env:
MACOSX_DEPLOYMENT_TARGET: ${{ inputs.macos-target }}
run: |
uv pip install build
uv run --no-project setup.py clean --all
MLX_BUILD_STAGE=1 uv run -m build -w
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 }}
run: |
uv run --no-project setup.py clean --all
MLX_BUILD_STAGE=2 uv run -m build -w
conda activate env
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Conda needs to be set up for nightlies as well

python setup.py clean --all
MLX_BUILD_STAGE=2 python -m build -w
25 changes: 25 additions & 0 deletions .github/actions/build-macos/action.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,31 @@
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 }}
run: |
uv pip install --upgrade pip
uv pip install cmake setuptools nanobind==2.4.0
Expand All @@ -29,6 +46,7 @@ runs:
shell: bash
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
Expand All @@ -38,6 +56,8 @@ runs:

- name: Build example extension
shell: bash
env:
MACOSX_DEPLOYMENT_TARGET: ${{ inputs.macos-target }}
run: |
cd examples/extensions
uv pip install -r requirements.txt
Expand All @@ -46,6 +66,8 @@ runs:

- name: Build CPP only
shell: bash
env:
MACOSX_DEPLOYMENT_TARGET: ${{ inputs.macos-target }}
run: |
mkdir -p build
cd build
Expand All @@ -62,6 +84,8 @@ runs:

- name: Build small binary with JIT
shell: bash
env:
MACOSX_DEPLOYMENT_TARGET: ${{ inputs.macos-target }}
run: |
mkdir -p build
cd build
Expand All @@ -80,6 +104,7 @@ runs:
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
Expand Down
12 changes: 0 additions & 12 deletions .github/actions/setup-macos/action.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
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 @@ -17,9 +11,3 @@ runs:
- name: Verify MetalToolchain installed
shell: bash
run: xcodebuild -showComponent MetalToolchain

- name: Setup uv
uses: astral-sh/setup-uv@v6
with:
python-version: ${{ inputs.python-version }}
activate-environment: true
5 changes: 5 additions & 0 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,17 @@ jobs:

mac_build_and_test:
if: github.repository == 'ml-explore/mlx'
strategy:
matrix:
macos-target: ["14.0", "15.0"]
runs-on: [self-hosted, macos]
needs: check_lint
steps:
- uses: actions/checkout@v5
- uses: ./.github/actions/setup-macos
- uses: ./.github/actions/build-macos
with:
macos-target: ${{ matrix.macos-target }}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this more useful than setting an env for the entire step?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By no means, I'd rather set it for the full step, just didn't know it was possible.


cuda_build_and_test:
if: github.repository == 'ml-explore/mlx'
Expand Down
50 changes: 25 additions & 25 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,18 @@ on:
tags:
- 'v*'
workflow_dispatch:
inputs:
dev_release:
description: "Do a dev release or regular release"
required: true
default: "false"

permissions:
contents: read

jobs:
setup:
runs-on: ubuntu-latest
outputs:
pypi_env: ${{ github.event_name == 'push' && 'pypi' || 'test-pypi' }}
pypi_url: ${{ github.event_name == 'push' && 'https://upload.pypi.org/legacy/' || 'https://test.pypi.org/legacy/' }}
skip_duplicates: ${{ github.event_name == 'push' && 'false' || 'true' }}
steps:
- name: Set publishing variables
run: echo "Publishing setup complete"
Expand Down Expand Up @@ -54,6 +55,7 @@ jobs:
runs-on: ${{ matrix.runner }}
env:
PYPI_RELEASE: 1
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dos this need to be the opposite of DEV_RELEASE?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, PYPI_RELEASE is always on for this. And if DEV_RELEASE is also on it will do a dev release with a dev tag included.

DEV_RELEASE: ${{ github.event.inputs.dev_release == 'true' && 1 || 0 }}
steps:
- uses: actions/checkout@v5
- uses: ./.github/actions/setup-linux
Expand Down Expand Up @@ -83,22 +85,27 @@ jobs:
runs-on: [self-hosted, macos]
env:
PYPI_RELEASE: 1
DEV_RELEASE: ${{ github.event.inputs.dev_release == 'true' && 1 || 0 }}

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
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
run: |
uv pip install typing_extensions
uv run --no-project setup.py generate_stubs
pip install typing_extensions
python setup.py generate_stubs
- name: Build macOS 14 package
uses: ./.github/actions/build-macos-release
with:
Expand Down Expand Up @@ -126,6 +133,7 @@ jobs:
runs-on: ubuntu-22-large
env:
PYPI_RELEASE: 1
DEV_RELEASE: ${{ github.event.inputs.dev_release == 'true' && 1 || 0 }}
steps:
- uses: actions/checkout@v5
- uses: ./.github/actions/setup-linux
Expand All @@ -148,7 +156,7 @@ jobs:
permissions:
id-token: write
environment:
name: ${{ needs.setup.outputs.pypi_env }}
name: pypi
url: https://pypi.org/p/mlx
steps:
- uses: actions/download-artifact@v6
Expand All @@ -166,9 +174,7 @@ jobs:
- name: Publish package distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
repository-url: ${{ needs.setup.outputs.pypi_url }}
skip-existing: ${{ needs.setup.outputs.skip_duplicates }}
print-hash: true
repository-url: https://upload.pypi.org/legacy/
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the default and doesn’t need to be set


pypi-publish-cuda:
name: Upload CUDA release to PyPI
Expand All @@ -177,7 +183,7 @@ jobs:
permissions:
id-token: write
environment:
name: ${{ needs.setup.outputs.pypi_env }}
name: pypi
url: https://pypi.org/p/mlx-cuda
steps:
- uses: actions/download-artifact@v6
Expand All @@ -189,9 +195,7 @@ jobs:
- name: Publish package distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
repository-url: ${{ needs.setup.outputs.pypi_url }}
skip-existing: ${{ needs.setup.outputs.skip_duplicates }}
print-hash: true
repository-url: https://upload.pypi.org/legacy/

pypi-publish-cpu:
name: Upload CPU release to PyPI
Expand All @@ -200,7 +204,7 @@ jobs:
permissions:
id-token: write
environment:
name: ${{ needs.setup.outputs.pypi_env }}
name: pypi
url: https://pypi.org/p/mlx-cpu
steps:
- uses: actions/download-artifact@v6
Expand All @@ -212,9 +216,7 @@ jobs:
- name: Publish package distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
repository-url: ${{ needs.setup.outputs.pypi_url }}
skip-existing: ${{ needs.setup.outputs.skip_duplicates }}
print-hash: true
repository-url: https://upload.pypi.org/legacy/

pypi-publish-metal:
name: Upload Metal release to PyPI
Expand All @@ -223,7 +225,7 @@ jobs:
permissions:
id-token: write
environment:
name: ${{ needs.setup.outputs.pypi_env }}
name: pypi
url: https://pypi.org/p/mlx-metal
steps:
- uses: actions/download-artifact@v6
Expand All @@ -235,6 +237,4 @@ jobs:
- name: Publish package distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
repository-url: ${{ needs.setup.outputs.pypi_url }}
skip-existing: ${{ needs.setup.outputs.skip_duplicates }}
print-hash: true
repository-url: https://upload.pypi.org/legacy/
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ def get_version():
if "#define MLX_VERSION_PATCH" in l:
patch = l.split()[-1]
version = f"{major}.{minor}.{patch}"
if "PYPI_RELEASE" not in os.environ:
if os.environ.get("PYPI_RELEASE", False):
today = datetime.date.today()
version = f"{version}.dev{today.year}{today.month:02d}{today.day:02d}"

if "DEV_RELEASE" not in os.environ:
if os.environ.get("DEV_RELEASE", False):
git_hash = (
run(
"git rev-parse --short HEAD".split(),
Expand Down