CI change (#645)

* CI update

* Skip large binary test for now

* Upgrade pip

* Add proper env variable skipping

* Update the CI

* Fix workflow name

* Set the low memory flag for the tests

* Change build process

* Add pip upgrade

* Use a venv

* Add a missing env activate

* Add setuptools

* Add twine upload back

* Re-enable automatic release builds
This commit is contained in:
Angelos Katharopoulos 2024-02-07 06:04:34 -08:00 committed by GitHub
parent 146bd69470
commit ea406d5e33
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 62 additions and 151 deletions

View File

@ -57,17 +57,18 @@ jobs:
command: ./build/tests/tests command: ./build/tests/tests
mac_build_and_test: mac_build_and_test:
machine: true macos:
resource_class: ml-explore/m-builder xcode: "15.2.0"
resource_class: macos.m1.large.gen1
steps: steps:
- checkout - checkout
- run: - run:
name: Install dependencies name: Install dependencies
command: | command: |
eval "$(conda shell.bash hook)" brew install python@3.9
rm -r $CONDA_PREFIX/envs/runner-env python3.9 -m venv env
conda create -y -n runner-env python=3.9 source env/bin/activate
conda activate runner-env pip install --upgrade pip
pip install --upgrade cmake pip install --upgrade cmake
pip install --upgrade pybind11[global] pip install --upgrade pybind11[global]
pip install pybind11-stubgen pip install pybind11-stubgen
@ -78,191 +79,94 @@ jobs:
- run: - run:
name: Install Python package name: Install Python package
command: | command: |
eval "$(conda shell.bash hook)" source env/bin/activate
conda activate runner-env CMAKE_BUILD_PARALLEL_LEVEL="" pip install -e . -v
CMAKE_BUILD_PARALLEL_LEVEL="" python setup.py build_ext --inplace
CMAKE_BUILD_PARALLEL_LEVEL="" python setup.py develop
- run: - run:
name: Generate package stubs name: Generate package stubs
command: | command: |
eval "$(conda shell.bash hook)" source env/bin/activate
conda activate runner-env
python setup.py generate_stubs python setup.py generate_stubs
- run: - run:
name: Run Python tests name: Run Python tests
command: | command: |
eval "$(conda shell.bash hook)" source env/bin/activate
conda activate runner-env LOW_MEMORY=1 DEVICE=cpu python -m xmlrunner discover -v python/tests -o test-results/cpu
DEVICE=cpu python -m xmlrunner discover -v python/tests -o test-results/cpu # TODO: Reenable when Circle CI can run gpu jobs
DEVICE=gpu python -m xmlrunner discover -v python/tests -o test-results/gpu # DEVICE=gpu python3.9 -m xmlrunner discover -v python/tests -o test-results/gpu
# TODO: Reenable when extension api becomes stable # TODO: Reenable when extension api becomes stable
# - run: # - run:
# name: Build example extension # name: Build example extension
# command: | # command: |
# eval "$(conda shell.bash hook)" # cd examples/extensions && python3.11 -m pip install .
# conda activate runner-env
# cd examples/extensions && python -m pip install .
- store_test_results: - store_test_results:
path: test-results path: test-results
- run: - run:
name: Build CPP only name: Build CPP only
command: | command: |
source env/bin/activate
mkdir -p build && cd build && cmake .. && make -j mkdir -p build && cd build && cmake .. && make -j
- run: - run:
name: Run CPP tests name: Run CPP tests
command: METAL_DEVICE_WRAPPER_TYPE=1 METAL_DEBUG_ERROR_MODE=0 ./build/tests/tests #command: METAL_DEVICE_WRAPPER_TYPE=1 METAL_DEBUG_ERROR_MODE=0 ./build/tests/tests
command: DEVICE=cpu ./build/tests/tests
build_release: build_release:
machine: true
resource_class: ml-explore/m-builder
parameters: parameters:
python_version: python_version:
type: string type: string
default: "3.9" default: "3.9"
macos_version: xcode_version:
type: string type: string
default: "14" default: "15.2.0"
build_env:
type: string
default: ""
macos:
xcode: << parameters.xcode_version >>
resource_class: macos.m1.large.gen1
steps: steps:
- checkout - checkout
- run: - run:
name: Install dependencies name: Install dependencies
command: | command: |
eval "$(conda shell.bash hook)" brew install python@<< parameters.python_version >>
rm -r $CONDA_PREFIX/envs/runner-env python<< parameters.python_version >> -m venv env
conda create -y -n runner-env python=<< parameters.python_version >> source env/bin/activate
conda activate runner-env pip install --upgrade pip
pip install --upgrade cmake pip install --upgrade cmake
pip install --upgrade pybind11[global] pip install --upgrade pybind11[global]
pip install --upgrade setuptools
pip install pybind11-stubgen pip install pybind11-stubgen
pip install numpy pip install numpy
pip install twine pip install twine
# TODO: Update build system to switch away from setup.py develop pip install build
- run: - run:
name: Install Python package name: Install Python package
command: | command: |
eval "$(conda shell.bash hook)" source env/bin/activate
conda activate runner-env DEV_RELEASE=1 \
DEVELOPER_DIR=$(developer_dir_macos_<< parameters.macos_version >>) \
PYPI_RELEASE=1 \
CMAKE_BUILD_PARALLEL_LEVEL="" \ CMAKE_BUILD_PARALLEL_LEVEL="" \
python setup.py develop pip install . -v
- run: - run:
name: Generate package stubs name: Generate package stubs
command: | command: |
eval "$(conda shell.bash hook)" source env/bin/activate
conda activate runner-env
python setup.py generate_stubs python setup.py generate_stubs
- run: - run:
name: Publish Python package name: Build Python package
command: | command: |
eval "$(conda shell.bash hook)" source env/bin/activate
conda activate runner-env << parameters.build_env >> \
DEVELOPER_DIR=$(developer_dir_macos_<< parameters.macos_version >>) \
PYPI_RELEASE=1 \
CMAKE_BUILD_PARALLEL_LEVEL="" \ CMAKE_BUILD_PARALLEL_LEVEL="" \
python setup.py bdist_wheel python -m build -w
twine upload dist/* --repository mlx - when:
- store_artifacts: condition: << parameters.build_env >>
path: dist/ steps:
- run:
build_dev_release: name: Upload package
machine: true command: |
resource_class: ml-explore/m-builder source env/bin/activate
parameters: twine upload dist/*
python_version:
type: string
default: "3.9"
macos_version:
type: string
default: "14"
steps:
- checkout
- run:
name: Install dependencies
command: |
eval "$(conda shell.bash hook)"
rm -r $CONDA_PREFIX/envs/runner-env
conda create -y -n runner-env python=<< parameters.python_version >>
conda activate runner-env
pip install --upgrade cmake
pip install --upgrade pybind11[global]
pip install pybind11-stubgen
pip install numpy
pip install twine
- run:
name: Install Python package
command: |
eval "$(conda shell.bash hook)"
conda activate runner-env
DEVELOPER_DIR=$(developer_dir_macos_<< parameters.macos_version >>) \
DEV_RELEASE=1 \
CMAKE_BUILD_PARALLEL_LEVEL="" \
python setup.py develop
- run:
name: Generate package stubs
command: |
eval "$(conda shell.bash hook)"
conda activate runner-env
python setup.py generate_stubs
- run:
name: Publish Python package
command: |
eval "$(conda shell.bash hook)"
conda activate runner-env
DEVELOPER_DIR=$(developer_dir_macos_<< parameters.macos_version >>) \
DEV_RELEASE=1 \
CMAKE_BUILD_PARALLEL_LEVEL="" \
python setup.py bdist_wheel
twine upload dist/* --repository mlx
- store_artifacts:
path: dist/
build_package:
machine: true
resource_class: ml-explore/m-builder
parameters:
python_version:
type: string
default: "3.9"
macos_version:
type: string
default: "14"
steps:
- checkout
- run:
name: Install dependencies
command: |
eval "$(conda shell.bash hook)"
rm -r $CONDA_PREFIX/envs/runner-env
conda create -y -n runner-env python=<< parameters.python_version >>
conda activate runner-env
pip install --upgrade cmake
pip install --upgrade pybind11[global]
pip install pybind11-stubgen
pip install numpy
pip install twine
- run:
name: Install Python package
command: |
eval "$(conda shell.bash hook)"
conda activate runner-env
DEVELOPER_DIR=$(developer_dir_macos_<< parameters.macos_version >>) \
CMAKE_BUILD_PARALLEL_LEVEL="" \
python setup.py develop
- run:
name: Generate package stubs
command: |
eval "$(conda shell.bash hook)"
conda activate runner-env
python setup.py generate_stubs
- run:
name: Build package distribution
command: |
eval "$(conda shell.bash hook)"
conda activate runner-env
DEVELOPER_DIR=$(developer_dir_macos_<< parameters.macos_version >>) \
CMAKE_BUILD_PARALLEL_LEVEL="" \
python setup.py bdist_wheel
- store_artifacts: - store_artifacts:
path: dist/ path: dist/
@ -273,8 +177,8 @@ workflows:
- not: << pipeline.parameters.nightly_build >> - not: << pipeline.parameters.nightly_build >>
- not: << pipeline.parameters.weekly_build >> - not: << pipeline.parameters.weekly_build >>
jobs: jobs:
- linux_build_and_test
- mac_build_and_test - mac_build_and_test
- linux_build_and_test
- build_release: - build_release:
filters: filters:
tags: tags:
@ -284,20 +188,22 @@ workflows:
matrix: matrix:
parameters: parameters:
python_version: ["3.8", "3.9", "3.10", "3.11", "3.12"] python_version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
macos_version: ["13", "14"] xcode_version: ["14.3.1", "15.2.0"]
build_env: ["PYPI_RELEASE=1"]
nightly_build: nightly_build:
when: << pipeline.parameters.nightly_build >> when: << pipeline.parameters.nightly_build >>
jobs: jobs:
- build_package: - build_release:
matrix: matrix:
parameters: parameters:
python_version: ["3.8", "3.9", "3.10", "3.11", "3.12"] python_version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
macos_version: ["13", "14"] xcode_version: ["14.3.1", "15.2.0"]
weekly_build: weekly_build:
when: << pipeline.parameters.weekly_build >> when: << pipeline.parameters.weekly_build >>
jobs: jobs:
- build_dev_release: - build_release:
matrix: matrix:
parameters: parameters:
python_version: ["3.8", "3.9", "3.10", "3.11", "3.12"] python_version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
macos_version: ["13", "14"] xcode_version: ["14.3.1", "15.2.0"]
build_env: ["DEV_RELEASE=1"]

View File

@ -1,4 +1,4 @@
include CMakeLists.txt include CMakeLists.txt
recursive-include mlx/ * recursive-include mlx/ *
include python/src/* include python/src/*
python/mlx/py.typed # support type hinting as in PEP-561 include python/mlx/py.typed # support type hinting as in PEP-561

View File

@ -1,6 +1,7 @@
# Copyright © 2023-2024 Apple Inc. # Copyright © 2023-2024 Apple Inc.
import math import math
import os
import unittest import unittest
from itertools import permutations from itertools import permutations
@ -1566,6 +1567,10 @@ class TestOps(mlx_tests.MLXTestCase):
d_np = np.take(b_mx, np.arange(kth), axis=axis) d_np = np.take(b_mx, np.arange(kth), axis=axis)
self.assertTrue(np.all(d_np <= c_mx)) self.assertTrue(np.all(d_np <= c_mx))
@unittest.skipIf(
os.getenv("LOW_MEMORY", None) is not None,
"This test requires a lot of memory",
)
def test_large_binary(self): def test_large_binary(self):
a = mx.ones([1000, 2147484], mx.int8) a = mx.ones([1000, 2147484], mx.int8)
b = mx.ones([2147484], mx.int8) b = mx.ones([2147484], mx.int8)