Repository navigation
Qualcomm AI Engine Direct - Keep an fp16a8w conv valid when it falls back to CPU - #24022
Open
msluszniak wants to merge 2 commits into
Open
msluszniak wants to merge 2 commits into
msluszniak wants to merge 2 commits into
Conversation
…ze on CPU FoldQDQ marks a quantized parameter's dequantize as a bypass node, which the partitioner force-passes. When its consumer is not delegated, the dequantize was lowered alone as a QNN Dequantize, which rejects per-channel encodings and fails context binary generation. Leave it on CPU with its consumer. Fixes pytorch#19908.
…back to CPU InsertCastForFpActQuantizedWeight moves a conv/linear with an fp16a8w weight to fp16, but retypes the bias in meta only and leaves the weight dequantize at fp32. When the op is not delegated (the HTP only takes fp16a8w for 1x1 conv and linear), to_executorch fails on a bias buffer half the size its spec expects. The weight dequantize now outputs fp16, and after lowering any parameter left on CPU has its data cast to its meta dtype, into a new tensor so the caller's module is untouched.
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/24022
Note: Links to docs will display an error until the docs builds have been completed.
|
This PR needs a
|
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
InsertCastForFpActQuantizedWeightmoves an fp16a8w conv/linear to fp16 but retypes its bias in meta only and leaves the weight dequantize at fp32. When the op isn't delegated (the HTP only takes fp16a8w for 1x1 conv and linear),to_executorchfails with "Tensor spec has buffer of size N, but expected nbytes of N/2". The weight dequantize now outputs fp16, and after lowering any CPU-side parameter has its data cast to its meta dtype, into a new tensor so the caller's module is untouched.Stacked on #23915 (without it, these models fail earlier on the orphaned dequantize); only the last commit is new.
Test plan
test_passes.py::TestPasses::test_fp16a8w_conv_on_cpu_stays_fp16fails without this commit and passes with it; the rest oftest_passes.pypasses. torchvision DeepLabV3-ResNet50 and LR-ASPP fp16a8w now lower and serialize for SM8850.cc @cccclai @winskuo-quic @shewu-quic @haowhsu-quic @DannyYuyang-quic @cbilgin @abhinaykukkadapu @psiddh @nil-is-all