Skip to content

Commit f121f28

Browse files
huydhnfacebook-github-bot
authored andcommitted
Add OSS CI workflow for MacOS M1 (#32)
Summary: This builds and runs Executorch on MacOS M1, similar to the Linux x86_64 job Pull Request resolved: #32 Differential Revision: D47929778 Pulled By: huydhn fbshipit-source-id: 77177ce9087351d03aac4c4abccbdabe8189168f
1 parent 4a5e147 commit f121f28

File tree

10 files changed

+121
-21
lines changed

10 files changed

+121
-21
lines changed

.ci/docker/build.sh

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
# This source code is licensed under the BSD-style license found in the
66
# LICENSE file in the root directory of this source tree.
77

8-
set -ex
8+
set -exu
99

1010
IMAGE_NAME="$1"
1111
shift
@@ -17,10 +17,8 @@ OS_VERSION=22.04
1717
CLANG_VERSION=12
1818
PYTHON_VERSION=3.10
1919
MINICONDA_VERSION=23.5.1-0
20-
21-
# TODO: Pin PyTorch version for now until we have the CI in place to update this
22-
# safely
23-
TORCH_VERSION=2.1.0.dev20230731
20+
TORCH_VERSION=$(cat ci_commit_pins/pytorch.txt)
21+
BUCK2_VERSION=$(cat ci_commit_pins/buck2.txt)
2422

2523
docker build \
2624
--no-cache \
@@ -30,6 +28,7 @@ docker build \
3028
--build-arg "PYTHON_VERSION=${PYTHON_VERSION}" \
3129
--build-arg "MINICONDA_VERSION=${MINICONDA_VERSION}" \
3230
--build-arg "TORCH_VERSION=${TORCH_VERSION}" \
31+
--build-arg "BUCK2_VERSION=${BUCK2_VERSION}" \
3332
-f "${OS}"/Dockerfile \
3433
"$@" \
3534
.

.ci/docker/ci_commit_pins/buck2.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
2023-08-01

.ci/docker/ci_commit_pins/pytorch.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
2.1.0.dev20230731

.ci/docker/common/install_buck.sh

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,14 @@ install_ubuntu() {
1111
apt-get update
1212
apt-get install -y zstd
1313

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

1718
chmod +x buck2
1819
mv buck2 /usr/bin/
1920

20-
rm buck2-x86_64-unknown-linux-gnu.zst
21+
rm "${BUCK2}"
2122
# Cleanup package manager
2223
apt-get autoclean && apt-get clean
2324
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

.ci/docker/requirements-ci.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
mpmath==1.3.0
2+
numpy==1.25.2
23
PyYAML==6.0.1
34
ruamel.yaml==0.17.32
45
sympy==1.12
6+
zstd==1.5.5.1

.ci/docker/ubuntu/Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ COPY ./common/install_clang.sh install_clang.sh
1616
RUN bash ./install_clang.sh && rm install_clang.sh
1717

1818
# Setup buck
19+
ARG BUCK2_VERSION
1920
COPY ./common/install_buck.sh install_buck.sh
2021
RUN bash ./install_buck.sh && rm install_buck.sh
2122

.ci/scripts/setup-macos.sh

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
#!/bin/bash
2+
# Copyright (c) Meta Platforms, Inc. and affiliates.
3+
# All rights reserved.
4+
#
5+
# This source code is licensed under the BSD-style license found in the
6+
# LICENSE file in the root directory of this source tree.
7+
8+
set -exu
9+
10+
install_buck() {
11+
if ! command -v zstd &> /dev/null; then
12+
brew install zstd
13+
fi
14+
15+
if ! command -v wget &> /dev/null; then
16+
brew install wget
17+
fi
18+
19+
if ! command -v buck2 &> /dev/null; then
20+
pushd .ci/docker
21+
22+
BUCK2=buck2-aarch64-apple-darwin.zst
23+
BUCK2_VERSION=$(cat ci_commit_pins/buck2.txt)
24+
25+
wget -q "https://github.com/facebook/buck2/releases/download/${BUCK2_VERSION}/${BUCK2}"
26+
zstd -d "${BUCK2}" -o buck2
27+
28+
chmod +x buck2
29+
mv buck2 /opt/homebrew/bin
30+
31+
rm "${BUCK2}"
32+
popd
33+
fi
34+
}
35+
36+
install_conda() {
37+
pushd .ci/docker
38+
# Install conda dependencies like flatbuffer
39+
conda install --file conda-env-ci.txt
40+
popd
41+
}
42+
43+
install_pip_dependencies() {
44+
pushd .ci/docker
45+
# Install all Python dependencies, including PyTorch
46+
pip install --progress-bar off -r requirements-ci.txt
47+
48+
TORCH_VERSION=$(cat ci_commit_pins/pytorch.txt)
49+
pip install --progress-bar off --pre torch=="${TORCH_VERSION}" --index-url https://download.pytorch.org/whl/nightly/cpu
50+
popd
51+
}
52+
53+
install_buck
54+
install_conda
55+
install_pip_dependencies

.ci/scripts/test.sh

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/bin/bash
2+
# Copyright (c) Meta Platforms, Inc. and affiliates.
3+
# All rights reserved.
4+
#
5+
# This source code is licensed under the BSD-style license found in the
6+
# LICENSE file in the root directory of this source tree.
7+
8+
set -exu
9+
10+
install_executorch() {
11+
which pip
12+
# Install executorch, this assumes that Executorch is checked out in the
13+
# current directory
14+
pip install .
15+
# Just print out the list of packages for debugging
16+
pip list
17+
}
18+
19+
build_and_test_executorch() {
20+
# Build executorch runtime
21+
buck2 build //examples/executor_runner:executor_runner
22+
23+
which python
24+
# Export a test model
25+
python -m examples.export.export_example --model_name="linear"
26+
# Run test model
27+
buck2 run //examples/executor_runner:executor_runner -- --model_path ./linear.pte
28+
}
29+
30+
install_executorch
31+
build_and_test_executorch

.github/workflows/pull.yml

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ concurrency:
1212
cancel-in-progress: true
1313

1414
jobs:
15-
buck-build-test:
16-
name: buck-build-test
15+
buck-build-test-linux:
16+
name: buck-build-test-linux
1717
uses: pytorch/test-infra/.github/workflows/linux_job.yml@main
1818
with:
1919
runner: linux.2xlarge
@@ -27,14 +27,23 @@ jobs:
2727
# here, as it's there in the container
2828
export PATH="/opt/conda/envs/py_${PYTHON_VERSION}/bin:${PATH}"
2929
30-
# Install executorch
31-
pip3 install .
32-
# Just print out the list of packages for debugging
33-
pip3 list
30+
# Build and test Executorch
31+
bash .ci/scripts/test.sh
3432
35-
# Build executorch runtime
36-
buck2 build //examples/executor_runner:executor_runner
37-
# Export a test model
38-
python3 -m examples.export.export_example --model_name="linear"
39-
# Run test model
40-
buck2 run //examples/executor_runner:executor_runner -- --model_path ./linear.pte
33+
buck-build-test-macos:
34+
name: buck-build-test-macos
35+
uses: pytorch/test-infra/.github/workflows/macos_job.yml@main
36+
with:
37+
runner: macos-m1-12
38+
submodules: 'true'
39+
ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}
40+
script: |
41+
WORKSPACE=$(pwd)
42+
43+
pushd "${WORKSPACE}/pytorch/executorch"
44+
# Setup MacOS dependencies as there is no Docker support on MacOS atm
45+
bash .ci/scripts/setup-macos.sh
46+
47+
# Build and test Executorch
48+
bash .ci/scripts/test.sh
49+
popd

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
def custom_command():
1717
src_dst_list = [
1818
("schema/scalar_type.fbs", "exir/serialize/scalar_type.fbs"),
19-
("schema/schema.fbs", "exir/serialize/program.fbs"),
19+
("schema/program.fbs", "exir/serialize/program.fbs"),
2020
]
2121
for src, dst in src_dst_list:
2222
print(f"copying from {src} to {dst}")

0 commit comments

Comments
 (0)