Skip to content

Absorb an input quantize read by several fused ops into all of them - #25740

Open
DrJessop wants to merge 1 commit into
pytorch:mainfrom
DrJessop:export-D134566322
Open

DrJessop wants to merge 1 commit into
pytorch:mainfrom
DrJessop:export-D134566322

Conversation

@DrJessop

Copy link
Copy Markdown
Contributor

Summary:
Input-side quant absorption (absorb_into_inputs) absorbs a dequantize -> quantize pair into the input qparams of the fused op that reads it, but only when the quantize has one reader. A model input read by several ops keeps the pair, which then becomes a requantize: with --image-input, XLSR's uint8 pixels feed its five parallel first-layer convs, so a uint8 -> int8 requantize (same scale, zero point 0 -> -128, exact) runs before them, while UNet's single first conv reads uint8 directly.

_try_absorb_input_fan_out absorbs the pair into every reader, or into none: each reader must be a fused op that reads the quantize only through input slots, has per-tensor qparams, can represent its composed qparams, and keeps a zero point of 0 if it is in symmetric_quant_input_ops. Each reader composes its own qparams, as a single reader does. A reader behind a passthrough still does not qualify, since the chain itself would fork. The single-reader path is unchanged; the symmetric check is now made per reader, so _try_absorb_input takes the op set instead of a flag.

It stays behind the absorb_into_inputs opt-in.

Differential Revision: D134566322

Summary:
Input-side quant absorption (`absorb_into_inputs`) absorbs a dequantize -> quantize pair into the input qparams of the fused op that reads it, but only when the quantize has one reader. A model input read by several ops keeps the pair, which then becomes a requantize: with `--image-input`, XLSR's uint8 pixels feed its five parallel first-layer convs, so a uint8 -> int8 requantize (same scale, zero point 0 -> -128, exact) runs before them, while UNet's single first conv reads uint8 directly.

`_try_absorb_input_fan_out` absorbs the pair into every reader, or into none: each reader must be a fused op that reads the quantize only through input slots, has per-tensor qparams, can represent its composed qparams, and keeps a zero point of 0 if it is in `symmetric_quant_input_ops`. Each reader composes its own qparams, as a single reader does. A reader behind a passthrough still does not qualify, since the chain itself would fork. The single-reader path is unchanged; the symmetric check is now made per reader, so `_try_absorb_input` takes the op set instead of a flag.

It stays behind the `absorb_into_inputs` opt-in.

Differential Revision: D134566322
@pytorch-bot

pytorch-bot Bot commented Nov 25, 2026 •

Copy link
Copy Markdown

🔗 Helpful Links

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

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

✅ No Failures

As of commit 26a25fd with merge base 3469d36 (image):
💚 Looks good so far! There are no failures yet. 💚

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@meta-codesync

meta-codesync Bot commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

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

@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 Nov 25, 2026
@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.

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. meta-exported

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant