Skip to content

Qualcomm AI Engine Direct - Keep an fp16a8w conv valid when it falls back to CPU - #24022

Open
msluszniak wants to merge 2 commits into
pytorch:mainfrom
msluszniak:ms/qnn-fp16a8w-cpu-fallback
Open

msluszniak wants to merge 2 commits into
pytorch:mainfrom
msluszniak:ms/qnn-fp16a8w-cpu-fallback

Conversation

@msluszniak

Copy link
Copy Markdown
Contributor

Summary

InsertCastForFpActQuantizedWeight moves 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_executorch fails 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_fp16 fails without this commit and passes with it; the rest of test_passes.py passes. 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

…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.
@msluszniak
msluszniak requested a review from psiddh as a code owner October 20, 2026 12:54
@pytorch-bot

pytorch-bot Bot commented Oct 20, 2026 •

Copy link
Copy Markdown

🔗 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.

⚠️ 15 Awaiting Approval

As of commit 7e85941 with merge base e6cfbf8 (image):

AWAITING APPROVAL - The following workflows need approval before CI can run:

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

@meta-cla meta-cla 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 Oct 20, 2026
@github-actions

Copy link
Copy Markdown

This PR needs a release notes: label

If your change should be included in the release notes (i.e. would users of this library care about this change?), please use a label starting with release notes:. This helps us keep track and include your important work in the next release notes.

To add a label, you can comment to pytorchbot, for example
@pytorchbot label "release notes: none"

For more information, see
https://github.com/pytorch/pytorch/wiki/PyTorch-AutoLabel-Bot#why-categorize-for-release-notes-and-how-does-it-work.

@executorch-triage executorch-triage Bot added the community: contribution PRs coming from community (excluding hardware partners) label Oct 20, 2026

This branch has not been deployed

No deployments
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. community: contribution PRs coming from community (excluding hardware partners)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant