-
Notifications
You must be signed in to change notification settings - Fork 504
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
fix(pt): set weights_only=True
for torch.load
#4147
base: devel
Are you sure you want to change the base?
Conversation
Fix deepmodeling#4143. Signed-off-by: Jinzhe Zeng <[email protected]>
WalkthroughWalkthroughThe changes in this pull request involve modifying multiple files to update the Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant Model
participant Torch
User->>Model: Request to load model
Model->>Torch: Load model with weights_only=True
Torch-->>Model: Return model weights
Model-->>User: Provide loaded model
Assessment against linked issues
Possibly related PRs
Suggested reviewers
Recent review detailsConfiguration used: CodeRabbit UI Files selected for processing (2)
Files skipped from review as they are similar to previous changes (2)
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
weights_only=True
for torch.load
weights_only=True
for torch.load
Surprisingly, in some place, NumPy arrays are saved to the state dict. cc @iProzd @wanghan-iapcm |
>>> type(torch.load("model.ckpt.pt")["model"]["_extra_state"]["train_infos"]["lr"])
<class 'numpy.float64'> |
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 -->
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## devel #4147 +/- ##
=======================================
Coverage 83.41% 83.42%
=======================================
Files 532 532
Lines 52048 52048
Branches 3046 3046
=======================================
+ Hits 43416 43419 +3
+ Misses 7684 7682 -2
+ Partials 948 947 -1 ☔ View full report in Codecov by Sentry. |
Fix #4143.
Summary by CodeRabbit
New Features
Bug Fixes
Tests