pulsatrix 1.1.0
Loading...
Searching...
No Matches
checkpoint.hpp File Reference

Saving and resuming models (roadmap IO-2): parameters and buffers in one safetensors file, optimizer state in a sibling file, and a format version with a migration table. More...

#include <map>
#include <string>
#include "pulsatrix/adam_optimizer.hpp"
#include "pulsatrix/module.hpp"
Include dependency graph for checkpoint.hpp:

Go to the source code of this file.

Classes

struct  pulsatrix::CheckpointLoadOptions
 Options for LoadCheckpoint(). More...
 

Namespaces

namespace  pulsatrix
 

Functions

std::string pulsatrix::OptimizerStatePath (const std::string &checkpoint_path)
 Where the optimizer state for checkpoint_path is stored: model.safetensors becomes model.optim.safetensors; any other name gets .optim.safetensors appended.
 
void pulsatrix::SaveCheckpoint (const std::string &path, Module &model, const std::map< std::string, std::string > &metadata={})
 Writes every parameter and buffer of model, under their hierarchical names, to a safetensors file with format = "pulsatrix" and format_version metadata.
 
void pulsatrix::SaveCheckpoint (const std::string &path, Module &model, const AdamOptimizer &optimizer, const std::map< std::string, std::string > &metadata={})
 SaveCheckpoint(), plus optimizer's per-parameter state in OptimizerStatePath(path).
 
void pulsatrix::LoadCheckpoint (const std::string &path, Module &model, CheckpointLoadOptions options={})
 Loads parameters and buffers saved by SaveCheckpoint() (or any safetensors file whose names match) into model, in place.
 
void pulsatrix::LoadCheckpoint (const std::string &path, Module &model, AdamOptimizer &optimizer, CheckpointLoadOptions options={})
 LoadCheckpoint(), plus optimizer's state from OptimizerStatePath(path), so training resumes exactly where it stopped.
 

Variables

constexpr int pulsatrix::kCheckpointFormatVersion = 1
 The checkpoint format this build writes. Files record it as format_version; a file without one (any plain safetensors file) is version 0. Older versions load through a migration table; newer ones are rejected.
 

Detailed Description

Saving and resuming models (roadmap IO-2): parameters and buffers in one safetensors file, optimizer state in a sibling file, and a format version with a migration table.