OptimEngine.fit()#
- OptimEngine.fit(*, checkpoint=None, pause_after=None, checkpoint_every=10, allow_version_mismatch=False)[source]#
Runs optimization and returns processed results.
- Parameters:
checkpoint (
OptimCheckpoint|str|PathLike[str] |None, default:None) –Nonestarts fresh in memory. AnOptimCheckpointresumes in memory. A path selects a persistent run: load it if present, or start fresh if absent, and save subsequent checkpoints there. The parent directory must exist. Only load trusted checkpoint files.pause_after (
int|None, default:None) – Maximum additional epochs for this call. Pausing preserves optimizer state inresult.checkpoint. The stopper still owns the total epoch budget; changeengine.stopper.epochsto extend it explicitly.checkpoint_every (
int, default:10) – Save every this many completed epochs when a path is supplied, by default 10. Also save at a deliberate pause or normal completion. A NaN failure leaves the last saved file intact.allow_version_mismatch (
bool, default:False) – Attempt recovery despite differing Liesel, JAX, jaxlib, Optax, or NumPy versions, issuing a warning. Structural checks still apply.
- Return type:
- Returns:
OptimResult – Processed history, final and best-monitor positions, monitoring source, cumulative active runtime, status, and an independent checkpoint for continuation (
Noneon NaN failure).
Notes
Reconstruct the same model, data, and optimizer settings before resuming. Parameter and observed-variable names, shapes, and dtypes must agree. Compatibility checks cannot detect changed data or learning rates. Resuming a checkpoint that permits no further epochs under the current stopper settings issues a warning and returns its result. Use a new path or call
fit()without a checkpoint to start a fresh run. Extending the epoch budget permits continuation only if early stopping does not apply. A failed checkpoint write raises and preserves the previous file. Interruptions recover from the last successful periodic save.