Skip to content

Conversation

@liangel-02
Copy link
Contributor

@liangel-02 liangel-02 commented Nov 5, 2025

Summary

We keep track of what has been processed by deleting processed keys from the original state dict. This is for the case when not all tensor attributes are available to us when loading, so we reconstruct the tensor subclasses with missing attributes in a later call.

We expect the state dict to be empty after loading is complete

Test
python test/prototype/safetensors/test_safetensors_support.py

@pytorch-bot
Copy link

pytorch-bot bot commented Nov 5, 2025

🔗 Helpful Links

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

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

⏳ No Failures, 1 Pending

As of commit f179ca5 with merge base e2aab90 (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 Nov 5, 2025
@liangel-02 liangel-02 added the topic: improvement Use this tag if this PR is an improvement (doesn't fit into any of the other categories) label Nov 5, 2025
@liangel-02 liangel-02 force-pushed the update_metadata_structure branch 6 times, most recently from 0e290bb to cdc5ca2 Compare November 5, 2025 23:55
@liangel-02 liangel-02 requested a review from jerryzh168 November 6, 2025 16:22
@liangel-02 liangel-02 marked this pull request as ready for review November 6, 2025 16:22
Copy link
Contributor

@jerryzh168 jerryzh168 left a comment

Choose a reason for hiding this comment

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

I think current impl is a bit hacky, what we can do is:

unflatten_tensor_state_dict with incomplete state_dict:
   return a tuple of (unflattened_state_dict, unused part of incomplete_state_dict)
   
next call: combine the new state_dict input, with the previous unconsumed part

@liangel-02 liangel-02 force-pushed the update_metadata_structure branch 2 times, most recently from ae774e7 to cea5523 Compare November 13, 2025 21:16
@liangel-02 liangel-02 force-pushed the update_metadata_structure branch from cea5523 to 21875a1 Compare November 14, 2025 15:56
@liangel-02 liangel-02 force-pushed the update_metadata_structure branch 3 times, most recently from ab10de6 to e1202bc Compare November 14, 2025 20:30
Copy link
Contributor

@jerryzh168 jerryzh168 left a comment

Choose a reason for hiding this comment

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

looks good, thanks!

@liangel-02 liangel-02 force-pushed the update_metadata_structure branch from e1202bc to a684afa Compare November 14, 2025 20:45
@liangel-02 liangel-02 force-pushed the update_metadata_structure branch from a684afa to f179ca5 Compare November 14, 2025 21:07
@liangel-02 liangel-02 merged commit 0292cb8 into main Nov 14, 2025
18 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: improvement Use this tag if this PR is an improvement (doesn't fit into any of the other categories)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants