Skip to content
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

torch.load warnings #4143

Open
njzjz opened this issue Sep 19, 2024 · 0 comments · May be fixed by #4147
Open

torch.load warnings #4143

njzjz opened this issue Sep 19, 2024 · 0 comments · May be fixed by #4147
Labels

Comments

@njzjz
Copy link
Member

njzjz commented Sep 19, 2024

/home/njzjz/codes/deepmd-kit/deepmd/pt/infer/inference.py:37: 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.
state_dict = torch.load(model_ckpt, map_location=DEVICE)

@njzjz njzjz added the bug label Sep 19, 2024
njzjz added a commit to njzjz/deepmd-kit that referenced this issue Sep 19, 2024
Fix deepmodeling#4143.

Signed-off-by: Jinzhe Zeng <jinzhe.zeng@rutgers.edu>
@njzjz njzjz linked a pull request Sep 19, 2024 that will close this issue
@njzjz njzjz linked a pull request Sep 19, 2024 that will close this issue
github-merge-queue bot pushed a commit that referenced this issue Sep 21, 2024
See #4147 and #4143.
We can first make `state_dict` safe for `weights_only`, then make a
breaking change when loading `state_dict` in the future.

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

- **New Features**
- Enhanced model saving functionality by ensuring learning rates are
consistently stored as floats, improving type consistency.
  
- **Bug Fixes**
- Updated model loading behavior in tests to focus solely on model
weights, which may resolve issues related to state dictionary loading.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant