Skip to content

Commit e3104ff

Browse files
guangy10facebook-github-bot
authored andcommitted
Decouple model e2e tests (#487)
Summary: Pull Request resolved: #487 We should not couple e2e tests with different recipes *(e.g. run with portable kernels, run with xnnpack options)* in a single job. Addressing timeout issue and improving CI stability is one of the reasons, however, even w/o timeout we still want to do it for: 1. Maximal parallelism to reduce waiting time 2. Flexibility to enable/disable an e2e test for a given recipe, e.g. disable slow running e2e test with portable kernels but keep the xnnpack e2e tests enabled, or if there are issue with a flavor 3. Cleaner CI job names to describe what it does Of course this is not real fix of the timeout issue we're facing, the complete fix will include 1) introducing release build for both cmake and buck2 and 2) fixing the slow portable kernels from the root. And both are far away and not possible before MVP. For MVP as we have more and more models enabled with XNNPACK as a part of the out-of-box experience, our CI is facing extra stress. See the [ci dashboard](https://hud.pytorch.org/hud/pytorch/executorch/main). The major motivation in this diff is to ensure the healthiness of enabled models as well as our CI. Reviewed By: huydhn, kirklandsign Differential Revision: D49622665 fbshipit-source-id: 40495d623313287cffc865b7f6b1336788b95d93
1 parent 59d84ee commit e3104ff

File tree

3 files changed

+43
-44
lines changed

3 files changed

+43
-44
lines changed

.ci/scripts/gather_test_models.py

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -49,25 +49,29 @@ def export_models_for_ci() -> None:
4949
# https://docs.github.com/en/actions/using-jobs/using-a-matrix-for-your-jobs
5050
models = {"include": []}
5151
for name in MODEL_NAME_TO_MODEL.keys():
52-
quantization = (
53-
name in MODEL_NAME_TO_OPTIONS and MODEL_NAME_TO_OPTIONS[name].quantization
54-
)
55-
xnnpack_delegation = (
52+
quantization_configs = {
53+
False,
54+
name in MODEL_NAME_TO_OPTIONS and MODEL_NAME_TO_OPTIONS[name].quantization,
55+
}
56+
delegation_configs = {
57+
False,
5658
name in MODEL_NAME_TO_OPTIONS
57-
and MODEL_NAME_TO_OPTIONS[name].xnnpack_delegation
58-
)
59+
and MODEL_NAME_TO_OPTIONS[name].xnnpack_delegation,
60+
}
5961
for build_tool in BUILD_TOOLS:
60-
models["include"].append(
61-
{
62-
"build-tool": build_tool,
63-
"model": name,
64-
"quantization": quantization,
65-
"xnnpack_delegation": xnnpack_delegation,
66-
"runner": RUNNERS.get(name, DEFAULT_RUNNER),
67-
# demo_backend_delegation test only supports add_mul model
68-
"demo_backend_delegation": name == "add_mul",
69-
}
70-
)
62+
for q_config in quantization_configs:
63+
for d_config in delegation_configs:
64+
models["include"].append(
65+
{
66+
"build-tool": build_tool,
67+
"model": name,
68+
"xnnpack_quantization": q_config,
69+
"xnnpack_delegation": d_config,
70+
"runner": RUNNERS.get(name, DEFAULT_RUNNER),
71+
# demo_backend_delegation test only supports add_mul model
72+
"demo_backend_delegation": name == "add_mul",
73+
}
74+
)
7175
set_output("models", json.dumps(models))
7276

7377

.ci/scripts/test.sh

Lines changed: 18 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ if [[ -z "${BUILD_TOOL:-}" ]]; then
2222
exit 1
2323
fi
2424

25-
QUANTIZATION=$3
26-
if [[ -z "${QUANTIZATION:-}" ]]; then
27-
QUANTIZATION=false
25+
XNNPACK_QUANTIZATION=$3
26+
if [[ -z "${XNNPACK_QUANTIZATION:-}" ]]; then
27+
XNNPACK_QUANTIZATION=false
2828
fi
2929

3030
XNNPACK_DELEGATION=$4
@@ -88,6 +88,15 @@ build_cmake_xnn_executor_runner() {
8888

8989
test_model_with_xnnpack() {
9090
WITH_QUANTIZATION=$1
91+
WITH_DELEGATION=$2
92+
93+
# Quantization-only
94+
if [[ ${WITH_QUANTIZATION} == true ]] && [[ ${WITH_DELEGATION} == false ]]; then
95+
bash examples/quantization/test_quantize.sh "${BUILD_TOOL}" "${MODEL_NAME}"
96+
exit 0
97+
fi
98+
99+
# Delegation
91100
if [[ ${WITH_QUANTIZATION} == true ]]; then
92101
SUFFIX="q8"
93102
"${PYTHON_EXECUTABLE}" -m examples.backend.xnnpack_examples --model_name="${MODEL_NAME}" --delegate --quantize
@@ -97,6 +106,7 @@ test_model_with_xnnpack() {
97106
fi
98107

99108
OUTPUT_MODEL_PATH="${MODEL_NAME}_xnnpack_${SUFFIX}.pte"
109+
100110
# Run test model
101111
if [[ "${BUILD_TOOL}" == "buck2" ]]; then
102112
buck2 run //examples/backend:xnn_executor_runner -- --model_path "${OUTPUT_MODEL_PATH}"
@@ -135,27 +145,12 @@ test_demo_backend_delegation() {
135145
fi
136146
}
137147

138-
echo "Testing ${MODEL_NAME} (fp32, quantized, xnnpack) with ${BUILD_TOOL}..."
139-
# Test the select model without XNNPACK or quantization
140-
test_model
141-
142-
# Test quantization
143-
if [[ "${QUANTIZATION}" == true ]]; then
144-
bash examples/quantization/test_quantize.sh "${BUILD_TOOL}" "${MODEL_NAME}"
148+
if [[ "${XNNPACK_DELEGATION}" == false ]] && [[ "${XNNPACK_QUANTIZATION}" == false ]]; then
149+
echo "Testing ${MODEL_NAME} with portable kernels..."
150+
test_model
145151
else
146-
echo "The model ${MODEL_NAME} doesn't support quantization yet"
147-
fi
148-
149-
# Test XNNPACK without quantization
150-
if [[ "${XNNPACK_DELEGATION}" == true ]]; then
151-
test_model_with_xnnpack false
152-
else
153-
echo "The model ${MODEL_NAME} doesn't support XNNPACK yet"
154-
fi
155-
156-
# Test XNNPACK with quantization
157-
if [[ "${XNNPACK_DELEGATION}" == true ]] && [[ "${QUANTIZATION}" == true ]]; then
158-
test_model_with_xnnpack true
152+
echo "Testing ${MODEL_NAME} with XNNPACK quantization=${XNNPACK_QUANTIZATION} delegation=${XNNPACK_DELEGATION}..."
153+
test_model_with_xnnpack "${XNNPACK_QUANTIZATION}" "${XNNPACK_DELEGATION}"
159154
fi
160155

161156
# Test demo backend delegation

.github/workflows/pull.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,13 +57,13 @@ jobs:
5757
5858
MODEL_NAME=${{ matrix.model }}
5959
BUILD_TOOL=${{ matrix.build-tool }}
60-
QUANTIZATION=${{ matrix.quantization }}
60+
XNNPACK_QUANTIZATION=${{ matrix.xnnpack_quantization }}
6161
XNNPACK_DELEGATION=${{ matrix.xnnpack_delegation }}
6262
DEMO_BACKEND_DELEGATION=${{ matrix.demo_backend_delegation }}
6363
6464
PYTHON_EXECUTABLE=python bash .ci/scripts/setup-linux.sh "${BUILD_TOOL}"
6565
# Build and test Executorch
66-
PYTHON_EXECUTABLE=python bash .ci/scripts/test.sh "${MODEL_NAME}" "${BUILD_TOOL}" "${QUANTIZATION}" "${XNNPACK_DELEGATION}" "${DEMO_BACKEND_DELEGATION}"
66+
PYTHON_EXECUTABLE=python bash .ci/scripts/test.sh "${MODEL_NAME}" "${BUILD_TOOL}" "${XNNPACK_QUANTIZATION}" "${XNNPACK_DELEGATION}" "${DEMO_BACKEND_DELEGATION}"
6767
6868
test-models-macos:
6969
name: test-models-macos
@@ -83,14 +83,14 @@ jobs:
8383
8484
MODEL_NAME=${{ matrix.model }}
8585
BUILD_TOOL=${{ matrix.build-tool }}
86-
QUANTIZATION=${{ matrix.quantization }}
86+
XNNPACK_QUANTIZATION=${{ matrix.xnnpack_quantization }}
8787
XNNPACK_DELEGATION=${{ matrix.xnnpack_delegation }}
8888
DEMO_BACKEND_DELEGATION=${{ matrix.demo_backend_delegation }}
8989
9090
# Setup MacOS dependencies as there is no Docker support on MacOS atm
9191
PYTHON_EXECUTABLE=python bash .ci/scripts/setup-macos.sh "${BUILD_TOOL}"
9292
# Build and test Executorch
93-
PYTHON_EXECUTABLE=python bash .ci/scripts/test.sh "${MODEL_NAME}" "${BUILD_TOOL}" "${QUANTIZATION}" "${XNNPACK_DELEGATION}" "${DEMO_BACKEND_DELEGATION}"
93+
PYTHON_EXECUTABLE=python bash .ci/scripts/test.sh "${MODEL_NAME}" "${BUILD_TOOL}" "${XNNPACK_QUANTIZATION}" "${XNNPACK_DELEGATION}" "${DEMO_BACKEND_DELEGATION}"
9494
popd
9595
9696
test-custom-ops-linux:

0 commit comments

Comments
 (0)