---
title: CheckpointIO
description: Interface to save/load checkpoints as they are saved through the Strategy.
canonical: >-
  https://lightning.ai/docs/fabric/stable/full-api-reference/api/generated/lightning.fabric.plugins.io.checkpoint_io.CheckpointIO
---
# CheckpointIO {#checkpointio}

### `class lightning.fabric.plugins.io.checkpoint_io.CheckpointIO` {#lightning.fabric.plugins.io.checkpoint_io.CheckpointIO}

Bases: [`ABC`](https://docs.python.org/3/library/abc.html#abc.ABC "(in Python v3.15)")

Interface to save/load checkpoints as they are saved through the `Strategy`.

Warning

This is an [experimental](/docs/pytorch/stable/versioning#experimental-api "(in PyTorch Lightning v2.7.0.dev)") feature.

Typically most plugins either use the Torch based IO Plugin; `TorchCheckpointIO` but may require particular handling depending on the plugin.

In addition, you can pass a custom `CheckpointIO` by extending this class and passing it to the Trainer, i.e `Trainer(plugins=[MyCustomCheckpointIO()])`.

Note

For some plugins, it is not possible to use a custom checkpoint plugin as checkpointing logic is not modifiable.

#### `abstract load_checkpoint(path, map_location=None, weights_only=None)` {#lightning.fabric.plugins.io.checkpoint_io.CheckpointIO.load_checkpoint}

Load checkpoint from a path when resuming or loading ckpt for test/validate/predict stages.

Parameters:

*   **path** (`Union`\[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str "(in Python v3.15)"), [`Path`](https://docs.python.org/3/library/pathlib.html#pathlib.Path "(in Python v3.15)")\]) – Path to checkpoint
    
*   **map\_location** ([`Optional`](https://docs.python.org/3/library/typing.html#typing.Optional "(in Python v3.15)")\[[`Any`](https://docs.python.org/3/library/typing.html#typing.Any "(in Python v3.15)")\]) – a function, [`torch.device`](https://docs.pytorch.org/docs/stable/tensor_attributes.html#torch.device "(in PyTorch v2.15)"), string or a dict specifying how to remap storage locations.
    
*   **weights\_only** ([`Optional`](https://docs.python.org/3/library/typing.html#typing.Optional "(in Python v3.15)")\[[`bool`](https://docs.python.org/3/builtins/functions.html#bool "(in Python v3.15)")\]) – Defaults to `None`. If `True`, restricts loading to `state_dicts` of plain `torch.Tensor` and other primitive types. If loading a checkpoint from a trusted source that contains an `nn.Module`, use `weights_only=False`. If loading checkpoint from an untrusted source, we recommend using `weights_only=True`. For more information, please refer to the [PyTorch Developer Notes on Serialization Semantics](https://docs.pytorch.org/docs/main/notes/serialization.html#id3).
    

Return type:

[`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)")\]

Returns: The loaded checkpoint.

#### `abstract remove_checkpoint(path)` {#lightning.fabric.plugins.io.checkpoint_io.CheckpointIO.remove_checkpoint}

Remove checkpoint file from the filesystem.

Parameters:

**path** (`Union`\[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str "(in Python v3.15)"), [`Path`](https://docs.python.org/3/library/pathlib.html#pathlib.Path "(in Python v3.15)")\]) – Path to checkpoint

Return type:

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

#### `abstract save_checkpoint(checkpoint, path, storage_options=None)` {#lightning.fabric.plugins.io.checkpoint_io.CheckpointIO.save_checkpoint}

Save model/training states as a checkpoint file through state-dump and file-write.

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)")\]) – dict containing model and trainer state
    
*   **path** (`Union`\[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str "(in Python v3.15)"), [`Path`](https://docs.python.org/3/library/pathlib.html#pathlib.Path "(in Python v3.15)")\]) – write-target path
    
*   **storage\_options** ([`Optional`](https://docs.python.org/3/library/typing.html#typing.Optional "(in Python v3.15)")\[[`Any`](https://docs.python.org/3/library/typing.html#typing.Any "(in Python v3.15)")\]) – Optional parameters when saving the model/training states.
    

Return type:

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

#### `teardown()` {#lightning.fabric.plugins.io.checkpoint_io.CheckpointIO.teardown}

This method is called to teardown the process.

Return type:

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

---

**Navigation**

- Parent: [Generated](/docs/fabric/2.6.6/full-api-reference/api/generated.md)
