-
Notifications
You must be signed in to change notification settings - Fork 26.3k
Closed
Closed
Copy link
Labels
actionablemodule: docsRelated to our documentation, both in docs/ and docblocksRelated to our documentation, both in docs/ and docblocksmodule: serializationIssues related to serialization (e.g., via pickle, or otherwise) of PyTorch objectsIssues related to serialization (e.g., via pickle, or otherwise) of PyTorch objectstriagedThis issue has been looked at a team member, and triaged and prioritized into an appropriate moduleThis issue has been looked at a team member, and triaged and prioritized into an appropriate module
Description
📚 The doc issue
The doc of save() says the default value of pickle_protocol parameter is DEFAULT_PROTOCOL as shown below:
torch.save(..., pickle_protocol=DEFAULT_PROTOCOL, ...)
But DEFAULT_PROTOCOL has 2 by default according to the source code as shown below:
...
import copyreg
import pickle
import torch._weights_only_unpickler as _weights_only_unpickler
DEFAULT_PROTOCOL = 2 # Here
LONG_SIZE = struct.Struct('=l').size
INT_SIZE = struct.Struct('=i').size
SHORT_SIZE = struct.Struct('=h').size
...
[[docs]](https://pytorch.org/docs/stable/generated/torch.save.html#torch.save)def save(
obj: object,
f: FILE_LIKE,
pickle_module: Any = pickle,
pickle_protocol: int = DEFAULT_PROTOCOL,
_use_new_zipfile_serialization: bool = True,
_disable_byteorder_record: bool = False
) -> None:Suggest a potential alternative/fix
So, the doc of save() should say the default value of pickle_protocol parameter is 2 as shown below:
torch.save(..., pickle_protocol=2, ...)
cc @svekars @brycebortree @sekyondaMeta @mruberry @mikaylagawarecki
Metadata
Metadata
Assignees
Labels
actionablemodule: docsRelated to our documentation, both in docs/ and docblocksRelated to our documentation, both in docs/ and docblocksmodule: serializationIssues related to serialization (e.g., via pickle, or otherwise) of PyTorch objectsIssues related to serialization (e.g., via pickle, or otherwise) of PyTorch objectstriagedThis issue has been looked at a team member, and triaged and prioritized into an appropriate moduleThis issue has been looked at a team member, and triaged and prioritized into an appropriate module