Skip to content

Ensure checkpoint loading works with PyTorch 2.6#14

Open
yeonsungk1m wants to merge 1 commit into
mainfrom
codex/fix-unpicklingerror-in-model-loading
Open

Ensure checkpoint loading works with PyTorch 2.6#14
yeonsungk1m wants to merge 1 commit into
mainfrom
codex/fix-unpicklingerror-in-model-loading

Conversation

@yeonsungk1m

Copy link
Copy Markdown
Owner

Summary

  • pass weights_only=False to all torch.load checkpoints so legacy files continue to load under PyTorch 2.6

Testing

  • not run (not requested)

https://chatgpt.com/codex/tasks/task_e_68fdc5efc2ac832799c070a431cf71cf

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread main.py
Comment on lines 304 to +311
chk_filename = os.path.join(args.checkpoint, args.resume if args.resume else args.evaluate)
# chk_filename = args.resume or args.evaluate
print('Loading checkpoint', chk_filename)
checkpoint = torch.load(chk_filename, map_location=lambda storage, loc: storage)
checkpoint = torch.load(
chk_filename,
map_location=lambda storage, loc: storage,
weights_only=False,
)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Guard torch.load weights_only for pre-2.6 PyTorch

The new torch.load(..., weights_only=False) calls assume the argument exists, but earlier PyTorch releases (e.g. 1.x) do not accept weights_only and raise TypeError: torch.load() got an unexpected keyword argument 'weights_only' before any checkpoint is loaded. The README still advertises support for PyTorch ≥0.4, so this change will crash on previously supported environments. Consider only passing weights_only when running on PyTorch versions that provide the parameter (e.g. via feature detection or try/except). The same pattern is repeated in the other files modified in this commit.

Useful? React with 👍 / 👎.

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 this pull request may close these issues.

1 participant