pub struct DeviceGroup { /* private fields */ }Expand description
A set of devices participating in single-process collectives.
The first device is the leader: reductions land there, because a reduced value has to live somewhere and the caller needs to know where without asking.
Implementations§
Source§impl DeviceGroup
impl DeviceGroup
Sourcepub fn new(devices: Vec<Device>) -> Result<Self>
pub fn new(devices: Vec<Device>) -> Result<Self>
Build a group over devices. The first is the leader.
Returns Err for an empty list rather than panicking — a group with no
devices has no leader, so every collective on it would be undefined.
Sourcepub fn all_reduce(&self, shards: &[Tensor], op: ReduceOp) -> Result<Tensor>
pub fn all_reduce(&self, shards: &[Tensor], op: ReduceOp) -> Result<Tensor>
Reduce shards element-wise onto the leader device.
Shard i is taken to live on device i — the group’s device list is
the residency map, so shards.len() must not exceed size.
Each shard is brought to the leader (staging through CPU when it must
cross vendors) and folded
with op.
Sourcepub fn all_gather(&self, shards: &[Tensor], dim: usize) -> Result<Tensor>
pub fn all_gather(&self, shards: &[Tensor], dim: usize) -> Result<Tensor>
Concatenate shards along dim onto the leader device.
The gather counterpart of all_reduce: where reduce
combines values element-wise, this preserves every shard’s contribution.
Sourcepub fn realize_f32(&self, t: &Tensor) -> Result<Vec<f32>>
pub fn realize_f32(&self, t: &Tensor) -> Result<Vec<f32>>
Realize t as f32, seeding a device handle for every device in the
group.
A plain Tensor::realize_f32 seeds only the primary device, so a
graph whose nodes span several backends cannot be executed through it —
the non-primary backends have no handle to allocate against. This routes
through pipelined_bridge::realize_one_as_multi_device with the leader as
primary and the remaining group devices as extras, which is the entry the
existing live multi-vendor tests use.
Callers should not have to know that: the group already owns the device list, so it is the natural place for the seeding to live.
Trait Implementations§
Source§impl Clone for DeviceGroup
impl Clone for DeviceGroup
Auto Trait Implementations§
impl !RefUnwindSafe for DeviceGroup
impl !UnwindSafe for DeviceGroup
impl Freeze for DeviceGroup
impl Send for DeviceGroup
impl Sync for DeviceGroup
impl Unpin for DeviceGroup
impl UnsafeUnpin for DeviceGroup
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> ErasedDestructor for Twhere
T: 'static,
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