Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for s-column as part of the support for LogUp-GKR #297

Merged
merged 58 commits into from
Sep 3, 2024
Merged
Show file tree
Hide file tree
Changes from 51 commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
29c033a
feat: math utilities needed for sum-check protocol
Al-Kindi-0 Aug 6, 2024
0d7fa67
feat: add sum-check prover and verifier
Al-Kindi-0 Aug 6, 2024
6da91af
tests: add sanity tests for utils
Al-Kindi-0 Aug 6, 2024
0dfc229
feat: use SmallVec
Al-Kindi-0 Aug 7, 2024
a51a464
feat: add remaining functions for sum-check verifier
Al-Kindi-0 Aug 9, 2024
581343d
chore: move prover into sub-mod
Al-Kindi-0 Aug 9, 2024
34807c9
chore: remove utils mod
Al-Kindi-0 Aug 9, 2024
e610411
chore: move logup evaluator trait to separate file
Al-Kindi-0 Aug 9, 2024
d98407a
feat: add multi-threading support and simplify input sum-check
Al-Kindi-0 Aug 15, 2024
3feaff8
feat: add benchmarks and address feedback
Al-Kindi-0 Aug 19, 2024
0475b4e
feat: address feedback and add benchmarks
Al-Kindi-0 Aug 19, 2024
9bfa423
feat: add GKR backend for LogUp-GKR
Al-Kindi-0 Aug 9, 2024
3576e3f
chore: remove old way of handling Lagrange kernel
Al-Kindi-0 Aug 12, 2024
d6f0bd4
feat: simplify sum-check for input layer
Al-Kindi-0 Aug 14, 2024
5dfed3d
feat: add mult-threading to sum-checks and multi-linears
Al-Kindi-0 Aug 14, 2024
b62b31d
chore: unify serial and concurrent EQ impls
Al-Kindi-0 Aug 14, 2024
6a1cc1c
fix: formatting
Al-Kindi-0 Aug 14, 2024
70ea9d6
fix: concurrent feature flag
Al-Kindi-0 Aug 14, 2024
d49cdbb
feat: make query a mut ref in build_query
Al-Kindi-0 Aug 19, 2024
5f5b189
chore: update var names and simplify some structs
Al-Kindi-0 Aug 20, 2024
49f02a7
chore: rebase
Al-Kindi-0 Aug 20, 2024
64c5fde
chore: fix rebase against facebook:logup-gkr
Al-Kindi-0 Aug 21, 2024
843b90d
chore: address feedback
Al-Kindi-0 Aug 21, 2024
229d9ed
chore: add dummy GkrLogUp evaluator
Al-Kindi-0 Aug 23, 2024
b36eaa3
chore: fix clippy warnings
Al-Kindi-0 Aug 23, 2024
b8dcb35
chore: address feedback
Al-Kindi-0 Aug 26, 2024
7f9e870
chore: loosen the trait bound
Al-Kindi-0 Aug 26, 2024
b5464bd
chore: address feedback 1
Al-Kindi-0 Aug 27, 2024
9322da9
chore: address feedback 2
Al-Kindi-0 Aug 27, 2024
1863629
feat: math utilities needed for sum-check protocol
Al-Kindi-0 Aug 6, 2024
ea3ed02
feat: add sum-check prover and verifier
Al-Kindi-0 Aug 6, 2024
3ae1ec0
tests: add sanity tests for utils
Al-Kindi-0 Aug 6, 2024
e44894a
feat: use SmallVec
Al-Kindi-0 Aug 7, 2024
0613574
feat: add remaining functions for sum-check verifier
Al-Kindi-0 Aug 9, 2024
de5eee7
chore: move prover into sub-mod
Al-Kindi-0 Aug 9, 2024
7e3ad84
chore: remove utils mod
Al-Kindi-0 Aug 9, 2024
e03416f
chore: remove utils mod
Al-Kindi-0 Aug 9, 2024
e7a88f6
chore: move logup evaluator trait to separate file
Al-Kindi-0 Aug 9, 2024
e25d49c
feat: add multi-threading support and simplify input sum-check
Al-Kindi-0 Aug 15, 2024
d0c221d
feat: add benchmarks and address feedback
Al-Kindi-0 Aug 19, 2024
e779b3e
feat: address feedback and add benchmarks
Al-Kindi-0 Aug 19, 2024
57793e7
feat: add GKR backend for LogUp-GKR
Al-Kindi-0 Aug 9, 2024
7bcf677
feat: simplify sum-check for input layer
Al-Kindi-0 Aug 14, 2024
3778c88
feat: add mult-threading to sum-checks and multi-linears
Al-Kindi-0 Aug 14, 2024
707ba7a
chore: unify serial and concurrent EQ impls
Al-Kindi-0 Aug 14, 2024
31ab68d
fix: concurrent feature flag
Al-Kindi-0 Aug 14, 2024
351e9d9
wip: add s-column constraints
Al-Kindi-0 Aug 12, 2024
a6570ca
feat: add support for s-col and merge it with the that of Lagrange ke…
Al-Kindi-0 Aug 15, 2024
cc5aab7
chore: rebase and remove conflicts
Al-Kindi-0 Aug 20, 2024
344c995
chore: rebase
Al-Kindi-0 Aug 27, 2024
4d6514c
chore: fix post rebase issues
Al-Kindi-0 Aug 30, 2024
11ccbff
chore: address feedback 1
Al-Kindi-0 Sep 2, 2024
1503983
chore: address feedback 2
Al-Kindi-0 Sep 2, 2024
1bdb849
chore: re-organise logup_gkr module
Al-Kindi-0 Sep 2, 2024
431215a
chore: re-organise logup_gkr module
Al-Kindi-0 Sep 2, 2024
e3b2dd0
feat: add s-column constraint validation
Al-Kindi-0 Sep 2, 2024
b0ca76c
chore: improve doc and remove obsolete file
Al-Kindi-0 Sep 2, 2024
b547459
chore: address feeback 3
Al-Kindi-0 Sep 2, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions air/src/air/aux.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

use alloc::vec::Vec;

use math::FieldElement;
use math::{ExtensionOf, FieldElement};

use super::{lagrange::LagrangeKernelRandElements, LogUpGkrOracle};

Expand Down Expand Up @@ -130,7 +130,11 @@ impl<E: FieldElement> GkrData<E> {
.fold(E::ZERO, |acc, (a, b)| acc + *a * *b)
}

pub fn compute_batched_query(&self, query: &[E::BaseField]) -> E {
pub fn compute_batched_query<F>(&self, query: &[F]) -> E
where
F: FieldElement<BaseField = E::BaseField>,
E: ExtensionOf<F>,
{
E::from(query[0])
+ query
.iter()
Expand Down
3 changes: 2 additions & 1 deletion air/src/air/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use core::cmp;

use math::StarkField;

use super::LAGRANGE_KERNEL_OFFSET;
use crate::{air::TransitionConstraintDegree, ProofOptions, TraceInfo};

// AIR CONTEXT
Expand Down Expand Up @@ -253,7 +254,7 @@ impl<B: StarkField, P> AirContext<B, P> {
/// Returns the index of the auxiliary column which implements the Lagrange kernel, if any
pub fn lagrange_kernel_aux_column_idx(&self) -> Option<usize> {
irakliyk marked this conversation as resolved.
Show resolved Hide resolved
if self.logup_gkr_enabled() {
Some(self.trace_info().aux_segment_width() - 1)
Some(self.trace_info().aux_segment_width() - LAGRANGE_KERNEL_OFFSET)
} else {
None
}
irakliyk marked this conversation as resolved.
Show resolved Hide resolved
Expand Down
64 changes: 64 additions & 0 deletions air/src/air/logup_gkr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ use math::{ExtensionOf, FieldElement, StarkField, ToElements};

use super::{EvaluationFrame, GkrData, LagrangeKernelRandElements};

// CONSTANTS
// ===============================================================================================
pub const LAGRANGE_KERNEL_OFFSET: usize = 1;
pub const S_COLUMN_OFFSET: usize = 2;
irakliyk marked this conversation as resolved.
Show resolved Hide resolved

/// A trait containing the necessary information in order to run the LogUp-GKR protocol of [1].
///
/// The trait contains useful information for running the GKR protocol as well as for implementing
Expand Down Expand Up @@ -200,3 +205,62 @@ pub enum LogUpGkrOracle<B: StarkField> {
/// must be a power of 2.
PeriodicValue(Vec<B>),
}

#[derive(Clone, Default)]
pub struct DummyLogUpGkrEval<B: StarkField, P: Clone + Send + Sync + ToElements<B>> {
irakliyk marked this conversation as resolved.
Show resolved Hide resolved
_field: PhantomData<B>,
_public_inputs: PhantomData<P>,
}

impl<B, P> LogUpGkrEvaluator for DummyLogUpGkrEval<B, P>
where
B: StarkField,
P: Clone + Send + Sync + ToElements<B>,
{
type BaseField = B;

type PublicInputs = P;

fn get_oracles(&self) -> &[LogUpGkrOracle<Self::BaseField>] {
panic!("LogUpGkrEvaluator method called but LogUp-GKR is not implemented")
}

fn get_num_rand_values(&self) -> usize {
panic!("LogUpGkrEvaluator method called but LogUp-GKR is not implemented")
}

fn get_num_fractions(&self) -> usize {
panic!("LogUpGkrEvaluator method called but LogUp-GKR is not implemented")
}

fn max_degree(&self) -> usize {
panic!("LogUpGkrEvaluator method called but LogUp-GKR is not implemented")
}

fn build_query<E>(&self, _frame: &EvaluationFrame<E>, _periodic_values: &[E], _query: &mut [E])
where
E: FieldElement<BaseField = Self::BaseField>,
{
panic!("LogUpGkrEvaluator method called but LogUp-GKR is not implemented")
}

fn evaluate_query<F, E>(
&self,
_query: &[F],
_rand_values: &[E],
_numerator: &mut [E],
_denominator: &mut [E],
) where
F: FieldElement<BaseField = Self::BaseField>,
E: FieldElement<BaseField = Self::BaseField> + ExtensionOf<F>,
{
panic!("LogUpGkrEvaluator method called but LogUp-GKR is not implemented")
}

fn compute_claim<E>(&self, _inputs: &Self::PublicInputs, _rand_values: &[E]) -> E
where
E: FieldElement<BaseField = Self::BaseField>,
{
panic!("LogUpGkrEvaluator method called but LogUp-GKR is not implemented")
}
}
8 changes: 5 additions & 3 deletions air/src/air/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ pub use lagrange::{
};

mod logup_gkr;
pub use logup_gkr::{LogUpGkrEvaluator, LogUpGkrOracle};
pub use logup_gkr::{
LogUpGkrEvaluator, LogUpGkrOracle, LAGRANGE_KERNEL_OFFSET, S_COLUMN_OFFSET,
};

mod coefficients;
pub use coefficients::{
Expand Down Expand Up @@ -600,7 +602,7 @@ pub trait Air: Send + Sync {
None
};

let s_col = if self.context().logup_gkr_enabled() {
let s_col_cc = if self.context().logup_gkr_enabled() {
Some(public_coin.draw()?)
} else {
None
Expand All @@ -610,7 +612,7 @@ pub trait Air: Send + Sync {
trace: t_coefficients,
constraints: c_coefficients,
lagrange: lagrange_cc,
s_col,
s_col: s_col_cc,
})
}
}
1 change: 0 additions & 1 deletion air/src/air/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,6 @@ impl MockAir {
impl Air for MockAir {
type BaseField = BaseElement;
type PublicInputs = ();
//type LogUpGkrEvaluator = DummyLogUpGkrEval<Self::BaseField, ()>;

fn new(trace_info: TraceInfo, _pub_inputs: (), _options: ProofOptions) -> Self {
let num_assertions = trace_info.meta()[0] as usize;
Expand Down
5 changes: 3 additions & 2 deletions air/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ pub use air::{
DeepCompositionCoefficients, EvaluationFrame, GkrData,
LagrangeConstraintsCompositionCoefficients, LagrangeKernelBoundaryConstraint,
LagrangeKernelConstraints, LagrangeKernelEvaluationFrame, LagrangeKernelRandElements,
LagrangeKernelTransitionConstraints, LogUpGkrEvaluator, LogUpGkrOracle, TraceInfo,
TransitionConstraintDegree, TransitionConstraints,
LagrangeKernelTransitionConstraints, LogUpGkrEvaluator, LogUpGkrOracle,
TraceInfo, TransitionConstraintDegree, TransitionConstraints, LAGRANGE_KERNEL_OFFSET,
S_COLUMN_OFFSET,
};
37 changes: 20 additions & 17 deletions prover/src/constraints/evaluator/default.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ use utils::iter_mut;
use utils::{iterators::*, rayon};

use super::{
super::EvaluationTableFragment, lagrange::LagrangeKernelConstraintsBatchEvaluator,
BoundaryConstraints, CompositionPolyTrace, ConstraintEvaluationTable, ConstraintEvaluator,
PeriodicValueTable, StarkDomain, TraceLde,
super::EvaluationTableFragment, logup_gkr::LogUpGkrConstraintsEvaluator, BoundaryConstraints,
CompositionPolyTrace, ConstraintEvaluationTable, ConstraintEvaluator, PeriodicValueTable,
StarkDomain, TraceLde,
};

// CONSTANTS
Expand All @@ -40,7 +40,7 @@ pub struct DefaultConstraintEvaluator<'a, A: Air, E: FieldElement<BaseField = A:
air: &'a A,
boundary_constraints: BoundaryConstraints<E>,
transition_constraints: TransitionConstraints<E>,
lagrange_constraints_evaluator: Option<LagrangeKernelConstraintsBatchEvaluator<E>>,
logup_gkr_constraints_evaluator: Option<LogUpGkrConstraintsEvaluator<'a, E, A>>,
aux_rand_elements: Option<AuxRandElements<E>>,
periodic_values: PeriodicValueTable<E::BaseField>,
}
Expand Down Expand Up @@ -117,10 +117,10 @@ where
evaluation_table.validate_transition_degrees();

// combine all constraint evaluations into a single column, including the evaluations of the
// Lagrange kernel constraints (if present)
// LogUp-GKR constraints (if present)
let combined_evaluations = {
let mut constraints_evaluations = evaluation_table.combine();
self.evaluate_lagrange_kernel_constraints(trace, domain, &mut constraints_evaluations);
self.evaluate_logup_gkr_constraints(trace, domain, &mut constraints_evaluations);

constraints_evaluations
};
Expand Down Expand Up @@ -158,18 +158,21 @@ where
&composition_coefficients.boundary,
);

let lagrange_constraints_evaluator = if air.context().logup_gkr_enabled() {
let logup_gkr_constraints_evaluator = if air.context().logup_gkr_enabled() {
let aux_rand_elements =
aux_rand_elements.as_ref().expect("expected aux rand elements to be present");
let lagrange_rand_elements = aux_rand_elements
.lagrange()
.expect("expected lagrange rand elements to be present");
Some(LagrangeKernelConstraintsBatchEvaluator::new(

Some(LogUpGkrConstraintsEvaluator::new(
air,
lagrange_rand_elements.clone(),
aux_rand_elements
.gkr_data()
.expect("expected LogUp-GKR randomness to be present"),
composition_coefficients
.lagrange
.expect("expected Lagrange kernel composition coefficients to be present"),
composition_coefficients
.s_col
.expect("expected s-column composition coefficient to be present"),
))
} else {
None
Expand All @@ -179,7 +182,7 @@ where
air,
boundary_constraints,
transition_constraints,
lagrange_constraints_evaluator,
logup_gkr_constraints_evaluator,
aux_rand_elements,
periodic_values,
}
Expand Down Expand Up @@ -295,22 +298,22 @@ where
}
}

/// If present, evaluates the Lagrange kernel constraints over the constraint evaluation domain.
/// If present, evaluates the LogUp-GKR constraints over the constraint evaluation domain.
/// The evaluation of each constraint (both boundary and transition) is divided by its divisor,
/// multiplied by its composition coefficient, the result of which is added to
/// `combined_evaluations_accumulator`.
///
/// Specifically, `combined_evaluations_accumulator` is a buffer whose length is the size of the
/// constraint evaluation domain, where each index contains combined evaluations of other
/// constraints in the system.
fn evaluate_lagrange_kernel_constraints<T: TraceLde<E>>(
fn evaluate_logup_gkr_constraints<T: TraceLde<E>>(
&self,
trace: &T,
domain: &StarkDomain<A::BaseField>,
combined_evaluations_accumulator: &mut [E],
) {
if let Some(ref lagrange_constraints_evaluator) = self.lagrange_constraints_evaluator {
lagrange_constraints_evaluator.evaluate_constraints(
if let Some(ref logup_gkr_constraints_evaluator) = self.logup_gkr_constraints_evaluator {
logup_gkr_constraints_evaluator.evaluate_constraints(
trace,
domain,
combined_evaluations_accumulator,
Expand Down
Loading
Loading