-
Notifications
You must be signed in to change notification settings - Fork 177
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for using AffineQuantizedTensor with weights_only=True
#630
Conversation
🔗 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 FailuresAs of commit 009d28e with merge base 8bba8ed (): This comment was automatically generated by Dr. CI and updates every 15 minutes. |
a8b7ee6
to
42ccee6
Compare
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:
42ccee6
to
009d28e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@@ -466,3 +481,7 @@ def int8_dynamic_activation_int8_semi_sparse_weight(): | |||
""" | |||
from torchao.dtypes import SemiSparseLayoutType | |||
return int8_dynamic_activation_int8_weight(layout_type=SemiSparseLayoutType()) | |||
|
|||
|
|||
if TORCH_VERSION_AFTER_2_5: |
There was a problem hiding this comment.
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 :)
There was a problem hiding this comment.
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
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 withweights_only=True
Test Plan:
python test/dtypes/test_affine_quantized.py
Reviewers:
Subscribers:
Tasks:
Tags: