pub struct SparseMomentumState {
pub momentum: HashMap<usize, f32>,
pub last_update: HashMap<usize, usize>,
pub grad_norm_acc: HashMap<usize, f32>,
pub is_compressed: bool,
}Expand description
Sparse momentum state for a parameter.
Fields§
§momentum: HashMap<usize, f32>Momentum buffer (only for active indices)
last_update: HashMap<usize, usize>Last update step for each active index
grad_norm_acc: HashMap<usize, f32>Accumulated gradient norm (for adaptive methods)
is_compressed: boolWhether state is compressed
Implementations§
Source§impl SparseMomentumState
impl SparseMomentumState
pub fn new() -> Self
Sourcepub fn num_active(&self) -> usize
pub fn num_active(&self) -> usize
Get the number of active parameters.
Sourcepub fn apply_lazy_update(&mut self, current_step: usize, decay: f32)
pub fn apply_lazy_update(&mut self, current_step: usize, decay: f32)
Apply lazy momentum updates.
Sourcepub fn cleanup(&mut self, max_age_steps: usize, current_step: usize)
pub fn cleanup(&mut self, max_age_steps: usize, current_step: usize)
Clean up old momentum states.
Sourcepub fn decompress(&mut self)
pub fn decompress(&mut self)
Decompress momentum states.
Trait Implementations§
Source§impl Clone for SparseMomentumState
impl Clone for SparseMomentumState
Source§fn clone(&self) -> SparseMomentumState
fn clone(&self) -> SparseMomentumState
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 SparseMomentumState
impl Debug for SparseMomentumState
Auto Trait Implementations§
impl Freeze for SparseMomentumState
impl RefUnwindSafe for SparseMomentumState
impl Send for SparseMomentumState
impl Sync for SparseMomentumState
impl Unpin for SparseMomentumState
impl UnwindSafe for SparseMomentumState
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> 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