-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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 weights_only=True in torch.load #6094
Add weights_only=True in torch.load #6094
Conversation
I didnt check which case should not use weights_only=True. I just add it in all of the torch.load. Hope it will help. |
@terry-for-github, thanks for making DeepSpeed more secure. |
@@ -116,7 +116,7 @@ def show_transformer_file_map(self): | |||
self._dump_mapping(self.transformer_file_map, 'rank_to_transformer_files') | |||
|
|||
def _build_global_state(self): | |||
sd = torch.load(self.mp_rank_files[0], map_location=torch.device('cpu')) |
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.
Hi @terry-for-github - could you run the pre-commit formatter, that should fix the formatting errors on these files.
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.
ok, I'll try that.
…erry-for-github/DeepSpeed into torch_load_weight_only_warning
Is this OK? I haven't use pre-commit tools brefore. I do it by myself lol. |
Yes @terry-for-github thanks, the formatting checks appear to be passing, though other checks are not now. |
I found that not all of the |
Agreed, we've fixed most of the unrelated CI issues, would you be interested in continuing this PR? |
Hi @terry-for-github - no worries if you aren't, but I'll make a PR as well to fix these warnings. |
Closing in favor of #6751 |
FutureWarning: You are using
torch.load
withweights_only=False
(the current default value), which uses the default pickle module implicitly. It is possible to construct malicious pickle data which will execute arbitrary code during unpickling (See https://github.com/pytorch/pytorch/blob/main/SECURITY.md#untrusted-models for more details). In a future release, the default value forweights_only
will be flipped toTrue
. This limits the functions that could be executed during unpickling. Arbitrary objects will no longer be allowed to be loaded via this mode unless they are explicitly allowlisted by the user viatorch.serialization.add_safe_globals
. We recommend you start settingweights_only=True
for any use case where you don't have full control of the loaded file. Please open an issue on GitHub for any issues related to this experimental feature.