Skip to content

Qualcomm AI Engine Direct - Fold views of parameters before annotation - #24384

Open
msluszniak wants to merge 2 commits into
pytorch:mainfrom
msluszniak:ms/qnn-fold-constant-views
Open

msluszniak wants to merge 2 commits into
pytorch:mainfrom
msluszniak:ms/qnn-fold-constant-views

Conversation

@msluszniak

@msluszniak msluszniak commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor

With query != value, nn.MultiheadAttention splits in_proj_weight at runtime. Quantized with per-channel linear weights (8a8w or 16a8w), lowering then fails in AnnotateQuantAttrs with KeyError: 'scale', since the weight is a split output, not a parameter. FoldConstantViews replaces views and splits of a parameter with constants before annotation.

Found quantizing RF-DETR. Test: test_fold_constant_views_mha_in_proj (fails without the pass).

cc @cccclai @winskuo-quic @shewu-quic @haowhsu-quic @DannyYuyang-quic @qti-horodnic @cbilgin @abhinaykukkadapu @psiddh @nil-is-all

With query != value, nn.MultiheadAttention splits in_proj_weight at runtime, so
each projection's weight is a split output, not a parameter. Quantized with
per-channel linear weights, that per-channel encoding never becomes a static
weight and AnnotateQuantAttrs fails with KeyError 'scale'. FoldConstantViews
replaces views and splits of a parameter with constants first.
@msluszniak
msluszniak requested a review from psiddh as a code owner October 31, 2026 13:37
@pytorch-bot

pytorch-bot Bot commented Oct 31, 2026 •

Copy link
Copy Markdown

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/24384

Note: Links to docs will display an error until the docs builds have been completed.

✅ No Failures

As of commit fa14b48 with merge base 2d8cd35 (image):
💚 Looks good so far! There are no failures yet. 💚

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 31, 2026
@executorch-triage executorch-triage Bot added the community: contribution PRs coming from community (excluding hardware partners) label Oct 31, 2026
@nil-is-all nil-is-all added partner: qualcomm For backend delegation, kernels, demo, etc. from the 3rd-party partner, Qualcomm module: qnn Issues related to Qualcomm's QNN delegate and code under backends/qualcomm/ release notes: qualcomm Changes to the Qualcomm backend delegate labels Nov 9, 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) module: qnn Issues related to Qualcomm's QNN delegate and code under backends/qualcomm/ partner: qualcomm For backend delegation, kernels, demo, etc. from the 3rd-party partner, Qualcomm release notes: qualcomm Changes to the Qualcomm backend delegate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants