mapping_networks.checkpoint.save_checkpoint

mapping_networks.checkpoint.save_checkpoint(path: str | Path, model: MappingModel, *, config: MappingConfig | None = None, trainer: MappingTrainer | None = None, save_trainer_state: bool = True, metadata: dict[str, Any] | None = None) None

Save a compact, versioned checkpoint for the mapping network.

Only trainable latent vectors and required mapper buffers are written. Generated target weights are excluded — they are ephemeral and can be fully reconstructed at inference time.

Parameters:
  • path – Destination file path (e.g. "ckpt/epoch10.pt"). Parent directories are created automatically.

  • model – A MappingModel instance (may be on any device).

  • config – Optional MappingConfig saved for reference. Not used during load, but useful for reproducibility auditing.

  • trainer – Optional MappingTrainer whose optimizer, scheduler, and epoch state are serialised when save_trainer_state is True.

  • save_trainer_state – When True and a trainer is supplied, include optimizer state dict, scheduler state dict (if any), current epoch, and should_stop flag so training can be resumed exactly.

  • metadata – Free-form dict of user annotations (dataset name, notes …).

Example:

save_checkpoint(
    "checkpoints/epoch10.pt",
    model=model,
    config=mapping_config,
    trainer=trainer,
)