Skip to main content

ACMap

Trait ACMap 

Source
pub trait ACMap<S, V, H, W>:
    Clone
    + ACMapBase
    + ACMapAddAssign<S, V, H, W>
    + ACMapMulAssign<V, H>
    + ACMapInsert<S, V, H, W>
    + ACMapContains<S, V, H, W>
    + ACMapScale<S, V, H, W>
    + ACMapRetain<S, V, H, W>
    + ACMapConsume{ }
Expand description

Aggregate trait combining every operation a backing map must support to be usable as the storage for a PauliSum.

You don’t normally implement ACMap directly: the blanket impl below covers any type that implements all the constituent traits.

§Map-backend implementor’s guide

A new backing map (a GPU-resident map, a sharded map, anything beyond the existing HashMap / IndexMap / AHashMap / DashMap backends) needs these to satisfy the ACMap bound itself:

Satisfying ACMap is necessary but not sufficient: ppvm-pauli-sum bounds individual operations on further traits, so a backend that skips them only fails to compile at those call sites. In practice you also want:

  • ACMapIter — borrowing iteration over (key, value); needed by PauliSum::iter, Display, and the approximate-comparison helpers.
  • Trace — needed by PauliSum::trace.
  • Extend<(Word, Coeff)> — needed by the arithmetic operators.
  • PartialEq — needed by PauliSum’s approximate comparisons.

Of these, map_insert_vec, map_insert_multiple, scale, mul_assign, retain, and consume are whole-collection batch entry points: a concurrent or GPU backend can dispatch each of them as one parallel pass over every entry. add_assign is the exception — it operates on a single key at a time, so a thread-pool backend typically only parallelizes its batch sibling, map_add_assign. See the DashMap impl in crates/ppvm-traits/src/map/dashmap.rs for a working concurrent precedent: map_add_assign, mul_assign, map_insert_vec, map_insert_multiple, scale, consume, and trace all go through rayon par_iter. retain is the one that does not — its FnMut predicate is not shareable across threads, so DashMap forwards to the sequential DashMap::retain.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl<T, Storage, Coeff, Hasher, Word> ACMap<Storage, Coeff, Hasher, Word> for T
where Storage: PauliStorage, Coeff: Coefficient, Hasher: BuildHasher + Clone + Default, Word: PauliWordTrait, T: Clone + ACMapBase + ACMapAddAssign<Storage, Coeff, Hasher, Word> + ACMapMulAssign<Coeff, Hasher> + ACMapInsert<Storage, Coeff, Hasher, Word> + ACMapScale<Storage, Coeff, Hasher, Word> + ACMapContains<Storage, Coeff, Hasher, Word> + ACMapRetain<Storage, Coeff, Hasher, Word> + ACMapConsume,