DistributedSum

Struct DistributedSum 

Source
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>

Source

pub fn rank(&self) -> u32

This rank’s index in the group.

Source

pub fn size(&self) -> u32

Ranks in the group, which is also the partition count.

Source

pub fn transport(&self) -> &X

This rank’s endpoint, for a collective of the caller’s own.

Source

pub fn rows(&self) -> &PartitionRows<W>

The rows deciding which rank a key belongs to.

Source

pub fn runtime(&self) -> &Arc<PartitionRuntime>

The runtime this rank’s work runs on, for handing to another DistributedSum.

Source

pub fn enable_trace(&mut self)

Start recording a PartitionTrace of this rank’s layers on every later propagation; idempotent.

Source

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>

Source

pub fn len(&self) -> usize

Terms in the whole sum. Collective.

Source

pub fn is_empty(&self) -> bool

Whether the whole sum is empty. Collective, via len.

Source

pub fn bits(&self) -> u8

The bucket bits, equal on every rank.

Source

pub fn num_qubits(&self) -> usize

Qubits the sum is over.

Source§

impl<const W: usize, X: Transport> DistributedSum<W, X>

Source

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.

Source

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.

Source

pub fn propagate<T>( &mut self, circuit: &Circuit<W>, policy: &T, direction: Direction, )
where T: TruncationPolicy<W> + ?Sized,

Source

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.

Source

pub fn gather(&self) -> Option<PauliSum<W>>

Collect the whole sum on rank 0, None elsewhere, leaving self intact. Collective.

Source

pub fn local(&self) -> &PauliSum<W>

This rank’s share, a valid PauliSum under the group’s shared hash.

Source

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>
where B: Freeze, X: Freeze,

§

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>
where B: Unpin, X: Unpin,

§

impl<const W: usize, X, B = HostPartition<W>> !UnwindSafe for DistributedSum<W, X, B>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,