Uh oh!
There was an error while loading. Please reload this page.
Qualcomm AI Engine Direct - heap profiling at runtime with HTP backend - #19224
Conversation
Summary:
Heap profiling at runtime with HTP backend on Android platforms.
DSP heap profiling is available for QnnContext_createFromBinary use-cases. It captures total DSP heap usage at two checkpoints:
- Before the first context is created (before_context_created)
- After the last context is freed (after_context_freed)
The difference between the two values represents heap consumed during context execution. The value after freeing is typically equal to or greater than before creation.
Test plan:
python backends/qualcomm/tests/test_qnn_delegate.py TestQNNQuantizedUtils.test_qnn_backend_runtime_option_heap_profile -b build-android -H ${HOST} -s ${SN} -m ${SOC_MODEL}🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/19224
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: ⏳ No Failures, 125 PendingAs of commit e304022 with merge base 10c8958 ( This comment was automatically generated by Dr. CI and updates every 15 minutes. |
jethroqti
commented
Apr 30, 2026
@pytorchbot label "release notes: qualcomm" |
jethroqti
commented
Apr 30, 2026
This PR is used to measure heap profiling at runtime with HTP backend on Android platforms. |
jethroqti
commented
May 1, 2026
@pytorchbot label "release notes: qualcomm" |
1 similar comment
jethroqti
commented
May 4, 2026
@pytorchbot label "release notes: qualcomm" |
winskuo-quic
commented
May 8, 2026
Hi @abhinaykukkadapu, |
shewu-quic
commented
May 15, 2026
Hi @psiddh, |
psiddh
commented
May 15, 2026
@claude review this PR |
Claude finished @psiddh's task in 4m 13s —— View job PR Review: Qualcomm AI Engine Direct - Heap Profiling at Runtime
SummaryThis PR adds DSP heap profiling support for the HTP backend at runtime, measuring total DSP heap usage at context creation and context free. The implementation involves:
Overall the design is sound and follows existing patterns in the codebase. Below are specific findings: Issues1. Missing |
jethroqti
commented
May 17, 2026
@psiddh Thanks for this review. I will handle ASAP. |
jethroqti
commented
May 18, 2026
@pytorchbot label "release notes: qualcomm" |
psiddh
commented
May 20, 2026
@claude re-review the PR again thoroughly |
psiddh
commented
May 20, 2026
@jethroqti Looks like this branch has few merge conflicts |
Claude finished @psiddh's task in 2m 26s —— View job Re-review: Qualcomm AI Engine Direct - Heap Profiling at Runtime
Previous Review Issues — Status
Remaining Issues1. File truncation depends on event ordering assumption (Medium)
if (strcmp(event_data.identifier, DEFINE_HEAP_BEFORE_CREATION) == 0) {
open_mode = std::ios::trunc;
} elseif (strcmp(event_data.identifier, DEFINE_HEAP_AFTER_FREED) == 0) {
open_mode = std::ios::app;
} else {
count_num_events++;
continue;
}This assumes QNN always returns the "before_context_created" event before the "after_context_freed" event. If the order is ever reversed, the "before" value written first would be lost when "after" truncates the file. Recommendation: Always truncate at the beginning of 2. |
jethroqti
commented
May 20, 2026
It seems one README file. I will check. |
jethroqti
commented
May 20, 2026
@pytorchbot label "release notes: qualcomm" |
jethroqti
commented
May 20, 2026
@psiddh |
Uh oh!
There was an error while loading. Please reload this page.
…P backend" (#19705) Reverts #19224 This is failing internal CI tests: buck test [@fbcode](https://www.internalfb.com/intern/profile/fbcode)//mode/dev fbcode//executorch/backends/qualcomm/tests/fb:test_qnn_delegate_simulator -- --exact 'fbcode//executorch/backends/qualcomm/tests/fb:test_qnn_delegate_simulator - test_qnn_backend_runtime_option_heap_profile (executorch.backends.qualcomm.tests.fb.test_qnn_delegate_simulator.TestQNNQuantizedUtilsSimulator)' buck test [@fbcode](https://www.internalfb.com/intern/profile/fbcode)//mode/dev fbcode//executorch/backends/qualcomm/tests/fb:test_qnn_delegate_simulator -- --exact 'fbcode//executorch/backends/qualcomm/tests/fb:test_qnn_delegate_simulator - test_qnn_backend_runtime_option_heap_profile (executorch.backends.qualcomm.tests.fb.test_qnn_delegate_simulator.TestQNNFloatingPointUtilsSimulator)' ``` ====================================================================== ERROR: test_qnn_backend_runtime_option_heap_profile (executorch.backends.qualcomm.tests.fb.test_qnn_delegate_simulator.TestQNNFloatingPointUtilsSimulator) ---------------------------------------------------------------------- Traceback (most recent call last): File "/data/sandcastle/boxes/trunk-hg-full-fbsource/buck-out/v2/art/fbcode/4c4ca07d1cf3712f/executorch/backends/qualcomm/tests/fb/__test_qnn_delegate_simulator__/test_qnn_delegate_simulator#link-tree/executorch/backends/qualcomm/tests/test_qnn_delegate.py", line 5851, in test_qnn_backend_runtime_option_heap_profile self.verify_output( TypeError: TestQNNFloatingPointUtilsSimulator.verify_output() got an unexpected keyword argument 'save_heap_result' ```
#19710) … with HTP backend" (#19705)" This reverts commit 576ed77 which reverted the original heap profiling feature (#19224). The internal CI test failures that caused the original revert have been fixed by adding @unittest.skip overrides for test_qnn_backend_runtime_option_heap_profile in the simulator test classes. Original commit changeset: 576ed77
Summary:
Heap profiling at runtime with HTP backend on Android platforms. DSP heap profiling is available for QnnContext_createFromBinary use-cases. It captures total DSP heap usage at two checkpoints:
The difference between the two values represents heap consumed during context execution. The value after freeing is typically equal to or greater than before creation.
Test plan:
python backends/qualcomm/tests/test_qnn_delegate.py TestQNNQuantizedUtils.test_qnn_backend_runtime_option_heap_profile -b build-android -H ${HOST} -s ${SN} -m ${SOC_MODEL}