Skip to main content

Checkpoint

Trait Checkpoint 

Source
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§

Source

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

Save the record to path.

Source

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

Load the record from path.

Source

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

Creates a checkpoint from bytes

Source

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§

Source§

impl Checkpoint for ()

A stateless record: nothing to save or load.

Source§

impl Checkpoint for LrSchedulerRecord

Source§

impl Checkpoint for ModuleRecord

Source§

impl Checkpoint for OptimizerRecord

Implementors§