pub struct DeviceMesh { /* private fields */ }Expand description
A 2-D logical device mesh: tensor-parallel dimension × pipeline-parallel dimension.
Devices are stored in row-major order: device at (tp_rank, pp_rank) has
linear index tp_rank + pp_rank * tp_size.
Implementations§
Source§impl DeviceMesh
impl DeviceMesh
Sourcepub fn tensor_parallel(n: usize) -> Self
pub fn tensor_parallel(n: usize) -> Self
Create a 1-D tensor-parallel mesh of n simulated devices.
Sourcepub fn new(tp_size: usize, pp_size: usize) -> Self
pub fn new(tp_size: usize, pp_size: usize) -> Self
Create a 2-D (tp_size × pp_size) mesh.
Total device count is tp_size * pp_size.
Sourcepub fn get(&self, tp_rank: usize, pp_rank: usize) -> Option<&DeviceInfo>
pub fn get(&self, tp_rank: usize, pp_rank: usize) -> Option<&DeviceInfo>
Get the device at tensor-parallel rank tp_rank and pipeline-parallel rank pp_rank.
Returns None if either rank is out of bounds.
Sourcepub fn tp_group(&self, pp_rank: usize) -> Vec<&DeviceInfo>
pub fn tp_group(&self, pp_rank: usize) -> Vec<&DeviceInfo>
All devices in the tensor-parallel group for a given pp_rank.
Returns an empty vec if pp_rank is out of range.
Sourcepub fn pp_group(&self, tp_rank: usize) -> Vec<&DeviceInfo>
pub fn pp_group(&self, tp_rank: usize) -> Vec<&DeviceInfo>
All devices in the pipeline-parallel group for a given tp_rank.
Returns an empty vec if tp_rank is out of range.
Auto 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
Mutably borrows from an owned value. Read more
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