pub struct DeviceMesh { /* private fields */ }Expand description
An n-D arrangement of ranks. The product of shape must equal the
world size; ranks are laid out in row-major order (last dim varies
fastest).
Implementations§
Source§impl DeviceMesh
impl DeviceMesh
Sourcepub fn new(shape: Vec<usize>, world_size: usize) -> FerrotorchResult<Self>
pub fn new(shape: Vec<usize>, world_size: usize) -> FerrotorchResult<Self>
Create a mesh with the given shape. world_size must equal the
product of shape (verified eagerly so misconfigured launches
fail loudly instead of silently splitting wrong).
Sourcepub fn new_with_names(
shape: Vec<usize>,
dim_names: Vec<String>,
world_size: usize,
) -> FerrotorchResult<Self>
pub fn new_with_names( shape: Vec<usize>, dim_names: Vec<String>, world_size: usize, ) -> FerrotorchResult<Self>
Variant of [new] that also attaches names to each dim.
dim_names.len() must match shape.len().
Sourcepub fn dim_index(&self, name: &str) -> FerrotorchResult<usize>
pub fn dim_index(&self, name: &str) -> FerrotorchResult<usize>
Resolve a dim name to its index.
Sourcepub fn coords(&self, rank: usize) -> FerrotorchResult<Vec<usize>>
pub fn coords(&self, rank: usize) -> FerrotorchResult<Vec<usize>>
Convert a rank to its multi-dim coordinate within the mesh. Row-major: the last dim varies fastest.
Sourcepub fn rank_of(&self, coords: &[usize]) -> FerrotorchResult<usize>
pub fn rank_of(&self, coords: &[usize]) -> FerrotorchResult<usize>
Inverse of [coords]: convert a coordinate to its rank.
Sourcepub fn ranks_along_dim(
&self,
dim: usize,
rank: usize,
) -> FerrotorchResult<Vec<usize>>
pub fn ranks_along_dim( &self, dim: usize, rank: usize, ) -> FerrotorchResult<Vec<usize>>
All ranks along dim that share rank’s coordinates on every
other dim. Useful for constructing per-axis collective groups
(e.g. one TP group per data-parallel slice).
Returns the ranks in increasing-coord order on dim.
Sourcepub fn groups_along_dim(&self, dim: usize) -> FerrotorchResult<Vec<Vec<usize>>>
pub fn groups_along_dim(&self, dim: usize) -> FerrotorchResult<Vec<Vec<usize>>>
All sub-groups along dim: a partitioning of the world into
disjoint groups of shape[dim] ranks each, such that every
group consists of ranks differing only on dim. Useful for
building sub-backends in bulk.
Trait Implementations§
Source§impl Clone for DeviceMesh
impl Clone for DeviceMesh
Source§fn clone(&self) -> DeviceMesh
fn clone(&self) -> DeviceMesh
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for DeviceMesh
impl RefUnwindSafe for DeviceMesh
impl Send for DeviceMesh
impl Sync for DeviceMesh
impl Unpin for DeviceMesh
impl UnsafeUnpin for DeviceMesh
impl UnwindSafe for DeviceMesh
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> DistributionExt for Twhere
T: ?Sized,
impl<T> DistributionExt for Twhere
T: ?Sized,
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>
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>
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