Skip to content

Add more sample models to OSS CI #76

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 36 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
9abe1ea
Add more e2e models to OSS CI
huydhn Aug 18, 2023
20098af
Set PYTHON_EXECUTABLE to python
huydhn Aug 18, 2023
1185029
Run cmake model tests on MacOS
huydhn Aug 18, 2023
3f18ec2
Set default python
huydhn Aug 18, 2023
335cc14
Check for unbound variable
huydhn Aug 18, 2023
de98573
Try to add matrix support
huydhn Aug 18, 2023
c617850
Syntax error
huydhn Aug 18, 2023
37d3e57
JSON input
huydhn Aug 18, 2023
70a3729
The YAML looks valid
huydhn Aug 18, 2023
7db30c3
Debug invalid YAML
huydhn Aug 18, 2023
8d12f7d
Debug passing model name
huydhn Aug 18, 2023
64ec005
Debug passing model name
huydhn Aug 18, 2023
5bf8102
Try to reuse binary-matrix param
huydhn Aug 18, 2023
0736a6b
Debug JSON format
huydhn Aug 18, 2023
dade4e9
Use double quote
huydhn Aug 18, 2023
df33e70
Silly me, the example is right there
huydhn Aug 18, 2023
89659e2
Use a fixed list of models (v1)
huydhn Aug 18, 2023
9811290
No need to set binary-matrix
huydhn Aug 18, 2023
a04a539
Remove linear
huydhn Aug 18, 2023
7bceb78
Install torchvision
huydhn Aug 18, 2023
cf4e4d8
Dynamically gather the list of test models
huydhn Aug 18, 2023
740e40f
Fix workflow syntax
huydhn Aug 18, 2023
4caadd4
Fix workflow syntax
huydhn Aug 18, 2023
9368d2f
Run as a linux job
huydhn Aug 18, 2023
08fa8e4
Install executorch
huydhn Aug 18, 2023
a843d6d
Need to use regular job
huydhn Aug 18, 2023
6f43a30
Install executorch
huydhn Aug 18, 2023
66c3a78
Debug GitHub output
huydhn Aug 18, 2023
791f92d
Correctly set the job output
huydhn Aug 18, 2023
b6b6ff5
Merge branch 'main' into add-more-e2d-models-T160762924
huydhn Aug 18, 2023
82089d6
Fix typo
huydhn Aug 18, 2023
3600da2
Install torchaudio
huydhn Aug 18, 2023
f27b84e
Remove fetch-depth 0
huydhn Aug 18, 2023
f2fa004
Add torchaudio to Docker image
huydhn Aug 18, 2023
b5667d5
Fix internal linter comments
huydhn Aug 18, 2023
dd79992
Put nightly suffix in a separate file to be shared by torch/vision/audio
huydhn Aug 19, 2023
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
10 changes: 8 additions & 2 deletions .ci/docker/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,23 @@ OS_VERSION=22.04
CLANG_VERSION=12
PYTHON_VERSION=3.10
MINICONDA_VERSION=23.5.1-0
TORCH_VERSION=$(cat ci_commit_pins/pytorch.txt)
BUCK2_VERSION=$(cat ci_commit_pins/buck2.txt)

NIGHTLY=$(cat ci_commit_pins/nightly.txt)
TORCH_VERSION=$(cat ci_commit_pins/pytorch.txt)
TORCHAUDIO_VERSION=$(cat ci_commit_pins/audio.txt)
TORCHVISION_VERSION=$(cat ci_commit_pins/vision.txt)

docker build \
--no-cache \
--progress=plain \
--build-arg "OS_VERSION=${OS_VERSION}" \
--build-arg "CLANG_VERSION=${CLANG_VERSION}" \
--build-arg "PYTHON_VERSION=${PYTHON_VERSION}" \
--build-arg "MINICONDA_VERSION=${MINICONDA_VERSION}" \
--build-arg "TORCH_VERSION=${TORCH_VERSION}" \
--build-arg "TORCH_VERSION=${TORCH_VERSION}.${NIGHTLY}" \
--build-arg "TORCHAUDIO_VERSION=${TORCHAUDIO_VERSION}.${NIGHTLY}" \
--build-arg "TORCHVISION_VERSION=${TORCHVISION_VERSION}.${NIGHTLY}" \
--build-arg "BUCK2_VERSION=${BUCK2_VERSION}" \
-f "${OS}"/Dockerfile \
"$@" \
Expand Down
1 change: 1 addition & 0 deletions .ci/docker/ci_commit_pins/audio.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2.1.0
1 change: 1 addition & 0 deletions .ci/docker/ci_commit_pins/nightly.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
dev20230813
2 changes: 1 addition & 1 deletion .ci/docker/ci_commit_pins/pytorch.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.1.0.dev20230813
2.1.0
1 change: 1 addition & 0 deletions .ci/docker/ci_commit_pins/vision.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0.16.0
6 changes: 5 additions & 1 deletion .ci/docker/common/install_conda.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,11 @@ install_pip_dependencies() {
pushd /opt/conda
# Install all Python dependencies, including PyTorch
pip_install -r /opt/conda/requirements-ci.txt
pip_install --pre torch=="${TORCH_VERSION}" --index-url https://download.pytorch.org/whl/nightly/cpu
pip_install --pre \
torch=="${TORCH_VERSION}" \
torchaudio=="${TORCHAUDIO_VERSION}" \
torchvision=="${TORCHVISION_VERSION}" \
--index-url https://download.pytorch.org/whl/nightly/cpu
popd
}

Expand Down
2 changes: 2 additions & 0 deletions .ci/docker/ubuntu/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ RUN bash ./install_user.sh && rm install_user.sh
ARG MINICONDA_VERSION
ARG PYTHON_VERSION
ARG TORCH_VERSION
ARG TORCHAUDIO_VERSION
ARG TORCHVISION_VERSION
ENV PYTHON_VERSION=$PYTHON_VERSION
ENV PATH /opt/conda/envs/py_$PYTHON_VERSION/bin:/opt/conda/bin:$PATH
COPY requirements-ci.txt /opt/conda/
Expand Down
39 changes: 39 additions & 0 deletions .ci/scripts/gather_test_models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#!/usr/bin/env python
# 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.

import json
import os
from typing import Any

from examples.models import MODEL_NAME_TO_MODEL


def set_output(name: str, val: Any) -> None:
"""
Set the GitHb output so that it can be accessed by other jobs
"""
print(f"Setting {val} to GitHub output")

if os.getenv("GITHUB_OUTPUT"):
with open(str(os.getenv("GITHUB_OUTPUT")), "a") as env:
print(f"{name}={val}", file=env)
else:
print(f"::set-output name={name}::{val}")


def export_models_for_ci() -> None:
"""
This gathers all the example models that we want to test on GitHub OSS CI
"""
# This is the JSON syntax for configuration matrix used by GitHub
# https://docs.github.com/en/actions/using-jobs/using-a-matrix-for-your-jobs
models = {"include": [{"model": name} for name in MODEL_NAME_TO_MODEL.keys()]}
set_output("models", json.dumps(models))


if __name__ == "__main__":
export_models_for_ci()
20 changes: 3 additions & 17 deletions .ci/scripts/setup-macos.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@

set -exu

# shellcheck source=/dev/null
source "$(dirname "${BASH_SOURCE[0]}")/utils.sh"

install_buck() {
if ! command -v zstd &> /dev/null; then
brew install zstd
Expand All @@ -33,23 +36,6 @@ install_buck() {
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
19 changes: 15 additions & 4 deletions .ci/scripts/test-cmake.sh
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,15 @@ set -exu
# shellcheck source=/dev/null
source "$(dirname "${BASH_SOURCE[0]}")/utils.sh"

MODEL_NAME=$1
if [[ -z "${MODEL_NAME:-}" ]]; then
echo "Missing model name, exiting..."
exit 1
else
echo "Testing ${MODEL_NAME} ..."
fi

test_model() {
MODEL_NAME=$1
python -m examples.export.export_example --model_name="${MODEL_NAME}"

# Run test model
Expand All @@ -24,7 +31,7 @@ build_and_test_executorch() {
rm -rf "${CMAKE_OUTPUT_DIR}" && mkdir "${CMAKE_OUTPUT_DIR}"

pushd "${CMAKE_OUTPUT_DIR}"
cmake -DBUCK2=buck2 ..
cmake -DBUCK2=buck2 -DPYTHON_EXECUTABLE="${PYTHON_EXECUTABLE}" ..
popd

if [ "$(uname)" == "Darwin" ]; then
Expand All @@ -35,9 +42,13 @@ build_and_test_executorch() {
cmake --build "${CMAKE_OUTPUT_DIR}" -j "${CMAKE_JOBS}"

which python
# Test the example linear model
test_model "linear"
# Test the select model
test_model
}

if [[ -z "${PYTHON_EXECUTABLE:-}" ]]; then
PYTHON_EXECUTABLE=python3
fi

install_executorch
build_and_test_executorch
13 changes: 10 additions & 3 deletions .ci/scripts/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,15 @@ set -exu
# shellcheck source=/dev/null
source "$(dirname "${BASH_SOURCE[0]}")/utils.sh"

MODEL_NAME=$1
if [[ -z "${MODEL_NAME:-}" ]]; then
echo "Missing model name, exiting..."
exit 1
else
echo "Testing ${MODEL_NAME} ..."
fi

test_model() {
MODEL_NAME=$1
python -m examples.export.export_example --model_name="${MODEL_NAME}"

# Run test model
Expand All @@ -23,8 +30,8 @@ build_and_test_executorch() {
buck2 build //examples/executor_runner:executor_runner

which python
# Test the example linear model
test_model "linear"
# Test the select model
test_model
}

install_executorch
Expand Down
25 changes: 25 additions & 0 deletions .ci/scripts/utils.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,28 @@ install_executorch() {
# Just print out the list of packages for debugging
pip list
}

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

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

NIGHTLY=$(cat ci_commit_pins/nightly.txt)
TORCH_VERSION=$(cat ci_commit_pins/pytorch.txt)
TORCHAUDIO_VERSION=$(cat ci_commit_pins/audio.txt)
TORCHVISION_VERSION=$(cat ci_commit_pins/vision.txt)

pip install --progress-bar off --pre \
torch=="${TORCH_VERSION}.${NIGHTLY}" \
torchaudio=="${TORCHAUDIO_VERSION}.${NIGHTLY}" \
torchvision=="${TORCHVISION_VERSION}.${NIGHTLY}" \
--index-url https://download.pytorch.org/whl/nightly/cpu
popd || return
}
60 changes: 52 additions & 8 deletions .github/workflows/pull.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,39 @@ concurrency:
cancel-in-progress: true

jobs:
gather-models:
runs-on: ubuntu-22.04
outputs:
models: ${{ steps.gather-models.outputs.models }}
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: '3.10'
cache: pip
- name: Extract the list of models to test
id: gather-models
run: |
set -eux

source .ci/scripts/utils.sh
# This is a simple Python script but as it tries to import executorch.examples.models,
# it requires a whole bunch of Executorch dependencies on the Docker image
install_pip_dependencies
install_executorch

PYTHONPATH="${PWD}" python .ci/scripts/gather_test_models.py

buck-build-test-linux:
name: buck-build-test-linux
uses: pytorch/test-infra/.github/workflows/linux_job.yml@main
needs: gather-models
strategy:
matrix: ${{ fromJSON(needs.gather-models.outputs.models) }}
fail-fast: false
with:
runner: linux.2xlarge
docker-image: executorch-ubuntu-22.04-clang12
fetch-depth: 0
submodules: 'true'
ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}
script: |
Expand All @@ -27,15 +53,20 @@ jobs:
# here, as it's there in the container
export PATH="/opt/conda/envs/py_${PYTHON_VERSION}/bin:${PATH}"

# The name of model we are going to test
MODEL_NAME=${{ matrix.model }}
# Build and test Executorch
bash .ci/scripts/test.sh

bash .ci/scripts/test.sh "${MODEL_NAME}"
# Test custom ops
bash examples/custom_ops/test_custom_ops.sh buck2

buck-build-test-macos:
name: buck-build-test-macos
uses: pytorch/test-infra/.github/workflows/macos_job.yml@main
needs: gather-models
strategy:
matrix: ${{ fromJSON(needs.gather-models.outputs.models) }}
fail-fast: false
with:
runner: macos-m1-12
submodules: 'true'
Expand All @@ -47,20 +78,24 @@ jobs:
# Setup MacOS dependencies as there is no Docker support on MacOS atm
bash .ci/scripts/setup-macos.sh

# The name of model we are going to test
MODEL_NAME=${{ matrix.model }}
# Build and test Executorch
bash .ci/scripts/test.sh

PYTHON_EXECUTABLE=python bash .ci/scripts/test.sh "${MODEL_NAME}"
# Test custom ops
PYTHON_EXECUTABLE=python bash examples/custom_ops/test_custom_ops.sh buck2
popd

cmake-build-test-linux:
name: cmake-build-test-linux
uses: pytorch/test-infra/.github/workflows/linux_job.yml@main
needs: gather-models
strategy:
matrix: ${{ fromJSON(needs.gather-models.outputs.models) }}
fail-fast: false
with:
runner: linux.2xlarge
docker-image: executorch-ubuntu-22.04-clang12
fetch-depth: 0
submodules: 'true'
ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}
script: |
Expand All @@ -69,15 +104,20 @@ jobs:
# here, as it's there in the container
export PATH="/opt/conda/envs/py_${PYTHON_VERSION}/bin:${PATH}"

# The name of model we are going to test
MODEL_NAME=${{ matrix.model }}
# Build and test Executorch
bash .ci/scripts/test-cmake.sh

bash .ci/scripts/test-cmake.sh "${MODEL_NAME}"
# Build and test custom ops
bash examples/custom_ops/test_custom_ops.sh cmake

cmake-build-test-macos:
name: cmake-build-test-macos
uses: pytorch/test-infra/.github/workflows/macos_job.yml@main
needs: gather-models
strategy:
matrix: ${{ fromJSON(needs.gather-models.outputs.models) }}
fail-fast: false
with:
runner: macos-m1-12
submodules: 'true'
Expand All @@ -89,6 +129,10 @@ jobs:
# Setup MacOS dependencies as there is no Docker support on MacOS atm
bash .ci/scripts/setup-macos.sh

# The name of model we are going to test
MODEL_NAME=${{ matrix.model }}
# Build and test Executorch
PYTHON_EXECUTABLE=python bash .ci/scripts/test-cmake.sh "${MODEL_NAME}"
# Build and test custom ops
PYTHON_EXECUTABLE=python bash examples/custom_ops/test_custom_ops.sh cmake
popd