Skip to main content

MleStore

Struct MleStore 

Source
pub struct MleStore<'a, A: Allocator, P: PackedField> { /* private fields */ }
Expand description

A store of equal-length multilinear columns shared by a group of round evaluators.

See the module documentation for the folding invariant.

Implementations§

Source§

impl<'a, A: Allocator, F: Field, P: PackedField<Scalar = F>> MleStore<'a, A, P>

Source

pub const fn new(n_vars: usize, alloc: &'a A) -> Self

Creates an empty store over columns with n_vars variables.

Source

pub const fn n_vars(&self) -> usize

Returns the number of variables remaining in the columns.

Decrements with each Self::fold call.

Source

pub fn push(&mut self, column: FieldSlice<'a, P>) -> ColId

Pushes a borrowed column and returns its identifier.

The column is not copied; the first Self::fold writes into a fresh half-size buffer.

Source

pub fn push_owned(&mut self, column: FieldVec<P, A>) -> ColId

Pushes an owned column and returns its identifier.

Source

pub fn push_split_half(&mut self, buffer: FieldVec<P, A>) -> [ColId; 2]

Pushes the low and high halves of buffer as two columns, returning their ids [low, high].

The halves are not copied: the store takes ownership of buffer and holds both columns in it as a single split-half entry, so no up-front copy of the full buffer is made. Each Self::fold advances both halves in place within the buffer. buffer splits on its highest variable, so its low half fixes that variable to 0 and its high half to 1 — matching the store’s high-to-low fold order.

Source

pub fn register_eq_tracker(&mut self, eval_point: &[F]) -> EqId

Registers an equality-indicator tracker for an MLE-check evaluation point.

Trackers are deduplicated: evaluators registering the same evaluation point share one tracker, which the store folds once per challenge.

Source

pub fn eq_expansions(&self) -> Vec<&FieldBuffer<P>>

Returns the equality-indicator expansion of every registered tracker, in EqId order.

The driving prover slices each expansion per chunk once per round; the returned order matches EqId::index, so an evaluator’s tracker id indexes the resulting per-chunk slices.

Source

pub fn round_context(&self) -> RoundContext<'_, P>

Returns the read-only view of the current round that the evaluators interpolate against.

Valid until the next Self::fold, which is when the values it exposes advance.

Source

pub fn fold(&mut self, challenge: F)

Folds every column and every eq tracker with a verifier challenge.

Columns fold on the highest variable, matching the high-to-low binding order of the sumcheck provers this store backs.

Source

pub fn column(&self, id: ColId) -> FieldSlice<'_, P>

Returns the borrowed view of one logical column, addressed by its ColId.

The slice spans the column’s 2^n_vars() live scalars, so it tracks the store’s folding.

Source

pub fn column_slices(&self) -> Vec<FieldSlice<'_, P>> ⓘ

Expands the store into one borrowed slice per logical column, in ColId order.

A split-half entry expands into the front 2^n_vars scalars of its low and high halves, so the returned length is the logical column count — larger than the physical entry count whenever a split-half column is present.

Source

pub fn final_evals(&self) -> Vec<F>

Returns the evaluation of every column at the challenge point, indexed by ColId.

Each column’s evaluation is computed once, no matter how many claims read the column.

Source

pub fn map_reduce<T: Send>( &self, chunk_vars: usize, map: impl for<'c> Fn(EvaluationChunk<'c, P>) -> T + Sync, reduce: impl Fn(T, T, usize) -> T + Sync, ) -> T

Maps every chunk of the halved hypercube through map and combines the results with reduce, driven by a recursive [rayon::join] tree.

The store’s columns are expanded once — a split-half column becomes its two halves — and each column is split on the round’s highest variable into its low and high halves. The recursion peels the remaining variables off both halves, and off every eq-indicator expansion, together, so each leaf hands map one EvaluationChunk: the paired column halves and the matching eq chunk, at 2^chunk_vars scalars per half.

reduce(low, high, level) combines the two sub-results of a bisection, where level is the index of the variable that was bisected to produce them (low fixes it to 0, high to 1). A plain sum ignores level; an eq-weighted reduction uses it to pick the round’s coordinate.

chunk_vars is capped at n_vars() - 1, so leaves never exceed the halved hypercube.

§Preconditions
  • n_vars() must be greater than 0.
Source

pub fn map_reduce_with_fold<T: Send>( &mut self, chunk_vars: usize, challenge: F, map: impl for<'c> Fn(EvaluationChunk<'c, P>) -> T + Sync, reduce: impl Fn(T, T, usize) -> T + Sync, ) -> T

Folds the store with challenge and, in the same pass, maps and reduces the resulting halved hypercube — equivalent to Self::fold followed by Self::map_reduce, but folding each column and eq expansion into the map’s read of it so they are touched once instead of twice.

chunk_vars is capped at n_vars() - 2 (the folded store’s leaf size). For a chunk size below P::LOG_WIDTH the columns are already cache-resident and the fused pass cannot split sub-packing-width leaves, so this falls back to a plain Self::fold then Self::map_reduce.

§Preconditions
  • n_vars() must be greater than 1.

Auto Trait Implementations§

§

impl<'a, A, P> Freeze for MleStore<'a, A, P>

§

impl<'a, A, P> RefUnwindSafe for MleStore<'a, A, P>

§

impl<'a, A, P> Send for MleStore<'a, A, P>

§

impl<'a, A, P> Sync for MleStore<'a, A, P>
where <A as Allocator>::Vec<P>: Sync,

§

impl<'a, A, P> Unpin for MleStore<'a, A, P>
where <A as Allocator>::Vec<P>: Unpin, <P as FieldOps>::Scalar: Unpin, P: Unpin,

§

impl<'a, A, P> UnsafeUnpin for MleStore<'a, A, P>

§

impl<'a, A, P> UnwindSafe for MleStore<'a, A, P>

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.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> Same for T

Source§

type Output = T

Should always be Self
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<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more