Use max filtered degree found with the tree method in CircuitBuilder::build

This commit is contained in:
wborgeaud 2021-06-29 14:00:34 +02:00
parent 493e81d786
commit bae3777bcd
5 changed files with 14 additions and 24 deletions

View File

@ -300,14 +300,7 @@ impl<F: Extendable<D>, const D: usize> CircuitBuilder<F, D> {
let degree_bits = log2_strict(degree);
let subgroup = F::two_adic_subgroup(degree_bits);
let constant_vecs = self.constant_polys(&prefixed_gates);
let num_constants = constant_vecs.len();
let constant_vecs = self.constant_polys(&prefixed_gates, num_constants);
let constants_commitment = ListPolynomialCommitment::new(
constant_vecs.into_iter().map(|v| v.ifft()).collect(),
self.config.fri_config.rate_bits,
false,
);
let k_is = get_unique_coset_shifts(degree, self.config.num_routed_wires);
let sigma_vecs = self.sigma_vecs(&k_is, &subgroup);
@ -355,7 +348,7 @@ impl<F: Extendable<D>, const D: usize> CircuitBuilder<F, D> {
config: self.config,
degree_bits,
gates: prefixed_gates,
max_filtered_constraint_degree_bits: 3, // TODO: compute this correctly once filters land.
max_filtered_constraint_degree,
num_gate_constraints,
num_constants,
k_is,

View File

@ -146,7 +146,7 @@ pub struct CommonCircuitData<F: Extendable<D>, const D: usize> {
pub(crate) gates: Vec<PrefixedGate<F, D>>,
/// The maximum degree of a filter times a constraint by any gate.
pub(crate) max_filtered_constraint_degree_bits: usize,
pub(crate) max_filtered_constraint_degree: usize,
/// The largest number of constraints imposed by any gate.
pub(crate) num_gate_constraints: usize,
@ -184,7 +184,7 @@ impl<F: Extendable<D>, const D: usize> CommonCircuitData<F, D> {
}
pub fn quotient_degree(&self) -> usize {
((1 << self.max_filtered_constraint_degree_bits) - 1) * self.degree()
(self.max_filtered_constraint_degree - 1) * self.degree()
}
pub fn total_constraints(&self) -> usize {

View File

@ -88,7 +88,7 @@ impl<F: Extendable<D>, const D: usize> Tree<GateRef<F, D>> {
}
}
info!(
"Found tree with max degree {} and {} constants in {}s.",
"Found tree with max degree {} and {} constants wires in {}s.",
best_degree,
best_num_constants,
timer.elapsed().as_secs_f32()

View File

@ -327,7 +327,7 @@ mod tests {
},
degree_bits: 0,
gates: vec![],
max_filtered_constraint_degree_bits: 0,
max_filtered_constraint_degree: 0,
num_gate_constraints: 0,
num_constants: 4,
k_is: vec![F::ONE; 6],

View File

@ -12,7 +12,7 @@ use crate::polynomial::commitment::ListPolynomialCommitment;
use crate::polynomial::polynomial::{PolynomialCoeffs, PolynomialValues};
use crate::proof::Proof;
use crate::timed;
use crate::util::transpose;
use crate::util::{log2_ceil, transpose};
use crate::vars::EvaluationVarsBase;
use crate::witness::{PartialWitness, Witness};
@ -219,23 +219,22 @@ fn compute_quotient_polys<'a, F: Extendable<D>, const D: usize>(
alphas: &[F],
) -> Vec<PolynomialCoeffs<F>> {
let num_challenges = common_data.config.num_challenges;
let max_filtered_constraint_degree_bits = log2_ceil(common_data.max_filtered_constraint_degree);
assert!(
common_data.max_filtered_constraint_degree_bits <= common_data.config.rate_bits,
max_filtered_constraint_degree_bits <= common_data.config.rate_bits,
"Having constraints of degree higher than the rate is not supported yet. \
If we need this in the future, we can precompute the larger LDE before computing the `ListPolynomialCommitment`s."
);
// We reuse the LDE computed in `ListPolynomialCommitment` and extract every `step` points to get
// an LDE matching `max_filtered_constraint_degree`.
let step =
1 << (common_data.config.rate_bits - common_data.max_filtered_constraint_degree_bits);
let step = 1 << (common_data.config.rate_bits - max_filtered_constraint_degree_bits);
// When opening the `Z`s polys at the "next" point in Plonk, need to look at the point `next_step`
// steps away since we work on an LDE of degree `max_filtered_constraint_degree`.
let next_step = 1 << common_data.max_filtered_constraint_degree_bits;
let next_step = 1 << max_filtered_constraint_degree_bits;
let points = F::two_adic_subgroup(
common_data.degree_bits + common_data.max_filtered_constraint_degree_bits,
);
let points =
F::two_adic_subgroup(common_data.degree_bits + max_filtered_constraint_degree_bits);
let lde_size = points.len();
// Retrieve the LDE values at index `i`.
@ -243,10 +242,8 @@ fn compute_quotient_polys<'a, F: Extendable<D>, const D: usize>(
comm.get_lde_values(i * step)
};
let z_h_on_coset = ZeroPolyOnCoset::new(
common_data.degree_bits,
common_data.max_filtered_constraint_degree_bits,
);
let z_h_on_coset =
ZeroPolyOnCoset::new(common_data.degree_bits, max_filtered_constraint_degree_bits);
let quotient_values: Vec<Vec<F>> = points
.into_par_iter()