pub struct DistributedSum<const W: usize, X: Transport, B = HostPartition<W>> { /* private fields */ }Expand description
One process’s partition of a sum split across a Transport’s group, held across calls so a driver scatters once, steps many times and gathers once.
The input is replicated: every rank scatters the same sum and keeps its own partition.
gather returns Some on rank 0 only, and a PartitionTrace holds this rank’s counts only.
B is where the partition lives: host memory, or a CUDA device under the cuda feature (gpu::GpuDistributedSum).
Implementations§
Source§impl<const W: usize, X: Transport, B> DistributedSum<W, X, B>
impl<const W: usize, X: Transport, B> DistributedSum<W, X, B>
Sourcepub fn rows(&self) -> &PartitionRows<W>
pub fn rows(&self) -> &PartitionRows<W>
The rows deciding which rank a key belongs to.
Sourcepub fn runtime(&self) -> &Arc<PartitionRuntime>
pub fn runtime(&self) -> &Arc<PartitionRuntime>
The runtime this rank’s work runs on, for handing to another DistributedSum.
Sourcepub fn enable_trace(&mut self)
pub fn enable_trace(&mut self)
Start recording a PartitionTrace of this rank’s layers on every later propagation; idempotent.
Sourcepub fn take_trace(&mut self) -> Option<PartitionTrace>
pub fn take_trace(&mut self) -> Option<PartitionTrace>
Drain this rank’s per-layer records, or None if tracing was never enabled; tracing stays enabled.
terms_in, terms_out and rows_received have one entry, while rows_sent[0] and bytes_sent[0] are indexed by destination rank.
Source§impl<const W: usize, X: Transport, B: PartitionStorage<W>> DistributedSum<W, X, B>
impl<const W: usize, X: Transport, B: PartitionStorage<W>> DistributedSum<W, X, B>
Source§impl<const W: usize, X: Transport> DistributedSum<W, X>
impl<const W: usize, X: Transport> DistributedSum<W, X>
Sourcepub fn scatter(
sum: PauliSum<W>,
transport: X,
config: &PartitionConfig,
) -> Result<Self, TopologyError>
pub fn scatter( sum: PauliSum<W>, transport: X, config: &PartitionConfig, ) -> Result<Self, TopologyError>
Split the replicated sum across transport’s group by the default rows (PartitionRowPolicy::Seeded at the sum’s own hash seed), keeping this rank’s share on the one-partition runtime config describes.
§Errors
TopologyError if config cannot be resolved or the pool cannot be built.
§Panics
If config asks for more than one partition, or if the group size is not a power of two.
Sourcepub fn scatter_with(
sum: PauliSum<W>,
transport: X,
options: ScatterOptions<W>,
) -> Self
pub fn scatter_with( sum: PauliSum<W>, transport: X, options: ScatterOptions<W>, ) -> Self
scatter onto a caller-built runtime, split by the rows options names.
ScatterRows::Explicit rows must be the same on every rank; nothing checks it, and a disagreement misroutes an exchange.
§Panics
If the runtime has more than one partition, if the group size is not a power of two, if the rows do not name one partition per rank or are for a different qubit count than sum, or as PartitionRows::cut.
In debug builds, if the rows are not independent of the sum’s hash rows.
Sourcepub fn propagate<T>(
&mut self,
circuit: &Circuit<W>,
policy: &T,
direction: Direction,
)where
T: TruncationPolicy<W> + ?Sized,
pub fn propagate<T>(
&mut self,
circuit: &Circuit<W>,
policy: &T,
direction: Direction,
)where
T: TruncationPolicy<W> + ?Sized,
Sourcepub fn propagate_with<T>(
&mut self,
circuit: &Circuit<W>,
policy: &T,
direction: Direction,
options: PropagateOptions,
)where
T: TruncationPolicy<W> + ?Sized,
pub fn propagate_with<T>(
&mut self,
circuit: &Circuit<W>,
policy: &T,
direction: Direction,
options: PropagateOptions,
)where
T: TruncationPolicy<W> + ?Sized,
Propagate through circuit under policy, in place. Collective: every rank passes the same circuit, direction and options.
A shape fingerprint of the run (channel count, direction, options, qubit count, W) is checked across ranks first; channel contents are not.
§Panics
If options fail PropagateOptions::validate, if a channel’s preparation declines, or if the ranks disagree about the run’s shape.
Before the first layer, above one rank, unless policy.supports_partitioned() — exact TopN is not yet supported partitioned.
Sourcepub fn gather(&self) -> Option<PauliSum<W>>
pub fn gather(&self) -> Option<PauliSum<W>>
Collect the whole sum on rank 0, None elsewhere, leaving self intact. Collective.
Sourcepub fn local(&self) -> &PauliSum<W>
pub fn local(&self) -> &PauliSum<W>
This rank’s share, a valid PauliSum under the group’s shared hash.
Sourcepub fn assert_invariants(&self)
pub fn assert_invariants(&self)
Panic unless this rank’s share is well-formed and holds only its own keys; O(terms), local only.
Auto Trait Implementations§
impl<const W: usize, X, B> Freeze for DistributedSum<W, X, B>
impl<const W: usize, X, B = HostPartition<W>> !RefUnwindSafe for DistributedSum<W, X, B>
impl<const W: usize, X, B> Send for DistributedSum<W, X, B>where
B: Send,
impl<const W: usize, X, B> Sync for DistributedSum<W, X, B>where
B: Sync,
impl<const W: usize, X, B> Unpin for DistributedSum<W, X, B>
impl<const W: usize, X, B = HostPartition<W>> !UnwindSafe for DistributedSum<W, X, B>
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> 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