DeepSpeed icon indicating copy to clipboard operation
DeepSpeed copied to clipboard

Add weights_only=True in torch.load

Open terry-for-github opened this issue 1 year ago • 5 comments

FutureWarning: You are using torch.load with weights_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 for weights_only will be flipped to True. 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 via torch.serialization.add_safe_globals. We recommend you start setting weights_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.

terry-for-github avatar Aug 17 '24 17:08 terry-for-github

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 avatar Aug 17 '24 17:08 terry-for-github

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.

tjruwase avatar Aug 19 '24 00:08 tjruwase

Is this OK? I haven't use pre-commit tools brefore. I do it by myself lol.

terry-for-github avatar Aug 23 '24 10:08 terry-for-github

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.

loadams avatar Aug 26 '24 17:08 loadams

I found that not all of the torch.load are compatible with weights_only=True. Some of them should be set to weights_only=False explicitly instead.

terry-for-github avatar Aug 27 '24 11:08 terry-for-github

I found that not all of the torch.load are compatible with weights_only=True. Some of them should be set to weights_only=False explicitly instead.

Agreed, we've fixed most of the unrelated CI issues, would you be interested in continuing this PR?

loadams avatar Oct 25 '24 16:10 loadams

I found that not all of the torch.load are compatible with weights_only=True. Some of them should be set to weights_only=False explicitly instead.

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.

loadams avatar Nov 13 '24 15:11 loadams

Closing in favor of #6751

loadams avatar Nov 14 '24 23:11 loadams