Qualcomm: let the 8a8w QAT activation spec share an observer with per… - #22238
Open
psiddh wants to merge 1 commit into
Open
Qualcomm: let the 8a8w QAT activation spec share an observer with per…#22238psiddh wants to merge 1 commit into
psiddh wants to merge 1 commit into
Conversation
…-channel QNN carries two activation specs: the default config for most ops and the per-channel config for conv and linear. PT2E gives an edge one observer only when the producer's output qspec and the consumer's input qspec agree on every attribute _union_input_edge_with compares -- dtype, is_dynamic, quant_min, quant_max, qscheme, ch_axis, scale, zero_point. observer_or_fake_quant_ctr is deliberately excluded, so this is about attribute values, not spec identity or SharedQuantizationSpec. get_8a8w_qnn_qat_config built its activation spec unconditionally in the symmetric shape: ch_axis=0, no quant_min/quant_max, with only qscheme switching on act_symmetric. get_qat_per_channel_quant_config branches properly, so on the default asymmetric path the two disagree on quant_min, quant_max and ch_axis. Every per-channel conv output meeting a default-config consumer then gets two observers instead of one, which convert_pt2e materializes as a dequantize immediately followed by a requantize. On a conv-relu-conv model with no BatchNorm, QAT produced three such clusters where PTQ produced none. Split on act_symmetric the way get_8a8w_qnn_ptq_config already does. Passing explicit uint8 bounds for per_tensor_affine is a numerical no-op -- the observer already defaults to 0/255, and scale, zero_point and fake-quant output are bit-identical either way -- it only makes the attributes visible to the comparison. Two tests. The first compares the default and per-channel activation specs across every QUANT_CONFIG_DICT entry using PT2E's own _has_same_attr; it carries a _KNOWN_UNSHAREABLE list for the eight 16-bit act_symmetric combinations, where the default configs set quant_min/quant_max unconditionally while the per-channel config omits them. Repairing those changes the observed zero_point on a path that works today, so it is left for a follow-up; the list asserts they still mismatch, so it fails if anything shifts. The second test is the end-to-end guard, counting quantize nodes fed directly by a dequantize. Both fail without the fix: 3 != 0, and mismatched on ['quant_min', 'quant_max', 'ch_axis']. test_passes.py already runs in OSS CI by name, so no workflow change is needed. Authored with assistance from Claude Code.
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/22238
Note: Links to docs will display an error until the docs builds have been completed. This comment was automatically generated by Dr. CI and updates every 15 minutes. |
This PR needs a
|
billmguo
approved these changes
Aug 28, 2026
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.
…-channel
QNN carries two activation specs: the default config for most ops and the per-channel config for conv and linear. PT2E gives an edge one observer only when the producer's output qspec and the consumer's input qspec agree on every attribute _union_input_edge_with compares -- dtype, is_dynamic, quant_min, quant_max, qscheme, ch_axis, scale, zero_point. observer_or_fake_quant_ctr is deliberately excluded, so this is about attribute values, not spec identity or SharedQuantizationSpec.
get_8a8w_qnn_qat_config built its activation spec unconditionally in the symmetric shape: ch_axis=0, no quant_min/quant_max, with only qscheme switching on act_symmetric. get_qat_per_channel_quant_config branches properly, so on the default asymmetric path the two disagree on quant_min, quant_max and ch_axis. Every per-channel conv output meeting a default-config consumer then gets two observers instead of one, which convert_pt2e materializes as a dequantize immediately followed by a requantize. On a conv-relu-conv model with no BatchNorm, QAT produced three such clusters where PTQ produced none.
Split on act_symmetric the way get_8a8w_qnn_ptq_config already does. Passing explicit uint8 bounds for per_tensor_affine is a numerical no-op -- the observer already defaults to 0/255, and scale, zero_point and fake-quant output are bit-identical either way -- it only makes the attributes visible to the comparison.
Two tests. The first compares the default and per-channel activation specs across every QUANT_CONFIG_DICT entry using PT2E's own _has_same_attr; it carries a _KNOWN_UNSHAREABLE list for the eight 16-bit act_symmetric combinations, where the default configs set quant_min/quant_max unconditionally while the per-channel config omits them. Repairing those changes the observed zero_point on a path that works today, so it is left for a follow-up; the list asserts they still mismatch, so it fails if anything shifts. The second test is the end-to-end guard, counting quantize nodes fed directly by a dequantize.
Both fail without the fix: 3 != 0, and mismatched on ['quant_min', 'quant_max', 'ch_axis'].
test_passes.py already runs in OSS CI by name, so no workflow change is needed.