mirror of
https://github.com/logos-storage/plonky2.git
synced 2026-01-08 16:53:07 +00:00
Use max filtered degree found with the tree method in CircuitBuilder::build
This commit is contained in:
parent
493e81d786
commit
bae3777bcd
@ -300,14 +300,7 @@ impl<F: Extendable<D>, const D: usize> CircuitBuilder<F, D> {
|
|||||||
let degree_bits = log2_strict(degree);
|
let degree_bits = log2_strict(degree);
|
||||||
let subgroup = F::two_adic_subgroup(degree_bits);
|
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 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 k_is = get_unique_coset_shifts(degree, self.config.num_routed_wires);
|
||||||
let sigma_vecs = self.sigma_vecs(&k_is, &subgroup);
|
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,
|
config: self.config,
|
||||||
degree_bits,
|
degree_bits,
|
||||||
gates: prefixed_gates,
|
gates: prefixed_gates,
|
||||||
max_filtered_constraint_degree_bits: 3, // TODO: compute this correctly once filters land.
|
max_filtered_constraint_degree,
|
||||||
num_gate_constraints,
|
num_gate_constraints,
|
||||||
num_constants,
|
num_constants,
|
||||||
k_is,
|
k_is,
|
||||||
|
|||||||
@ -146,7 +146,7 @@ pub struct CommonCircuitData<F: Extendable<D>, const D: usize> {
|
|||||||
pub(crate) gates: Vec<PrefixedGate<F, D>>,
|
pub(crate) gates: Vec<PrefixedGate<F, D>>,
|
||||||
|
|
||||||
/// The maximum degree of a filter times a constraint by any gate.
|
/// 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.
|
/// The largest number of constraints imposed by any gate.
|
||||||
pub(crate) num_gate_constraints: usize,
|
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 {
|
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 {
|
pub fn total_constraints(&self) -> usize {
|
||||||
|
|||||||
@ -88,7 +88,7 @@ impl<F: Extendable<D>, const D: usize> Tree<GateRef<F, D>> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
info!(
|
info!(
|
||||||
"Found tree with max degree {} and {} constants in {}s.",
|
"Found tree with max degree {} and {} constants wires in {}s.",
|
||||||
best_degree,
|
best_degree,
|
||||||
best_num_constants,
|
best_num_constants,
|
||||||
timer.elapsed().as_secs_f32()
|
timer.elapsed().as_secs_f32()
|
||||||
|
|||||||
@ -327,7 +327,7 @@ mod tests {
|
|||||||
},
|
},
|
||||||
degree_bits: 0,
|
degree_bits: 0,
|
||||||
gates: vec![],
|
gates: vec![],
|
||||||
max_filtered_constraint_degree_bits: 0,
|
max_filtered_constraint_degree: 0,
|
||||||
num_gate_constraints: 0,
|
num_gate_constraints: 0,
|
||||||
num_constants: 4,
|
num_constants: 4,
|
||||||
k_is: vec![F::ONE; 6],
|
k_is: vec![F::ONE; 6],
|
||||||
|
|||||||
@ -12,7 +12,7 @@ use crate::polynomial::commitment::ListPolynomialCommitment;
|
|||||||
use crate::polynomial::polynomial::{PolynomialCoeffs, PolynomialValues};
|
use crate::polynomial::polynomial::{PolynomialCoeffs, PolynomialValues};
|
||||||
use crate::proof::Proof;
|
use crate::proof::Proof;
|
||||||
use crate::timed;
|
use crate::timed;
|
||||||
use crate::util::transpose;
|
use crate::util::{log2_ceil, transpose};
|
||||||
use crate::vars::EvaluationVarsBase;
|
use crate::vars::EvaluationVarsBase;
|
||||||
use crate::witness::{PartialWitness, Witness};
|
use crate::witness::{PartialWitness, Witness};
|
||||||
|
|
||||||
@ -219,23 +219,22 @@ fn compute_quotient_polys<'a, F: Extendable<D>, const D: usize>(
|
|||||||
alphas: &[F],
|
alphas: &[F],
|
||||||
) -> Vec<PolynomialCoeffs<F>> {
|
) -> Vec<PolynomialCoeffs<F>> {
|
||||||
let num_challenges = common_data.config.num_challenges;
|
let num_challenges = common_data.config.num_challenges;
|
||||||
|
let max_filtered_constraint_degree_bits = log2_ceil(common_data.max_filtered_constraint_degree);
|
||||||
assert!(
|
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. \
|
"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."
|
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
|
// We reuse the LDE computed in `ListPolynomialCommitment` and extract every `step` points to get
|
||||||
// an LDE matching `max_filtered_constraint_degree`.
|
// an LDE matching `max_filtered_constraint_degree`.
|
||||||
let step =
|
let step = 1 << (common_data.config.rate_bits - max_filtered_constraint_degree_bits);
|
||||||
1 << (common_data.config.rate_bits - common_data.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`
|
// 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`.
|
// 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(
|
let points =
|
||||||
common_data.degree_bits + common_data.max_filtered_constraint_degree_bits,
|
F::two_adic_subgroup(common_data.degree_bits + max_filtered_constraint_degree_bits);
|
||||||
);
|
|
||||||
let lde_size = points.len();
|
let lde_size = points.len();
|
||||||
|
|
||||||
// Retrieve the LDE values at index `i`.
|
// 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)
|
comm.get_lde_values(i * step)
|
||||||
};
|
};
|
||||||
|
|
||||||
let z_h_on_coset = ZeroPolyOnCoset::new(
|
let z_h_on_coset =
|
||||||
common_data.degree_bits,
|
ZeroPolyOnCoset::new(common_data.degree_bits, max_filtered_constraint_degree_bits);
|
||||||
common_data.max_filtered_constraint_degree_bits,
|
|
||||||
);
|
|
||||||
|
|
||||||
let quotient_values: Vec<Vec<F>> = points
|
let quotient_values: Vec<Vec<F>> = points
|
||||||
.into_par_iter()
|
.into_par_iter()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user