pub struct CheckpointManager<T> { /* private fields */ }Expand description
Manager for activation checkpointing
Implementations§
Source§impl<T> CheckpointManager<T>
impl<T> CheckpointManager<T>
Sourcepub fn new(config: CheckpointingConfig) -> Self
pub fn new(config: CheckpointingConfig) -> Self
Create a new checkpoint manager
Sourcepub fn with_memory_budget(
memory_budget_mb: usize,
avg_activation_mb: usize,
) -> Self
pub fn with_memory_budget( memory_budget_mb: usize, avg_activation_mb: usize, ) -> Self
Create with automatic memory-based policy
Sourcepub fn should_checkpoint(&self, layer_index: usize, total_layers: usize) -> bool
pub fn should_checkpoint(&self, layer_index: usize, total_layers: usize) -> bool
Check if layer should be checkpointed according to policy
Sourcepub fn save_checkpoint(
&self,
layer_index: usize,
activations: Vec<Tensor<T>>,
) -> Result<()>
pub fn save_checkpoint( &self, layer_index: usize, activations: Vec<Tensor<T>>, ) -> Result<()>
Save a checkpoint for the given layer
Sourcepub fn get_checkpoint(
&self,
layer_index: usize,
) -> Result<Option<Checkpoint<T>>>
pub fn get_checkpoint( &self, layer_index: usize, ) -> Result<Option<Checkpoint<T>>>
Retrieve a checkpoint for the given layer
Sourcepub fn restore_rng_state(&self, _rng_state: &[u8]) -> Result<()>
pub fn restore_rng_state(&self, _rng_state: &[u8]) -> Result<()>
Restore RNG state previously captured by capture_rng_state.
The current scirs2_core RNG (a rand 0.10 ChaCha-backed generator)
does not expose serializable PRNG state, so there is nothing that can be
faithfully restored. This returns an honest UnsupportedOperation error
instead of silently pretending the state was restored.
Sourcepub fn record_recomputation(&self, compute_time_us: u64)
pub fn record_recomputation(&self, compute_time_us: u64)
Record a recomputation event
Sourcepub fn record_backward_pass(&self)
pub fn record_backward_pass(&self)
Record a backward pass
Sourcepub fn get_statistics(&self) -> Result<CheckpointStatistics>
pub fn get_statistics(&self) -> Result<CheckpointStatistics>
Get current statistics
Sourcepub fn checkpoint_count(&self) -> usize
pub fn checkpoint_count(&self) -> usize
Get number of active checkpoints
Sourcepub fn total_memory_bytes(&self) -> usize
pub fn total_memory_bytes(&self) -> usize
Get total memory used by checkpoints
Trait Implementations§
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
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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> ⓘ
Converts
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> ⓘ
Converts
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 more