API reference

Checkpoints

Signatures, parameters, return contracts, and source for checkpoints.

Overview

Checkpoint files contain model_kind, config, state_dict, and metadata. save_checkpoint writes a temporary sibling then atomically replaces the destination. Model-only checkpoints do not store a complete optimizer or scheduler trajectory. load_checkpoint uses torch.load with weights_only=False, so load trusted artifacts.

Source revision: caef7be03abd. Public export index.

save_checkpoint

axosim.checkpoint.save_checkpoint(model: torch.nn.Module, path: str | Path, *, metadata: dict[str, Any] | None=None) -> None

Source

Serialize supported model weights, configuration, model kind, and caller metadata.

Writes model kind, serializable configuration, state_dict, and metadata. Creates parent directories. Unsupported model types raise TypeError. Returns None.

Parameters

model torch.nn.Module
required. Model to execute, optimize, count, or serialize for this operation.
path str | Path
required. Filesystem location to read or write; see the operation's persistence contract.
metadata dict[str, Any] | None
keyword-only, default=None. Caller metadata stored with model state.

Returns

result None
No return value.

load_checkpoint

axosim.checkpoint.load_checkpoint(path: str | Path, *, map_location: str='cpu') -> tuple[torch.nn.Module, dict[str, Any]]

Source

Reconstruct a supported model and its stored metadata from a trusted checkpoint.

Returns (reconstructed torch.nn.Module, metadata dictionary). Supports baseline/branch_elm, official, branch-trace-rnn, axomamba and axomamba-pytorch, axo-temporal variants, axo-block-forecast variants, adaptive P4 variants, and generic Mamba kinds. An unknown kind raises ValueError; PyTorch artifacts are loaded with weights_only=False.

Parameters

path str | Path
required. Filesystem location to read or write; see the operation's persistence contract.
map_location str
keyword-only, default='cpu'. PyTorch destination for loaded tensors.

Returns

model torch.nn.Module
Reconstructed model with its stored weights, architecture configuration, and backend.
metadata dict[str, Any]
Metadata stored with the checkpoint; an empty dictionary when absent.

Search guides, examples, and API signatures.