Repository navigation
Qualcomm AI Engine Direct - Zero-initialize delegate-owned mutable buffers - #23404
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/23404
Note: Links to docs will display an error until the docs builds have been completed. ❌ 1 New FailureAs of commit aed080b with merge base e2b7ee5 ( NEW FAILURE - The following job has failed:
This comment was automatically generated by Dr. CI and updates every 15 minutes. |
|
|
|
Hi @XinyuXinyuGrocery, thanks for the PR! Could you rebase and ping for review when ready? This would ensure the CI workflows focus on this PR's code changes post some fixes from our end. |
@XinyuXinyuGrocery pinging again, branch is out-of-date so please do update branch as well and give us a ping. |
b0b9cc1 to
d6f7243
Compare
|
@pytorchbot label "release notes: qualcomm" |
|
@XinyuXinyuGrocery as I run CI again, could you sign EasyCLA? |
|
@nil-is-all Rebased onto the latest main and signed the EasyCLA. Ready for review, thanks! |
Thanks, could you resolve the CI failure and also update branch with main? |
d6f7243 to
b1d4ebb
Compare
|
Updated the branch with main. The failing test ( |
b1d4ebb to
c147f00
Compare
|
Rebased onto the latest main. The only failure in the last run, |
c147f00 to
1a5948f
Compare
|
@nil-is-all Thanks for re-running. All QNN jobs passed. The four failures are not from this change:
I rebased onto |
qti-horodnic
left a comment
There was a problem hiding this comment.
Thanks @XinyuXinyuGrocery, lgtm.
|
|
||
| Error TensorWrapper::AllocateDataBuffer() { | ||
| char* static_data_buffer = new (std::nothrow) char[bytes_]; // NOLINT | ||
| // Zero-initialize: this memory is owned by the delegate, not the runner. |
There was a problem hiding this comment.
Minor: Ownership doesn't tell why zero is necessary, maybe "The graph reads mutable buffers before the first write; start from zero." would be more accurate.
…ffers AllocateDataBuffer() left the memory of delegate-owned mutable buffers uninitialized. The runner cannot initialize memory the delegate owns, so the first execution could read stale data. Zero-initialize it.
1a5948f to
aed080b
Compare
|
@qti-horodnic Thanks for the review! Updated the comment as suggested and rebased onto the latest viable/strict. |
Summary
TensorWrapper::AllocateDataBuffer()allocates delegate-owned mutable buffers (mutbuf_*, used whenskip_mutable_buffer=False) withnew char[bytes_], leaving them uninitialized. This memory is owned by the delegate, not the runner, so the delegate has to initialize it. Otherwise the first execution reads stale data. A freshadb shellprocess usually gets zeroed pages, so this goes unnoticed there, but inside an Android app process the memory can be recycled and the output is wrong. This change zero-initializes the allocation.Test plan
SM8850 (HTP V81), ExecuTorch v1.3.1 with this change: a model with a delegated mutable buffer gave wrong output inside an Android app before the change and correct output after. Filling the buffer with a non-zero pattern right after allocation reproduces the wrong output deterministically.
cc @cccclai @winskuo-quic @shewu-quic @haowhsu-quic @DannyYuyang-quic @qti-horodnic @cbilgin @abhinaykukkadapu @psiddh @nil-is-all