---
title: CheckpointHooks
description: Hooks to be used with Checkpointing.
canonical: >-
  https://lightning.ai/docs/pytorch/stable/optional-api/api/lightning.pytorch.core.hooks.CheckpointHooks
---
# CheckpointHooks {#checkpointhooks}

### `class lightning.pytorch.core.hooks.CheckpointHooks` {#lightning.pytorch.core.hooks.CheckpointHooks}

Bases: [`object`](https://docs.python.org/3/builtins/functions.html#object "(in Python v3.15)")

Hooks to be used with Checkpointing.

#### `on_load_checkpoint(checkpoint)` {#lightning.pytorch.core.hooks.CheckpointHooks.on_load_checkpoint}

Called by Lightning to restore your model. If you saved something with [`on_save_checkpoint()`](#lightning.pytorch.core.hooks.CheckpointHooks.on_save_checkpoint "lightning.pytorch.core.hooks.CheckpointHooks.on_save_checkpoint") this is your chance to restore this.

Parameters:

**checkpoint** ([`dict`](https://docs.python.org/3/builtins/stdtypes.html#dict "(in Python v3.15)")\[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str "(in Python v3.15)"), [`Any`](https://docs.python.org/3/library/typing.html#typing.Any "(in Python v3.15)")\]) – Loaded checkpoint

Return type:

[`None`](https://docs.python.org/3/builtins/constants.html#None "(in Python v3.15)")

Example:

```python
def on_load_checkpoint(self, checkpoint):
    # 99% of the time you don't need to implement this method
    self.something_cool_i_want_to_save = checkpoint['something_cool_i_want_to_save']
```

Note

Lightning auto-restores global step, epoch, and train state including amp scaling. There is no need for you to restore anything regarding training.

#### `on_save_checkpoint(checkpoint)` {#lightning.pytorch.core.hooks.CheckpointHooks.on_save_checkpoint}

Called by Lightning when saving a checkpoint to give you a chance to store anything else you might want to save.

Parameters:

**checkpoint** ([`dict`](https://docs.python.org/3/builtins/stdtypes.html#dict "(in Python v3.15)")\[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str "(in Python v3.15)"), [`Any`](https://docs.python.org/3/library/typing.html#typing.Any "(in Python v3.15)")\]) – The full checkpoint dictionary before it gets dumped to a file. Implementations of this hook can insert additional data into this dictionary.

Return type:

[`None`](https://docs.python.org/3/builtins/constants.html#None "(in Python v3.15)")

Example:

```python
def on_save_checkpoint(self, checkpoint):
    # 99% of use cases you don't need to implement this method
    checkpoint['something_cool_i_want_to_save'] = my_cool_pickable_object
```

Note

Lightning saves all aspects of training (epoch, global step, etc…) including amp scaling. There is no need for you to store anything about training.

---

**Navigation**

- Parent: [Api](/docs/pytorch/2.6.6/optional-api/api.md)
