Skip to content

[Quant][PT2E][X86] Enable annotation of aten.mul.tensor with X86InductorQuantizer #2075

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
Apr 24, 2025

Conversation

Xia-Weiwen
Copy link
Collaborator

@Xia-Weiwen Xia-Weiwen commented Apr 18, 2025

Summary
(It's a port from pytorch/pytorch#150831)
This PR enabled annotation of aten.mul.tensor with X86InductorQuantizer. However, mul is not annotated by default. Users need to set the following to enable annotation of mul:

quantizer.set_function_type_qconfig(
    torch.mul, quantizer.get_global_quantization_config()
)

After convert_pt2e, users get patterns like

quantize_per_tensor_default = torch.ops.quantized_decomposed.quantize_per_tensor.default(x, ...)
dequantize_per_tensor_default = torch.ops.quantized_decomposed.dequantize_per_tensor.default(quantize_per_tensor_default, ...)
quantize_per_tensor_default_1 = torch.ops.quantized_decomposed.quantize_per_tensor.default(y, ...);
dequantize_per_tensor_default_1 = torch.ops.quantized_decomposed.dequantize_per_tensor.default(quantize_per_tensor_default_1, ...)
mul = torch.ops.aten.mul.Tensor(dequantize_per_tensor_default, dequantize_per_tensor_default_1);

Test plan

pytest test/quantization/pt2e/test_x86inductor_quantizer.py -k test_annotate_mul_tensor

Copy link

pytorch-bot bot commented Apr 18, 2025

🔗 Helpful Links

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

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

✅ No Failures

As of commit f01c1fa with merge base 34421b1 (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 Apr 18, 2025
@Xia-Weiwen Xia-Weiwen added the topic: new feature Use this tag if this PR adds a new feature label Apr 18, 2025
Copy link
Collaborator

@leslie-fang-intel leslie-fang-intel left a comment

Choose a reason for hiding this comment

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

LGTM

@Xia-Weiwen Xia-Weiwen requested a review from jerryzh168 April 21, 2025 01:58
@Xia-Weiwen
Copy link
Collaborator Author

Hi @jerryzh168 Could you please review this PR? Thanks.

@Xia-Weiwen Xia-Weiwen marked this pull request as ready for review April 23, 2025 06:10
@Xia-Weiwen Xia-Weiwen merged commit ddce558 into pytorch:main Apr 24, 2025
25 of 28 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: new feature Use this tag if this PR adds a new feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants