Skip to content

Mismatch between docstring and code regarding when on_load_checkpoint hook is called #3993

Closed
@hbredin

Description

🐛 Bug

The docstring of on_load_checkpoint hook says that it is called before trying to load_state_dict:
https://github.com/PyTorchLightning/pytorch-lightning/blob/cea5f1f53876399dfaa0d37accdc527af7ca39af/pytorch_lightning/core/saving.py#L203-L206

However, in LightningModule.load_from_checkpoint, it is called after load_state_dict:
https://github.com/PyTorchLightning/pytorch-lightning/blob/cea5f1f53876399dfaa0d37accdc527af7ca39af/pytorch_lightning/core/saving.py#L195-L199

Additional context

Related discussion on Slack: https://pytorch-lightning.slack.com/archives/CQXV8BRH9/p1602168345184000

I think the docstring is correct and the call to on_load_checkpoint should be moved right before load_state_dict to give the model a chance to call setup.

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingdocsDocumentation relatedhelp wantedOpen to be worked on

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions