Skip to content

Commit

Permalink
relation tracker preprocessed bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
ohad-starkware committed Jan 29, 2025
1 parent 6ab8bf1 commit 4178749
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 3 deletions.
2 changes: 1 addition & 1 deletion crates/prover/src/constraint_framework/component.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ pub struct TraceLocationAllocator {
/// Mapping of tree index to next available column offset.
next_tree_offsets: TreeVec<usize>,
/// Mapping of preprocessed columns to their index.
preprocessed_columns: Vec<PreProcessedColumnId>,
pub(super) preprocessed_columns: Vec<PreProcessedColumnId>,
/// Controls whether the preprocessed columns are dynamic or static (default=Dynamic).
preprocessed_columns_allocation_mode: PreprocessedColumnsAllocationMode,
}
Expand Down
26 changes: 24 additions & 2 deletions crates/prover/src/constraint_framework/relation_tracker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use num_traits::Zero;

use super::{
Batching, EvalAtRow, FrameworkEval, InfoEvaluator, Relation, RelationEntry,
TraceLocationAllocator, INTERACTION_TRACE_IDX,
TraceLocationAllocator, INTERACTION_TRACE_IDX, PREPROCESSED_TRACE_IDX,
};
use crate::core::backend::simd::m31::{PackedBaseField, LOG_N_LANES, N_LANES};
use crate::core::backend::simd::qm31::PackedSecureField;
Expand Down Expand Up @@ -34,6 +34,7 @@ pub struct RelationTrackerEntry {
pub struct RelationTrackerComponent<E: FrameworkEval> {
eval: E,
trace_locations: TreeVec<TreeSubspan>,
preprocessed_column_indices: Vec<usize>,
n_rows: usize,
}
impl<E: FrameworkEval> RelationTrackerComponent<E> {
Expand All @@ -44,11 +45,27 @@ impl<E: FrameworkEval> RelationTrackerComponent<E> {
SecureField::default(),
));
let mut mask_offsets = info.mask_offsets;
let preprocessed_column_indices = info
.preprocessed_columns
.iter()
.map(|col| {
if let Some(pos) = location_allocator
.preprocessed_columns
.iter()
.position(|x| x.id == col.id)
{
pos
} else {
panic!()
}
})
.collect();
mask_offsets.drain(INTERACTION_TRACE_IDX..);
let trace_locations = location_allocator.next_for_structure(&mask_offsets);
Self {
eval,
trace_locations,
preprocessed_column_indices,
n_rows,
}
}
Expand All @@ -60,9 +77,14 @@ impl<E: FrameworkEval> RelationTrackerComponent<E> {
let log_size = self.eval.log_size();

// Deref the sub-tree. Only copies the references.
let sub_tree = trace
let mut sub_tree = trace
.sub_tree(&self.trace_locations)
.map(|vec| vec.into_iter().copied().collect_vec());
sub_tree[PREPROCESSED_TRACE_IDX] = self
.preprocessed_column_indices
.iter()
.map(|idx| trace[PREPROCESSED_TRACE_IDX][*idx])
.collect();
let mut entries = vec![];

for vec_row in 0..(1 << (log_size - LOG_N_LANES)) {
Expand Down

0 comments on commit 4178749

Please sign in to comment.