pub struct CheckpointManager<T: Float + Debug + ScalarOperand + Send + Sync + 'static> { /* private fields */ }Expand description
Checkpoint management
Implementations§
Source§impl<T: Float + Debug + ScalarOperand + Send + Sync + 'static> CheckpointManager<T>
impl<T: Float + Debug + ScalarOperand + Send + Sync + 'static> CheckpointManager<T>
Sourcepub fn new(config: &TransformerBasedOptimizerConfig<T>) -> Result<Self>
pub fn new(config: &TransformerBasedOptimizerConfig<T>) -> Result<Self>
Build a checkpoint manager whose auto-save cadence follows config.
The auto-save frequency used to be a fixed 100 steps regardless of the
optimizer’s configuration; it now tracks
StateConfig::from_optimizer_config, which derives it from
performance_config.metrics_interval.
Sourcepub fn auto_save_config(&self) -> &AutoSaveConfig
pub fn auto_save_config(&self) -> &AutoSaveConfig
The auto-save policy this manager was built with.
Sourcepub fn maybe_auto_save(
&mut self,
step: usize,
snapshot: OptimizerStateSnapshot<T>,
) -> Result<Option<String>>
pub fn maybe_auto_save( &mut self, step: usize, snapshot: OptimizerStateSnapshot<T>, ) -> Result<Option<String>>
Save snapshot if step falls on the configured auto-save cadence.
Returns the new checkpoint id, or None when auto-save is disabled or
step is not a save point. Auto-saves are named auto_<step> and are
capped at AutoSaveConfig::max_auto_saves independently of the
explicit-checkpoint limit, oldest evicted first, so a long run cannot
grow the store without bound. step == 0 saves the initial state.
Without this, auto_save_config was populated at construction and never
read by anything: the auto-save policy existed only as a value.
Sourcepub fn auto_save_count(&self) -> usize
pub fn auto_save_count(&self) -> usize
Number of auto-saved checkpoints currently retained.
pub fn save_checkpoint( &mut self, name: String, snapshot: OptimizerStateSnapshot<T>, ) -> Result<String>
pub fn load_checkpoint( &self, checkpoint_id: &str, ) -> Result<OptimizerStateSnapshot<T>>
pub fn list_checkpoints(&self) -> Vec<CheckpointMetadata>
pub fn delete_checkpoint(&mut self, checkpoint_id: &str) -> Result<bool>
pub fn get_checkpoint_count(&self) -> usize
Auto Trait Implementations§
impl<T> Freeze for CheckpointManager<T>
impl<T> RefUnwindSafe for CheckpointManager<T>
impl<T> Send for CheckpointManager<T>
impl<T> Sync for CheckpointManager<T>
impl<T> Unpin for CheckpointManager<T>
impl<T> UnsafeUnpin for CheckpointManager<T>
impl<T> UnwindSafe for CheckpointManager<T>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.