Skip to content

Add documentation and example of arbitrary QAT flow used with recipe-based export. - #22408

Open
MartinPavella wants to merge 1 commit into
pytorch:mainfrom
nxp-upstream:nxg01483/EIEX-1066-add-documentation-example-for-complex-qat-recipe-flow
Open

Add documentation and example of arbitrary QAT flow used with recipe-based export.#22408
MartinPavella wants to merge 1 commit into
pytorch:mainfrom
nxp-upstream:nxg01483/EIEX-1066-add-documentation-example-for-complex-qat-recipe-flow

Conversation

@MartinPavella

@MartinPavella MartinPavella commented Sep 1, 2026

Copy link
Copy Markdown
Collaborator

Summary

Adds a runnable example and documentation showing how to run an arbitrary Quantization-Aware Training flow in the middle of the declarative export recipe, by splitting the recipe around the QUANTIZE stage.

The declarative ExportRecipe / ExportSession path runs the whole pipeline as one export() call, which is fine for simple calibration but cannot host complex QAT — real training runs involve iterative loops, checkpointing, job restarts, validation-accuracy evaluation, rollback on regression, and possibly separate machines. The recipe's pipeline_stages attribute is used to run the pre-quantize stages, hand the graph off to an out-of-band QAT flow as a .pt2, and resume the recipe from TORCH_EXPORT onward.

  1. New example under examples/export/qat_pipeline_split/: four independently-invokable stages driven by run.sh. 1_prepare.py captures up to the quantize boundary, 2_qat.py prepares with prepare_qat_pt2e and does a stand-in train + checkpoint round-trip before convert_pt2e, 3_lower.py lowers to model.pte via the recipe, and 4_run.py runs the .pte through the runtime. Each stage asserts its own invariants, so the example doubles as a smoke test.

  2. The example shows one method with optional simplifications: the full split sets pipeline_stages explicitly on both halves, while the simplified path skips the pre-quantize slice and lets the recipe auto-skip SOURCE_TRANSFORM / QUANTIZE / TORCH_EXPORT for ExportedProgram input (default pipeline only).

  3. New doc docs/source/using-complex-qat-flows-with-recipe-based-lowering.md, registered in the usage.md toctree and cross-linked from quantization-overview.md. using-executorch-export.md was left untouched since it documents only the imperative API.

Authored with Vero Code.

cc @mergennachin @nil-is-all @iseeyuan @lucylq @helunwencser @tarun292 @kimishpatel @jackzhxng

@MartinPavella MartinPavella self-assigned this Sep 1, 2026
@MartinPavella MartinPavella added module: doc Issues related to documentation, both in docs/ and inlined in code module: examples Issues related to demos under examples/ labels Sep 1, 2026
@pytorch-bot

pytorch-bot Bot commented Sep 1, 2026

Copy link
Copy Markdown

🔗 Helpful Links

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

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

❌ 4 New Failures, 2 Unrelated Failures

As of commit 993330f with merge base a822ab2 (image):

NEW FAILURES - The following jobs have failed:

FLAKY - The following jobs failed but were likely due to flakiness present on trunk:

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

Copy link
Copy Markdown

CLA Not Signed

@github-actions

github-actions Bot commented Sep 1, 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. module: doc Issues related to documentation, both in docs/ and inlined in code module: examples Issues related to demos under examples/

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant