+
Skip to content

Conversation

jerryzh168
Copy link
Contributor

Summary:
torch.load(file, weights_only=True) is safer so ideally we can use that, by default it does not work with tensor subclasses, since now we have https://pytorch.org/docs/main/notes/serialization.html#torch.serialization.add_safe_globals we can add all tensor subclass classes and special types to globals so that these can work with weights_only=True

Test Plan:
python test/dtypes/test_affine_quantized.py

Reviewers:

Subscribers:

Tasks:

Tags:

Copy link

pytorch-bot bot commented Aug 7, 2024

🔗 Helpful Links

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

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

✅ No Failures

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

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

@jerryzh168 jerryzh168 requested a review from msaroufim August 7, 2024 19:59
@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 Aug 7, 2024
@jerryzh168 jerryzh168 force-pushed the add-aqt-to-safe-global branch 3 times, most recently from a8b7ee6 to 42ccee6 Compare August 8, 2024 00:07
Summary:
`torch.load(file, weights_only=True)` is safer so ideally we can use that, by default it does not work
with tensor subclasses, since now we have https://pytorch.org/docs/main/notes/serialization.html#torch.serialization.add_safe_globals
we can add all tensor subclass classes and special types to globals so that these can work with `weights_only=True`

Test Plan:
python test/dtypes/test_affine_quantized.py

Reviewers:

Subscribers:

Tasks:

Tags:
@jerryzh168 jerryzh168 force-pushed the add-aqt-to-safe-global branch from 42ccee6 to 009d28e Compare August 8, 2024 01:58
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.

LGTM

return int8_dynamic_activation_int8_weight(layout_type=SemiSparseLayoutType())


if TORCH_VERSION_AFTER_2_5:
Copy link

@mikaylagawarecki mikaylagawarecki Aug 8, 2024

Choose a reason for hiding this comment

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

A n00b qn: it wasn't super clear to me why these functions are used during unpickling?

but I trust that you added them because they appeared in the error message :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah that's correct, these functions are serialized as well when we do dynamic quantization

@msaroufim msaroufim merged commit 433cd14 into pytorch:main Aug 8, 2024
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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载