Skip to content

Commit 7e1d1a3

Browse files
authored
[Backend Tester] Pick backend test changes onto release/1.0 (#14553)
### Summary This is a manual cherry-pick of backend testing PRs onto release/1.0. As there are a sizable number of key PRs, I've pulled in all changes under `backends/test/suite` via `git checkout upstream/main -- backends/test/suite/` and then manually picked the relevant files under .github/workflows and .ci/scripts. This should be low-risk, as it only affects backend test logic.
1 parent 6071ae9 commit 7e1d1a3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+574
-103
lines changed

.ci/scripts/test_backend_linux.sh

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,17 @@ if [[ "$FLOW" == *qnn* ]]; then
3939
fi
4040

4141
if [[ "$FLOW" == *vulkan* ]]; then
42-
# Setup swiftshader and Vulkan SDK which are required to build the Vulkan delegate
42+
# Setup swiftshader and Vulkan SDK which are required to build the Vulkan delegate.
4343
source .ci/scripts/setup-vulkan-linux-deps.sh
4444

4545
EXTRA_BUILD_ARGS+=" -DEXECUTORCH_BUILD_VULKAN=ON"
4646
fi
4747

48+
if [[ "$FLOW" == *arm* ]]; then
49+
# Setup ARM deps.
50+
.ci/scripts/setup-arm-baremetal-tools.sh
51+
fi
52+
4853
# We need the runner to test the built library.
4954
PYTHON_EXECUTABLE=python CMAKE_ARGS="$EXTRA_BUILD_ARGS" .ci/scripts/setup-linux.sh --build-tool cmake --build-mode Release --editable true
5055

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
name: Test Backend
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
backend:
7+
description: 'Backend to test (xnnpack, coreml, vulkan, qnn)'
8+
required: true
9+
type: string
10+
flows:
11+
description: 'JSON array of flows to test'
12+
required: true
13+
type: string
14+
ref:
15+
description: 'Git ref to checkout'
16+
required: false
17+
type: string
18+
default: ${{ github.sha }}
19+
timeout:
20+
description: 'Job timeout in minutes'
21+
required: false
22+
type: number
23+
default: 120
24+
run-linux:
25+
description: 'Whether to run Linux tests'
26+
required: false
27+
type: boolean
28+
default: false
29+
run-macos:
30+
description: 'Whether to run macOS tests'
31+
required: false
32+
type: boolean
33+
default: false
34+
runner-linux:
35+
description: 'Runner type for Linux jobs'
36+
required: false
37+
type: string
38+
default: linux.4xlarge.memory
39+
40+
jobs:
41+
test-backend-linux:
42+
if: ${{ inputs.run-linux }}
43+
strategy:
44+
fail-fast: false
45+
matrix:
46+
flow: ${{ fromJSON(inputs.flows) }}
47+
suite: [models, operators]
48+
49+
uses: pytorch/test-infra/.github/workflows/linux_job_v2.yml@release/2.9
50+
with:
51+
ref: ${{ inputs.ref }}
52+
runner: ${{ inputs.runner-linux }}
53+
docker-image: ci-image:executorch-ubuntu-22.04-clang12
54+
submodules: recursive
55+
timeout: ${{ inputs.timeout }}
56+
upload-artifact: test-report-${{ matrix.flow }}-${{ matrix.suite }}
57+
script: |
58+
set -eux
59+
60+
source .ci/scripts/test_backend_linux.sh "${{ matrix.suite }}" "${{ matrix.flow }}" "${RUNNER_ARTIFACT_DIR}"
61+
62+
test-backend-macos:
63+
if: ${{ inputs.run-macos }}
64+
strategy:
65+
fail-fast: false
66+
matrix:
67+
flow: ${{ fromJSON(inputs.flows) }}
68+
suite: [models, operators]
69+
70+
uses: pytorch/test-infra/.github/workflows/macos_job.yml@release/2.9
71+
with:
72+
ref: ${{ inputs.ref }}
73+
runner: macos-m1-stable
74+
python-version: "3.12"
75+
submodules: recursive
76+
timeout: ${{ inputs.timeout }}
77+
upload-artifact: test-report-${{ matrix.flow }}-${{ matrix.suite }}
78+
script: |
79+
set -eux
80+
81+
# This is needed to get the prebuilt PyTorch wheel from S3
82+
${CONDA_RUN} --no-capture-output pip install awscli==1.37.21
83+
84+
source .ci/scripts/test_backend_macos.sh "${{ matrix.suite }}" "${{ matrix.flow }}" "${RUNNER_ARTIFACT_DIR}"

.github/workflows/nightly.yml

Lines changed: 1 addition & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ jobs:
2727
repo-name: pytorch
2828
branch: main
2929
pin-folder: .ci/docker/ci_commit_pins
30-
test-infra-ref: release/2.9
30+
test-infra-ref: main
3131
updatebot-token: ${{ secrets.UPDATEBOT_TOKEN }}
3232
pytorchbot-token: ${{ secrets.GH_PYTORCHBOT_TOKEN }}
3333

@@ -36,51 +36,3 @@ jobs:
3636
uses: ./.github/workflows/_link_check.yml
3737
with:
3838
ref: ${{ github.sha }}
39-
40-
backend-test-linux:
41-
uses: pytorch/test-infra/.github/workflows/linux_job_v2.yml@release/2.9
42-
strategy:
43-
fail-fast: false
44-
matrix:
45-
flow: [
46-
qnn, qnn_16a16w, qnn_16a8w, qnn_16a4w, qnn_16a4w_block, qnn_8a8w,
47-
vulkan, vulkan_static_int8_per_channel,
48-
xnnpack, xnnpack_dynamic_int8_per_channel, xnnpack_static_int8_per_channel, xnnpack_static_int8_per_tensor
49-
]
50-
suite: [models, operators]
51-
with:
52-
ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}
53-
runner: linux.4xlarge.memory
54-
docker-image: ci-image:executorch-ubuntu-22.04-clang12
55-
submodules: recursive
56-
timeout: 120
57-
upload-artifact: test-report-${{ matrix.flow }}-${{ matrix.suite }}
58-
script: |
59-
set -eux
60-
61-
source .ci/scripts/test_backend_linux.sh "${{ matrix.suite }}" "${{ matrix.flow }}" "${RUNNER_ARTIFACT_DIR}"
62-
63-
backend-test-macos:
64-
uses: pytorch/test-infra/.github/workflows/macos_job.yml@release/2.9
65-
permissions:
66-
id-token: write
67-
contents: read
68-
strategy:
69-
fail-fast: false
70-
matrix:
71-
flow: [coreml, coreml_static_int8]
72-
suite: [models, operators]
73-
with:
74-
ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}
75-
runner: macos-m1-stable
76-
python-version: 3.12
77-
submodules: recursive
78-
timeout: 120
79-
upload-artifact: test-report-${{ matrix.flow }}-${{ matrix.suite }}
80-
script: |
81-
set -eux
82-
83-
# This is needed to get the prebuilt PyTorch wheel from S3
84-
${CONDA_RUN} --no-capture-output pip install awscli==1.37.21
85-
86-
source .ci/scripts/test_backend_macos.sh "${{ matrix.suite }}" "${{ matrix.flow }}" "${RUNNER_ARTIFACT_DIR}"
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: Test ARM Backend
2+
3+
on:
4+
schedule:
5+
- cron: 0 2 * * *
6+
push:
7+
branches:
8+
- release/*
9+
tags:
10+
- ciflow/nightly/*
11+
pull_request:
12+
paths:
13+
- .github/workflows/test-backend-arm.yml
14+
- .github/workflows/_test_backend.yml
15+
workflow_dispatch:
16+
17+
concurrency:
18+
group: ${{ github.workflow }}--${{ github.event.pull_request.number || github.sha }}-${{ github.event_name == 'workflow_dispatch' }}
19+
cancel-in-progress: true
20+
21+
jobs:
22+
test-arm:
23+
uses: ./.github/workflows/_test_backend.yml
24+
with:
25+
backend: arm
26+
flows: '["arm_tosa"]'
27+
ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}
28+
timeout: 120
29+
run-linux: true
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: Test CoreML Backend
2+
3+
on:
4+
schedule:
5+
- cron: 0 2 * * *
6+
push:
7+
branches:
8+
- release/*
9+
tags:
10+
- ciflow/nightly/*
11+
pull_request:
12+
paths:
13+
- .github/workflows/test-backend-coreml.yml
14+
- .github/workflows/_test_backend.yml
15+
workflow_dispatch:
16+
17+
concurrency:
18+
group: ${{ github.workflow }}--${{ github.event.pull_request.number || github.sha }}-${{ github.event_name == 'workflow_dispatch' }}
19+
cancel-in-progress: true
20+
21+
jobs:
22+
test-coreml:
23+
uses: ./.github/workflows/_test_backend.yml
24+
with:
25+
backend: coreml
26+
flows: '["coreml", "coreml_static_int8"]'
27+
ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}
28+
timeout: 120
29+
run-macos: true
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: Test QNN Backend
2+
3+
on:
4+
schedule:
5+
- cron: 0 2 * * *
6+
push:
7+
branches:
8+
- release/*
9+
tags:
10+
- ciflow/nightly/*
11+
pull_request:
12+
paths:
13+
- .github/workflows/test-backend-qnn.yml
14+
- .github/workflows/_test_backend.yml
15+
workflow_dispatch:
16+
17+
concurrency:
18+
group: ${{ github.workflow }}--${{ github.event.pull_request.number || github.sha }}-${{ github.event_name == 'workflow_dispatch' }}
19+
cancel-in-progress: true
20+
21+
jobs:
22+
test-qnn:
23+
uses: ./.github/workflows/_test_backend.yml
24+
with:
25+
backend: qnn
26+
flows: '["qnn", "qnn_16a16w", "qnn_16a8w", "qnn_16a4w", "qnn_16a4w_block", "qnn_8a8w"]'
27+
ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}
28+
timeout: 120
29+
run-linux: true
30+
runner-linux: linux.8xlarge.memory
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: Test Vulkan Backend
2+
3+
on:
4+
schedule:
5+
- cron: 0 2 * * *
6+
push:
7+
branches:
8+
- release/*
9+
tags:
10+
- ciflow/nightly/*
11+
pull_request:
12+
paths:
13+
- .github/workflows/test-backend-vulkan.yml
14+
- .github/workflows/_test_backend.yml
15+
workflow_dispatch:
16+
17+
concurrency:
18+
group: ${{ github.workflow }}--${{ github.event.pull_request.number || github.sha }}-${{ github.event_name == 'workflow_dispatch' }}
19+
cancel-in-progress: true
20+
21+
jobs:
22+
test-vulkan:
23+
uses: ./.github/workflows/_test_backend.yml
24+
with:
25+
backend: vulkan
26+
flows: '["vulkan", "vulkan_static_int8_per_channel"]'
27+
ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}
28+
timeout: 120
29+
run-linux: true
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: Test XNNPACK Backend
2+
3+
on:
4+
schedule:
5+
- cron: 0 2 * * *
6+
push:
7+
branches:
8+
- release/*
9+
tags:
10+
- ciflow/nightly/*
11+
pull_request:
12+
paths:
13+
- .github/workflows/test-backend-xnnpack.yml
14+
- .github/workflows/_test_backend.yml
15+
workflow_dispatch:
16+
17+
concurrency:
18+
group: ${{ github.workflow }}--${{ github.event.pull_request.number || github.sha }}-${{ github.event_name == 'workflow_dispatch' }}
19+
cancel-in-progress: true
20+
21+
jobs:
22+
test-xnnpack:
23+
uses: ./.github/workflows/_test_backend.yml
24+
with:
25+
backend: xnnpack
26+
flows: '["xnnpack", "xnnpack_dynamic_int8_per_channel", "xnnpack_static_int8_per_channel", "xnnpack_static_int8_per_tensor"]'
27+
ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}
28+
timeout: 120
29+
run-linux: true

backends/test/suite/flow.py

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import logging
22

3-
from dataclasses import dataclass
3+
from dataclasses import dataclass, field
44
from typing import Callable
55

66
from executorch.backends.test.harness import Tester
@@ -35,6 +35,15 @@ class TestFlow:
3535
is_delegated: bool = True
3636
""" Indicates whether the flow is expected to generate CALL_DELEGATE nodes. """
3737

38+
skip_patterns: list[str] = field(default_factory=lambda: [])
39+
""" Tests with names containing any substrings in this list are skipped. """
40+
41+
supports_serialize: bool = True
42+
""" True if the test flow supports the Serialize stage. """
43+
44+
def should_skip_test(self, test_name: str) -> bool:
45+
return any(pattern in test_name for pattern in self.skip_patterns)
46+
3847

3948
def all_flows() -> dict[str, TestFlow]:
4049
flows = []
@@ -109,4 +118,13 @@ def all_flows() -> dict[str, TestFlow]:
109118
except Exception as e:
110119
logger.info(f"Skipping QNN flow registration: {e}")
111120

121+
try:
122+
from executorch.backends.test.suite.flows.arm import ARM_TOSA_FLOW
123+
124+
flows += [
125+
ARM_TOSA_FLOW,
126+
]
127+
except Exception as e:
128+
logger.info(f"Skipping ARM flow registration: {e}")
129+
112130
return {f.name: f for f in flows if f is not None}

backends/test/suite/flows/arm.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
from executorch.backends.arm.test import common
2+
from executorch.backends.arm.test.tester.arm_tester import ArmTester
3+
from executorch.backends.test.suite.flow import TestFlow
4+
5+
6+
def _create_arm_tester_tosa_fp(*args, **kwargs) -> ArmTester:
7+
kwargs["compile_spec"] = common.get_tosa_compile_spec(tosa_spec="TOSA-1.0+FP")
8+
9+
return ArmTester(
10+
*args,
11+
**kwargs,
12+
)
13+
14+
15+
def _create_tosa_flow() -> TestFlow:
16+
return TestFlow(
17+
"arm_tosa",
18+
backend="arm",
19+
tester_factory=_create_arm_tester_tosa_fp,
20+
supports_serialize=False,
21+
)
22+
23+
24+
ARM_TOSA_FLOW = _create_tosa_flow()

0 commit comments

Comments
 (0)