Repository navigation
Qualcomm AI Engine Direct - Default use_16a16w to per-tensor conv weights - #24250
Open
qti-horodnic wants to merge 1 commit into
Open
qti-horodnic wants to merge 1 commit into
qti-horodnic wants to merge 1 commit into
Conversation
🔗 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 ( 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. |
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
This is a fix/workaround for a community-reported issue.
With
use_16a16w,make_quantizerdefaulted to per-channel int16 conv weights. The conv bias is quantized to int32 with a derived scale ofact_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 / scalereaches 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_quantizernow takesper_channel_conv=Noneand resolves it to per-tensor foruse_16a16wand per-channel for every other dtype. An explicitper_channel_conv=Trueis respected, andset_default_quant_configlogs 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
Quantizationindocs/source/backends-qualcomm.md.This changes the conv weight encoding for existing 16a16w users who did not pass
per_channel_conv, including theefficientnet.py,albert.pyandeurobert.pyexamples.Test plan
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 explicitper_channel_conv=Truestays per-channel and warns. It fails on the previous code and passes with this change.test_passes.pyalso 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