Skip to content

Conversation

liangel-02
Copy link
Contributor

Context

Currently we serialize and distribute torchao quantized model with pytorch native APIs, specifically torch.save(model.state_dict())and model.load_state_dict(state_dict, assign=True)

Summary

This PR builds out the functionality save_tensor_subclass_dict and load_tensor_subclass_dict using save_file and load_file from safetensors library for FP8 based off of the script here.

Test Plan

Outputs match after saving/loading model.state_dict()

Copy link

pytorch-bot bot commented Aug 26, 2025

🔗 Helpful Links

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

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

⏳ No Failures, 1 Pending

As of commit c4e9165 with merge base 2f78cfe (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 Aug 26, 2025
@liangel-02 liangel-02 added topic: not user facing Use this tag if you don't want this PR to show up in release notes module: rocm ciflow/rocm ciflow/4xh100 labels Aug 26, 2025
@liangel-02 liangel-02 requested a review from jerryzh168 August 26, 2025 18:11
@liangel-02 liangel-02 marked this pull request as ready for review August 26, 2025 18:11
@liangel-02 liangel-02 changed the title safetensor support safetensors support Aug 26, 2025
Comment on lines +9 to +11
from torchao.quantization import Float8Tensor
from torchao.quantization.quantize_.common import KernelPreference
from torchao.quantization.quantize_.workflows import QuantizeTensorToFloat8Kwargs
Copy link
Contributor

Choose a reason for hiding this comment

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

looks like some imports are not used?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

these are used to create the ALLOWED_CLASSES dict

Copy link

@mikaylagawarecki mikaylagawarecki left a comment

Choose a reason for hiding this comment

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

Thanks for restricting to ALLOWED_CLASSES

@liangel-02 liangel-02 merged commit 4236656 into main Aug 29, 2025
20 checks passed
@liangel-02 liangel-02 deleted the safetensor branch August 29, 2025 01:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ciflow/rocm ciflow/4xh100 CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. module: rocm 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