Skip to content

pytorch: Set weights_only=False when loading models from a trusted source#115

Merged
kailun-qin merged 1 commit intogramineproject:masterfrom
sahason:sahason/pytorch_fix
Jun 20, 2025
Merged

pytorch: Set weights_only=False when loading models from a trusted source#115
kailun-qin merged 1 commit intogramineproject:masterfrom
sahason:sahason/pytorch_fix

Conversation

@sahason
Copy link
Copy Markdown
Contributor

@sahason sahason commented Jun 17, 2025

  • Updated pytorchexample.py to set the weights_only argument to False when calling torch.load.
  • This change resolves the UnpicklingError encountered when loading the pre-trained model.

Fixes #113


This change is Reviewable

@sahason
Copy link
Copy Markdown
Contributor Author

sahason commented Jun 17, 2025

Continuation of this PR #114

Copy link
Copy Markdown
Contributor

@kailun-qin kailun-qin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 1 of 1 files at r1, all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion, not enough approvals from maintainers (3 more required), not enough approvals from different teams (2 more required, approved so far: )


pytorch/pytorchexample.py line 7 at r1 (raw file):

import torch

# Load the model from a file. This file needs to be obtained from a trusted

Pls rewrap to 100 chars.

mkow
mkow previously approved these changes Jun 17, 2025
Copy link
Copy Markdown
Member

@mkow mkow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 1 of 1 files at r1, all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion, not enough approvals from maintainers (2 more required), not enough approvals from different teams (1 more required, approved so far: ITL) (waiting on @sahason)

Copy link
Copy Markdown
Contributor Author

@sahason sahason left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: 0 of 1 files reviewed, 1 unresolved discussion, not enough approvals from maintainers (3 more required), not enough approvals from different teams (2 more required, approved so far: ), "fixup! " found in commit messages' one-liners (waiting on @kailun-qin and @mkow)


pytorch/pytorchexample.py line 7 at r1 (raw file):

Previously, kailun-qin (Kailun Qin) wrote…

Pls rewrap to 100 chars.

Done.

kailun-qin
kailun-qin previously approved these changes Jun 18, 2025
Copy link
Copy Markdown
Contributor

@kailun-qin kailun-qin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 1 of 1 files at r2, all commit messages.
Reviewable status: all files reviewed, all discussions resolved, not enough approvals from maintainers (2 more required), not enough approvals from different teams (1 more required, approved so far: Intel), "fixup! " found in commit messages' one-liners

Copy link
Copy Markdown
Member

@mkow mkow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 1 of 1 files at r2, all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion, not enough approvals from maintainers (2 more required), not enough approvals from different teams (1 more required, approved so far: Intel), "fixup! " found in commit messages' one-liners


pytorch/pytorchexample.py line 8 at r2 (raw file):

# Load the model from a file. This file needs to be obtained from a trusted source, because it can
# contain code, not only data. Note: For PyTorch 2.6 and later, unpickling with weights_only=True

Please leave Note: at a newline.

Copy link
Copy Markdown
Contributor Author

@sahason sahason left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: 0 of 1 files reviewed, 1 unresolved discussion, not enough approvals from maintainers (3 more required), not enough approvals from different teams (2 more required, approved so far: ), "fixup! " found in commit messages' one-liners (waiting on @kailun-qin and @mkow)


pytorch/pytorchexample.py line 8 at r2 (raw file):

Previously, mkow (Michał Kowalczyk) wrote…

Please leave Note: at a newline.

Done.

Copy link
Copy Markdown
Contributor

@kailun-qin kailun-qin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 1 of 1 files at r3, all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion, not enough approvals from maintainers (2 more required), not enough approvals from different teams (1 more required, approved so far: Intel), "fixup! " found in commit messages' one-liners (waiting on @mkow)

Copy link
Copy Markdown
Member

@mkow mkow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 1 of 1 files at r3, all commit messages.
Reviewable status: all files reviewed, all discussions resolved, not enough approvals from maintainers (1 more required), "fixup! " found in commit messages' one-liners

…urce

Signed-off-by: Sonali <sonali.saha@intel.com>
@kailun-qin kailun-qin force-pushed the sahason/pytorch_fix branch from fb75895 to 9fdd89c Compare June 20, 2025 01:50
Copy link
Copy Markdown
Contributor

@kailun-qin kailun-qin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed all commit messages.
Reviewable status: all files reviewed, all discussions resolved, not enough approvals from maintainers (1 more required)

@kailun-qin kailun-qin merged commit 9fdd89c into gramineproject:master Jun 20, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

PyTorch 2.6.0 Release: Model Loading Fails with Unpickling Error

3 participants