From 946b5ba41f902af558541d2fe317e54089e8c85c Mon Sep 17 00:00:00 2001 From: awaelchli Date: Wed, 26 Oct 2022 15:59:06 +0200 Subject: [PATCH 1/2] update docs --- docs/source-pytorch/common/checkpointing.rst | 26 +++++++---- .../common/checkpointing_advanced.rst | 6 +-- .../common/checkpointing_basic.rst | 6 +-- .../common/checkpointing_expert.rst | 6 +-- .../common/checkpointing_intermediate.rst | 6 +-- .../common/checkpointing_migration.rst | 45 +++++++++++++++++++ 6 files changed, 74 insertions(+), 21 deletions(-) create mode 100644 docs/source-pytorch/common/checkpointing_migration.rst diff --git a/docs/source-pytorch/common/checkpointing.rst b/docs/source-pytorch/common/checkpointing.rst index 765d5cce6c36e..c1552fa153263 100644 --- a/docs/source-pytorch/common/checkpointing.rst +++ b/docs/source-pytorch/common/checkpointing.rst @@ -12,33 +12,41 @@ Checkpointing .. Add callout items below this line .. displayitem:: - :header: Basic + :header: Saving and loading checkpoints :description: Learn to save and load checkpoints - :col_css: col-md-3 + :col_css: col-md-4 :button_link: checkpointing_basic.html :height: 150 :tag: basic .. displayitem:: - :header: Intermediate - :description: Customize checkpointing behavior - :col_css: col-md-3 + :header: Customize checkpointing behavior + :description: Learn how to change the behavior of checkpointing + :col_css: col-md-4 :button_link: checkpointing_intermediate.html :height: 150 :tag: intermediate .. displayitem:: - :header: Advanced + :header: Upgrading checkpoints + :description: Learn how to upgrade old checkpoints to the newest Lightning version + :col_css: col-md-4 + :button_link: checkpointing_migration.html + :height: 150 + :tag: intermediate + +.. displayitem:: + :header: Cloud-based checkpoints :description: Enable cloud-based checkpointing and composable checkpoints. - :col_css: col-md-3 + :col_css: col-md-4 :button_link: checkpointing_advanced.html :height: 150 :tag: advanced .. displayitem:: - :header: Expert + :header: Distributed checkpoints :description: Customize checkpointing for custom distributed strategies and accelerators. - :col_css: col-md-3 + :col_css: col-md-4 :button_link: checkpointing_expert.html :height: 150 :tag: expert diff --git a/docs/source-pytorch/common/checkpointing_advanced.rst b/docs/source-pytorch/common/checkpointing_advanced.rst index eb4ff4dc0e607..3ef5bf6b778f1 100644 --- a/docs/source-pytorch/common/checkpointing_advanced.rst +++ b/docs/source-pytorch/common/checkpointing_advanced.rst @@ -1,8 +1,8 @@ .. _checkpointing_advanced: -######################## -Checkpointing (advanced) -######################## +################################## +Cloud-based checkpoints (advanced) +################################## ***************** diff --git a/docs/source-pytorch/common/checkpointing_basic.rst b/docs/source-pytorch/common/checkpointing_basic.rst index 8a4834096c44d..85292b0a7085d 100644 --- a/docs/source-pytorch/common/checkpointing_basic.rst +++ b/docs/source-pytorch/common/checkpointing_basic.rst @@ -2,9 +2,9 @@ .. _checkpointing_basic: -##################### -Checkpointing (basic) -##################### +###################################### +Saving and loading checkpoints (basic) +###################################### **Audience:** All users ---- diff --git a/docs/source-pytorch/common/checkpointing_expert.rst b/docs/source-pytorch/common/checkpointing_expert.rst index f800d822aa1c5..20511d3a3c97c 100644 --- a/docs/source-pytorch/common/checkpointing_expert.rst +++ b/docs/source-pytorch/common/checkpointing_expert.rst @@ -2,9 +2,9 @@ .. _checkpointing_expert: -###################### -Checkpointing (expert) -###################### +################################ +Distributed checkpoints (expert) +################################ ********************************* Writing your own Checkpoint class diff --git a/docs/source-pytorch/common/checkpointing_intermediate.rst b/docs/source-pytorch/common/checkpointing_intermediate.rst index 7e17d8abc808f..02293effcd767 100644 --- a/docs/source-pytorch/common/checkpointing_intermediate.rst +++ b/docs/source-pytorch/common/checkpointing_intermediate.rst @@ -2,9 +2,9 @@ .. _checkpointing_intermediate: -############################ -Checkpointing (intermediate) -############################ +############################################### +Customize checkpointing behavior (intermediate) +############################################### **Audience:** Users looking to customize the checkpointing behavior ---- diff --git a/docs/source-pytorch/common/checkpointing_migration.rst b/docs/source-pytorch/common/checkpointing_migration.rst new file mode 100644 index 0000000000000..22812aa900c53 --- /dev/null +++ b/docs/source-pytorch/common/checkpointing_migration.rst @@ -0,0 +1,45 @@ +:orphan: + +.. _checkpointing_basic: + +#################################### +Upgrading checkpoints (intermediate) +#################################### +**Audience:** Users who are upgrading Lightning and their code and want to reuse their old checkpoints. + +---- + +************************************** +Resume training from an old checkpoint +************************************** + +Next to the model weights and trainer state, a Lightning checkpoint contains the version number of Lightning with which the checkpoint was saved. +When you load a checkpoint file, either by resuming training + +.. code-block:: python + + trainer = Trainer(...) + trainer.fit(model, ckpt_path="path/to/checkpoint.ckpt") + +or by loading the state directly into your model, + +.. code-block:: python + + model = LitModel.load_from_checkpoint("path/to/checkpoint.ckpt") + +Lightning will automatically recognize that it is from an older version and migrates the internal structure so it can be loaded properly. +This is done without any action required by the user. + +---- + +************************************ +Upgrade checkpoint files permanently +************************************ + +When Lightning loads a checkpoint, it applies the version migration on-the-fly as explained above, but it does not modify your checkpoint files. +You can upgrade checkpoint files permanently with the following command: + +.. code-block:: python + + python -m lightning.pytorch.utilities.upgrade_checkpoint --file model.ckpt + From b8186cd4c66241c1b4d6ba26d1b7dc7224727a15 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 28 Oct 2022 12:24:22 +0000 Subject: [PATCH 2/2] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- docs/source-pytorch/common/checkpointing_migration.rst | 1 - 1 file changed, 1 deletion(-) diff --git a/docs/source-pytorch/common/checkpointing_migration.rst b/docs/source-pytorch/common/checkpointing_migration.rst index 22812aa900c53..3a3b7ffd166cb 100644 --- a/docs/source-pytorch/common/checkpointing_migration.rst +++ b/docs/source-pytorch/common/checkpointing_migration.rst @@ -42,4 +42,3 @@ You can upgrade checkpoint files permanently with the following command: .. code-block:: python python -m lightning.pytorch.utilities.upgrade_checkpoint --file model.ckpt -