pub struct MicroAdam { /* private fields */ }Expand description
MicroAdam optimizer implementation
Provides memory-efficient Adam optimization through compressed gradient storage while maintaining convergence guarantees through careful state management.
Implementations§
Source§impl MicroAdam
impl MicroAdam
Sourcepub fn new_with_lr(learning_rate: f32) -> Self
pub fn new_with_lr(learning_rate: f32) -> Self
Create MicroAdam with custom learning rate
Sourcepub fn for_large_models() -> Self
pub fn for_large_models() -> Self
Create MicroAdam for large language models with optimized compression
Sourcepub fn for_memory_constrained() -> Self
pub fn for_memory_constrained() -> Self
Create MicroAdam for memory-constrained environments
Sourcepub fn with_config(config: MicroAdamConfig) -> Self
pub fn with_config(config: MicroAdamConfig) -> Self
Create MicroAdam with custom configuration
Sourcepub fn memory_savings_ratio(&self) -> f32
pub fn memory_savings_ratio(&self) -> f32
Get memory savings compared to standard Adam
Sourcepub fn compression_statistics(&self) -> String
pub fn compression_statistics(&self) -> String
Get compression statistics
Trait Implementations§
Source§impl Optimizer for MicroAdam
impl Optimizer for MicroAdam
Source§fn update(&mut self, parameter: &mut Tensor, grad: &Tensor) -> Result<()>
fn update(&mut self, parameter: &mut Tensor, grad: &Tensor) -> Result<()>
Updates a parameter based on its gradient. Read more
Source§fn accumulate_grad(
&mut self,
parameter: &mut Tensor,
grad: &Tensor,
) -> Result<(), TrustformersError>
fn accumulate_grad( &mut self, parameter: &mut Tensor, grad: &Tensor, ) -> Result<(), TrustformersError>
Accumulates gradients for gradient accumulation. Read more
Source§fn apply_accumulated_grads(
&mut self,
accumulation_steps: usize,
) -> Result<(), TrustformersError>
fn apply_accumulated_grads( &mut self, accumulation_steps: usize, ) -> Result<(), TrustformersError>
Applies accumulated gradients after gradient accumulation. Read more
Source§impl StatefulOptimizer for MicroAdam
impl StatefulOptimizer for MicroAdam
Source§type Config = MicroAdamConfig
type Config = MicroAdamConfig
The configuration type for this optimizer.
Source§type State = OptimizerState
type State = OptimizerState
The state type used by this optimizer.
Source§fn state_mut(&mut self) -> &mut Self::State
fn state_mut(&mut self) -> &mut Self::State
Gets a mutable reference to the optimizer’s internal state.
Source§fn state_dict(&self) -> Result<HashMap<String, Tensor>>
fn state_dict(&self) -> Result<HashMap<String, Tensor>>
Saves the optimizer state to a dictionary for checkpointing.
Source§fn load_state_dict(&mut self, state_dict: HashMap<String, Tensor>) -> Result<()>
fn load_state_dict(&mut self, state_dict: HashMap<String, Tensor>) -> Result<()>
Loads optimizer state from a dictionary during checkpoint restoration.
Source§fn memory_usage(&self) -> StateMemoryStats
fn memory_usage(&self) -> StateMemoryStats
Gets memory usage statistics for this optimizer.
Source§fn reset_state(&mut self)
fn reset_state(&mut self)
Resets the optimizer state (useful for training restarts).
Source§fn num_parameters(&self) -> usize
fn num_parameters(&self) -> usize
Returns the number of parameters being optimized.
Auto Trait Implementations§
impl Freeze for MicroAdam
impl RefUnwindSafe for MicroAdam
impl Send for MicroAdam
impl Sync for MicroAdam
impl Unpin for MicroAdam
impl UnwindSafe for MicroAdam
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> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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