pytorch-lightning: `load_from_checkpoint` should not be called as an instance method

Outline & Motivation

Spent a while debugging :

model.load_from_checkpoint(model_path)

which should be :

model = LitModel.load_from_checkpoint(model_path)

there should be a warning when the instance method is called.

Pitch

model.load_from_checkpoint(model_path)

which should be :

model = LitModel.load_from_checkpoint(model_path)

there should be a warning when the first approach i.e. instance method is called.

Additional context

No response

cc @justusschock @awaelchli @carmocca @borda

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Reactions: 3
  • Comments: 15 (13 by maintainers)

Most upvoted comments

Glad we were finally able to address this. We had already given up on it in the past. Great work @kwsp!

I see. Mistake from my side was assuming behaviour similar to Pytorch’s load_state_dict which does inplace. If I do :

model = model.load_from_checkpoint(model_path)

it works fine. I can open a PR if you suggest the improved instructions. I am familiar with the codebase. I think logging to not call inplace would be nice.