Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
86 changes: 84 additions & 2 deletions .github/workflows/pull.yml
Original file line number Diff line number Diff line change
Expand Up @@ -674,6 +674,40 @@ jobs:
build-tool: buck2
docker-image: ci-image:executorch-ubuntu-22.04-clang12

test-qnn-buck-build-linux:
name: test-qnn-buck-build-linux
uses: pytorch/test-infra/.github/workflows/linux_job_v2.yml@main
permissions:
id-token: write
contents: read
strategy:
fail-fast: false
with:
runner: linux.2xlarge
docker-image: ci-image:executorch-ubuntu-22.04-qnn-sdk
submodules: 'recursive'
ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}
timeout: 90
script: |
set -eux

CONDA_ENV=$(conda env list --json | jq -r ".envs | .[-1]")
conda activate "${CONDA_ENV}"

# Download QNN SDK and get the path
QNN_SDK_ROOT=$(python3 backends/qualcomm/scripts/download_qnn_sdk.py --print-sdk-path)
echo "QNN_SDK_ROOT=${QNN_SDK_ROOT}"

# Configure Buck to find the QNN SDK
echo "[qualcomm]" >> .buckconfig
echo " qnn_sdk_root = ${QNN_SDK_ROOT}" >> .buckconfig

# Setup buck2
PYTHON_EXECUTABLE=python bash .ci/scripts/setup-linux.sh --build-tool buck2

# Build QNN backend with Buck
buck2 build //backends/qualcomm/...

unittest-arm-backend-with-no-deps:
name: unittest-arm-backend-with-no-deps
uses: pytorch/test-infra/.github/workflows/linux_job_v2.yml@main
Expand Down Expand Up @@ -823,6 +857,8 @@ jobs:
id-token: write
contents: read
strategy:
matrix:
model: [mv2, mv3, dl3]
fail-fast: false
with:
runner: linux.2xlarge
Expand All @@ -834,9 +870,55 @@ jobs:
# The generic Linux job chooses to use base env, not the one setup by the image
CONDA_ENV=$(conda env list --json | jq -r ".envs | .[-1]")
conda activate "${CONDA_ENV}"
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
PYTHON_EXECUTABLE=python bash .ci/scripts/test_model.sh ${{ matrix.model }} "cmake" "qnn"

test-qnn-testsuite-linux:
name: test-qnn-testsuite-linux
permissions:
id-token: write
contents: read
uses: ./.github/workflows/_test_backend.yml
with:
backend: qnn
flows: '["qnn"]'
ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}
timeout: 120
run-linux: true
runner-linux: linux.2xlarge

test-qnn-passes-linux:
name: test-qnn-passes-linux
uses: pytorch/test-infra/.github/workflows/linux_job_v2.yml@main
permissions:
id-token: write
contents: read
strategy:
fail-fast: false
with:
runner: linux.2xlarge
docker-image: ci-image:executorch-ubuntu-22.04-qnn-sdk
submodules: 'recursive'
ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}
timeout: 30
script: |
# The generic Linux job chooses to use base env, not the one setup by the image
CONDA_ENV=$(conda env list --json | jq -r ".envs | .[-1]")
conda activate "${CONDA_ENV}"

PYTHON_EXECUTABLE=python bash .ci/scripts/setup-qnn-deps.sh
# Source (not bash) so QNN_SDK_ROOT stays in the environment
PYTHON_EXECUTABLE=python source .ci/scripts/build-qnn-sdk.sh

# Editable install so the PyQnnManagerAdaptor .so built by build-qnn-sdk.sh
# is visible in the source tree (the _passes import chain pulls it in transitively)
CMAKE_ARGS="-DEXECUTORCH_BUILD_QNN=ON -DQNN_SDK_ROOT=$QNN_SDK_ROOT" \
PYTHON_EXECUTABLE=python bash .ci/scripts/setup-linux.sh --build-tool cmake --editable true

# placeholder for running test_qnn_delegate.py, can use matrix such that we can trigger different jobs, refers to test-llama-runner-qnn-linux
# reminder: make sure each job runs fast
# Run QNN pass unit tests
pytest -xvs backends/qualcomm/tests/test_passes.py

test-phi-3-mini-runner-linux:
name: test-phi-3-mini-runner-linux
Expand Down
18 changes: 8 additions & 10 deletions backends/qualcomm/aot/python/targets.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ load(
"CXX",
)
load("@fbsource//xplat/executorch/build:runtime_wrapper.bzl", "runtime")
load("@fbsource//xplat/executorch/backends/qualcomm/qnn_version.bzl", "get_qnn_library_version")
load("@fbsource//xplat/executorch/backends/qualcomm/third-party:third_party_libs.bzl", "qnn_third_party_dep")

PYTHON_MODULE_NAME = "PyQnnManagerAdaptor"

Expand Down Expand Up @@ -32,17 +32,15 @@ def define_common_targets():
"//executorch/backends/qualcomm/runtime:logging",
"//executorch/backends/qualcomm:schema",
"//executorch/backends/qualcomm/runtime:runtime",
"fbsource//third-party/pybind11:pybind11",
"fbsource//third-party/qualcomm/qnn/qnn-{0}:api".format(get_qnn_library_version()),
"fbsource//third-party/qualcomm/qnn/qnn-{0}:app_sources".format(get_qnn_library_version()),
qnn_third_party_dep("api"),
qnn_third_party_dep("app_sources"),
qnn_third_party_dep("pybind11"),
],
external_deps = [
"libtorch_python",
],
use_static_deps = True,
visibility = [
"//executorch/backends/qualcomm/...",
],
visibility = ["PUBLIC"],
)


Expand All @@ -61,8 +59,8 @@ def define_common_targets():
"//executorch/backends/qualcomm/runtime:logging",
"//executorch/backends/qualcomm:schema",
"//executorch/backends/qualcomm/runtime:runtime",
"fbsource//third-party/pybind11:pybind11",
"fbsource//third-party/qualcomm/qnn/qnn-{0}:api".format(get_qnn_library_version()),
"fbsource//third-party/qualcomm/qnn/qnn-{0}:app_sources".format(get_qnn_library_version()),
qnn_third_party_dep("api"),
qnn_third_party_dep("app_sources"),
qnn_third_party_dep("pybind11"),
],
)
6 changes: 3 additions & 3 deletions backends/qualcomm/aot/wrappers/targets.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ load(
"ANDROID",
)
load("@fbsource//xplat/executorch/build:runtime_wrapper.bzl", "runtime")
load("@fbsource//xplat/executorch/backends/qualcomm/qnn_version.bzl", "get_qnn_library_version")
load("@fbsource//xplat/executorch/backends/qualcomm/third-party:third_party_libs.bzl", "qnn_third_party_dep")

def define_common_targets():
"""Defines targets that should be shared between fbcode and xplat.
Expand All @@ -23,8 +23,8 @@ def define_common_targets():
platforms = [ANDROID],
visibility = ["PUBLIC"],
deps = [
"fbsource//third-party/qualcomm/qnn/qnn-{0}:api".format(get_qnn_library_version()),
"fbsource//third-party/qualcomm/qnn/qnn-{0}:app_sources".format(get_qnn_library_version()),
qnn_third_party_dep("api"),
qnn_third_party_dep("app_sources"),
"//executorch/runtime/backend:interface",
"//executorch/runtime/core:core",
],
Expand Down
6 changes: 3 additions & 3 deletions backends/qualcomm/recipes/BUCK
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@ fbcode_target(_kind = runtime.python_library,
],
visibility = ["PUBLIC"],
deps = [
"//caffe2:torch",
"//executorch/export:lib",
"//executorch/runtime:runtime", # @manual
"//executorch/backends/qualcomm/partition:partition",
"//executorch/backends/qualcomm/serialization:serialization",
"//executorch/backends/qualcomm/utils:utils",
"//executorch/backends/qualcomm/_passes:passes",
":qnn_recipe_types",
],
] + ([] if runtime.is_oss else [
"//executorch/runtime:runtime", # @manual
]),
)

fbcode_target(_kind = runtime.python_library,
Expand Down
14 changes: 7 additions & 7 deletions backends/qualcomm/runtime/targets.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ load(
"ANDROID",
)
load("@fbsource//xplat/executorch/build:runtime_wrapper.bzl", "runtime")
load("@fbsource//xplat/executorch/backends/qualcomm/qnn_version.bzl", "get_qnn_library_version")
load("@fbsource//xplat/executorch/backends/qualcomm/third-party:third_party_libs.bzl", "qnn_third_party_dep")

def define_common_targets():
"""Defines targets that should be shared between fbcode and xplat.
Expand All @@ -24,12 +24,12 @@ def define_common_targets():
platforms = [ANDROID],
visibility = ["PUBLIC"],
deps = [
"fbsource//third-party/qualcomm/qnn/qnn-{0}:api".format(get_qnn_library_version()),
"fbsource//third-party/qualcomm/qnn/qnn-{0}:app_sources".format(get_qnn_library_version()),
qnn_third_party_dep("api"),
qnn_third_party_dep("app_sources"),
"//executorch/runtime/backend:interface",
],
exported_deps = [
"fbsource//third-party/toolchains:log",
qnn_third_party_dep("log"),
"//executorch/backends/qualcomm:schema",
"//executorch/runtime/core:core",
],
Expand Down Expand Up @@ -71,12 +71,12 @@ def define_common_targets():
platforms = [ANDROID],
visibility = ["PUBLIC"],
resources = ({
"qnn_lib": "fbsource//third-party/qualcomm/qnn/qnn-{0}:qnn_offline_compile_libs".format(get_qnn_library_version()),
"qnn_lib": qnn_third_party_dep("qnn_offline_compile_libs"),
} if include_aot_qnn_lib else {
}),
deps = [
"fbsource//third-party/qualcomm/qnn/qnn-{0}:api".format(get_qnn_library_version()),
"fbsource//third-party/qualcomm/qnn/qnn-{0}:app_sources".format(get_qnn_library_version()),
qnn_third_party_dep("api"),
qnn_third_party_dep("app_sources"),
":logging",
"//executorch/backends/qualcomm:schema",
"//executorch/backends/qualcomm/aot/wrappers:wrappers",
Expand Down
9 changes: 8 additions & 1 deletion backends/qualcomm/serialization/targets.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,17 @@ def define_common_targets():
TARGETS and BUCK files that call this function.
"""

# Used by the INPUT_SCHEMA genrule in targets.bzl for OSS builds,
# where cross-package relative paths don't work in genrule srcs.
export_file(
name = "qc_compiler_spec.fbs",
visibility = ["PUBLIC"],
)

export_file(
name = "qc_compiler_spec_schema",
src = "qc_compiler_spec.fbs",
visibility = ["//executorch/backends/qualcomm/serialization/..."],
visibility = ["PUBLIC"],
)

runtime.python_library(
Expand Down
19 changes: 7 additions & 12 deletions backends/qualcomm/targets.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,15 @@ load(
"ANDROID",
)
load("@fbsource//xplat/executorch/build:runtime_wrapper.bzl", "runtime")
load("@fbsource//xplat/executorch/backends/qualcomm/qnn_version.bzl", "get_qnn_library_version")
load("@fbsource//xplat/executorch/backends/qualcomm/third-party:third_party_libs.bzl", "qnn_third_party_dep")

# Construct the input and output file names. All input and output files rely on scalar_type file.
SCHEMA_NAME = "qc_compiler_spec"

INPUT_SCHEMA = "serialization/" + SCHEMA_NAME + ".fbs"
# In OSS, genrule srcs can't use cross-package relative paths, so use
# an export_file target. In fbcode/xplat, relative path works and avoids
# the srcs patching gap in _patch_executorch_references.
INPUT_SCHEMA = "//backends/qualcomm/serialization:qc_compiler_spec.fbs" if runtime.is_oss else "serialization/" + SCHEMA_NAME + ".fbs"

OUTPUT_SCHEMA_HEADER = SCHEMA_NAME + "_generated.h"

Expand Down Expand Up @@ -60,15 +63,7 @@ def define_common_targets():
runtime.cxx_library(
name = "schema",
srcs = [],
visibility = [
# Lock this down as tightly as possible to ensure that flatbuffers
# are an implementation detail. Ideally this list would only include
# //executorch/runtime/executor/...
"//executorch/codegen/tools/...",
"//executorch/runtime/executor/...",
"//executorch/backends/qualcomm/...",
"//executorch/backends/qualcomm/runtime/...",
],
visibility = ["PUBLIC"],
exported_headers = {
OUTPUT_SCHEMA_HEADER: ":{}[{}]".format(SCHEMA_GEN_RULE_NAME, OUTPUT_SCHEMA_HEADER),
},
Expand All @@ -84,7 +79,7 @@ def define_common_targets():
define_static_target = True,
visibility = ["PUBLIC"],
deps = [
"fbsource//third-party/qualcomm/qnn/qnn-{0}:api".format(get_qnn_library_version()),
qnn_third_party_dep("api"),
"//executorch/runtime/backend:interface",
"//executorch/runtime/core:core",
"//executorch/backends/qualcomm/runtime:runtime_android_build",
Expand Down
18 changes: 13 additions & 5 deletions backends/qualcomm/tests/BUCK
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ fbcode_target(_kind = runtime.python_library,
]
)

# Test targets have transitive deps (caffe2, torchvision, torchaudio, etc.)
# that are not available in OSS Buck builds.
fbcode_target(_kind = runtime.python_library,
name = "test_qnn_delegate",
srcs = [
Expand All @@ -28,18 +30,22 @@ fbcode_target(_kind = runtime.python_library,
"//caffe2/functorch:functorch_src",
"//executorch/exir/backend:partitioner",
"//executorch/exir/dialects:lib",
"//executorch/extension/pybindings:portable_lib", # @manual
"//executorch/extension/pytree:pylib",
"//executorch/backends/qualcomm/partition:partition",
"//executorch/backends/qualcomm/quantizer:quantizer",
"//executorch/backends/qualcomm/serialization:serialization",
"//executorch/backends/qualcomm/utils:utils",
"//executorch/devtools:lib",
"//executorch/examples/qualcomm:utils",
"//executorch/examples/models:models",
"//executorch/backends/qualcomm/debugger:utils",
"//executorch/backends/qualcomm/debugger:qnn_intermediate_debugger",
],
] + ([] if runtime.is_oss else [
# These deps have pre-existing issues in OSS Buck:
# portable_lib: shim//build_defs/cpp_python_extension.bzl missing
# models: examples/models/BUCK uses raw python_library (no dep patching)
"//executorch/extension/pybindings:portable_lib", # @manual
"//executorch/examples/models:models",
]),
)

fbcode_target(_kind = runtime.python_library,
Expand Down Expand Up @@ -67,9 +73,11 @@ fbcode_target(_kind = runtime.python_test,
"//executorch/backends/qualcomm/partition:partition",
"//executorch/backends/qualcomm/serialization:serialization",
"//executorch/backends/qualcomm/utils:utils",
"//executorch/backends/qualcomm/builders:builders",
] + ([] if runtime.is_oss else [
# These deps fail in OSS: keep_gpu_sections kwarg breaks TARGETS evaluation
"//executorch/examples/models/llama:transformer_modules",
"//executorch/examples/qualcomm/oss_scripts/llama:masking_utils",
"//executorch/examples/qualcomm/oss_scripts/llama:static_llama",
"//executorch/backends/qualcomm/builders:builders",
],
]),
)
Loading
Loading