Skip to content

Walk transparent ops when extracting input quant params#20139

Open
ethansfng wants to merge 1 commit into
pytorch:mainfrom
ethansfng:export-D107922730
Open

Walk transparent ops when extracting input quant params#20139
ethansfng wants to merge 1 commit into
pytorch:mainfrom
ethansfng:export-D107922730

Conversation

@ethansfng

Copy link
Copy Markdown
Contributor

Summary:
extract_input_quant_params_from_graph (used by QuantizedInputWrapper to dequantize pre-quantized inputs) only matched a quantize_per_tensor placed directly on the input placeholder. Inputs that pass through a shape-only op first -- an nhwc permute, or a patchify reshape -- defeated it, so callers had to pre-compute the quant params themselves.

Walk from each input placeholder through a chain of transparent ops (view/reshape/permute/transpose/slice/to/...) to the first quantize_per_tensor, so QuantizedInputWrapper(module, input_names) resolves those inputs automatically. Backward compatible (a quantize directly on the placeholder is just a zero-hop walk) and subsumes the narrower extract_quant_params_through_permute.

Differential Revision: D107922730

Summary:
`extract_input_quant_params_from_graph` (used by `QuantizedInputWrapper` to dequantize pre-quantized inputs) only matched a `quantize_per_tensor` placed directly on the input placeholder. Inputs that pass through a shape-only op first -- an nhwc `permute`, or a patchify `reshape` -- defeated it, so callers had to pre-compute the quant params themselves.

Walk from each input placeholder through a chain of transparent ops (`view`/`reshape`/`permute`/`transpose`/`slice`/`to`/...) to the first `quantize_per_tensor`, so `QuantizedInputWrapper(module, input_names)` resolves those inputs automatically. Backward compatible (a quantize directly on the placeholder is just a zero-hop walk) and subsumes the narrower `extract_quant_params_through_permute`.

Differential Revision: D107922730
@pytorch-bot

pytorch-bot Bot commented Jun 9, 2026

Copy link
Copy Markdown

🔗 Helpful Links

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

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

✅ No Failures

As of commit e9b1f53 with merge base dc55469 (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 Jun 9, 2026
@meta-codesync

meta-codesync Bot commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

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

@github-actions

github-actions Bot commented Jun 9, 2026

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.

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.

1 participant