Skip to content

Qualcomm AI Engine Direct - Default use_16a16w to per-tensor conv weights - #24250

Open
qti-horodnic wants to merge 1 commit into
pytorch:mainfrom
CodeLinaro:horodnic/16a16w_per_channel_fix
Open

qti-horodnic wants to merge 1 commit into
pytorch:mainfrom
CodeLinaro:horodnic/16a16w_per_channel_fix

Conversation

@qti-horodnic

@qti-horodnic qti-horodnic commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

Summary

This is a fix/workaround for a community-reported issue.

With use_16a16w, make_quantizer defaulted to per-channel int16 conv weights. The conv bias is quantized to int32 with a derived scale of act_scale * weight_scale[c]. Per-channel int16 weight scales are about 256x smaller than int8 ones, so on channels with small weights and a large bias, bias / scale reaches the int32 limit which makes 16a16w far less accurate than 16a8w.
On ResNet18 (host QDQ, SQNR vs fp32), 16a8w gives 26.7 dB and per-channel 16a16w gives -1.2 dB. SM8850 matches host exactly, so the loss comes from the quantization parameters, not HTP execution. Leaving the bias in float recovers 45.3 dB, which isolates the bias as the cause.

make_quantizer now takes per_channel_conv=None and resolves it to per-tensor for use_16a16w and per-channel for every other dtype. An explicit per_channel_conv=True is respected, and set_default_quant_config logs a warning in that case. With the new default, ResNet18 16a16w gives 45.1 dB on host and 43.1 dB on SM8850. Linear and embedding defaults are unchanged.

The limitation and the new default are documented under Quantization in docs/source/backends-qualcomm.md.

This changes the conv weight encoding for existing 16a16w users who did not pass per_channel_conv, including the efficientnet.py, albert.py and eurobert.py examples.

Test plan

python -m pytest --import-mode=importlib backends/qualcomm/tests/rework/htp/op/{v73,v75,v79,v81}/test.py -k "conv2d_16a16w_default" -v

New test_conv2d_16a16w_default (registered for V73, V75, V79 and V81, since 16a16w requires V73+) checks that the 16a16w default is per-tensor, and that an explicit per_channel_conv=True stays per-channel and warns. It fails on the previous code and passes with this change.

test_passes.py also passes (38/38).
The 16a16w op tests show no new failures. The 6 test_linear_non_constant_weight[16a16w_ptq] failures ('ExceptionInfo' object has no attribute 'assert_close') are pre-existing.

cc @cbilgin @psiddh

@pytorch-bot

pytorch-bot Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

🔗 Helpful Links

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

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

✅ You can merge normally! (1 Unrelated Failure)

As of commit db8867a with merge base 616a0b4 (image):

BROKEN TRUNK - The following job failed but were present on the merge base:

👉 Rebase onto the `viable/strict` branch to avoid these failures

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 28, 2026
@qti-horodnic

Copy link
Copy Markdown
Contributor Author

@pytorchbot label "release notes: qualcomm"

@pytorch-bot pytorch-bot Bot added the release notes: qualcomm Changes to the Qualcomm backend delegate label Oct 28, 2026
@nil-is-all nil-is-all added the module: qnn Issues related to Qualcomm's QNN delegate and code under backends/qualcomm/ label Oct 28, 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. module: qnn Issues related to Qualcomm's QNN delegate and code under backends/qualcomm/ release notes: qualcomm Changes to the Qualcomm backend delegate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants