Skip to content

Qualcomm AI Engine Direct - LPAI Direct Mode Support#19142

Merged
abhinaykukkadapu merged 2 commits intopytorch:mainfrom
CodeLinaro:dev1/winskuo/lpai_direct_mode
Apr 29, 2026
Merged

Qualcomm AI Engine Direct - LPAI Direct Mode Support#19142
abhinaykukkadapu merged 2 commits intopytorch:mainfrom
CodeLinaro:dev1/winskuo/lpai_direct_mode

Conversation

@winskuo-quic
Copy link
Copy Markdown
Collaborator

Summary

  • Support LPAI Direct Mode
  • Automate signing process and safety check in build.sh
  • Updating SKILL.md to align with the new flow.
  • TODO: Improve direct mode performance

Example:
backends/qualcomm/scripts/build.sh --build_direct_mode 0 --soc_model SM8850
python examples/qualcomm/scripts/inception_v3.py --model SM8850 --device $DEVICE --build_folder build-android --dataset ../datasets/imagenet-mini/val/ --backend lpai --direct_build_folder build-direct/

python backends/qualcomm/tests/test_qnn_delegate.py -k TestQNNQuantizedOperator.test_qnn_backend_relu_simple --model SM8850 -s $DEVICE --build_folder build-android --backend lpai --direct_build_folder build-direct/

Test plan

Passing operator test and ic3 with flag --backend lpai --direct_build_folder build-direct. Also ensure traditional lpai flow and cDSP traditional/direct mode flow didn't breal.

Ensure --no_clean works fine when build.sh with following verification script.

backends/qualcomm/scripts/build.sh --build_direct_mode 3 --soc_model SM8750
python backends/qualcomm/tests/test_qnn_delegate.py -k TestQNNQuantizedOperator.test_qnn_backend_adaptive_avg_pool2d --model SM8750  --device $DEVICE --build_folder build-android --direct_build_folder build-direct/
python backends/qualcomm/tests/test_qnn_delegate.py -k TestQNNQuantizedOperator.test_qnn_backend_adaptive_avg_pool2d --model SM8750  --device $DEVICE --build_folder build-android
backends/qualcomm/scripts/build.sh --build_direct_mode 0 --soc_model SM8850 --no_clean
python backends/qualcomm/tests/test_qnn_delegate.py -k TestQNNQuantizedOperator.test_qnn_backend_adaptive_avg_pool2d --model SM8850  --device $DEVICE --build_folder build-android --backend lpai --direct_build_folder build-direct/
backends/qualcomm/scripts/sign_library.sh --lpai_arch v6
python backends/qualcomm/tests/test_qnn_delegate.py -k TestQNNQuantizedOperator.test_qnn_backend_adaptive_avg_pool2d --model SM8850  --device $DEVICE --build_folder build-android --backend lpai

@pytorch-bot
Copy link
Copy Markdown

pytorch-bot Bot commented Apr 27, 2026

🔗 Helpful Links

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

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

❗ 1 Active SEVs

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

❌ 2 New Failures, 1 Cancelled Job, 3 Unrelated Failures

As of commit cdf7fd1 with merge base 4ac044b (image):

NEW FAILURES - The following jobs have failed:

CANCELLED JOB - The following job was cancelled. Please retry:

FLAKY - The following job failed but was likely due to flakiness present on trunk:

BROKEN TRUNK - The following jobs failed but was 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 Apr 27, 2026
@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.

@meta-codesync
Copy link
Copy Markdown
Contributor

meta-codesync Bot commented Apr 28, 2026

@abhinaykukkadapu has imported this pull request. If you are a Meta employee, you can view this in D102704988.

@abhinaykukkadapu
Copy link
Copy Markdown
Contributor

abhinaykukkadapu commented Apr 28, 2026

@winskuo-quic i think this PR is a good litmus test for the buck ci signal, can you try and fix the error, i think you need to guard the QnnCustomProtocol.h for hexagon. Also you might have to move QNN_TENSOR_ALIGNMENT constant to wrapper to avoid circular dep between wrapper -> runtime -> wrapper.

FYI, i just put a skill together to address this #19197

I think it does a decent job.
Screenshot 2026-04-28 at 2 24 41 PM

@winskuo-quic winskuo-quic force-pushed the dev1/winskuo/lpai_direct_mode branch from 0059142 to 7309076 Compare April 29, 2026 06:47
@winskuo-quic
Copy link
Copy Markdown
Collaborator Author

@winskuo-quic i think this PR is a good litmus test for the buck ci signal, can you try and fix the error, i think you need to guard the QnnCustomProtocol.h for hexagon. Also you might have to move QNN_TENSOR_ALIGNMENT constant to wrapper to avoid circular dep between wrapper -> runtime -> wrapper.

FYI, i just put a skill together to address this #19197

@abhinaykukkadapu,
Thanks for the adding CI for QNN backend buck build and introducing this pr: #19197.
Both these are super helpful. I tried applying #19197 to my branch. Claude just setup buck environment for me and help me debug the issue, which should align with what you mentioned above.
Please have another look at my new commit addressing the issue.

@winskuo-quic winskuo-quic force-pushed the dev1/winskuo/lpai_direct_mode branch from 7309076 to cdf7fd1 Compare April 29, 2026 07:05
@abhinaykukkadapu
Copy link
Copy Markdown
Contributor

@winskuo-quic i think this PR is a good litmus test for the buck ci signal, can you try and fix the error, i think you need to guard the QnnCustomProtocol.h for hexagon. Also you might have to move QNN_TENSOR_ALIGNMENT constant to wrapper to avoid circular dep between wrapper -> runtime -> wrapper.
FYI, i just put a skill together to address this #19197

@abhinaykukkadapu, Thanks for the adding CI for QNN backend buck build and introducing this pr: #19197. Both these are super helpful. I tried applying #19197 to my branch. Claude just setup buck environment for me and help me debug the issue, which should align with what you mentioned above. Please have another look at my new commit addressing the issue.

This is amazing, this is the workflow we envisioned. CC: @digantdesai

@abhinaykukkadapu abhinaykukkadapu merged commit e4ab34d into pytorch:main Apr 29, 2026
167 of 173 checks passed
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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants