nvalchemi.training.TrainingStrategy.load_checkpoint#
- classmethod TrainingStrategy.load_checkpoint(root_folder, checkpoint_index=-1, map_location=None, *, models=None, hooks=None, training_fn=None, validators=None, **runtime_overrides)[source]#
Load a restartable strategy checkpoint.
This is the strategy-focused convenience wrapper around
nvalchemi.training.load_checkpoint(). Use the module-level function when callers need the full manifest, component dictionaries, partial component loads, or foreign checkpoint adapters.- Parameters:
root_folder (Path | str) – Root directory containing checkpoint files.
checkpoint_index (int, optional) – Checkpoint index to load.
-1loads the latest manifest index.map_location (str | torch.device | None, optional) – Device override passed through to
torch.load()and the restored strategy metadata.models (BaseModelMixin | dict[str, BaseModelMixin] | None, optional) – Live models to restore the checkpoint’s weights into, in place of the ones the loader builds from the saved specs. Their names must be exactly the checkpoint’s; see
nvalchemi.training.load_checkpoint(). DefaultNone.hooks (Sequence[Hook | TrainingUpdateHook | TrainingUpdateOrchestrator] | None, optional) – Runtime hooks to attach to the restored strategy.
training_fn (Callable[..., Mapping[str, torch.Tensor]] | str | None, optional) – Runtime training function override. This is required when the saved strategy used a local or otherwise non-importable training function.
validators (Sequence[CheckpointValidator] | None, optional) – Optional loaded-checkpoint validators forwarded to the lower-level loader.
**runtime_overrides (Any) – Runtime overrides: live objects that the saved spec cannot carry, passed as extra keyword arguments and forwarded to the strategy class’s
from_spec_dict(). A subclass documents the ones it accepts.
- Returns:
Restored strategy with model, optimizer, scheduler, and runtime counters loaded.
- Return type:
- Raises:
ValueError – If the checkpoint does not contain restartable strategy metadata.
TypeError – If the restored strategy is not an instance of
cls, or if a runtime override reaches afrom_spec_dictthat does not accept it.