Skip to content
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

[Intel GPU] Docs of XPUInductorQuantizer #3293

Draft
wants to merge 11 commits into
base: main
Choose a base branch
from

Conversation

ZhiweiYan-96
Copy link

@ZhiweiYan-96 ZhiweiYan-96 commented Mar 18, 2025

Description

Add tutorials for XPUInductorQuantzer, which serves as the INT8 quantization backend for Intel GPU inside PT2E.

Copy link

pytorch-bot bot commented Mar 18, 2025

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/tutorials/3293

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

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

Comment on lines 180 to 183
::
quantizer = XPUInductorQuantizer()
quantizer.set_global(get_xpu_inductor_symm_quantization_config())

Choose a reason for hiding this comment

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

The code format has not taken effect.

Copy link
Author

Choose a reason for hiding this comment

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

thanks for reminding, added the fix.

@ZhiweiYan-96 ZhiweiYan-96 marked this pull request as draft March 19, 2025 05:48
@svekars svekars added the 2.7 label Mar 19, 2025
@svekars svekars requested a review from AlannaBurke March 21, 2025 16:14
@@ -96,6 +96,13 @@ Prototype features are not available as part of binary distributions like PyPI o
:link: ../prototype/pt2e_quant_x86_inductor.html
:tags: Quantization

.. customcarditem::
:header: PyTorch 2 Export Quantization with Intel GPU Backend through Inductor

Choose a reason for hiding this comment

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

Intel XPU

Copy link
Author

Choose a reason for hiding this comment

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

At previous stage when we upload RFCs, we recommend using GPU instead of XPU for readability for users. Do we have some changes on this description desicsion?

@@ -0,0 +1,234 @@
PyTorch 2 Export Quantization with Intel GPU Backend through Inductor

Choose a reason for hiding this comment

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

Intel XPU

Copy link
Author

Choose a reason for hiding this comment

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

ditto

utilizes PyTorch 2 Export Quantization flow and lowers the quantized model into the inductor.

The pytorch 2 export quantization flow uses the torch.export to capture the model into a graph and perform quantization transformations on top of the ATen graph.
This approach is expected to have significantly higher model coverage, better programmability, and a simplified UX.

Choose a reason for hiding this comment

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

This approach is expected to have significantly higher model coverage with better programmability and a simplified user experience.

Copy link
Author

Choose a reason for hiding this comment

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

Thanks for suggestions, modified.

The quantization flow mainly includes three steps:

- Step 1: Capture the FX Graph from the eager Model based on the `torch export mechanism <https://pytorch.org/docs/main/export.html>`_.
- Step 2: Apply the Quantization flow based on the captured FX Graph, including defining the backend-specific quantizer, generating the prepared model with observers,

Choose a reason for hiding this comment

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

Apply the quantization flow based on the captured FX Graph, including defining the backend-specific quantizer, generating the prepared model with observers,

Copy link
Author

Choose a reason for hiding this comment

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

Thanks for suggestions, has changed the description here.

performing the prepared model's calibration, and converting the prepared model into the quantized model.
- Step 3: Lower the quantized model into inductor with the API ``torch.compile``.

During Step 3, the inductor would decide which kernels are dispatched into. There are two kinds of kernels the Intel GPU would obtain benefits, oneDNN kernels and triton kernels. `Intel oneAPI Deep Neural Network Library (oneDNN) <https://github.com/uxlfoundation/oneDNN>`_ contains

Choose a reason for hiding this comment

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

If a end-user documentation, I think we could focus on PyTorch itself, and remove this section explanation.

Copy link
Author

Choose a reason for hiding this comment

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

Thanks for suggestion, I removed the prolonged description over oneDNN and triton. Instead, I add a simple mention at Step 3 above.

Post Training Quantization
----------------------------

Static quantization is the only method we support currently. QAT and dynamic quantization will be available in later versions.

Choose a reason for hiding this comment

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

remove the further ready context from current introduction - "QAT and dynamic quantization will be available in later versions."

Copy link
Author

Choose a reason for hiding this comment

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

Thanks for suggestion, removed.


::

pip install torchvision pytorch-triton-xpu --index-url https://download.pytorch.org/whl/nightly/xpu

Choose a reason for hiding this comment

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

Let's use standard "pip install torch torchvision torchaudio", not separate internal commands to highlight the internal dependencies command.

Copy link
Author

@ZhiweiYan-96 ZhiweiYan-96 Mar 24, 2025

Choose a reason for hiding this comment

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

Lets keep using our own channels, since torchvision is customized on XPU, we need let user could run example in this doc successfully. Synced with @jingxu10 let's us pip3 install torch torchvision torchaudio pytorch-triton-xpu --index-url https://download.pytorch.org/whl/xpu, instead of nightly wheel.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants