Skip to content

Add pt2e tutorials to torchao doc page #2384

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 17, 2025
Merged

Conversation

jerryzh168
Copy link
Contributor

Summary:
att, after we migrate pt2e quant code from pytorch to torchao, now we also want to migrate the docs as well

Test Plan:
check generated docs

Reviewers:

Subscribers:

Tasks:

Tags:

Copy link

pytorch-bot bot commented Jun 16, 2025

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/ao/2384

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

⏳ No Failures, 4 Pending

As of commit 15ab040 with merge base 5239ce7 (image):
💚 Looks good so far! There are no failures yet. 💚

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

@facebook-github-bot facebook-github-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 16, 2025
@jerryzh168 jerryzh168 force-pushed the pt2e-docs branch 2 times, most recently from 5787021 to 7743246 Compare June 16, 2025 20:28
@jerryzh168 jerryzh168 added the topic: documentation Use this tag if this PR adds or improves documentation label Jun 16, 2025
@jerryzh168 jerryzh168 requested a review from andrewor14 June 16, 2025 20:47
tutorials_source/pt2e_quant_x86_inductor
tutorials_source/pt2e_quant_xpu_inductor
tutorials_source/pt2e_quantizer
tutorials_source/openvino_quantizer
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it possible to group these somehow? Maybe a new "PT2E Tutorials" section or something? Right now it looks kind of cluttered and makes other torchao tutorials look small

Screenshot 2025-06-16 at 4 50 05 PM

Copy link
Contributor

Choose a reason for hiding this comment

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

Also what do you think about renaming these tutorials to make the titles look more consistent, e.g.

PyTorch 2 Export: Post-Training Quantization (PTQ) (prototype)
PyTorch 2 Export: Quantization-Aware Training (QAT) (prototype)
PyTorch 2 Export: Quantization with X86 Backend through Inductor
PyTorch 2 Export: Quantization with Intel GPU Backend through Inductor
PyTorch 2 Export: How to Write Your Own Quantizer
PyTorch 2 Export: Quantization for OpenVINO torch.compile Backend

Copy link
Contributor

Choose a reason for hiding this comment

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

If these are all under a "PyTorch 2 Export Tutorials" section I feel we can even just drop the prefix in front of each one of these (but keep them on the actual tutorial page if that's possible, not sure how though)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sure, updated

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have put these in a separate category

# we have a model with aten ops doing integer computations when possible
# move the quantized model to eval mode, equivalent to `m.eval()`
torch.ao.quantization.move_exported_model_to_eval(converted_model)
Copy link
Contributor

Choose a reason for hiding this comment

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

did we also migrate this helper function over? I feel this is needed for QAT

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah we did

@jerryzh168 jerryzh168 force-pushed the pt2e-docs branch 3 times, most recently from bcc9a54 to 853f501 Compare June 16, 2025 21:51
@jerryzh168
Copy link
Contributor Author

jerryzh168 commented Jun 16, 2025

cc @Xia-Weiwen @leslie-fang-intel we are moving these tutorials to torchao docs, please take a look
cc @ZhiweiYan-96 @EikanWang @liangan1 @riverliuintel @CuiYifeng on xpu tutorials
cc @daniil-lyakhov @anzr299 @alexsu52 @ynimmaga @AlexKoff88 on openvino tutorials

I just moved the docs, haven't really checking whether these new APIs works or not since it may require updates in the backend quantizers. please help check the new APIs and also help update backend related code to make sure the tutorials works as well

@daniil-lyakhov
Copy link

daniil-lyakhov commented Jun 17, 2025

Hello, @jerryzh168!
Unfortunately, the OpenVINOQuantizer tutorial does not work with the torchao, but migration is not straightforward for us:
NNCF and OpenVINOQuantizer have to migrate to torchao. But NNCF supports other quantizers, like XNNPACKQuantizer and X86InductorQuantizer. We are using them to run precommit tests, but with the update, we have to add torchao and executorch (master branch) as a dependencies. (because 0.6.0 XNNPACKQuantizer still uses torch.ao)

So the question is - when there will be the next executorch release? Will it depend on the latest torch==2.7.1?
To enable tests as they are, we have to build the repo from the source, so, before doing that, I would like your opinion on that. Is it better to wait until the executorch release or better start to use master branch immediately?

@jerryzh168
Copy link
Contributor Author

jerryzh168 commented Jun 17, 2025

But NNCF supports other quantizers, like XNNPACKQuantizer and X86InductorQuantizer.

@daniil-lyakhov XNNPACKQuantizer is moved to executorch and X86InductorQuantizer is also moved to torchao can you change dependency to these?

ET next release is end of July: pytorch/executorch#11075, torchao next release will happen soon.

Will it depend on the latest torch==2.7.1?

I heard from @metascroy that it will depend on 2.8

I'm not sure how the dependency situation in nncf, but typically the way we are doing it is have some version check for the required libraries like

ao/torchao/utils.py

Lines 363 to 369 in 63a91d7

TORCH_VERSION_AT_LEAST_2_8 = torch_version_at_least("2.8.0")
TORCH_VERSION_AT_LEAST_2_7 = torch_version_at_least("2.7.0")
TORCH_VERSION_AT_LEAST_2_6 = torch_version_at_least("2.6.0")
TORCH_VERSION_AT_LEAST_2_5 = torch_version_at_least("2.5.0")
TORCH_VERSION_AT_LEAST_2_4 = torch_version_at_least("2.4.0")
TORCH_VERSION_AT_LEAST_2_3 = torch_version_at_least("2.3.0")
TORCH_VERSION_AT_LEAST_2_2 = torch_version_at_least("2.2.0")
and implement the new changes in a branch while keep both new and old paths working, and provide support for old path for a few releases and then remove them.

for example currently torchao only supports pytorch version >= 2.5.1

it probably doesn't have to block the doc, I can put up the doc first and feel free to update the new torchao doc and remove the old one when you are ready

Summary:
att, after we migrate pt2e quant code from pytorch to torchao, now we
also want to migrate the docs as well

Test Plan:
check generated docs

Reviewers:

Subscribers:

Tasks:

Tags:
@jerryzh168 jerryzh168 merged commit 0a93be7 into pytorch:main Jun 17, 2025
22 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. topic: documentation Use this tag if this PR adds or improves documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants