Skip to content

Add OSS CI workflow for MacOS M1 #32

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
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
9 changes: 4 additions & 5 deletions .ci/docker/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.

set -ex
set -exu

IMAGE_NAME="$1"
shift
Expand All @@ -17,10 +17,8 @@ OS_VERSION=22.04
CLANG_VERSION=12
PYTHON_VERSION=3.10
MINICONDA_VERSION=23.5.1-0

# TODO: Pin PyTorch version for now until we have the CI in place to update this
# safely
TORCH_VERSION=2.1.0.dev20230731
TORCH_VERSION=$(cat ci_commit_pins/pytorch.txt)
BUCK2_VERSION=$(cat ci_commit_pins/buck2.txt)

docker build \
--no-cache \
Expand All @@ -30,6 +28,7 @@ docker build \
--build-arg "PYTHON_VERSION=${PYTHON_VERSION}" \
--build-arg "MINICONDA_VERSION=${MINICONDA_VERSION}" \
--build-arg "TORCH_VERSION=${TORCH_VERSION}" \
--build-arg "BUCK2_VERSION=${BUCK2_VERSION}" \
-f "${OS}"/Dockerfile \
"$@" \
.
1 change: 1 addition & 0 deletions .ci/docker/ci_commit_pins/buck2.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2023-08-01
1 change: 1 addition & 0 deletions .ci/docker/ci_commit_pins/pytorch.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2.1.0.dev20230731
7 changes: 4 additions & 3 deletions .ci/docker/common/install_buck.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,14 @@ install_ubuntu() {
apt-get update
apt-get install -y zstd

wget -q https://github.com/facebook/buck2/releases/download/2023-07-18/buck2-x86_64-unknown-linux-gnu.zst
zstd -d buck2-x86_64-unknown-linux-gnu.zst -o buck2
BUCK2=buck2-x86_64-unknown-linux-gnu.zst
wget -q "https://github.com/facebook/buck2/releases/download/${BUCK2_VERSION}/${BUCK2}"
zstd -d "${BUCK2}" -o buck2

chmod +x buck2
mv buck2 /usr/bin/

rm buck2-x86_64-unknown-linux-gnu.zst
rm "${BUCK2}"
# Cleanup package manager
apt-get autoclean && apt-get clean
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
Expand Down
2 changes: 2 additions & 0 deletions .ci/docker/requirements-ci.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
mpmath==1.3.0
numpy==1.25.2
PyYAML==6.0.1
ruamel.yaml==0.17.32
sympy==1.12
zstd==1.5.5.1
1 change: 1 addition & 0 deletions .ci/docker/ubuntu/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ COPY ./common/install_clang.sh install_clang.sh
RUN bash ./install_clang.sh && rm install_clang.sh

# Setup buck
ARG BUCK2_VERSION
COPY ./common/install_buck.sh install_buck.sh
RUN bash ./install_buck.sh && rm install_buck.sh

Expand Down
55 changes: 55 additions & 0 deletions .ci/scripts/setup-macos.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#!/bin/bash
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.

set -exu

install_buck() {
if ! command -v zstd &> /dev/null; then
brew install zstd
fi

if ! command -v wget &> /dev/null; then
brew install wget
fi

if ! command -v buck2 &> /dev/null; then
pushd .ci/docker

BUCK2=buck2-aarch64-apple-darwin.zst
BUCK2_VERSION=$(cat ci_commit_pins/buck2.txt)

wget -q "https://github.com/facebook/buck2/releases/download/${BUCK2_VERSION}/${BUCK2}"
zstd -d "${BUCK2}" -o buck2

chmod +x buck2
mv buck2 /opt/homebrew/bin

rm "${BUCK2}"
popd
fi
}

install_conda() {
pushd .ci/docker
# Install conda dependencies like flatbuffer
conda install --file conda-env-ci.txt
popd
}

install_pip_dependencies() {
pushd .ci/docker
# Install all Python dependencies, including PyTorch
pip install --progress-bar off -r requirements-ci.txt

TORCH_VERSION=$(cat ci_commit_pins/pytorch.txt)
pip install --progress-bar off --pre torch=="${TORCH_VERSION}" --index-url https://download.pytorch.org/whl/nightly/cpu
popd
}

install_buck
install_conda
install_pip_dependencies
31 changes: 31 additions & 0 deletions .ci/scripts/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/bin/bash
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.

set -exu

install_executorch() {
which pip
# Install executorch, this assumes that Executorch is checked out in the
# current directory
pip install .
# Just print out the list of packages for debugging
pip list
}

build_and_test_executorch() {
# Build executorch runtime
buck2 build //examples/executor_runner:executor_runner

which python
# Export a test model
python -m examples.export.export_example --model_name="linear"
# Run test model
buck2 run //examples/executor_runner:executor_runner -- --model_path ./linear.pte
}

install_executorch
build_and_test_executorch
33 changes: 21 additions & 12 deletions .github/workflows/pull.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ concurrency:
cancel-in-progress: true

jobs:
buck-build-test:
name: buck-build-test
buck-build-test-linux:
name: buck-build-test-linux
uses: pytorch/test-infra/.github/workflows/linux_job.yml@main
with:
runner: linux.2xlarge
Expand All @@ -27,14 +27,23 @@ jobs:
# here, as it's there in the container
export PATH="/opt/conda/envs/py_${PYTHON_VERSION}/bin:${PATH}"

# Install executorch
pip3 install .
# Just print out the list of packages for debugging
pip3 list
# Build and test Executorch
bash .ci/scripts/test.sh

# Build executorch runtime
buck2 build //examples/executor_runner:executor_runner
# Export a test model
python3 -m examples.export.export_example --model_name="linear"
# Run test model
buck2 run //examples/executor_runner:executor_runner -- --model_path ./linear.pte
buck-build-test-macos:
name: buck-build-test-macos
uses: pytorch/test-infra/.github/workflows/macos_job.yml@main
with:
runner: macos-m1-12
submodules: 'true'
ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}
script: |
WORKSPACE=$(pwd)

pushd "${WORKSPACE}/pytorch/executorch"
# Setup MacOS dependencies as there is no Docker support on MacOS atm
bash .ci/scripts/setup-macos.sh

# Build and test Executorch
bash .ci/scripts/test.sh
popd