Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use parallel batch inverse in logup #987

Merged
merged 1 commit into from
Jan 29, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 4 additions & 8 deletions crates/prover/src/constraint_framework/logup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ use crate::core::backend::simd::qm31::PackedSecureField;
use crate::core::backend::simd::SimdBackend;
use crate::core::backend::Column;
use crate::core::channel::Channel;
use crate::core::fields::batch_inverse_in_place;
use crate::core::fields::m31::BaseField;
use crate::core::fields::qm31::SecureField;
use crate::core::fields::secure_column::SecureColumnByCoords;
use crate::core::fields::FieldExpOps;
use crate::core::lookups::utils::Fraction;
use crate::core::poly::circle::{CanonicCoset, CircleEvaluation};
use crate::core::poly::BitReversedOrder;
Expand Down Expand Up @@ -124,19 +124,15 @@ pub struct LogupTraceGenerator {
trace: Vec<SecureColumnByCoords<SimdBackend>>,
/// Denominator expressions (z + sum_i alpha^i * x_i) being generated for the current lookup.
denom: SecureColumn,
/// Preallocated buffer for the Inverses of the denominators.
denom_inv: SecureColumn,
}
impl LogupTraceGenerator {
pub fn new(log_size: u32) -> Self {
let trace = vec![];
let denom = SecureColumn::zeros(1 << log_size);
let denom_inv = SecureColumn::zeros(1 << log_size);
Self {
log_size,
trace,
denom,
denom_inv,
}
}

Expand Down Expand Up @@ -221,12 +217,12 @@ impl LogupColGenerator<'_> {

/// Finalizes generating the column.
pub fn finalize_col(mut self) {
batch_inverse_in_place(&self.gen.denom.data, &mut self.gen.denom_inv.data);
let denom_inv = PackedSecureField::batch_inverse(&self.gen.denom.data);

#[allow(clippy::needless_range_loop)]
for vec_row in 0..(1 << (self.gen.log_size - LOG_N_LANES)) {
unsafe {
let value = self.numerator.packed_at(vec_row)
* *self.gen.denom_inv.data.get_unchecked(vec_row);
let value = self.numerator.packed_at(vec_row) * denom_inv[vec_row];
let prev_value = self
.gen
.trace
Comment on lines 224 to 228
Copy link

@semgrep-code-starkware-libs semgrep-code-starkware-libs bot Jan 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Detected 'unsafe' usage, please audit for secure usage

Ignore this finding from unsafe-usage.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/ar .

Expand Down
Loading