Repository navigation
Qualcomm AI Engine Direct - Replace in-place writes before annotation - #25202
Open
msluszniak wants to merge 3 commits into
Open
msluszniak wants to merge 3 commits into
msluszniak wants to merge 3 commits into
Conversation
prepare_pt2e observes a tensor before a later in-place write through a view, so the quantized model ignores what was written (torchvision's batch_images fills new_full with copy_). Add a replace_in_place_ops transform that rewrites such writes to their functional variants, and call it from XNNPACKQuantizer.transform_for_annotation. Writes to graph inputs and buffers are kept.
A write was rewritten even when the written view, or the in-place op's result, was used again afterwards, so a second write or read through it saw the old value. The alias check also missed unbind/split getitems. Keep those writes, and leave direct in-place ops alone, since later reads already use the in-place node. Rewrite only copy_, fill_, zero_ and arithmetic writes through select, slice and diagonal, compute val for the new nodes under the fake mode, and copy only provenance meta. Make the transform a PassBase, ReplaceInplaceOpsPass, and log the writes it keeps.
prepare_pt2e observes a tensor before a later in-place write through a view, so the quantized model ignores what was written. QnnQuantizer also annotates select, so its observers split the view chain and copy_ wrote into a dequantized copy of the buffer. Run ReplaceInplaceOpsPass in QnnQuantizer.transform_for_annotation.
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/25202
Note: Links to docs will display an error until the docs builds have been completed.
|
Contributor
Author
|
@pytorchbot label "release notes: qualcomm" |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
QNN half of #24499 (split per review).
QnnQuantizernow runsReplaceInplaceOpsPassintransform_for_annotation, so observers see values written in place through a view (pytorch/ao#5040). Depends on #24499, which adds the pass.Test plan
New
test_quantizer_observes_buffer_after_in_place_writein qualcommtest_passes.py: fails on main, passes with QAIRT 2.47.cc @psiddh @nil-is-all