ray.train.lightning.LightningCheckpoint
ray.train.lightning.LightningCheckpoint#
- class ray.train.lightning.LightningCheckpoint(*args, **kwargs)[source]#
Bases:
ray.train.torch.torch_checkpoint.TorchCheckpointA
Checkpointwith Lightning-specific functionality.LightningCheckpoint only support file based checkpoint loading. Create this by calling
LightningCheckpoint.from_directory(ckpt_dir),LightningCheckpoint.from_uri(uri)orLightningCheckpoint.from_path(path)LightningCheckpoint loads file named
modelunder the specified directory.Examples:
from ray.train.lightning import LightningCheckpoint # Suppose we saved a checkpoint in "./checkpoint_000000/model": # Option 1 (Preferred): Load from the checkpoint file checkpoint = LightningCheckpoint.from_path( path="./checkpoint_00000/model" ) # Option 2: Load from a directory checkpoint = LightningCheckpoint.from_directory( path="./checkpoint_00000/" ) # Suppose we saved a checkpoint in an S3 bucket: # Option 3: Load from URI checkpoint = LightningCheckpoint.from_uri( path="s3://path/to/checkpoint/directory/" )
PublicAPI (alpha): This API is in alpha and may change before becoming stable.
Methods
Return checkpoint directory path in a context.
from_bytes(data)Create a checkpoint from the given byte string.
from_checkpoint(other)Create a checkpoint from a generic
ray.air.checkpoint.Checkpoint.from_dict(data)Create checkpoint object from dictionary.
from_directory(path)Create checkpoint object from directory.
from_model(model, *[, preprocessor])Create a
Checkpointthat stores a Torch model.from_path(path, *[, preprocessor])Create a
ray.air.lightning.LightningCheckpointfrom a checkpoint file.from_state_dict(state_dict, *[, preprocessor])Create a
Checkpointthat stores a model state dictionary.from_uri(uri)Create checkpoint object from location URI (e.g.
Return tuple of (type, data) for the internal representation.
get_model(model_class, ...)Retrieve the model stored in this checkpoint.
Return the saved preprocessor, if one exists.
set_preprocessor(preprocessor)Saves the provided preprocessor to this Checkpoint.
to_bytes()Return Checkpoint serialized as bytes object.
to_dict()Return checkpoint data as dictionary.
to_directory([path])Write checkpoint data to directory.
to_uri(uri)Write checkpoint data to location URI (e.g.
Attributes
Return path to checkpoint, if available.
Return checkpoint URI, if available.