← Back

Module checkpoint

const CHECKPOINT_VERSION: u32

Checkpoint format version

Source: checkpoint.joule:12

const CHECKPOINT_MAGIC: [u8; 4]

Magic bytes for checkpoint files

Source: checkpoint.joule:15

struct CheckpointMetadata

Source: checkpoint.joule:19

fn new(epoch: u64, global_step: u64) -> Self

Source: checkpoint.joule:31

fn with_metric(mut self, name: &str, value: f64) -> Self

Source: checkpoint.joule:44

fn with_model_name(mut self, name: &str) -> Self

Source: checkpoint.joule:50

fn with_config(mut self, key: &str, value: &str) -> Self

Source: checkpoint.joule:55

struct StateDict

Source: checkpoint.joule:63

struct TensorData

Source: checkpoint.joule:69

fn from_tensor(tensor: &Tensor) -> Self

Create from tensor

Source: checkpoint.joule:77

fn to_tensor(&self) -> Tensor

Convert to tensor

Source: checkpoint.joule:86

fn new() -> Self

Create empty state dict

Source: checkpoint.joule:94

fn insert(&mut self, name: &str, tensor: &Tensor)

Add a tensor

Source: checkpoint.joule:101

fn get(&self, name: &str) -> Option<Tensor>

Get a tensor

Source: checkpoint.joule:106

fn keys(&self) -> impl Iterator<Item = &String>

Get tensor names

Source: checkpoint.joule:111

fn len(&self) -> usize

Number of tensors

Source: checkpoint.joule:116

struct Checkpoint

Source: checkpoint.joule:123

fn new(

Create new checkpoint

Source: checkpoint.joule:133

fn with_optimizer(mut self, state: HashMap<String, Tensor>) -> Self

Add optimizer state

Source: checkpoint.joule:147

fn with_scheduler(mut self, state: HashMap<String, f64>) -> Self

Add scheduler state

Source: checkpoint.joule:153

fn with_rng_state(mut self) -> Self

Add RNG state for reproducibility

Source: checkpoint.joule:159

fn save(&self, path: &str) -> Result<(), CheckpointError>

Source: checkpoint.joule:167

fn load(path: &str) -> Result<Self, CheckpointError>

Source: checkpoint.joule:190

enum CheckpointError

Source: checkpoint.joule:226

fn from(e: std::io::Error) -> Self

Source: checkpoint.joule:235

fn from(e: serde_json::Error) -> Self

Source: checkpoint.joule:241

struct CheckpointManager

Manages checkpoint saving and loading with best model tracking

Source: checkpoint.joule:251

struct CheckpointInfo

Source: checkpoint.joule:263

fn new(save_dir: &str) -> Self

Create new checkpoint manager

Source: checkpoint.joule:272

fn max_to_keep(mut self, n: usize) -> Self

Set maximum checkpoints to keep

Source: checkpoint.joule:287

fn save_best_only(mut self, metric_name: &str, mode: &str) -> Self

Only save when metric improves

Source: checkpoint.joule:293

fn is_better(&self, metric: f64) -> bool

Check if metric improved

Source: checkpoint.joule:301

fn save(

Source: checkpoint.joule:316

fn cleanup(&mut self) -> Result<(), CheckpointError>

Remove old checkpoints

Source: checkpoint.joule:368

fn load_latest(&self) -> Result<Checkpoint, CheckpointError>

Load latest checkpoint

Source: checkpoint.joule:379

fn load_best(&self) -> Result<Checkpoint, CheckpointError>

Load best checkpoint

Source: checkpoint.joule:386

fn load_epoch(&self, epoch: u64) -> Result<Checkpoint, CheckpointError>

Load checkpoint by epoch

Source: checkpoint.joule:392

fn list(&self) -> &[CheckpointInfo]

List all checkpoints

Source: checkpoint.joule:400

fn scan(&mut self) -> Result<(), CheckpointError>

Scan directory for existing checkpoints

Source: checkpoint.joule:405

fn get_state_dict<M: Module>(module: &M) -> StateDict

Extract state dict from a module

Source: checkpoint.joule:448

fn load_state_dict<M: Module>(module: &mut M, state: &StateDict) -> Result<(), CheckpointError>

Load state dict into a module

Source: checkpoint.joule:459

fn save_model<M: Module>(module: &M, path: &str) -> Result<(), CheckpointError>

Source: checkpoint.joule:476

fn load_model<M: Module>(module: &mut M, path: &str) -> Result<(), CheckpointError>

Source: checkpoint.joule:485

fn export_onnx<M: Module>(

Source: checkpoint.joule:492

fn export_script<M: Module>(

Source: checkpoint.joule:513