Skip to content

Commit 28e1165

Browse files
kirklandsignfacebook-github-bot
authored andcommitted
Migrate test-demo-backend-delegation to a separate job (#1078)
Summary: Instead of using test-models and test.sh, we use a separate job, because this job is quite different, and we want to get rid of the hack from the additional arg. See https://github.com/pytorch/executorch/actions/runs/6631141293/job/18014013866?pr=1078 for logs Pull Request resolved: #1078 Reviewed By: huydhn Differential Revision: D50611594 Pulled By: kirklandsign fbshipit-source-id: abcc03dec57484a7c6fb8629214d978d7a6b9067
1 parent 52da169 commit 28e1165

File tree

4 files changed

+79
-36
lines changed

4 files changed

+79
-36
lines changed

.ci/scripts/gather_test_models.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,6 @@ def export_models_for_ci() -> dict[str, dict]:
118118
"model": name,
119119
"backend": backend,
120120
"runner": DEFAULT_RUNNERS.get(target_os, "linux.2xlarge"),
121-
# demo_backend_delegation test only supports add_mul model
122-
"demo_backend_delegation": name == "add_mul",
123121
}
124122

125123
# NB: Some model requires much bigger Linux runner to avoid

.ci/scripts/test.sh

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,6 @@ if [[ -z "${BACKEND:-}" ]]; then
2828
exit 1
2929
fi
3030

31-
DEMO_BACKEND_DELEGATION=$4
32-
if [[ -z "${DEMO_BACKEND_DELEGATION:-}" ]]; then
33-
DEMO_BACKEND_DELEGATION=false
34-
fi
35-
3631
which "${PYTHON_EXECUTABLE}"
3732
# Just set this variable here, it's cheap even if we use buck2
3833
CMAKE_OUTPUT_DIR=cmake-out
@@ -123,30 +118,6 @@ test_model_with_xnnpack() {
123118
fi
124119
}
125120

126-
test_demo_backend_delegation() {
127-
echo "Testing demo backend delegation on AddMul"
128-
"${PYTHON_EXECUTABLE}" -m examples.portable.scripts.export_and_delegate --option "composite"
129-
"${PYTHON_EXECUTABLE}" -m examples.portable.scripts.export_and_delegate --option "partition"
130-
"${PYTHON_EXECUTABLE}" -m examples.portable.scripts.export_and_delegate --option "whole"
131-
132-
# Run test model
133-
if [[ "${BUILD_TOOL}" == "buck2" ]]; then
134-
buck2 run //examples/portable/executor_runner:executor_runner -- --model_path "./composite_model.pte"
135-
buck2 run //examples/portable/executor_runner:executor_runner -- --model_path "./partition_lowered_model.pte"
136-
buck2 run //examples/portable/executor_runner:executor_runner -- --model_path "./whole.pte"
137-
elif [[ "${BUILD_TOOL}" == "cmake" ]]; then
138-
if [[ ! -f ${CMAKE_OUTPUT_DIR}/executor_runner ]]; then
139-
build_cmake_executor_runner
140-
fi
141-
./${CMAKE_OUTPUT_DIR}/executor_runner --model_path "./composite_model.pte"
142-
./${CMAKE_OUTPUT_DIR}/executor_runner --model_path "./partition_lowered_model.pte"
143-
./${CMAKE_OUTPUT_DIR}/executor_runner --model_path "./whole.pte"
144-
else
145-
echo "Invalid build tool ${BUILD_TOOL}. Only buck2 and cmake are supported atm"
146-
exit 1
147-
fi
148-
}
149-
150121
if [[ "${BACKEND}" == "portable" ]]; then
151122
echo "Testing ${MODEL_NAME} with portable kernels..."
152123
test_model
@@ -173,8 +144,3 @@ else
173144
exit 1
174145
fi
175146
fi
176-
177-
# Test demo backend delegation
178-
if [[ "${DEMO_BACKEND_DELEGATION}" == true ]]; then
179-
test_demo_backend_delegation
180-
fi

.github/workflows/trunk.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,30 @@ jobs:
107107
PYTHON_EXECUTABLE=python bash examples/selective_build/test_selective_build.sh "${BUILD_TOOL}"
108108
popd
109109
110+
test-demo-backend-delegation:
111+
name: test-demo-backend-delegation
112+
uses: pytorch/test-infra/.github/workflows/linux_job.yml@main
113+
strategy:
114+
matrix:
115+
include:
116+
- build-tool: buck2
117+
- build-tool: cmake
118+
fail-fast: false
119+
with:
120+
runner: linux.2xlarge
121+
docker-image: executorch-ubuntu-22.04-clang12
122+
submodules: 'true'
123+
ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}
124+
script: |
125+
# The generic Linux job chooses to use base env, not the one setup by the image
126+
CONDA_ENV=$(conda env list --json | jq -r ".envs | .[-1]")
127+
conda activate "${CONDA_ENV}"
128+
129+
BUILD_TOOL=${{ matrix.build-tool }}
130+
PYTHON_EXECUTABLE=python bash .ci/scripts/setup-linux.sh "${BUILD_TOOL}"
131+
# Test selective build
132+
PYTHON_EXECUTABLE=python bash examples/portable/scripts/test_demo_backend_delegation.sh "${BUILD_TOOL}"
133+
110134
test-coreml-delegate:
111135
name: test-coreml-delegate
112136
uses: pytorch/test-infra/.github/workflows/macos_job.yml@main
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+
which "${PYTHON_EXECUTABLE}"
11+
12+
BUILD_TOOL=$1
13+
if [[ -z "${BUILD_TOOL:-}" ]]; then
14+
echo "Missing build tool (require buck2 or cmake), exiting..."
15+
exit 1
16+
fi
17+
18+
CMAKE_OUTPUT_DIR=cmake-out
19+
20+
build_cmake_executor_runner() {
21+
echo "Building executor_runner"
22+
(rm -rf ${CMAKE_OUTPUT_DIR} \
23+
&& mkdir ${CMAKE_OUTPUT_DIR} \
24+
&& cd ${CMAKE_OUTPUT_DIR} \
25+
&& retry cmake -DBUCK2=buck2 \
26+
-DPYTHON_EXECUTABLE="$PYTHON_EXECUTABLE" ..)
27+
28+
cmake --build ${CMAKE_OUTPUT_DIR} -j4
29+
}
30+
31+
test_demo_backend_delegation() {
32+
echo "Testing demo backend delegation on AddMul"
33+
"${PYTHON_EXECUTABLE}" -m examples.portable.scripts.export_and_delegate --option "composite"
34+
"${PYTHON_EXECUTABLE}" -m examples.portable.scripts.export_and_delegate --option "partition"
35+
"${PYTHON_EXECUTABLE}" -m examples.portable.scripts.export_and_delegate --option "whole"
36+
37+
# Run test model
38+
if [[ "${BUILD_TOOL}" == "buck2" ]]; then
39+
buck2 run //examples/portable/executor_runner:executor_runner -- --model_path "./composite_model.pte"
40+
buck2 run //examples/portable/executor_runner:executor_runner -- --model_path "./partition_lowered_model.pte"
41+
buck2 run //examples/portable/executor_runner:executor_runner -- --model_path "./whole.pte"
42+
elif [[ "${BUILD_TOOL}" == "cmake" ]]; then
43+
if [[ ! -f ${CMAKE_OUTPUT_DIR}/executor_runner ]]; then
44+
build_cmake_executor_runner
45+
fi
46+
./${CMAKE_OUTPUT_DIR}/executor_runner --model_path "./composite_model.pte"
47+
./${CMAKE_OUTPUT_DIR}/executor_runner --model_path "./partition_lowered_model.pte"
48+
./${CMAKE_OUTPUT_DIR}/executor_runner --model_path "./whole.pte"
49+
else
50+
echo "Invalid build tool ${BUILD_TOOL}. Only buck2 and cmake are supported atm"
51+
exit 1
52+
fi
53+
}
54+
55+
test_demo_backend_delegation

0 commit comments

Comments
 (0)