Skip to content

Commit ff2dbda

Browse files
committed
Fix golden artifact collisions, error handling, and pytest config path
- Prefix per-model golden zips with flow name to avoid cross-flow filename collisions (e.g. xnnpack_mobilenet_v3_small_golden.zip) - Collect pre-packaged golden zips in workflow instead of flattening raw .pte/.bin files that would overwrite across flows - Wrap _dump_golden_artifacts in try/except so filesystem errors don't fail otherwise-passing correctness tests - Append subtest_index to artifact name for parameterized test variants - Fix /dev/nul typo to /dev/null in pytest config override
1 parent 7038965 commit ff2dbda

4 files changed

Lines changed: 22 additions & 12 deletions

File tree

.ci/scripts/test_backend.sh

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,18 +89,17 @@ GOLDEN_DIR="${ARTIFACT_DIR}/golden-artifacts"
8989
export GOLDEN_ARTIFACTS_DIR="${GOLDEN_DIR}"
9090

9191
EXIT_CODE=0
92-
${CONDA_RUN_CMD} pytest -c /dev/nul -n auto backends/test/suite/$SUITE/ -m flow_$FLOW --json-report --json-report-file="$REPORT_FILE" || EXIT_CODE=$?
92+
${CONDA_RUN_CMD} pytest -c /dev/null -n auto backends/test/suite/$SUITE/ -m flow_$FLOW --json-report --json-report-file="$REPORT_FILE" || EXIT_CODE=$?
9393
# Generate markdown summary.
9494
${CONDA_RUN_CMD} python -m executorch.backends.test.suite.generate_markdown_summary_json "$REPORT_FILE" > ${GITHUB_STEP_SUMMARY:-"step_summary.md"} --exit-code $EXIT_CODE
9595

9696
# Package golden artifacts into per-model zips for downstream consumers.
9797
if [[ -d "${GOLDEN_DIR}/${FLOW}" ]]; then
9898
pushd "${GOLDEN_DIR}/${FLOW}"
99-
# Group files by model name prefix and zip each model's artifacts.
10099
for pte in *.pte; do
101100
[[ -f "$pte" ]] || continue
102101
model_name="${pte%.pte}"
103-
zip -j "${GOLDEN_DIR}/${model_name}_golden.zip" \
102+
zip -j "${GOLDEN_DIR}/${FLOW}_${model_name}_golden.zip" \
104103
"${model_name}.pte" \
105104
${model_name}_input*.bin \
106105
${model_name}_expected_output*.bin \

.github/workflows/_test_backend.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,12 +76,12 @@ jobs:
7676
TIMESTAMP=$(date -u +%y%m%d%H)
7777
mkdir -p golden_combined
7878
79-
find downloaded/ \( -name '*.pte' -o -name '*_input*.bin' -o -name '*_expected_output*.bin' \) \
80-
-exec cp {} golden_combined/ \;
79+
# Collect per-flow golden zips (already namespaced by flow in filename).
80+
find downloaded/ -name '*_golden.zip' -exec cp {} golden_combined/ \;
8181
82-
if ls golden_combined/*.pte 1>/dev/null 2>&1; then
82+
if ls golden_combined/*_golden.zip 1>/dev/null 2>&1; then
8383
(cd golden_combined && zip -r "../golden_artifacts_${TIMESTAMP}.zip" .)
84-
echo "Created golden_artifacts_${TIMESTAMP}.zip with $(ls golden_combined/*.pte | wc -l) models."
84+
echo "Created golden_artifacts_${TIMESTAMP}.zip with $(ls golden_combined/ | wc -l) golden zips."
8585
else
8686
echo "No golden artifacts found."
8787
fi

backends/test/harness/tester.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -352,9 +352,18 @@ def run_method_and_compare_outputs(
352352
)
353353

354354
if artifact_dir and artifact_name and not artifacts_saved:
355-
self._dump_golden_artifacts(
356-
artifact_dir, artifact_name, inputs_to_run, reference_output
357-
)
355+
try:
356+
self._dump_golden_artifacts(
357+
artifact_dir,
358+
artifact_name,
359+
inputs_to_run,
360+
reference_output,
361+
)
362+
except Exception:
363+
logging.getLogger(__name__).warning(
364+
f"Failed to dump golden artifacts for {artifact_name}",
365+
exc_info=True,
366+
)
358367
artifacts_saved = True
359368

360369
return self

backends/test/suite/runner.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -204,10 +204,12 @@ def build_result(
204204
# We can do this if we ever see to_executorch() or serialize() fail due a backend issue.
205205
return build_result(TestResult.UNKNOWN_FAIL, e)
206206

207-
# Derive a clean model name for golden artifacts (e.g. "test_mobilenet_v3_small" -> "mobilenet_v3_small").
208207
artifact_name = None
209208
if artifact_dir:
210-
artifact_name = test_base_name.removeprefix("test_")
209+
base = test_base_name.removeprefix("test_")
210+
artifact_name = (
211+
f"{base}_{subtest_index}" if subtest_index > 0 else base
212+
)
211213

212214
# TODO We should consider refactoring the tester slightly to return more signal on
213215
# the cause of a failure in run_method_and_compare_outputs. We can look for

0 commit comments

Comments
 (0)