Manager#
- class stable_pretraining.manager.Manager(*args, **kwargs)[source]#
Bases:
CheckpointableManages training with logging, scheduling, and checkpointing support.
- Parameters:
trainer (Union[dict, DictConfig, pl.Trainer]) – PyTorch Lightning trainer configuration or instance.
module (Union[dict, DictConfig, pl.LightningModule]) – Lightning module configuration or instance.
data (Union[dict, DictConfig, pl.LightningDataModule]) – Data module configuration or instance.
seed (int, optional) – Random seed for reproducibility. Defaults to None.
ckpt_path (str, optional) – Absolute path to a checkpoint to load from at the very start of a fresh run. Loaded once at step 0; after that the run lives in its own freshly-created
run_dirand produces its ownlast.ckpt. Ignored on SLURM requeue — see below. Must be absolute and must exist on disk; otherwiseManagerraises before training. Defaults toNone(train from scratch / pretrained backbone).weights_only (bool, optional) –
Controls how
ckpt_pathis loaded on a fresh run. Forwarded toTrainer.fit(weights_only=...)when supported by the installed Lightning version.True(the PyTorch ≥ 2.6 default fortorch.load) loads only model weights — optimizer / scheduler / RNG state are discarded, which is the usual “transfer-learning init” semantics. SetFalseto fully restore everything from the checkpoint.Has no effect on SLURM requeue: when
SLURM_RESTART_COUNT >= 1the Manager always loads<run_dir>/checkpoints/last.ckptwith full state (weights_only=False) regardless of this flag, because the goal is to resume in-flight training exactly where preempt struck.compile (bool, optional) – Should we compile the given module. Defaults to False.
- property instantiated_data#
Lazily instantiate and return the
LightningDataModule.If
datawas supplied as adictorDictConfig, it is instantiated viahydra.utils.instantiateon first access and the result is cached. If it was supplied as a pre-builtpl.LightningDataModuleinstance it is returned as-is.- Returns:
The instantiated data module ready for use.
- Return type:
pl.LightningDataModule
- property instantiated_module#
Lazily instantiate and return the
LightningModule.If
modulewas supplied as adictorDictConfig, it is instantiated viahydra.utils.instantiateon first access and the result is cached. If it was supplied as a pre-builtpl.LightningModuleinstance it is returned as-is.- Returns:
The instantiated module ready for training.
- Return type:
pl.LightningModule
- predict()[source]#
Run inference using the configured module and data.
Calls
Trainer.predictwith the lazily-instantiated module and data module, then flushes any buffered wandb offline data.
- test()[source]#
Run the test split using the configured module and data.
Calls
Trainer.testwith the lazily-instantiated module and data module, then flushes any buffered wandb offline data.
- validate()[source]#
Run one validation pass using the configured module and data.
Calls
Trainer.validatewith the lazily-instantiated module and data module, then flushes any buffered wandb offline data. Use this after__call__has already set up the trainer, or standalone when only evaluation is needed.