Skip to content

Expose weights_only option for loading checkpointsΒ #20058

@awaelchli

Description

@awaelchli

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    checkpointingRelated to checkpointingfeatureIs an improvement or enhancement

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions