KEMBAR78
[Quant][CPU] Enable fp8 qconv by Xia-Weiwen · Pull Request #157076 · pytorch/pytorch · GitHub
Skip to content

Conversation

@Xia-Weiwen
Copy link
Collaborator

@Xia-Weiwen Xia-Weiwen commented Jun 27, 2025

Summary
Enable fp8 qconv on CPU. It's part of the plan to enable fp8 static quantization on CPU. This PR only adds FP8 support of the existing int8 qconv op. It does not add a new op nor does it affect frontend or quantization flow. The schema of the qconv op is not changed either.

So, the FP8 qconv shares the same op as INT8 qconv and the difference is that src/wei dtype is fp8 instead of int8. The output dtype can be fp8/float32/bfloat16. The implementation uses the oneDNN library.

Note:
OneDNN does not support quantized fp8 convolution until v3.9 but the version used in PyTorch is v3.7.2. So, the op goes to the reference kernel for now. And we have also update the oneDNN path so that it's compatible with the fp8 dtype. Once oneDNN is upgraded to v3.9 or newer, minimum changes are needed to enable the oneDNN path. And we have ensured that the behavior of the reference kernel is the same as the new oneDNN's implementation.

  • oneDNN version < 3.9 (now)
    • Always go to the reference kernel
  • oneDNN version >= 3.9 (future)
    • Go to reference kernel on old platforms (without AMX)
    • Use oneDNN on new platforms (with AMX)

Test plan

pytest test/quantization/core/test_quantized_op.py -k "qconv and fp8"

cc @jgong5 @mingfeima @XiaobingSuper @sanchitintel @ashokei @jingxu10 @jerryzh168

@pytorch-bot pytorch-bot bot added module: cpu CPU specific problem (e.g., perf, algorithm) release notes: quantization release notes category labels Jun 27, 2025
@pytorch-bot
Copy link

pytorch-bot bot commented Jun 27, 2025

🔗 Helpful Links

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

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

✅ You can merge normally! (1 Unrelated Failure)

As of commit 0cc5b80 with merge base 84b77ec (image):

FLAKY - The following job failed but was likely due to flakiness present on trunk:

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

@Xia-Weiwen Xia-Weiwen added the intel This tag is for PR from Intel label Jul 4, 2025
@Xia-Weiwen Xia-Weiwen changed the title Fp8 qconv [Quant][CPU] Enable fp8 qconv Jul 4, 2025
@Xia-Weiwen Xia-Weiwen marked this pull request as ready for review July 10, 2025 10:03
@jerryzh168
Copy link
Contributor

have we discussed about long term whether these quantized ops should live in pytorch or torchao?

@Xia-Weiwen
Copy link
Collaborator Author

have we discussed about long term whether these quantized ops should live in pytorch or torchao?

Not yet. Do you have a plan to move all these kernels to Torchao? And does torchao have a plan to build cpp kernels for X86 CPU by default? Thanks.

@Xia-Weiwen
Copy link
Collaborator Author

@pytorchbot merge

@pytorch-bot pytorch-bot bot added the ciflow/trunk Trigger trunk jobs on your pull request label Jul 11, 2025
@pytorchmergebot
Copy link
Collaborator

Merge started

Your change will be merged once all checks pass (ETA 0-4 Hours).

Learn more about merging in the wiki.

Questions? Feedback? Please reach out to the PyTorch DevX Team

Advanced Debugging
Check the merge workflow status
here

@jerryzh168
Copy link
Contributor

does torchao have a plan to build cpp kernels for X86 CPU by default? Thanks.

this is in discussion I think, we can revisit moving these kernels to torchao in the future then. but I think in the end it makes sense to move

@Xia-Weiwen
Copy link
Collaborator Author

does torchao have a plan to build cpp kernels for X86 CPU by default? Thanks.

this is in discussion I think, we can revisit moving these kernels to torchao in the future then. but I think in the end it makes sense to move

Moving makes sense to me, too. Please let us know when you figure out a plan. Thanks.

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

Labels

ciflow/trunk Trigger trunk jobs on your pull request intel This tag is for PR from Intel Merged module: cpu CPU specific problem (e.g., perf, algorithm) open source release notes: quantization release notes category

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants