Skip to content

Add QAT support and pass hooks to QuantizationRecipe. - #21935

Open
MartinPavella wants to merge 1 commit into
pytorch:mainfrom
nxp-upstream:nxg01483/EIEX-1011-enable-qat-in-recipe-based-lowering
Open

Add QAT support and pass hooks to QuantizationRecipe.#21935
MartinPavella wants to merge 1 commit into
pytorch:mainfrom
nxp-upstream:nxg01483/EIEX-1011-enable-qat-in-recipe-based-lowering

Conversation

@MartinPavella

Copy link
Copy Markdown
Collaborator

Summary

Extend QuantizationRecipe with QAT support and four ordered pass hooks, then wire them into QuantizeStage.

QuantizationRecipe gains is_qat, train_fn, calibration_inputs_fn, and four pass-list fields (pre_prepare_passes, post_prepare_passes, pre_convert_passes, post_convert_passes). When is_qat=True, QuantizeStage calls prepare_qat_pt2e instead of prepare_pt2e, invokes train_fn on the prepared model, and skips calibration. When is_qat=False (default), PTQ proceeds as before, but callers may now supply a calibration_inputs_fn to supply their own calibration data. If omitted, the existing example-inputs fallback is used. The four pass hooks are applied at the appropriate points in both flows and compose cleanly with _combine_recipes.

_combine_recipes is overhauled to handle all previously dropped fields: the four pass lists are concatenated, is_qat must agree across all combined recipes, at most one train_fn is allowed, and multiple calibration_inputs_fn values are chained into a single factory. The strict, mode, pipeline_stages, and source_transform_in_place scalar fields are now also validated for agreement and propagated to the combined recipe. edge_manager_transform_passes from LoweringRecipe is similarly merged.

Test Plan

pytest -q export/tests/test_export_recipe.py export/tests/test_export_stages.py

@pytorch-bot

pytorch-bot Bot commented Aug 19, 2026

Copy link
Copy Markdown

🔗 Helpful Links

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

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

❌ 1 Cancelled Job

As of commit 538a19c with merge base bea0657 (image):

CANCELLED JOB - The following job was cancelled. Please retry:

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 19, 2026
@linux-foundation-easycla

Copy link
Copy Markdown

CLA Not Signed

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

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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant