mirror of
https://github.com/ml-explore/mlx.git
synced 2025-06-24 09:21:16 +08:00
314 lines
9.8 KiB
YAML
314 lines
9.8 KiB
YAML
version: 2.1
|
|
|
|
orbs:
|
|
apple: ml-explore/pr-approval@0.1.0
|
|
|
|
parameters:
|
|
nightly_build:
|
|
type: boolean
|
|
default: false
|
|
weekly_build:
|
|
type: boolean
|
|
default: false
|
|
test_release:
|
|
type: boolean
|
|
default: false
|
|
|
|
jobs:
|
|
linux_build_and_test:
|
|
docker:
|
|
- image: cimg/python:3.9
|
|
|
|
steps:
|
|
- checkout
|
|
- run:
|
|
name: Run style checks
|
|
command: |
|
|
pip install pre-commit
|
|
pre-commit run --all
|
|
if ! git diff --quiet; then echo 'Style checks failed, please install pre-commit and run pre-commit run --all and push the change'; exit 1; fi
|
|
- run:
|
|
name: Install dependencies
|
|
command: |
|
|
pip install --upgrade cmake
|
|
pip install git+https://github.com/wjakob/nanobind.git@4148debcf91f5ccab0c3b8d67b5c3cabd61f407f
|
|
pip install numpy
|
|
sudo apt-get update
|
|
sudo apt-get install libblas-dev liblapack-dev liblapacke-dev
|
|
- run:
|
|
name: Install Python package
|
|
command: |
|
|
CMAKE_ARGS="-DMLX_BUILD_METAL=OFF" CMAKE_BUILD_PARALLEL_LEVEL="" python3 setup.py build_ext --inplace
|
|
CMAKE_ARGS="-DMLX_BUILD_METAL=OFF" CMAKE_BUILD_PARALLEL_LEVEL="" python3 setup.py develop
|
|
- run:
|
|
name: Generate package stubs
|
|
command: |
|
|
echo "stubs"
|
|
python setup.py generate_stubs
|
|
- run:
|
|
name: Run Python tests
|
|
command: |
|
|
python3 -m unittest discover python/tests -v
|
|
# TODO: Reenable when extension api becomes stable
|
|
# - run:
|
|
# name: Build example extension
|
|
# command: |
|
|
# cd examples/extensions && python3 -m pip install .
|
|
- run:
|
|
name: Build CPP only
|
|
command: |
|
|
mkdir -p build && cd build && cmake .. -DMLX_BUILD_METAL=OFF && make -j
|
|
- run:
|
|
name: Run CPP tests
|
|
command: ./build/tests/tests
|
|
|
|
mac_build_and_test:
|
|
parameters:
|
|
xcode_version:
|
|
type: string
|
|
default: "15.2.0"
|
|
macos:
|
|
xcode: << parameters.xcode_version >>
|
|
resource_class: macos.m1.large.gen1
|
|
steps:
|
|
- checkout
|
|
- run:
|
|
name: Install dependencies
|
|
command: |
|
|
brew install python@3.8
|
|
python3.8 -m venv env
|
|
source env/bin/activate
|
|
pip install --upgrade pip
|
|
pip install --upgrade cmake
|
|
pip install git+https://github.com/wjakob/nanobind.git@4148debcf91f5ccab0c3b8d67b5c3cabd61f407f
|
|
pip install numpy
|
|
pip install torch
|
|
pip install tensorflow
|
|
pip install unittest-xml-reporting
|
|
- run:
|
|
name: Install Python package
|
|
command: |
|
|
source env/bin/activate
|
|
CMAKE_BUILD_PARALLEL_LEVEL="" pip install -e . -v
|
|
- run:
|
|
name: Generate package stubs
|
|
command: |
|
|
source env/bin/activate
|
|
python setup.py generate_stubs
|
|
- run:
|
|
name: Run Python tests
|
|
command: |
|
|
source env/bin/activate
|
|
LOW_MEMORY=1 DEVICE=cpu python -m xmlrunner discover -v python/tests -o test-results/cpu
|
|
LOW_MEMORY=1 DEVICE=gpu METAL_DEVICE_WRAPPER_TYPE=1 METAL_DEBUG_ERROR_MODE=0 python -m xmlrunner discover -v python/tests -o test-results/gpu
|
|
# TODO: Reenable when extension api becomes stable
|
|
# - run:
|
|
# name: Build example extension
|
|
# command: |
|
|
# cd examples/extensions && python3.11 -m pip install .
|
|
- store_test_results:
|
|
path: test-results
|
|
- run:
|
|
name: Build CPP only
|
|
command: |
|
|
source env/bin/activate
|
|
mkdir -p build && cd build && cmake .. && make -j
|
|
- run:
|
|
name: Run CPP tests
|
|
command: |
|
|
DEVICE=gpu METAL_DEVICE_WRAPPER_TYPE=1 METAL_DEBUG_ERROR_MODE=0 ./build/tests/tests
|
|
DEVICE=cpu ./build/tests/tests
|
|
|
|
build_release:
|
|
parameters:
|
|
python_version:
|
|
type: string
|
|
default: "3.9"
|
|
xcode_version:
|
|
type: string
|
|
default: "15.2.0"
|
|
build_env:
|
|
type: string
|
|
default: ""
|
|
macos:
|
|
xcode: << parameters.xcode_version >>
|
|
resource_class: macos.m1.large.gen1
|
|
steps:
|
|
- checkout
|
|
- run:
|
|
name: Install dependencies
|
|
command: |
|
|
brew install python@<< parameters.python_version >>
|
|
python<< parameters.python_version >> -m venv env
|
|
source env/bin/activate
|
|
pip install --upgrade pip
|
|
pip install --upgrade cmake
|
|
pip install git+https://github.com/wjakob/nanobind.git@4148debcf91f5ccab0c3b8d67b5c3cabd61f407f
|
|
pip install --upgrade setuptools
|
|
pip install numpy
|
|
pip install twine
|
|
pip install build
|
|
- run:
|
|
name: Install Python package
|
|
command: |
|
|
source env/bin/activate
|
|
DEV_RELEASE=1 \
|
|
CMAKE_BUILD_PARALLEL_LEVEL="" \
|
|
pip install . -v
|
|
- run:
|
|
name: Generate package stubs
|
|
command: |
|
|
source env/bin/activate
|
|
python setup.py generate_stubs
|
|
- run:
|
|
name: Build Python package
|
|
command: |
|
|
source env/bin/activate
|
|
<< parameters.build_env >> \
|
|
CMAKE_BUILD_PARALLEL_LEVEL="" \
|
|
python -m build -w
|
|
- when:
|
|
condition: << parameters.build_env >>
|
|
steps:
|
|
- run:
|
|
name: Upload package
|
|
command: |
|
|
source env/bin/activate
|
|
twine upload dist/*
|
|
- store_artifacts:
|
|
path: dist/
|
|
|
|
build_linux_test_release:
|
|
parameters:
|
|
python_version:
|
|
type: string
|
|
default: "3.9"
|
|
extra_env:
|
|
type: string
|
|
default: "DEV_RELEASE=1"
|
|
docker:
|
|
- image: ubuntu:20.04
|
|
steps:
|
|
- checkout
|
|
- run:
|
|
name: Build wheel
|
|
command: |
|
|
PYTHON=python<< parameters.python_version >>
|
|
apt-get update
|
|
apt-get upgrade -y
|
|
DEBIAN_FRONTEND=noninteractive TZ=Etc/UTC apt-get -y install tzdata
|
|
apt-get install -y apt-utils
|
|
apt-get install -y software-properties-common
|
|
add-apt-repository -y ppa:deadsnakes/ppa
|
|
apt-get install -y $PYTHON $PYTHON-dev $PYTHON-full
|
|
apt-get install -y libblas-dev liblapack-dev liblapacke-dev
|
|
apt-get install -y build-essential git
|
|
$PYTHON -m venv env
|
|
source env/bin/activate
|
|
pip install --upgrade pip
|
|
pip install --upgrade cmake
|
|
pip install git+https://github.com/wjakob/nanobind.git@4148debcf91f5ccab0c3b8d67b5c3cabd61f407f
|
|
pip install --upgrade setuptools
|
|
pip install numpy
|
|
pip install auditwheel
|
|
pip install patchelf
|
|
pip install build
|
|
<< parameters.extra_env >> \
|
|
CMAKE_BUILD_PARALLEL_LEVEL="" \
|
|
pip install . -v
|
|
python setup.py generate_stubs
|
|
<< parameters.extra_env >> \
|
|
CMAKE_BUILD_PARALLEL_LEVEL="" \
|
|
python -m build --wheel
|
|
auditwheel show dist/*
|
|
auditwheel repair dist/* --plat manylinux_2_31_x86_64
|
|
- store_artifacts:
|
|
path: wheelhouse/
|
|
|
|
workflows:
|
|
build_and_test:
|
|
when:
|
|
and:
|
|
- matches:
|
|
pattern: "^(?!pull/)[-\\w]+$"
|
|
value: << pipeline.git.branch >>
|
|
- not: << pipeline.parameters.nightly_build >>
|
|
- not: << pipeline.parameters.weekly_build >>
|
|
- not: << pipeline.parameters.test_release >>
|
|
jobs:
|
|
- mac_build_and_test:
|
|
matrix:
|
|
parameters:
|
|
xcode_version: ["15.0.0", "15.2.0"]
|
|
- linux_build_and_test
|
|
|
|
build_pypi_release:
|
|
when:
|
|
and:
|
|
- not: << pipeline.parameters.nightly_build >>
|
|
- not: << pipeline.parameters.weekly_build >>
|
|
- not: << pipeline.parameters.test_release >>
|
|
jobs:
|
|
- build_release:
|
|
filters:
|
|
tags:
|
|
only: /^v.*/
|
|
branches:
|
|
ignore: /.*/
|
|
matrix:
|
|
parameters:
|
|
python_version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
|
|
xcode_version: ["15.0.0", "15.2.0"]
|
|
build_env: ["PYPI_RELEASE=1"]
|
|
prb:
|
|
when:
|
|
matches:
|
|
pattern: "^pull/\\d+(/head)?$"
|
|
value: << pipeline.git.branch >>
|
|
jobs:
|
|
- hold:
|
|
type: approval
|
|
- apple/authenticate:
|
|
context: pr-approval
|
|
- mac_build_and_test:
|
|
requires: [ hold ]
|
|
matrix:
|
|
parameters:
|
|
xcode_version: ["15.0.0", "15.2.0"]
|
|
- linux_build_and_test:
|
|
requires: [ hold ]
|
|
nightly_build:
|
|
when:
|
|
and:
|
|
- equal: [ main, << pipeline.git.branch >> ]
|
|
- << pipeline.parameters.nightly_build >>
|
|
jobs:
|
|
- build_release:
|
|
matrix:
|
|
parameters:
|
|
python_version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
|
|
xcode_version: ["15.0.0", "15.2.0"]
|
|
weekly_build:
|
|
when:
|
|
and:
|
|
- equal: [ main, << pipeline.git.branch >> ]
|
|
- << pipeline.parameters.weekly_build >>
|
|
jobs:
|
|
- build_release:
|
|
matrix:
|
|
parameters:
|
|
python_version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
|
|
xcode_version: ["15.0.0", "15.2.0"]
|
|
build_env: ["DEV_RELEASE=1"]
|
|
linux_test_release:
|
|
when:
|
|
and:
|
|
- equal: [ main, << pipeline.git.branch >> ]
|
|
- << pipeline.parameters.test_release >>
|
|
jobs:
|
|
- build_linux_test_release:
|
|
matrix:
|
|
parameters:
|
|
python_version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
|
|
extra_env: ["PYPI_RELEASE=1"]
|