pub struct ZeRoOptimizer { /* private fields */ }Expand description
ZeRO optimizer state
Implementations§
Source§impl ZeRoOptimizer
impl ZeRoOptimizer
Sourcepub fn new(config: ZeRoConfig, learning_rate: f32) -> Self
pub fn new(config: ZeRoConfig, learning_rate: f32) -> Self
Create new ZeRO optimizer
Sourcepub fn partition_parameters(
&mut self,
params: &HashMap<String, Tensor>,
) -> Result<(), String>
pub fn partition_parameters( &mut self, params: &HashMap<String, Tensor>, ) -> Result<(), String>
Partition parameters across ranks
Sourcepub fn partition_gradients(
&mut self,
grads: &HashMap<String, Tensor>,
) -> Result<(), String>
pub fn partition_gradients( &mut self, grads: &HashMap<String, Tensor>, ) -> Result<(), String>
Partition gradients (Stage 2+)
Sourcepub fn reduce_scatter_gradients(&mut self) -> Result<(), String>
pub fn reduce_scatter_gradients(&mut self) -> Result<(), String>
Reduce-scatter gradients across ranks
Sourcepub fn all_gather_parameters(&self) -> Result<HashMap<String, Tensor>, String>
pub fn all_gather_parameters(&self) -> Result<HashMap<String, Tensor>, String>
All-gather parameters (Stage 3)
Sourcepub fn memory_savings_ratio(&self) -> f32
pub fn memory_savings_ratio(&self) -> f32
Get memory savings ratio
Auto Trait Implementations§
impl Freeze for ZeRoOptimizer
impl !RefUnwindSafe for ZeRoOptimizer
impl Send for ZeRoOptimizer
impl Sync for ZeRoOptimizer
impl Unpin for ZeRoOptimizer
impl !UnwindSafe for ZeRoOptimizer
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> 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