pub trait DistributedOptimizer: Optimizer {
type Communicator;
// Required methods
fn all_reduce_gradients(&mut self, gradients: &mut [Tensor]) -> Result<()>;
fn broadcast_parameters(&mut self, parameters: &mut [Tensor]) -> Result<()>;
fn rank(&self) -> usize;
fn world_size(&self) -> usize;
fn sync_state(&mut self) -> Result<()>;
}Expand description
Trait for distributed optimization capabilities.
Provides interfaces for gradient synchronization and distributed training.
Required Associated Types§
Sourcetype Communicator
type Communicator
The communicator type used for distributed operations.
Required Methods§
Sourcefn all_reduce_gradients(&mut self, gradients: &mut [Tensor]) -> Result<()>
fn all_reduce_gradients(&mut self, gradients: &mut [Tensor]) -> Result<()>
Performs all-reduce operation on gradients.
Sourcefn broadcast_parameters(&mut self, parameters: &mut [Tensor]) -> Result<()>
fn broadcast_parameters(&mut self, parameters: &mut [Tensor]) -> Result<()>
Broadcasts parameters from rank 0 to all other ranks.
Sourcefn world_size(&self) -> usize
fn world_size(&self) -> usize
Gets the total number of ranks in the distributed group.
Sourcefn sync_state(&mut self) -> Result<()>
fn sync_state(&mut self) -> Result<()>
Synchronizes optimizer state across all ranks.