Skip to main content

Module checkpoint

Module checkpoint 

Source
Expand description

Module checkpoints: capturing a module tree’s parameter payloads and restoring them into a Parameters state.

Two identities, two tiers. The positional pair (snapshot/restore) uses the module tree’s stable visit order — sufficient for resuming the same code, with no names anywhere. The named pair (named_snapshot/named_restore) matches by structured Path, which is what survives code evolution and what foreign checkpoints (name-to-tensor maps) require; missing and unexpected paths are loud errors.

A checkpoint is pure state, so both directions are plain Parameters transforms: no graph is touched, and shape mismatches panic through Parameters::with_payloads’s validation. The library stops at the name-to-payload map; file formats stay at the edge.

Functions§

named_restore
Returns a new state with module’s parameters replaced by entries, matched by path: the named restore.
named_snapshot
Returns every parameter payload in module’s tree with its structured path, in visit order: the named checkpoint, the form that survives code evolution and maps to foreign layouts.
restore
Returns a new state with module’s parameters replaced by payloads, matched in visit order: the positional restore. Parameters outside the module keep their payloads.
snapshot
Returns the payloads of every parameter in module’s tree, in visit order: the positional checkpoint.