Skip to content

Qualcomm AI Engine Direct - context dump utility #7931

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 1 commit into from
Feb 7, 2025

Conversation

haowhsu-quic
Copy link
Collaborator

Summary

  • utility for dumping compiled binaries (QNN context_binary / QCIR)
  • test cases

Test plan

python backends/qualcomm/tests/test_qnn_delegate.py -k TestQNNQuantizedUtils.test_qnn_backend_context_extraction -s $DEVICE_SERIAL -m SM8650 -b build-android/

Copy link

pytorch-bot bot commented Jan 24, 2025

🔗 Helpful Links

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

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

✅ No Failures

As of commit a89479d with merge base b1d76c9 (image):
💚 Looks good so far! There are no failures yet. 💚

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

@facebook-github-bot facebook-github-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 Jan 24, 2025
@haowhsu-quic
Copy link
Collaborator Author

haowhsu-quic commented Jan 24, 2025

Hi @cccclai, this PR provides methods to save compiled QNN context binaries / QCIR from EdgeProgramManager or PTE file. It might be helpful for user to conduct further analysis.
Please have a look, thank you.

Hi @limintang, this one might be similar to #6745 but slightly flexible. Hopefully this could help, thanks.

@haowhsu-quic haowhsu-quic force-pushed the dev_context_dump_utility branch from d3d3d78 to c4dfc68 Compare February 3, 2025 03:43
@haowhsu-quic
Copy link
Collaborator Author

Hi @cccclai, sorry for pinging. We probably need this feature for performance analysis when doing XR model enablement, please help merge this if it looks good to you.

@haowhsu-quic
Copy link
Collaborator Author

@pytorchbot label "release notes: qualcomm"

@pytorch-bot pytorch-bot bot added the release notes: qualcomm Changes to the Qualcomm backend delegate label Feb 3, 2025
@haowhsu-quic haowhsu-quic force-pushed the dev_context_dump_utility branch from c4dfc68 to 9fc0b96 Compare February 5, 2025 16:27
Copy link
Contributor

@cccclai cccclai left a comment

Choose a reason for hiding this comment

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

Sorry a bit late on this, looks good to me.

@facebook-github-bot
Copy link
Contributor

@cccclai has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@cccclai
Copy link
Contributor

cccclai commented Feb 7, 2025

Hey there is an internal error

In file included from fbcode/executorch/backends/qualcomm/aot/python/PyQnnManagerAdaptor.cpp:8:
buck-out/v2/gen/fbcode/339a51a8c50acc11/executorch/backends/qualcomm/aot/python/__PyQnnManagerAdaptor__/buck-private-headers/executorch/backends/qualcomm/aot/python/PyQnnManagerAdaptor.h:395:32: error: unused variable 'binary' [-Werror,-Wunused-variable]
  395 |     QnnExecuTorchContextBinary binary(
      |                                ^~~~~~
1 error generated.

Can you help fixing it?

@cccclai
Copy link
Contributor

cccclai commented Feb 7, 2025

Can you attach this patch?

--- a/executorch/backends/qualcomm/aot/python/PyQnnManagerAdaptor.h
+++ b/executorch/backends/qualcomm/aot/python/PyQnnManagerAdaptor.h
@@ -392,7 +392,7 @@
 
   py::array_t<char> StripProtocol(const py::bytes& preprocessed_binary) {
     py::buffer_info info(py::buffer(preprocessed_binary).request());
-    QnnExecuTorchContextBinary binary(
+    __ET_UNUSED QnnExecuTorchContextBinary binary(
         {info.ptr, static_cast<uint64_t>(info.size * info.itemsize)});
 
     void* buf_ptr = nullptr;

summary:
- utility for dumping compiled binaries (QNN context_binary / QCIR)
- test cases
@haowhsu-quic haowhsu-quic force-pushed the dev_context_dump_utility branch from 9fc0b96 to a89479d Compare February 7, 2025 03:01
@haowhsu-quic
Copy link
Collaborator Author

Can you attach this patch?

--- a/executorch/backends/qualcomm/aot/python/PyQnnManagerAdaptor.h
+++ b/executorch/backends/qualcomm/aot/python/PyQnnManagerAdaptor.h
@@ -392,7 +392,7 @@
 
   py::array_t<char> StripProtocol(const py::bytes& preprocessed_binary) {
     py::buffer_info info(py::buffer(preprocessed_binary).request());
-    QnnExecuTorchContextBinary binary(
+    __ET_UNUSED QnnExecuTorchContextBinary binary(
         {info.ptr, static_cast<uint64_t>(info.size * info.itemsize)});
 
     void* buf_ptr = nullptr;

Sorry didn't catch that, I just remove it and rebase again. Thank you.

@facebook-github-bot
Copy link
Contributor

@cccclai has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

Copy link
Contributor

@cccclai cccclai left a comment

Choose a reason for hiding this comment

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

Looks good to me. Thank you!

@cccclai cccclai merged commit 1ec88a6 into pytorch:main Feb 7, 2025
46 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. release notes: qualcomm Changes to the Qualcomm backend delegate
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants