pub trait Communicator: Send + Sync {
// Required methods
fn rank(&self) -> usize;
fn size(&self) -> usize;
fn all_reduce(
&self,
op: AllReduce,
dtype: DType,
data: &mut [u8],
) -> Result<()>;
fn all_gather(&self, input: &[u8], output: &mut [u8]) -> Result<()>;
fn send(&self, dst: usize, data: &[u8]) -> Result<()>;
fn recv(&self, src: usize, data: &mut [u8]) -> Result<()>;
// Provided methods
fn sum_scatter(
&self,
dtype: DType,
input: &[u8],
output: &mut [u8],
) -> Result<()> { ... }
fn health(&self) -> Result<()> { ... }
fn split(&self, color: i32, key: i32) -> Result<Arc<dyn Communicator>> { ... }
}Expand description
The transport of a Group: every rank of the group calls the same operations in the
same order. Buffers are row-contiguous elements; a failure names the peer.
Required Methods§
Sourcefn all_reduce(&self, op: AllReduce, dtype: DType, data: &mut [u8]) -> Result<()>
fn all_reduce(&self, op: AllReduce, dtype: DType, data: &mut [u8]) -> Result<()>
Reduces data (elements of dtype) with every rank’s data, in place; every rank
gets the same bits.
Provided Methods§
Sourcefn sum_scatter(
&self,
dtype: DType,
input: &[u8],
output: &mut [u8],
) -> Result<()>
fn sum_scatter( &self, dtype: DType, input: &[u8], output: &mut [u8], ) -> Result<()>
Rank r’s output is the element-wise sum (elements of dtype) of every rank’s
r-th chunk of input (input.len() == size · output.len()), as MLX’s
sum_scatter.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".