Skip to content

Enable buck-native x86 simulator test for QNN op tests (#20494)#20494

Open
billmguo wants to merge 1 commit into
pytorch:mainfrom
billmguo:export-D109606746
Open

Enable buck-native x86 simulator test for QNN op tests (#20494)#20494
billmguo wants to merge 1 commit into
pytorch:mainfrom
billmguo:export-D109606746

Conversation

@billmguo

@billmguo billmguo commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

Summary:

The QNN operator tests in backends/qualcomm/tests/test_qnn_delegate.py already support host x86_64 simulator execution via --enable_x86_64, but were only runnable as a standalone argparse script after a CMake build. There was no buck test path: test_qnn_delegate is a python_library (not a test target), and the host qnn_executor_runner binary was Android-only.

This change wires up a buck-native, internal-only test target //executorch/backends/qualcomm/tests:test_qnn_delegate_x86 that runs the FP16 and quantized operator suites (TestQNNFloatingPointOperator, TestQNNQuantizedOperator) on the x86 QNN simulator with no device and no CMake build tree.

Changes:

  • backends/qualcomm/runtime/targets.bzl: add CXX to the pal library platforms (gated if is_fbcode()). It already ships pal/src/linux/*.cpp, but was gated to [ANDROID], which blocked any host build of :runtime (an exported dep).
  • examples/qualcomm/executor_runner/targets.bzl: add CXX to qnn_executor_runner (gated if is_fbcode()) so the host runner binary builds, and add //executorch/kernels/portable:generated_lib to its deps. The CMake runner links full_portable_ops_lib + quantized_ops_lib; the Buck runner had only the quantized lib, so ops that leave a CPU-fallback node (e.g. acos -> aten::asin.out, cast, index_copy, index_put, logical_and, avg_pool1d) aborted the runner with a "Missing operator" error. The CXX (host) surface is gated to is_fbcode() because it is only used by the internal x86 simulator test; in OSS, CXX includes macOS (no QNN host libs), so the host runner/pal stay Android-only there, restoring the original OSS build surface.
  • backends/qualcomm/tests/test_qnn_delegate_x86.py (new): under buck test the file's argparse __main__/setup_environment() never runs, so this wrapper sets the equivalent TestQNN class attributes (enable_x86_64, backend, soc_model) at import and subclasses the operator TestCases so the runner discovers them.
  • backends/qualcomm/tests/BUCK: add the test_qnn_delegate_x86 python_test, gated behind runtime.is_oss via a top-level conditional expression (the BUCK dialect forbids top-level if/def). It stays out of the OSS graph to preserve the test-qnn-buck-build-linux CI signal. The QNN x86 SDK libs and host runner are supplied via env (QNN_SDK_ROOT, LD_LIBRARY_PATH, QNN_EXECUTOR_RUNNER). CUDA_VISIBLE_DEVICES is forced empty because these tests are CPU-only (calibration, AOT compile, x86 sim); without it, parallel test shards each grabbed CUDA and exhausted GPU memory.

The fbcode and xplat copies of all four files are kept byte-identical per the existing twin convention.

Differential Revision: D109606746

@pytorch-bot

pytorch-bot Bot commented Jun 24, 2026

Copy link
Copy Markdown

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/20494

Note: Links to docs will display an error until the docs builds have been completed.

❗ 2 Active SEVs

There are 2 currently active SEVs. If your PR is affected, please view them below:

❌ 3 New Failures, 1 Unrelated Failure

As of commit 3545844 with merge base 45a14b9 (image):

NEW FAILURES - The following jobs have failed:

BROKEN TRUNK - The following job failed but were present on the merge base:

👉 Rebase onto the `viable/strict` branch to avoid these failures

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Jun 24, 2026
@linux-foundation-easycla

linux-foundation-easycla Bot commented Jun 24, 2026

Copy link
Copy Markdown

CLA Not Signed

@meta-codesync

meta-codesync Bot commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

@billmguo has exported this pull request. If you are a Meta employee, you can view the originating Diff in D109606746.

@github-actions

Copy link
Copy Markdown

This PR needs a release notes: label

If your change should be included in the release notes (i.e. would users of this library care about this change?), please use a label starting with release notes:. This helps us keep track and include your important work in the next release notes.

To add a label, you can comment to pytorchbot, for example
@pytorchbot label "release notes: none"

For more information, see
https://github.com/pytorch/pytorch/wiki/PyTorch-AutoLabel-Bot#why-categorize-for-release-notes-and-how-does-it-work.

@billmguo billmguo force-pushed the export-D109606746 branch from b190fc6 to 970dea0 Compare June 24, 2026 22:54
@meta-codesync meta-codesync Bot changed the title Enable buck-native x86 simulator test for QNN op tests Enable buck-native x86 simulator test for QNN op tests (#20494) Jun 25, 2026
billmguo added a commit to billmguo/executorch that referenced this pull request Jun 25, 2026
Summary:

The QNN operator tests in `backends/qualcomm/tests/test_qnn_delegate.py` already support host x86_64 simulator execution via `--enable_x86_64`, but were only runnable as a standalone argparse script after a CMake build. There was no `buck test` path: `test_qnn_delegate` is a `python_library` (not a test target), and the host `qnn_executor_runner` binary was Android-only.

This change wires up a buck-native, internal-only test target `//executorch/backends/qualcomm/tests:test_qnn_delegate_x86` that runs the FP16 and quantized operator suites (`TestQNNFloatingPointOperator`, `TestQNNQuantizedOperator`) on the x86 QNN simulator with no device and no CMake build tree.

Changes:
- `backends/qualcomm/runtime/targets.bzl`: add `CXX` to the `pal` library platforms. It already ships `pal/src/linux/*.cpp`, but was gated to `[ANDROID]`, which blocked any host build of `:runtime` (an exported dep). This is a Buck/CMake parity fix.
- `examples/qualcomm/executor_runner/targets.bzl`: add `CXX` to `qnn_executor_runner` so the host runner binary builds, and add `//executorch/kernels/portable:generated_lib` to its deps. The CMake runner links `full_portable_ops_lib` + `quantized_ops_lib`; the Buck runner had only the quantized lib, so ops that leave a CPU-fallback node (e.g. `acos` -> `aten::asin.out`, `cast`, `index_copy`, `index_put`, `logical_and`, `avg_pool1d`) aborted the runner with a "Missing operator" error.
- `backends/qualcomm/tests/test_qnn_delegate_x86.py` (new): under `buck test` the file's argparse `__main__`/`setup_environment()` never runs, so this wrapper sets the equivalent `TestQNN` class attributes (`enable_x86_64`, `backend`, `soc_model`) at import and subclasses the operator TestCases so the runner discovers them.
- `backends/qualcomm/tests/BUCK`: add the `test_qnn_delegate_x86` `python_test`, gated behind `runtime.is_oss` via a top-level conditional expression (the BUCK dialect forbids top-level `if`/`def`). It stays out of the OSS graph to preserve the `test-qnn-buck-build-linux` CI signal. The QNN x86 SDK libs and host runner are supplied via `env` (`QNN_SDK_ROOT`, `LD_LIBRARY_PATH`, `QNN_EXECUTOR_RUNNER`). `CUDA_VISIBLE_DEVICES` is forced empty because these tests are CPU-only (calibration, AOT compile, x86 sim); without it, parallel test shards each grabbed CUDA and exhausted GPU memory.

The fbcode and xplat copies of all four files are kept byte-identical per the existing twin convention.

Differential Revision: D109606746
@billmguo billmguo force-pushed the export-D109606746 branch from 970dea0 to 224e6d6 Compare June 25, 2026 00:05
@meta-codesync meta-codesync Bot changed the title Enable buck-native x86 simulator test for QNN op tests (#20494) Enable buck-native x86 simulator test for QNN op tests Jun 25, 2026
@billmguo billmguo force-pushed the export-D109606746 branch from 224e6d6 to c0da9c3 Compare June 25, 2026 00:18
Summary:

The QNN operator tests in `backends/qualcomm/tests/test_qnn_delegate.py` already support host x86_64 simulator execution via `--enable_x86_64`, but were only runnable as a standalone argparse script after a CMake build. There was no `buck test` path: `test_qnn_delegate` is a `python_library` (not a test target), and the host `qnn_executor_runner` binary was Android-only.

This change wires up a buck-native, internal-only test target `//executorch/backends/qualcomm/tests:test_qnn_delegate_x86` that runs the FP16 and quantized operator suites (`TestQNNFloatingPointOperator`, `TestQNNQuantizedOperator`) on the x86 QNN simulator with no device and no CMake build tree.

Changes:
- `backends/qualcomm/runtime/targets.bzl`: add `CXX` to the `pal` library platforms (gated `if is_fbcode()`). It already ships `pal/src/linux/*.cpp`, but was gated to `[ANDROID]`, which blocked any host build of `:runtime` (an exported dep).
- `examples/qualcomm/executor_runner/targets.bzl`: add `CXX` to `qnn_executor_runner` (gated `if is_fbcode()`) so the host runner binary builds, and add `//executorch/kernels/portable:generated_lib` to its deps. The CMake runner links `full_portable_ops_lib` + `quantized_ops_lib`; the Buck runner had only the quantized lib, so ops that leave a CPU-fallback node (e.g. `acos` -> `aten::asin.out`, `cast`, `index_copy`, `index_put`, `logical_and`, `avg_pool1d`) aborted the runner with a "Missing operator" error. The `CXX` (host) surface is gated to `is_fbcode()` because it is only used by the internal x86 simulator test; in OSS, `CXX` includes macOS (no QNN host libs), so the host runner/pal stay Android-only there, restoring the original OSS build surface.
- `backends/qualcomm/tests/test_qnn_delegate_x86.py` (new): under `buck test` the file's argparse `__main__`/`setup_environment()` never runs, so this wrapper sets the equivalent `TestQNN` class attributes (`enable_x86_64`, `backend`, `soc_model`) at import and subclasses the operator TestCases so the runner discovers them.
- `backends/qualcomm/tests/BUCK`: add the `test_qnn_delegate_x86` `python_test`, gated behind `runtime.is_oss` via a top-level conditional expression (the BUCK dialect forbids top-level `if`/`def`). It stays out of the OSS graph to preserve the `test-qnn-buck-build-linux` CI signal. The QNN x86 SDK libs and host runner are supplied via `env` (`QNN_SDK_ROOT`, `LD_LIBRARY_PATH`, `QNN_EXECUTOR_RUNNER`). `CUDA_VISIBLE_DEVICES` is forced empty because these tests are CPU-only (calibration, AOT compile, x86 sim); without it, parallel test shards each grabbed CUDA and exhausted GPU memory.

The fbcode and xplat copies of all four files are kept byte-identical per the existing twin convention.

Differential Revision: D109606746
@meta-codesync meta-codesync Bot changed the title Enable buck-native x86 simulator test for QNN op tests Enable buck-native x86 simulator test for QNN op tests (#20494) Jun 25, 2026
@billmguo billmguo force-pushed the export-D109606746 branch from c0da9c3 to 3545844 Compare June 25, 2026 00:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. meta-exported

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant