LightningModule models using `setup` don't load checkpoints properly.
🐛 Bug
Using setup methods within a LightningModule does not allow proper checkpoint loading using the load_from_checkpoint method. Furthermore, even if setup and torch.load are used to manually load a checkpoint, the trainer seems to always invoke setup with fit is called, thereby overwriting the loaded parameters. There are ways to get around these issues, but they don't fit nicely into the recommended PTL style standards, as I interpreted them. This issue has been filed as a bug on the recommendation in this forum post.
Please reproduce using the BoringModel
I have reproduced this bug with a simple model in this Colab Notebook.
https://colab.research.google.com/drive/1weAyerRPpe5jQOD0s-yzymmF2czFx18Q?usp=sharing
To Reproduce
Use the above Colab notebook to reproduce, noting that cell [5] is expected to fail. Otherwise Notebook runs top-to-bottom.
Expected behavior
Ideally, code in cell [5] should not error. Additionally, trainer should not reset model Parameters with fit is called (e.g., in cell [7]).
Environment
This Colab Notebook includes a pip install of PTL in the top cell. Otherwise, it uses the default Colab environment settings.
Additional context
Please refer to this forum post for more information.