pub struct GradientCheckpointConfig {
pub enabled: bool,
pub strategy: CheckpointStrategy,
pub checkpoint_layers: Vec<String>,
pub memory_threshold: Option<usize>,
}Expand description
Gradient checkpointing configuration.
Gradient checkpointing reduces memory usage by recomputing activations during the backward pass instead of storing them. This trades compute for memory.
Fields§
§enabled: boolWhether gradient checkpointing is enabled.
strategy: CheckpointStrategyCheckpointing strategy.
checkpoint_layers: Vec<String>Layers to checkpoint (by name pattern).
memory_threshold: Option<usize>Memory threshold to trigger checkpointing (bytes).
Implementations§
Source§impl GradientCheckpointConfig
impl GradientCheckpointConfig
Sourcepub fn with_strategy(self, strategy: CheckpointStrategy) -> Self
pub fn with_strategy(self, strategy: CheckpointStrategy) -> Self
Set checkpointing strategy.
Sourcepub fn with_layers(self, layers: Vec<String>) -> Self
pub fn with_layers(self, layers: Vec<String>) -> Self
Set layers to checkpoint.
Sourcepub fn with_memory_threshold(self, threshold: usize) -> Self
pub fn with_memory_threshold(self, threshold: usize) -> Self
Set memory threshold for automatic checkpointing.
Trait Implementations§
Source§impl Clone for GradientCheckpointConfig
impl Clone for GradientCheckpointConfig
Source§fn clone(&self) -> GradientCheckpointConfig
fn clone(&self) -> GradientCheckpointConfig
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for GradientCheckpointConfig
impl Debug for GradientCheckpointConfig
Auto Trait Implementations§
impl Freeze for GradientCheckpointConfig
impl RefUnwindSafe for GradientCheckpointConfig
impl Send for GradientCheckpointConfig
impl Sync for GradientCheckpointConfig
impl Unpin for GradientCheckpointConfig
impl UnwindSafe for GradientCheckpointConfig
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
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