pub struct ModelParallelContext { /* private fields */ }Expand description
Model parallel context managing distributed execution
Implementations§
Source§impl ModelParallelContext
impl ModelParallelContext
Sourcepub fn new(config: ModelParallelConfig) -> Result<Self>
pub fn new(config: ModelParallelConfig) -> Result<Self>
Initialize model parallel context
Sourcepub fn world_size(&self) -> usize
pub fn world_size(&self) -> usize
Get total world size
Sourcepub fn partition_tensor(
&self,
tensor: &Tensor,
split_dim: usize,
) -> Result<DistributedTensor>
pub fn partition_tensor( &self, tensor: &Tensor, split_dim: usize, ) -> Result<DistributedTensor>
Partition a tensor across devices
Sourcepub fn all_gather(&self, distributed: &DistributedTensor) -> Result<Tensor>
pub fn all_gather(&self, distributed: &DistributedTensor) -> Result<Tensor>
Gather distributed tensor to full tensor
Sourcepub fn reduce_scatter(
&self,
tensor: &Tensor,
split_dim: usize,
) -> Result<Tensor>
pub fn reduce_scatter( &self, tensor: &Tensor, split_dim: usize, ) -> Result<Tensor>
Reduce scattered tensor across devices
Sourcepub fn all_reduce(&self, tensor: &mut Tensor) -> Result<()>
pub fn all_reduce(&self, tensor: &mut Tensor) -> Result<()>
All-reduce operation for gradient synchronization
Auto Trait Implementations§
impl Freeze for ModelParallelContext
impl !RefUnwindSafe for ModelParallelContext
impl Send for ModelParallelContext
impl Sync for ModelParallelContext
impl Unpin for ModelParallelContext
impl UnsafeUnpin for ModelParallelContext
impl !UnwindSafe for ModelParallelContext
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