Skip to content

Commit

Permalink
perf(test): use minimal size for quotient domain
Browse files Browse the repository at this point in the history
Previously, the quotient domain was artificially enlarged to pinpoint
the exact AIR constraint in case of a proving failure. However, since
then a lot more tests evaluating the constraints directly have been put
in place. They are simpler to use and don't change the critical code
path – i.e., proving – between test and release builds. Therefore,
remove the quotient domain enlarging.
  • Loading branch information
jan-ferdinand committed Apr 8, 2024
1 parent 71bec0a commit 727ff8e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 13 deletions.
3 changes: 2 additions & 1 deletion triton-vm/src/arithmetic_domain.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use std::ops::MulAssign;

use num_traits::One;
use rayon::prelude::*;
use twenty_first::prelude::*;
use twenty_first::shared_math::traits::FiniteField;
use twenty_first::shared_math::traits::PrimitiveRootOfUnity;
Expand Down Expand Up @@ -66,7 +67,7 @@ impl ArithmeticDomain {
FF: FiniteField + MulAssign<BFieldElement> + From<BFieldElement>,
{
self.domain_values()
.iter()
.par_iter()
.map(|&v| polynomial.evaluate(&v.into()))
.collect()
}
Expand Down
14 changes: 2 additions & 12 deletions triton-vm/src/stark.rs
Original file line number Diff line number Diff line change
Expand Up @@ -522,22 +522,12 @@ impl Stark {
/// polynomials. Concretely, the maximal degree of a polynomial over the quotient domain is at
/// most only slightly larger than the maximal degree allowed in the STARK proof, and could be
/// equal. This makes computation for the prover much faster.
///
/// When debugging, it is useful to check the degree of some intermediate polynomials.
/// However, the quotient domain's minimal length can make it impossible to check if some
/// operation (e.g., dividing out the zerofier) has (erroneously) increased the polynomial's
/// degree beyond the allowed maximum. Hence, a larger quotient domain is chosen when debugging
/// and testing.
pub(crate) fn quotient_domain(
fri_domain: ArithmeticDomain,
max_degree: Degree,
) -> Result<ArithmeticDomain, ProvingError> {
let maybe_blowup_factor = match cfg!(debug_assertions) {
true => 2,
false => 1,
};
let domain_length = (max_degree as u64).next_power_of_two() as usize;
let domain_length = maybe_blowup_factor * domain_length;
let max_degree = usize::try_from(max_degree).expect("AIR should constrain the VM");
let domain_length = max_degree.next_power_of_two();
Ok(ArithmeticDomain::of_length(domain_length)?.with_offset(fri_domain.offset))
}

Expand Down

0 comments on commit 727ff8e

Please sign in to comment.