Skip to main content

Checkpoint

Trait Checkpoint 

pub trait Checkpoint:
    Sized
    + Send
    + 'static {
    // Required methods
    fn save(self, path: PathBuf) -> Result<(), CheckpointerError>;
    fn load(path: PathBuf) -> Result<Self, CheckpointerError>;
    fn checkpoint_from_bytes(bytes: Bytes) -> Result<Self, RecordError>;
    fn checkpoint_into_bytes(self) -> Result<Bytes, RecordError>;
}
Expand description

A record that can be saved to and loaded from a burnpack file.

Implemented for the burnpack record types used during training: the module (ModuleRecord), the optimizer (OptimizerRecord) and the learning rate scheduler (LrSchedulerRecord).

Records are device-free: a checkpoint is just file-backed bytes. Device placement is decided when a record is applied (the module keeps its existing parameter device; optimizer state migrates to each parameter’s device on the next step), not when the checkpoint is loaded.

Required Methods§

fn save(self, path: PathBuf) -> Result<(), CheckpointerError>

Save the record to path.

fn load(path: PathBuf) -> Result<Self, CheckpointerError>

Load the record from path.

fn checkpoint_from_bytes(bytes: Bytes) -> Result<Self, RecordError>

Creates a checkpoint from bytes

fn checkpoint_into_bytes(self) -> Result<Bytes, RecordError>

Transforms a checkpoint into bytes

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

§

impl Checkpoint for ()

A stateless record: nothing to save or load.

Implementors§