Qualcomm AI Engine Direct - Python API Refactor#18312
Qualcomm AI Engine Direct - Python API Refactor#18312winskuo-quic wants to merge 4 commits intopytorch:mainfrom
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/18312
Note: Links to docs will display an error until the docs builds have been completed. ❗ 1 Active SEVsThere are 1 currently active SEVs. If your PR is affected, please view them below: ❌ 5 New Failures, 1 Cancelled Job, 5 Unrelated FailuresAs of commit 50cee3e with merge base 411ede2 ( NEW FAILURES - The following jobs have failed:
CANCELLED JOB - The following job was cancelled. Please retry:
FLAKY - The following jobs failed but were likely due to flakiness present on trunk:
BROKEN TRUNK - The following jobs 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. |
This PR needs a
|
4a6594d to
19ff5fc
Compare
backends/qualcomm/export_utils.py
Outdated
| backend_options = { | ||
| QnnExecuTorchBackendType.kGpuBackend: generate_gpu_compiler_spec(), | ||
| QnnExecuTorchBackendType.kHtpBackend: generate_htp_compiler_spec( | ||
| use_fp16=False if any([quant_dtype, custom_quantizer]) is not None else True |
There was a problem hiding this comment.
@winskuo-quic any() always yields a bool, this check should be use_fp16=not any([quant_dtype, custom_quantizer])
There was a problem hiding this comment.
Thanks for the catch. This is a lot cleaner. Fixed.
| backend=backend, | ||
| soc_model=soc_model, | ||
| backend=qnn_config.backend, |
There was a problem hiding this comment.
are we supposed to pass both backend params here?
There was a problem hiding this comment.
Ah, I think this is a rebase error. Thanks for the catch. Fixed.
| ) | ||
| elif args.pre_gen_pte: | ||
| logging.info("Inference only for QNN Static Decoder") | ||
| qnn_decode_res = inference_static_mimi_decoder( |
There was a problem hiding this comment.
Function signature mismatch.
There was a problem hiding this comment.
Fixed. Thanks
|
@winskuo-quic thank you for these changes, i def think this would help with user experience, i tried my best to comb through as the diff is big, i found some syntax issues which was highlighted by the ide but i wanted to make sure if you can check few examples. Other than that i think this is good to go, once you rebase for conflicts and address minor things. |
6a50775 to
ed6ba51
Compare
|
@abhinaykukkadapu has imported this pull request. If you are a Meta employee, you can view this in D99197179. |
|
@claude review the PR for potential internal CI build breakages and buck file drift. I see these failures on the imported diff internally, for example, deep dive and provide feedback to resolve buck issues. |
|
Claude finished @abhinaykukkadapu's task in 12m 1s —— View job Review: Internal CI Build Breakages and Buck File DriftI've analyzed the PR changes against the Buck/TARGETS build configuration. The reported Root CauseThe new file Issue 1: Missing Buck target for
|
| Priority | File | Action |
|---|---|---|
| Critical | backends/qualcomm/BUCK (or targets.bzl) |
Add export_utils python_library target |
| Critical | backends/qualcomm/tests/BUCK |
Add //executorch/backends/qualcomm:export_utils dep to test_qnn_delegate target |
| Moderate | examples/qualcomm/TARGETS |
Clean up stale deps on utils target |
| Moderate | examples/qualcomm/oss_scripts/llama/TARGETS |
Add //executorch/backends/qualcomm:export_utils dep to llama_lib |
| Moderate | examples/qualcomm/oss_scripts/whisper/TARGETS |
Add //executorch/backends/qualcomm:export_utils dep to whisper_lib |
| Low | Internal callers of generate_qnn_executorch_compiler_spec |
Verify no other callers use old profile=/optrace= kwargs |
The critical fix is straightforward: create the Buck target for export_utils.py and wire it into the dependency graph. Without this, any Buck-based build (like internal CI) will fail with the ModuleNotFoundError reported above.
|
@winskuo-quic the buck ones are spot on, can you please patch? |
ed6ba51 to
8e29c28
Compare
@abhinaykukkadapu thanks for providing the feedback. I tried to address issues suggested by claude. Please let me know if you buck build is still failing. |
8e29c28 to
94962f8
Compare
|
@winskuo-quic can you please rebase there seems to be some conflicts. I've merged your minimal inference PR and will do this one after you rebase. |
768fee5 to
5179a3a
Compare
@abhinaykukkadapu, |
|
@winskuo-quic Sorry, i see more conflicts. |
5179a3a to
428fcae
Compare
|
@winskuo-quic few things, i think this diff added few backward incompatible changes which is breaking internal CI. Option 1. Can we maintain API contracts this time and going forward, if you want this, remove export_util renaming and follow same var names and types for profile and optrace. I like this tbh. |
428fcae to
50cee3e
Compare
|
@abhinaykukkadapu thanks for sharing the options for bc fix. Personally, I think option1 won't be able to fulfill all the needs. We are moving from
I have just applied the patch from option2, and please let me know if there's any further question or concerns for the explanation above. |
Summary
The biggest goal of this PR is to improve user experience by maintaining consistency across all example scripts and provide an official config file for QNN APIs.

In the past, user has to manually provide params to APIs such as build_executorch_binary to make it work. However, not all the params are passed in the build_executorch_binary, making some of the flags not working, which leaves users confused. Taking example below, if user tries to skip node in script 1, it will fail.
For this reason, we want to maintain a QnnConfig structure as an official config file.
If we want to introduce a new flag to our APIs, if we want all scripts to benefit from the flag, we will need to update all our example scripts, making it hard to maintain as we support more flags and more scripts. With this feature, we don't have to manually update all example scripts when a new flag is introduced. Instead, all QnnConfig will parse it itself and we don't have to update the example script at all.
This PR does the following:
backends/qualcomm/export_utils.py. The reason of doing this is API calls shouldn't be underexamplesfolder. Furthermore,pip install executorchdoes not includeexamples/qualcommfolder, meaning these APIs are not exposed to users that usespip install.compile_only,pre_gen_pte,skip_push,profile_level,dump_intermediate_outputs,shared_buffer,skip_delegate_node_ids,skip_delegate_node_ops.Test plan
Passes all tests under
test_qnn_delegate.py.