Skip to content

Only claim conv overloads the QAT fold can actually match - #22241

Merged
meta-codesync[bot] merged 1 commit into
pytorch:mainfrom
billmguo:export-D117778197
Aug 28, 2026
Merged

Only claim conv overloads the QAT fold can actually match#22241
meta-codesync[bot] merged 1 commit into
pytorch:mainfrom
billmguo:export-D117778197

Conversation

@billmguo

Copy link
Copy Markdown
Contributor

Summary:
annotate_conv_bn_partitions listed aten.conv2d.padding and
aten.convolution.default in CONV_TARGETS, but torchao can never fold either.
_fuse_conv_bn_qat and _fold_conv_bn_qat both trace their patterns from
F.conv1d, F.conv2d, F.conv_transpose1d and F.conv_transpose2d, so only
those four overloads can match.

Claiming a conv the fold cannot match is worse than not claiming it. The pass
drops the conv's output qspec on the assumption the fold will move the bn output
observer onto the conv; when the fold misses, the conv is left emitting float32
into a quantized graph and QNN rejects it with 0x232 != 0x408 (FLOAT_32 meeting
UFIXED_POINT_8) -- the very failure the module docstring describes.

nn.Conv2d(..., padding="same") exports to aten.conv2d.padding and hit exactly
this. aten.convolution.default only appears after decomposition, long after
this pass runs, so it never matched anything.

Measured on master, conv+bn+relu through prepare_qat_pt2e -> convert_pt2e
with QnnQuantizer(8a8w, is_qat=True):

model exported target in CONV_TARGETS bn survives conv output unquantized
Conv2d(padding=1) conv2d.default yes no 0
Conv2d(padding="same") conv2d.padding yes yes 1
Conv1d(padding="same") conv1d.padding no yes 0
ConvTranspose2d conv_transpose2d.input yes no 0

conv1d.padding is the control: it also fails to fold -- that is a torchao
limitation this pass cannot fix -- but because it was never claimed, the per-node
annotator still gives the conv an output qspec and the graph stays valid. Only
the overload this pass claimed lost its output. After narrowing CONV_TARGETS,
the conv2d.padding case reports 0 unquantized conv outputs.

Note _is_conv_or_conv_transpose_node is not a usable guard here -- it returns
True for conv2d.padding (torchao/quantization/pt2e/utils.py, _is_conv_node).

Differential Revision: D117778197

Summary:
`annotate_conv_bn_partitions` listed `aten.conv2d.padding` and
`aten.convolution.default` in `CONV_TARGETS`, but torchao can never fold either.
`_fuse_conv_bn_qat` and `_fold_conv_bn_qat` both trace their patterns from
`F.conv1d`, `F.conv2d`, `F.conv_transpose1d` and `F.conv_transpose2d`, so only
those four overloads can match.

Claiming a conv the fold cannot match is worse than not claiming it. The pass
drops the conv's output qspec on the assumption the fold will move the bn output
observer onto the conv; when the fold misses, the conv is left emitting float32
into a quantized graph and QNN rejects it with `0x232 != 0x408` (FLOAT_32 meeting
UFIXED_POINT_8) -- the very failure the module docstring describes.

`nn.Conv2d(..., padding="same")` exports to `aten.conv2d.padding` and hit exactly
this. `aten.convolution.default` only appears after decomposition, long after
this pass runs, so it never matched anything.

Measured on master, conv+bn+relu through `prepare_qat_pt2e` -> `convert_pt2e`
with `QnnQuantizer(8a8w, is_qat=True)`:

| model | exported target | in CONV_TARGETS | bn survives | conv output unquantized |
| --- | --- | --- | --- | --- |
| `Conv2d(padding=1)` | `conv2d.default` | yes | no | 0 |
| `Conv2d(padding="same")` | `conv2d.padding` | **yes** | yes | **1** |
| `Conv1d(padding="same")` | `conv1d.padding` | no | yes | 0 |
| `ConvTranspose2d` | `conv_transpose2d.input` | yes | no | 0 |

`conv1d.padding` is the control: it also fails to fold -- that is a torchao
limitation this pass cannot fix -- but because it was never claimed, the per-node
annotator still gives the conv an output qspec and the graph stays valid. Only
the overload this pass claimed lost its output. After narrowing `CONV_TARGETS`,
the `conv2d.padding` case reports 0 unquantized conv outputs.

Note `_is_conv_or_conv_transpose_node` is not a usable guard here -- it returns
True for `conv2d.padding` (`torchao/quantization/pt2e/utils.py`, `_is_conv_node`).

Differential Revision: D117778197
@pytorch-bot

pytorch-bot Bot commented Aug 27, 2026

Copy link
Copy Markdown

🔗 Helpful Links

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

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

❌ 2 New Failures, 7 Pending, 1 Unrelated Failure

As of commit d4e9d75 with merge base d0c2da3 (image):

NEW FAILURES - The following jobs have failed:

  • Cadence Build & Test / hifi-build / hifi4 (gh)
    ##[error]Refusing to check out fork pull request code from a 'pull_request_target' workflow. This workflow runs with the base repository's GITHUB_TOKEN, secrets, default-branch cache scope, and runner access. Fetching and executing a fork's code in that trusted context commonly leads to "pwn request" vulnerabilities. To opt in, review the risks at https://gh.io/securely-using-pull_request_target and set 'allow-unsafe-pr-checkout: true' on the actions/checkout step.
  • Cadence Build & Test / vision-build / vision (gh)
    ##[error]Refusing to check out fork pull request code from a 'pull_request_target' workflow. This workflow runs with the base repository's GITHUB_TOKEN, secrets, default-branch cache scope, and runner access. Fetching and executing a fork's code in that trusted context commonly leads to "pwn request" vulnerabilities. To opt in, review the risks at https://gh.io/securely-using-pull_request_target and set 'allow-unsafe-pr-checkout: true' on the actions/checkout step.

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 Aug 27, 2026
@meta-codesync

meta-codesync Bot commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

@billmguo has exported this pull request. If you are a Meta employee, you can view the originating Diff in D117778197.

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

@qti-horodnic qti-horodnic left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks for fixing the issue quickly

@meta-codesync
meta-codesync Bot merged commit 517e56a into pytorch:main Aug 28, 2026
202 of 210 checks passed
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. meta-exported

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants