Skip to content

Commit

Permalink
Batch inverse lookup column denominators.
Browse files Browse the repository at this point in the history
  • Loading branch information
alonh5 committed Jun 25, 2024
1 parent 6cf38e5 commit f30431b
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 14 deletions.
2 changes: 0 additions & 2 deletions crates/prover/src/core/queries.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ use super::circle::Coset;
use super::poly::circle::CircleDomain;
use super::utils::bit_reverse_index;

// TODO(AlonH): Move file to fri directory.

pub const UPPER_BOUND_QUERY_BYTES: usize = 4;

/// An ordered set of query indices over a bit reversed [CircleDomain].
Expand Down
1 change: 0 additions & 1 deletion crates/prover/src/examples/fibonacci/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ impl Fibonacci {
pub fn get_trace(&self) -> CpuCircleEvaluation<BaseField, BitReversedOrder> {
// Trace.
let trace_domain = CanonicCoset::new(self.air.component.log_size);
// TODO(AlonH): Consider using Vec::new instead of Vec::with_capacity throughout file.
let mut trace = Vec::with_capacity(trace_domain.size());

// Fill trace with fibonacci squared.
Expand Down
1 change: 0 additions & 1 deletion crates/prover/src/examples/wide_fibonacci/simd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,6 @@ pub fn gen_trace(
.collect_vec()
}

// TODO(AlonH): Implement.
impl ComponentTraceWriter<SimdBackend> for SimdWideFibComponent {
fn write_interaction_trace(
&self,
Expand Down
26 changes: 16 additions & 10 deletions crates/prover/src/examples/wide_fibonacci/trace_gen.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use itertools::Itertools;
use num_traits::One;
use num_traits::{One, Zero};

use super::component::Input;
use crate::core::fields::m31::BaseField;
Expand Down Expand Up @@ -49,23 +49,29 @@ pub fn write_lookup_column(
})
.collect_vec();

(0..n_rows)
let denominators = (0..n_rows)
.map(|i| {
let numerator = shifted_secure_combination(
&[natural_ordered_trace[0][i], natural_ordered_trace[1][i]],
alpha,
z,
);
let denominator = shifted_secure_combination(
shifted_secure_combination(
&[
natural_ordered_trace[n_columns - 2][i],
natural_ordered_trace[n_columns - 1][i],
],
alpha,
z,
)
})
.collect_vec();
let mut denominator_inverses = vec![SecureField::zero(); denominators.len()];
SecureField::batch_inverse(&denominators, &mut denominator_inverses);

(0..n_rows)
.map(|i| {
let numerator = shifted_secure_combination(
&[natural_ordered_trace[0][i], natural_ordered_trace[1][i]],
alpha,
z,
);
// TODO(AlonH): Use batch inversion.
let cell = (numerator / denominator) * prev_value;
let cell = (numerator * denominator_inverses[i]) * prev_value;
prev_value = cell;
cell
})
Expand Down

0 comments on commit f30431b

Please sign in to comment.