Skip to content

Conversation

Xia-Weiwen
Copy link
Collaborator

@Xia-Weiwen Xia-Weiwen commented Sep 24, 2025

Summary
This is part of a previous PR #2505 since the original is too big.
This PR adds two ops for float8 linear on CPU, one for weight packing and the other for computation.

  • float8_linear_prepack_cpu
  • float8_linear_cpu

They will be used for float8 tensor subclass in the future.

Test plan

pytest -sv test/test_ops.py -k test_float8_linear_cpu

Copy link

pytorch-bot bot commented Sep 24, 2025

🔗 Helpful Links

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

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

✅ No Failures

As of commit fd3d6b5 with merge base 8e2ca35 (image):
💚 Looks good so far! There are no failures yet. 💚

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 24, 2025
@Xia-Weiwen Xia-Weiwen added the topic: not user facing Use this tag if you don't want this PR to show up in release notes label Sep 24, 2025
@Xia-Weiwen
Copy link
Collaborator Author

Xia-Weiwen commented Sep 24, 2025

CC @mingfeima This PR is a copy of the op implementation of the previous PR #2505 because the original PR is too big. Thanks.

Copy link

@mingfeima mingfeima 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 marked this pull request as ready for review September 24, 2025 06:30
@Xia-Weiwen Xia-Weiwen merged commit 5e90c47 into pytorch:main Sep 25, 2025
18 checks passed
@jcaip
Copy link
Contributor

jcaip commented Sep 29, 2025

Sorry @Xia-Weiwen @jerryzh168 but this is breaking some internal tests, going to revert: https://www.internalfb.com/tasks/?t=239795912

It looks to be complaining about a warning with the switch statement:

fbcode/pytorch/ao/torchao/csrc/cpu/aten_kernels/float8_linear.cpp:588:3: error: switch condition has boolean value [-Werror,-Wswitch-bool]
  588 |   AT_DISPATCH_LINEAR_KERNEL(output_dtype, cpublas_can_pack, act_quant_mode, wei_quant_mode, [&](){
      |   ^                                       ~~~~~~~~~~~~~~~~
fbcode/pytorch/ao/torchao/csrc/cpu/aten_kernels/utils.h:100:5: note: expanded from macro 'AT_DISPATCH_LINEAR_KERNEL'
  100 |     AT_DISPATCH_BOOL(                                                                   \
      |     ^
  101 |         CAN_PACK, "cpublas_can_pack", can_pack,                                         \
      |         ~~~~~~~~
fbcode/pytorch/ao/torchao/csrc/cpu/aten_kernels/utils.h:84:5: note: expanded from macro 'AT_DISPATCH_BOOL'
   84 |     switch (VALUE) {                                         \
      |     ^       ~~~~~

jcaip added a commit that referenced this pull request Sep 29, 2025
jcaip added a commit that referenced this pull request Sep 29, 2025
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: not user facing Use this tag if you don't want this PR to show up in release notes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants