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

Expose weights_only option for loading checkpoints #20058

Open
awaelchli opened this issue Jul 8, 2024 · 4 comments
Open

Expose weights_only option for loading checkpoints #20058

awaelchli opened this issue Jul 8, 2024 · 4 comments
Labels
checkpointing Related to checkpointing feature Is an improvement or enhancement
Milestone

Comments

@awaelchli
Copy link
Contributor

awaelchli commented Jul 8, 2024

Description & Motivation

PyTorch will default the torch.load(weights_only=) option to True in the future, and started emitting FutureWarning in 2.4. Since Lightning allows storing all kinds of data into the checkpoint (mainly through save_hyperparameters() and the on_save_checkpoint hooks), so far we have to explicitly set weights_only=False internally to be able to load checkpoints. But we could also expose this argument as a flag for the user to choose how strict they want to be when loading checkpoints.

Pitch

In Fabric.load, expose weights_only.
In PyTorch Lightning, either add fit(..., load_weights_only=...) or add an attribute to the LightningModule (similar to how we handle strict_loading).

Alternatives

No response

Additional context

No response

cc @Borda @awaelchli

@awaelchli awaelchli added feature Is an improvement or enhancement needs triage Waiting to be triaged by maintainers checkpointing Related to checkpointing and removed needs triage Waiting to be triaged by maintainers labels Jul 8, 2024
@awaelchli awaelchli added this to the future milestone Jul 8, 2024
@ryan597
Copy link
Contributor

ryan597 commented Jul 12, 2024

Is this issue closed with #20010 merged? @awaelchli

@awaelchli
Copy link
Contributor Author

No it isn't, because in #20010 we just set weights_only=False (because we have to). But a user wouldn't be able to control it (unless they set the environment variable).

Why do you ask @ryan597? :)

@ryan597
Copy link
Contributor

ryan597 commented Jul 12, 2024

Ah okay, I was looking at some issues to pickup :)

@awaelchli
Copy link
Contributor Author

awaelchli commented Jul 12, 2024

Cool. This one here probably needs a bit validation first that users actually need it.
If you're interested in picking up issues to work on, that's great and appreciated. Feel free to contact me on slack or discord and I can point you to some based on your interest. The ones labelled with help wanted are generally ones that are open to work on.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
checkpointing Related to checkpointing feature Is an improvement or enhancement
Projects
None yet
Development

No branches or pull requests

2 participants