Skip to content

[Backend Tester] Add additional quantized test flows for XNNPACK and Vulkan #13534

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

Merged
merged 327 commits into from
Aug 20, 2025
Merged
Show file tree
Hide file tree
Changes from 250 commits
Commits
Show all changes
327 commits
Select commit Hold shift + click to select a range
b2ab3a5
Update
GregoryComer Aug 8, 2025
c23c3e9
Update
GregoryComer Aug 8, 2025
c99c41a
Update
GregoryComer Aug 9, 2025
bf57d6c
Update
GregoryComer Aug 9, 2025
f261355
Update
GregoryComer Aug 11, 2025
c3a24f9
Update
GregoryComer Aug 11, 2025
1697cbc
Update
GregoryComer Aug 11, 2025
b94b45e
Update
GregoryComer Aug 11, 2025
5740f0a
Update
GregoryComer Aug 11, 2025
ed6840d
Update
GregoryComer Aug 11, 2025
f2a7e1f
Update
GregoryComer Aug 11, 2025
0e162ab
Update
GregoryComer Aug 11, 2025
c6bd56b
Update
GregoryComer Aug 11, 2025
144a8ae
Update
GregoryComer Aug 12, 2025
6f85fc1
Update
GregoryComer Aug 12, 2025
2439022
Update
GregoryComer Aug 12, 2025
bd79ef2
Update
GregoryComer Aug 12, 2025
8932c29
Update
GregoryComer Aug 12, 2025
ea2549c
Update
GregoryComer Aug 12, 2025
ffaa1c3
Update
GregoryComer Aug 12, 2025
bba2fa9
Update
GregoryComer Aug 12, 2025
3a3e026
Update
GregoryComer Aug 12, 2025
2c4488f
Update
GregoryComer Aug 12, 2025
491ec2b
Update
GregoryComer Aug 12, 2025
375b076
Update
GregoryComer Aug 12, 2025
fc1c2a7
Update
GregoryComer Aug 12, 2025
78086b4
Update
GregoryComer Aug 12, 2025
285e058
Update
GregoryComer Aug 12, 2025
cfbc408
Update
GregoryComer Aug 12, 2025
f4b0dc2
Update
GregoryComer Aug 12, 2025
5e92884
Update
GregoryComer Aug 12, 2025
605a0ad
Update
GregoryComer Aug 12, 2025
aa27776
Update
GregoryComer Aug 12, 2025
90ce443
Update
GregoryComer Aug 12, 2025
67f60e4
Update
GregoryComer Aug 12, 2025
1b9315e
Update
GregoryComer Aug 12, 2025
54563ee
Update
GregoryComer Aug 12, 2025
94d89c4
Update
GregoryComer Aug 12, 2025
d79d1a8
Update
GregoryComer Aug 12, 2025
733d4f9
Update
GregoryComer Aug 12, 2025
1e3e79c
Update
GregoryComer Aug 12, 2025
6043952
Update
GregoryComer Aug 12, 2025
8f476ea
Update
GregoryComer Aug 12, 2025
1c136d7
Update
GregoryComer Aug 12, 2025
780519f
Update
GregoryComer Aug 12, 2025
a62c6d0
Update
GregoryComer Aug 12, 2025
7e1a002
Update
GregoryComer Aug 12, 2025
a628d29
Update
GregoryComer Aug 12, 2025
3615d89
Update
GregoryComer Aug 12, 2025
e994bc1
Update
GregoryComer Aug 12, 2025
0aba8e1
Update
GregoryComer Aug 12, 2025
4329bf6
Update
GregoryComer Aug 12, 2025
105aabc
Update
GregoryComer Aug 12, 2025
c1a51ee
Update
GregoryComer Aug 12, 2025
dd30127
Update
GregoryComer Aug 12, 2025
4216805
Update
GregoryComer Aug 12, 2025
092b8d1
Update
GregoryComer Aug 12, 2025
bd786cd
Update
GregoryComer Aug 12, 2025
1d34f49
Update
GregoryComer Aug 12, 2025
933fba2
Update
GregoryComer Aug 12, 2025
d468ae4
Update
GregoryComer Aug 12, 2025
acbd480
Update
GregoryComer Aug 12, 2025
e515bf1
Update
GregoryComer Aug 12, 2025
803db00
Update
GregoryComer Aug 12, 2025
ab18089
Update
GregoryComer Aug 12, 2025
49944fa
Update
GregoryComer Aug 12, 2025
60f3932
Update
GregoryComer Aug 12, 2025
fe201b8
Update
GregoryComer Aug 12, 2025
a807a90
Update
GregoryComer Aug 12, 2025
1897d4e
Update
GregoryComer Aug 12, 2025
f65d80f
Update
GregoryComer Aug 12, 2025
0d1f097
Update
GregoryComer Aug 12, 2025
f0c2490
Update
GregoryComer Aug 12, 2025
0046b02
Update
GregoryComer Aug 12, 2025
32e1029
Update
GregoryComer Aug 12, 2025
f4df9c9
Update
GregoryComer Aug 12, 2025
832cea5
Update
GregoryComer Aug 12, 2025
40819b9
Update
GregoryComer Aug 12, 2025
692f0fa
Update
GregoryComer Aug 12, 2025
871312a
Update
GregoryComer Aug 12, 2025
53990fe
Update
GregoryComer Aug 12, 2025
567d055
Update
GregoryComer Aug 12, 2025
cd998cf
Update
GregoryComer Aug 12, 2025
2a837ab
Update
GregoryComer Aug 12, 2025
51c392a
Update
GregoryComer Aug 12, 2025
f066d46
Update
GregoryComer Aug 12, 2025
ab5415f
Update
GregoryComer Aug 12, 2025
e96c2ef
Update
GregoryComer Aug 12, 2025
31bc137
Update
GregoryComer Aug 12, 2025
dae5d43
Update
GregoryComer Aug 12, 2025
06b5532
Update
GregoryComer Aug 12, 2025
a343abc
Update
GregoryComer Aug 12, 2025
778f7cd
Update
GregoryComer Aug 12, 2025
c19a8ea
Update
GregoryComer Aug 12, 2025
b4a8428
Update
GregoryComer Aug 12, 2025
8aa25c7
Update
GregoryComer Aug 12, 2025
637b8a2
Update
GregoryComer Aug 12, 2025
7141f6c
Update
GregoryComer Aug 12, 2025
4b43363
Update
GregoryComer Aug 12, 2025
88d1dd3
Update
GregoryComer Aug 12, 2025
c583fa1
Update
GregoryComer Aug 12, 2025
7ba2a7f
Update
GregoryComer Aug 12, 2025
e7b7975
Update
GregoryComer Aug 13, 2025
29c1061
Update
GregoryComer Aug 13, 2025
995c4b5
Update
GregoryComer Aug 13, 2025
0fc4475
Update
GregoryComer Aug 13, 2025
1fec71c
Update
GregoryComer Aug 13, 2025
ad8ab13
Update
GregoryComer Aug 13, 2025
f955b94
Update
GregoryComer Aug 13, 2025
765e960
Update
GregoryComer Aug 13, 2025
a3c2dbe
Update
GregoryComer Aug 13, 2025
1008ad4
Update
GregoryComer Aug 13, 2025
e94e9ae
Update
GregoryComer Aug 13, 2025
0225d15
Update
GregoryComer Aug 13, 2025
724e992
Update
GregoryComer Aug 13, 2025
98eee4d
Update
GregoryComer Aug 13, 2025
ad04155
Update
GregoryComer Aug 13, 2025
20574c3
Update
GregoryComer Aug 13, 2025
4fd031e
Update
GregoryComer Aug 13, 2025
a5f702f
Update
GregoryComer Aug 13, 2025
569916c
Update
GregoryComer Aug 13, 2025
8303207
Update
GregoryComer Aug 13, 2025
0a017d0
Update
GregoryComer Aug 13, 2025
b299659
Update
GregoryComer Aug 13, 2025
b7d4b4e
Update
GregoryComer Aug 13, 2025
5a717d5
Update
GregoryComer Aug 13, 2025
5fc71bd
Update
GregoryComer Aug 13, 2025
55cb818
Update
GregoryComer Aug 13, 2025
d19e0db
Update
GregoryComer Aug 13, 2025
b1c89f6
Update
GregoryComer Aug 13, 2025
264fc53
Update
GregoryComer Aug 13, 2025
60b39ed
Update
GregoryComer Aug 13, 2025
8b814bc
Update
GregoryComer Aug 13, 2025
ceb875b
Update
GregoryComer Aug 13, 2025
600cf8a
Update
GregoryComer Aug 13, 2025
6880e0b
Update
GregoryComer Aug 13, 2025
f27ffc1
Update
GregoryComer Aug 14, 2025
6c41bd5
Update
GregoryComer Aug 14, 2025
6ed39c5
Update
GregoryComer Aug 14, 2025
82b83ef
Update
GregoryComer Aug 14, 2025
3b737f6
Update
GregoryComer Aug 14, 2025
871ea46
Update
GregoryComer Aug 14, 2025
f7cfc18
Update
GregoryComer Aug 14, 2025
1a3844c
Update
GregoryComer Aug 14, 2025
d951c8a
Update
GregoryComer Aug 14, 2025
fe7e387
Update
GregoryComer Aug 14, 2025
0dfca3b
Update
GregoryComer Aug 14, 2025
de1ef9a
Update
GregoryComer Aug 14, 2025
70fd984
Update
GregoryComer Aug 14, 2025
482c469
Update
GregoryComer Aug 14, 2025
4d42d47
Update
GregoryComer Aug 15, 2025
8ff7471
Update
GregoryComer Aug 15, 2025
ee716bc
Update
GregoryComer Aug 15, 2025
ac56137
Update
GregoryComer Aug 15, 2025
ad1ddaa
Update
GregoryComer Aug 15, 2025
d3553e1
Update
GregoryComer Aug 15, 2025
85ceee6
Update
GregoryComer Aug 15, 2025
2965ad6
Update
GregoryComer Aug 15, 2025
02c2e14
Update
GregoryComer Aug 15, 2025
5e34ef2
Update
GregoryComer Aug 15, 2025
32a34e3
Update
GregoryComer Aug 15, 2025
5038454
Update
GregoryComer Aug 15, 2025
46152fb
Update
GregoryComer Aug 15, 2025
d76bc1a
Update
GregoryComer Aug 15, 2025
bd5573a
Update
GregoryComer Aug 15, 2025
3f8bc4e
Update
GregoryComer Aug 15, 2025
5abef0c
Update
GregoryComer Aug 15, 2025
f070aa4
Update
GregoryComer Aug 15, 2025
1de7e98
Update
GregoryComer Aug 15, 2025
db6dc2b
Update
GregoryComer Aug 15, 2025
f944c0a
Update
GregoryComer Aug 15, 2025
4d5f1d0
Update
GregoryComer Aug 15, 2025
c986013
Update
GregoryComer Aug 15, 2025
c46aa24
Update
GregoryComer Aug 15, 2025
93a58c6
Update
GregoryComer Aug 15, 2025
e269157
Update
GregoryComer Aug 15, 2025
e1464a8
Update
GregoryComer Aug 15, 2025
d974e4a
Update
GregoryComer Aug 15, 2025
16ec464
Update
GregoryComer Aug 15, 2025
0498ae2
Update
GregoryComer Aug 15, 2025
69eff72
Update
GregoryComer Aug 15, 2025
a9875c5
Update
GregoryComer Aug 15, 2025
e9cb12c
Update
GregoryComer Aug 15, 2025
c519708
Update
GregoryComer Aug 15, 2025
8b8ac05
Update
GregoryComer Aug 15, 2025
33c7e16
Update
GregoryComer Aug 16, 2025
bcb823c
Update
GregoryComer Aug 16, 2025
89d18a2
Update
GregoryComer Aug 16, 2025
a64ed51
Update
GregoryComer Aug 16, 2025
f4785a5
Update
GregoryComer Aug 16, 2025
77d5d14
Update
GregoryComer Aug 16, 2025
8c36fd6
Update
GregoryComer Aug 16, 2025
412f963
Update
GregoryComer Aug 16, 2025
970a530
Update
GregoryComer Aug 17, 2025
6d626f2
Update
GregoryComer Aug 17, 2025
986d9f7
Update
GregoryComer Aug 17, 2025
ff331d1
Update
GregoryComer Aug 17, 2025
83c228a
Update
GregoryComer Aug 17, 2025
017d011
Update
GregoryComer Aug 17, 2025
9370958
Update
GregoryComer Aug 17, 2025
98a6e76
Update
GregoryComer Aug 17, 2025
927d00d
Update
GregoryComer Aug 17, 2025
685f5b5
Update
GregoryComer Aug 17, 2025
52ca00c
Update
GregoryComer Aug 17, 2025
7f15e20
Update
GregoryComer Aug 17, 2025
0cadcf4
Update
GregoryComer Aug 18, 2025
3f064c0
Update
GregoryComer Aug 18, 2025
6bc083c
Update
GregoryComer Aug 18, 2025
66ab2d6
Update
GregoryComer Aug 18, 2025
4639359
Update
GregoryComer Aug 18, 2025
eea49a0
Update
GregoryComer Aug 18, 2025
7293189
Update
GregoryComer Aug 18, 2025
ca2c9b2
Update
GregoryComer Aug 18, 2025
2c25957
Update
GregoryComer Aug 18, 2025
42a664e
Update
GregoryComer Aug 18, 2025
35e5f95
Update
GregoryComer Aug 18, 2025
5c820ba
Update
GregoryComer Aug 19, 2025
7b04d3b
Update
GregoryComer Aug 19, 2025
5cc215e
Update
GregoryComer Aug 19, 2025
ee7bfb3
Update
GregoryComer Aug 19, 2025
014130c
Update
GregoryComer Aug 19, 2025
108a284
Update
GregoryComer Aug 19, 2025
b8daf4e
Update
GregoryComer Aug 19, 2025
2b95d42
Update
GregoryComer Aug 19, 2025
b7f676e
Update
GregoryComer Aug 19, 2025
4457748
Update
GregoryComer Aug 19, 2025
35c56cc
Update
GregoryComer Aug 19, 2025
85d9244
Update
GregoryComer Aug 19, 2025
4dd373e
Update
GregoryComer Aug 19, 2025
6b95ce7
Update
GregoryComer Aug 19, 2025
9d942a3
Update
GregoryComer Aug 19, 2025
219a2aa
Update
GregoryComer Aug 19, 2025
c89a4d9
[Backend Tester] Add QNN test flow to nightly CI (#13468)
GregoryComer Aug 19, 2025
1925b9a
Update
GregoryComer Aug 20, 2025
baabb35
Update
GregoryComer Aug 20, 2025
b601683
Update
GregoryComer Aug 20, 2025
3558f8d
Update
GregoryComer Aug 20, 2025
df9a205
Update
GregoryComer Aug 20, 2025
4530c3e
Update
GregoryComer Aug 20, 2025
f0108aa
Update
GregoryComer Aug 20, 2025
1e0c6e8
Update
GregoryComer Aug 20, 2025
ee39628
Update
GregoryComer Aug 20, 2025
d8e486a
Update
GregoryComer Aug 20, 2025
e345809
Update
GregoryComer Aug 20, 2025
3cc5e63
Update
GregoryComer Aug 20, 2025
33ac51b
Update
GregoryComer Aug 20, 2025
27d6230
Update
GregoryComer Aug 20, 2025
814a262
Update
GregoryComer Aug 20, 2025
62c15f4
Update
GregoryComer Aug 20, 2025
9e604b4
Update
GregoryComer Aug 20, 2025
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
29 changes: 25 additions & 4 deletions .ci/scripts/test_backend_linux.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,34 @@ eval "$(conda shell.bash hook)"
CONDA_ENV=$(conda env list --json | jq -r ".envs | .[-1]")
conda activate "${CONDA_ENV}"

# Setup swiftshader and Vulkan SDK which are required to build the Vulkan delegate
source .ci/scripts/setup-vulkan-linux-deps.sh
export PYTHON_EXECUTABLE=python

# CMake options to use, in addition to the defaults.
EXTRA_BUILD_ARGS="-DEXECUTORCH_BUILD_VULKAN=ON"
EXTRA_BUILD_ARGS=""

if [[ "$FLOW" == *qnn* ]]; then
# Setup QNN sdk and deps - note that this is a bit hacky due to the nature of the
# Qualcomm build. TODO (gjcomer) Clean this up once the QNN pybinding integration is
# cleaned up.
PYTHON_EXECUTABLE=python bash .ci/scripts/setup-linux.sh --build-tool cmake
PYTHON_EXECUTABLE=python bash .ci/scripts/setup-qnn-deps.sh
PYTHON_EXECUTABLE=python bash .ci/scripts/build-qnn-sdk.sh
QNN_X86_LIB_DIR=`realpath build-x86/lib/`
QNN_SDK_ROOT="/tmp/qnn/2.28.0.241029"
export LD_LIBRARY_PATH"=$QNN_X86_LIB_DIR:$QNN_SDK_ROOT/lib/x86_64-linux-clang/:${LD_LIBRARY_PATH:-}"

# TODO Get SDK root from install scripts
EXTRA_BUILD_ARGS+=" -DEXECUTORCH_BUILD_QNN=ON -DQNN_SDK_ROOT=$QNN_SDK_ROOT"
fi

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

EXTRA_BUILD_ARGS+=" -DEXECUTORCH_BUILD_VULKAN=ON"
fi

# We need the runner to test the built library.
PYTHON_EXECUTABLE=python CMAKE_ARGS="$EXTRA_BUILD_ARGS" .ci/scripts/setup-linux.sh --build-tool cmake --build-mode Release
PYTHON_EXECUTABLE=python CMAKE_ARGS="$EXTRA_BUILD_ARGS" .ci/scripts/setup-linux.sh --build-tool cmake --build-mode Release --editable true

python -m executorch.backends.test.suite.runner $SUITE --flow $FLOW --report "$ARTIFACT_DIR/test_results.csv"
6 changes: 5 additions & 1 deletion .github/workflows/nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,11 @@ jobs:
strategy:
fail-fast: false
matrix:
flow: [vulkan, xnnpack, xnnpack_static_int8_per_channel]
flow: [
qnn, qnn_16a16w, qnn_16a8w, qnn_16a4w, qnn_16a4w_block, qnn_8a8w,
vulkan, vulkan_static_int8_per_channel,
xnnpack, xnnpack_dynamic_int8_per_channel, xnnpack_static_int8_per_channel, xnnpack_static_int8_per_tensor
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no groupwise 4b? I am ok for now, just checking if you run into something or just low prio for now.

Copy link
Member Author

@GregoryComer GregoryComer Aug 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I intend to add that. I was planning to confirm with @metascroy which AO API is recommended and update the XNNPACK delegate docs, as well.

]
suite: [models, operators]
with:
ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}
Expand Down
4 changes: 4 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -817,6 +817,10 @@ if(EXECUTORCH_BUILD_PYBIND)
list(APPEND _dep_libs openvino_backend)
endif()

if(EXECUTORCH_BUILD_QNN)
list(APPEND _dep_libs qnn_executorch_backend)
endif()

if(EXECUTORCH_BUILD_XNNPACK)
# need to explicitly specify XNNPACK and xnnpack-microkernels-prod here
# otherwise uses XNNPACK and microkernel-prod symbols from libtorch_cpu
Expand Down
10 changes: 5 additions & 5 deletions backends/qualcomm/scripts/install_qnn_sdk.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ source "${SCRIPT_DIR}/qnn_config.sh"
# Function to install Android NDK (only if not already set)
setup_android_ndk() {
# Check if ANDROID_NDK_ROOT is already set and valid
if [ -n "${ANDROID_NDK_ROOT}" ] && [ -d "${ANDROID_NDK_ROOT}" ]; then
if [ -n "${ANDROID_NDK_ROOT:-}" ] && [ -d "${ANDROID_NDK_ROOT:-}" ]; then
echo "Android NDK already set to ${ANDROID_NDK_ROOT} - skipping installation"
return
fi
Expand Down Expand Up @@ -41,7 +41,7 @@ verify_pkg_installed() {

install_qnn() {
# Check if QNN_SDK_ROOT is already set and valid
if [ -n "${QNN_SDK_ROOT}" ] && [ -d "${QNN_SDK_ROOT}" ]; then
if [ -n "${QNN_SDK_ROOT:-}" ] && [ -d "${QNN_SDK_ROOT:-}" ]; then
echo "QNN SDK already set to ${QNN_SDK_ROOT} - skipping installation"
return
fi
Expand Down Expand Up @@ -141,9 +141,9 @@ setup_libcpp() {
popd >/dev/null

# Set environment variables
export CPLUS_INCLUDE_PATH="${INSTALL_DIR}/include:$CPLUS_INCLUDE_PATH"
export LD_LIBRARY_PATH="${INSTALL_DIR}/lib:$LD_LIBRARY_PATH"
export LIBRARY_PATH="${INSTALL_DIR}/lib:$LIBRARY_PATH"
export CPLUS_INCLUDE_PATH="${INSTALL_DIR}/include:${CPLUS_INCLUDE_PATH:-}"
export LD_LIBRARY_PATH="${INSTALL_DIR}/lib:${LD_LIBRARY_PATH:-}"
export LIBRARY_PATH="${INSTALL_DIR}/lib:${LIBRARY_PATH:-}"

echo "libc++ installed to ${INSTALL_DIR}"
}
Expand Down
45 changes: 36 additions & 9 deletions backends/qualcomm/tests/tester.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.

from typing import Any, List, Optional, Tuple
from typing import Any, List, Optional, Sequence, Tuple

import executorch
import executorch.backends.test.harness.stages as BaseStages

import torch
from executorch.backends.qualcomm._passes.qnn_pass_manager import QnnPassManager
from executorch.backends.qualcomm.partition.qnn_partitioner import QnnPartitioner
from executorch.backends.qualcomm.quantizer.quantizer import QnnQuantizer
from executorch.backends.qualcomm.utils.utils import (
generate_htp_compiler_spec,
generate_qnn_executorch_compiler_spec,
Expand All @@ -21,9 +22,32 @@
from executorch.backends.test.harness.stages import StageType
from executorch.exir import EdgeCompileConfig, to_edge_transform_and_lower
from executorch.exir.backend.partitioner import Partitioner
from torch.ao.quantization.quantize_pt2e import (
convert_pt2e,
prepare_pt2e,
prepare_qat_pt2e,
)
from torch.export import ExportedProgram


class Quantize(BaseStages.Quantize):
def __init__(
self,
quantizer: QnnQuantizer,
quantization_config: Optional[Any] = None,
calibrate: bool = True,
calibration_samples: Optional[Sequence[Any]] = None,
is_qat: Optional[bool] = False,
):
super().__init__(
quantizer=quantizer,
calibrate=calibrate,
calibration_samples=calibration_samples,
is_qat=is_qat,
set_global=False,
)


class Partition(BaseStages.Partition):
def __init__(self, partitioner: Optional[Partitioner] = None):
super().__init__(
Expand All @@ -37,8 +61,9 @@ def __init__(
partitioners: Optional[List[Partitioner]] = None,
edge_compile_config: Optional[EdgeCompileConfig] = None,
soc_model: str = "SM8650",
use_fp16: bool = True,
):
backend_options = generate_htp_compiler_spec(use_fp16=True)
backend_options = generate_htp_compiler_spec(use_fp16=use_fp16)
self.chipset = get_soc_to_chipset_map()[soc_model]
self.compiler_specs = generate_qnn_executorch_compiler_spec(
soc_model=self.chipset,
Expand Down Expand Up @@ -73,15 +98,17 @@ def __init__(
module: torch.nn.Module,
example_inputs: Tuple[torch.Tensor],
dynamic_shapes: Optional[Tuple[Any]] = None,
use_fp16: bool = True,
):
def create_to_edge_transform_and_lower(*args, **kwargs):
kwargs["use_fp16"] = use_fp16
return ToEdgeTransformAndLower(*args, **kwargs)

# Specialize for Qualcomm
stage_classes = (
executorch.backends.test.harness.Tester.default_stage_classes()
| {
StageType.PARTITION: Partition,
StageType.TO_EDGE_TRANSFORM_AND_LOWER: ToEdgeTransformAndLower,
}
)
stage_classes = executorch.backends.test.harness.Tester.default_stage_classes() | {
StageType.PARTITION: Partition,
StageType.TO_EDGE_TRANSFORM_AND_LOWER: create_to_edge_transform_and_lower,
}

super().__init__(
module=module,
Expand Down
28 changes: 24 additions & 4 deletions backends/test/suite/flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,17 @@ def all_flows() -> dict[str, TestFlow]:

try:
from executorch.backends.test.suite.flows.xnnpack import (
XNNPACK_DYNAMIC_INT8_PER_CHANNEL_TEST_FLOW,
XNNPACK_STATIC_INT8_PER_CHANNEL_TEST_FLOW,
XNNPACK_STATIC_INT8_PER_TENSOR_TEST_FLOW,
XNNPACK_TEST_FLOW,
)

flows += [
XNNPACK_TEST_FLOW,
XNNPACK_DYNAMIC_INT8_PER_CHANNEL_TEST_FLOW,
XNNPACK_STATIC_INT8_PER_CHANNEL_TEST_FLOW,
XNNPACK_STATIC_INT8_PER_TENSOR_TEST_FLOW,
]
except Exception as e:
logger.info(f"Skipping XNNPACK flow registration: {e}")
Expand All @@ -72,21 +76,37 @@ def all_flows() -> dict[str, TestFlow]:
logger.info(f"Skipping Core ML flow registration: {e}")

try:
from executorch.backends.test.suite.flows.vulkan import VULKAN_TEST_FLOW
from executorch.backends.test.suite.flows.vulkan import (
VULKAN_STATIC_INT8_PER_CHANNEL_TEST_FLOW,
VULKAN_TEST_FLOW,
)

flows += [
VULKAN_TEST_FLOW,
VULKAN_STATIC_INT8_PER_CHANNEL_TEST_FLOW,
]
except Exception as e:
logger.info(f"Skipping Vulkan flow registration: {e}")

try:
from executorch.backends.test.suite.flows.qualcomm import QUALCOMM_TEST_FLOW
from executorch.backends.test.suite.flows.qualcomm import (
QNN_16A16W_TEST_FLOW,
QNN_16A4W_BLOCK_TEST_FLOW,
QNN_16A4W_TEST_FLOW,
QNN_16A8W_TEST_FLOW,
QNN_8A8W_TEST_FLOW,
QNN_TEST_FLOW,
)

flows += [
QUALCOMM_TEST_FLOW,
QNN_TEST_FLOW,
QNN_16A16W_TEST_FLOW,
QNN_16A8W_TEST_FLOW,
QNN_16A4W_TEST_FLOW,
QNN_16A4W_BLOCK_TEST_FLOW,
QNN_8A8W_TEST_FLOW,
]
except Exception as e:
logger.info(f"Skipping Qualcomm flow registration: {e}")
logger.info(f"Skipping QNN flow registration: {e}")

return {f.name: f for f in flows if f is not None}
52 changes: 48 additions & 4 deletions backends/test/suite/flows/qualcomm.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,61 @@
from executorch.backends.qualcomm.tests.tester import QualcommTester
from executorch.backends.qualcomm.quantizer.quantizer import QnnQuantizer, QuantDtype
from executorch.backends.qualcomm.tests.tester import QualcommTester, Quantize
from executorch.backends.test.suite.flow import TestFlow
from torchao.quantization.pt2e import MovingAverageMinMaxObserver


def _create_qualcomm_flow(
def _create_qnn_flow(
name: str,
quantize: bool = False,
quant_dtype: QuantDtype | None = None,
per_channel_conv=True,
per_channel_linear=False,
is_qat=False,
use_fp16=True,
) -> TestFlow:
if quantize and quant_dtype is None:
raise RuntimeError("Quant dtype must be provided when quantize is true.")

def create_tester(*args, **kwargs) -> QualcommTester:
kwargs["use_fp16"] = (use_fp16,)
return QualcommTester(*args, **kwargs)

def create_quantize_stage() -> Quantize:
quantizer = QnnQuantizer()
quantizer.set_default_quant_config(
quant_dtype,
is_qat=is_qat,
is_conv_per_channel=per_channel_conv,
is_linear_per_channel=per_channel_linear,
act_observer=MovingAverageMinMaxObserver,
)
return Quantize(quantizer=quantizer)

return TestFlow(
name,
backend="qualcomm",
tester_factory=QualcommTester,
tester_factory=create_tester,
quantize=quantize,
quantize_stage_factory=create_quantize_stage if quantize else None,
)


QUALCOMM_TEST_FLOW = _create_qualcomm_flow("qualcomm")
QNN_TEST_FLOW = _create_qnn_flow("qnn")
QNN_16A16W_TEST_FLOW = _create_qnn_flow(
"qnn_16a16w", quantize=True, quant_dtype=QuantDtype.use_8a8w, use_fp16=False
)
QNN_16A8W_TEST_FLOW = _create_qnn_flow(
"qnn_16a8w", quantize=True, quant_dtype=QuantDtype.use_16a8w, use_fp16=False
)
QNN_16A4W_TEST_FLOW = _create_qnn_flow(
"qnn_16a4w", quantize=True, quant_dtype=QuantDtype.use_16a4w, use_fp16=False
)
QNN_16A4W_BLOCK_TEST_FLOW = _create_qnn_flow(
"qnn_16a4w_block",
quantize=True,
quant_dtype=QuantDtype.use_8a8w,
use_fp16=False,
)
QNN_8A8W_TEST_FLOW = _create_qnn_flow(
"qnn_8a8w", quantize=True, quant_dtype=QuantDtype.use_8a8w, use_fp16=False
)
38 changes: 32 additions & 6 deletions backends/test/suite/flows/vulkan.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,43 @@
from typing import Callable

from executorch.backends.test.harness.stages import Quantize
from executorch.backends.test.suite.flow import TestFlow
from executorch.backends.vulkan.test.tester import VulkanTester
from executorch.backends.vulkan.quantizer.vulkan_quantizer import (
get_symmetric_quantization_config as get_symmetric_quantization_config_vulkan,
)
from executorch.backends.vulkan.test.tester import (
Quantize as VulkanQuantize,
VulkanTester,
)


def _create_vulkan_flow(
name: str,
quantize: bool = False,
def _create_vulkan_flow_base(
name: str, quantize_stage_factory: Callable[..., Quantize] | None = None
) -> TestFlow:
return TestFlow(
name,
backend="vulkan",
tester_factory=VulkanTester,
quantize=quantize,
quantize=quantize_stage_factory is not None,
quantize_stage_factory=quantize_stage_factory,
)


def _create_vulkan_flow() -> TestFlow:
return _create_vulkan_flow_base("vulkan")


def _create_vulkan_static_int8_per_channel_flow() -> TestFlow:
def create_quantize_stage() -> Quantize:
qparams = get_symmetric_quantization_config_vulkan()
return VulkanQuantize(
quantization_config=qparams,
)

return _create_vulkan_flow_base(
"vulkan_static_int8_per_channel", create_quantize_stage
)


VULKAN_TEST_FLOW = _create_vulkan_flow("vulkan")
VULKAN_TEST_FLOW = _create_vulkan_flow()
VULKAN_STATIC_INT8_PER_CHANNEL_TEST_FLOW = _create_vulkan_static_int8_per_channel_flow()
Loading
Loading