resume_config#
- torchrl.checkpoint.resume_config(cfg: DictConfig, checkpoint_path: str | Path, *, overrides: Sequence[str] | None = None) DictConfig[source]#
Return the configuration of a run resumed from
checkpoint_path.The configuration saved with the checkpoint under its
configcomponent is the base andoverridesare applied on top, soresume=<path>alone rebuilds the original run whileresume=<path> collector.total_frames=...extends it. Interpolations survive because recipes save the configuration unresolved. Config-group overrides such aslogger@logger=csv, deletions (~key) and bare flags cannot be applied to a saved configuration and are ignored with a warning. When the checkpoint holds noconfigcomponent,cfgis returned unchanged with a warning.- Parameters:
cfg (DictConfig) – the configuration composed for the current run.
checkpoint_path (str or Path) – the checkpoint being resumed.
overrides (Sequence[str], optional) –
key=valueoverrides applied over the saved configuration. Defaults to the task overrides of the current Hydra run, or none outside a Hydra application.
- Returns:
The configuration to run.
Examples
>>> import tempfile >>> from omegaconf import OmegaConf >>> from torchrl.checkpoint import Checkpoint, resume_config >>> saved = {"budget": 100, "trainer": {"total_frames": "${budget}"}} >>> with tempfile.TemporaryDirectory() as tmpdir: ... path = Checkpoint(config=saved).save(f"{tmpdir}/checkpoint") ... cfg = resume_config( ... OmegaConf.create({"budget": 5}), path, overrides=["budget=200"] ... ) >>> cfg.trainer.total_frames 200