Skip to content

Commit

Permalink
Remove wide fibonacci boundary constraint.
Browse files Browse the repository at this point in the history
  • Loading branch information
alonh5 committed Apr 18, 2024
1 parent 7f66643 commit 4f423a6
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 21 deletions.
12 changes: 2 additions & 10 deletions crates/prover/src/examples/wide_fibonacci/avx.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use itertools::Itertools;
use num_traits::{One, Zero};
use num_traits::One;
use tracing::{span, Level};

use super::component::{WideFibAir, WideFibComponent};
Expand Down Expand Up @@ -96,14 +96,7 @@ impl Component<AVX512Backend> for WideFibComponent {
for vec_row in 0..(1 << (eval_domain.log_size() - VECS_LOG_SIZE as u32)) {
// Numerator.
let a = trace_eval[0].data[vec_row];
let mut row_res =
PackedSecureField::from_packed_m31s([
a - PackedBaseField::one(),
PackedBaseField::zero(),
PackedBaseField::zero(),
PackedBaseField::zero(),
]) * PackedSecureField::broadcast(accum.random_coeff_powers[self.n_columns() - 2]);

let mut row_res = PackedSecureField::zero();
let mut a_sq = a.square();
let mut b_sq = trace_eval[1].data[vec_row].square();
#[allow(clippy::needless_range_loop)]
Expand Down Expand Up @@ -139,7 +132,6 @@ impl Component<AVX512Backend> for WideFibComponent {
) {
let zero_domain = CanonicCoset::new(self.log_column_size()).coset;
let denominator = coset_vanishing(zero_domain, point);
evaluation_accumulator.accumulate((mask[0][0] - SecureField::one()) / denominator);
for i in 0..(self.n_columns() - 2) {
let numerator = mask[i][0].square() + mask[i + 1][0].square() - mask[i + 2][0];
evaluation_accumulator.accumulate(numerator / denominator);
Expand Down
9 changes: 1 addition & 8 deletions crates/prover/src/examples/wide_fibonacci/constraint_eval.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use num_traits::{One, Zero};
use num_traits::Zero;

use super::component::WideFibComponent;
use crate::core::air::accumulation::{DomainEvaluationAccumulator, PointEvaluationAccumulator};
Expand Down Expand Up @@ -58,10 +58,6 @@ impl Component<CPUBackend> for WideFibComponent {

#[allow(clippy::needless_range_loop)]
for i in 0..trace_eval_domain.size() {
// Boundary constraint.
numerators[i] += accum.random_coeff_powers[self.n_columns() - 2]
* (trace_evals[0].values.at(i) - BaseField::one());

// Step constraints.
for j in 0..self.n_columns() - 2 {
numerators[i] += accum.random_coeff_powers[self.n_columns() - 3 - j]
Expand All @@ -84,9 +80,6 @@ impl Component<CPUBackend> for WideFibComponent {
let constraint_zero_domain = CanonicCoset::new(self.log_column_size()).coset;
let denom = coset_vanishing(constraint_zero_domain, point);
let denom_inverse = denom.inverse();
let numerator = mask[0][0] - BaseField::one();
evaluation_accumulator.accumulate(numerator * denom_inverse);

for i in 0..self.n_columns() - 2 {
let numerator = mask[i][0].square() + mask[i + 1][0].square() - mask[i + 2][0];
evaluation_accumulator.accumulate(numerator * denom_inverse);
Expand Down
6 changes: 3 additions & 3 deletions crates/prover/src/examples/wide_fibonacci/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,14 +158,14 @@ mod tests {
}

#[test_log::test]
fn test_prove() {
fn test_single_instance_wide_fib_prove() {
// Note: To see time measurement, run test with
// RUST_LOG_SPAN_EVENTS=enter,close RUST_LOG=info RUST_BACKTRACE=1 cargo test
// test_prove -- --nocapture

const LOG_N_INSTANCES: u32 = 3;
const LOG_N_INSTANCES: u32 = 0;
let component = WideFibComponent {
log_fibonacci_size: LOG_N_COLUMNS as u32,
log_fibonacci_size: 3 + LOG_N_COLUMNS as u32,
log_n_instances: LOG_N_INSTANCES,
};
let private_input = (0..(1 << LOG_N_INSTANCES))
Expand Down

0 comments on commit 4f423a6

Please sign in to comment.