From e13ef15bbbdfc8a02c24623645f00efa60e8f848 Mon Sep 17 00:00:00 2001 From: Mihai Date: Tue, 10 Dec 2024 09:42:07 +0200 Subject: [PATCH] slight clean-up --- ceno_zkvm/src/instructions.rs | 1 - ceno_zkvm/src/tables/ops/ops_impl.rs | 2 -- ceno_zkvm/src/tables/program.rs | 4 ---- ceno_zkvm/src/tables/ram/ram_impl.rs | 2 -- ceno_zkvm/src/tables/range/range_impl.rs | 2 -- ceno_zkvm/src/witness.rs | 15 ++++++--------- 6 files changed, 6 insertions(+), 20 deletions(-) diff --git a/ceno_zkvm/src/instructions.rs b/ceno_zkvm/src/instructions.rs index 7174318ea..bb3109d82 100644 --- a/ceno_zkvm/src/instructions.rs +++ b/ceno_zkvm/src/instructions.rs @@ -53,7 +53,6 @@ pub trait Instruction { } .max(1); let lk_multiplicity = LkMultiplicity::default(); - // dbg!(steps.len(), num_witin); let mut raw_witin = RowMajorMatrix::::new(steps.len(), num_witin, Self::padding_strategy()); let raw_witin_iter = raw_witin.par_batch_iter_mut(num_instance_per_batch); diff --git a/ceno_zkvm/src/tables/ops/ops_impl.rs b/ceno_zkvm/src/tables/ops/ops_impl.rs index 54bc3f4f7..4c34c5fec 100644 --- a/ceno_zkvm/src/tables/ops/ops_impl.rs +++ b/ceno_zkvm/src/tables/ops/ops_impl.rs @@ -48,7 +48,6 @@ impl OpTableConfig { num_fixed: usize, content: Vec<[u64; 3]>, ) -> RowMajorMatrix { - //dbg!(content.len(), num_fixed); let mut fixed = RowMajorMatrix::::new(content.len(), num_fixed, InstancePaddingStrategy::Zero); @@ -71,7 +70,6 @@ impl OpTableConfig { multiplicity: &HashMap, length: usize, ) -> Result, ZKVMError> { - //dbg!(length, num_witin); let mut witness = RowMajorMatrix::::new(length, num_witin, InstancePaddingStrategy::Zero); diff --git a/ceno_zkvm/src/tables/program.rs b/ceno_zkvm/src/tables/program.rs index 288f27548..2ff4dd5d5 100644 --- a/ceno_zkvm/src/tables/program.rs +++ b/ceno_zkvm/src/tables/program.rs @@ -159,7 +159,6 @@ impl TableCircuit for ProgramTableCircuit { let pc_base = program.base_address; assert!(num_instructions <= config.program_size); - // dbg!(config.program_size, num_fixed); let mut fixed = RowMajorMatrix::::new( config.program_size, num_fixed, @@ -181,7 +180,6 @@ impl TableCircuit for ProgramTableCircuit { } }); - // Self::padding_zero(&mut fixed, num_fixed).expect("padding error"); fixed } @@ -199,7 +197,6 @@ impl TableCircuit for ProgramTableCircuit { prog_mlt[i] = *mlt; } - // dbg!(config.program_size, num_witin); let mut witness = RowMajorMatrix::::new( config.program_size, num_witin, @@ -213,7 +210,6 @@ impl TableCircuit for ProgramTableCircuit { set_val!(row, config.mlt, E::BaseField::from(mlt as u64)); }); - // Self::padding_zero(&mut witness, num_witin).expect("padding error"); Ok(witness) } } diff --git a/ceno_zkvm/src/tables/ram/ram_impl.rs b/ceno_zkvm/src/tables/ram/ram_impl.rs index 616b933ba..b824c2646 100644 --- a/ceno_zkvm/src/tables/ram/ram_impl.rs +++ b/ceno_zkvm/src/tables/ram/ram_impl.rs @@ -119,7 +119,6 @@ impl NonVolatileTableConfig::new( NVRAM::len(&self.params), num_fixed, @@ -389,7 +388,6 @@ impl DynVolatileRamTableConfig ) -> Result, ZKVMError> { assert!(final_mem.len() <= DVRAM::max_len(&self.params)); assert!(DVRAM::max_len(&self.params).is_power_of_two()); - //dbg!(final_mem.len(), num_witness); let mut final_table = RowMajorMatrix::::new(final_mem.len(), num_witness, InstancePaddingStrategy::Zero); diff --git a/ceno_zkvm/src/tables/range/range_impl.rs b/ceno_zkvm/src/tables/range/range_impl.rs index e9637e4bc..11191e22f 100644 --- a/ceno_zkvm/src/tables/range/range_impl.rs +++ b/ceno_zkvm/src/tables/range/range_impl.rs @@ -43,7 +43,6 @@ impl RangeTableConfig { num_fixed: usize, content: Vec, ) -> RowMajorMatrix { - //dbg!(content.len(), num_fixed); let mut fixed = RowMajorMatrix::::new(content.len(), num_fixed, InstancePaddingStrategy::Zero); @@ -64,7 +63,6 @@ impl RangeTableConfig { multiplicity: &HashMap, length: usize, ) -> Result, ZKVMError> { - //dbg!(length, num_witin); let mut witness = RowMajorMatrix::::new(length, num_witin, InstancePaddingStrategy::Zero); diff --git a/ceno_zkvm/src/witness.rs b/ceno_zkvm/src/witness.rs index 94e9cda6b..6185b318b 100644 --- a/ceno_zkvm/src/witness.rs +++ b/ceno_zkvm/src/witness.rs @@ -1,5 +1,4 @@ use ff::Field; -use itertools::Itertools; use std::{ array, cell::RefCell, @@ -13,7 +12,7 @@ use std::{ use multilinear_extensions::mle::{DenseMultilinearExtension, IntoMLE}; use rayon::{ - iter::{IntoParallelIterator, IntoParallelRefIterator, ParallelIterator}, + iter::{IntoParallelIterator, ParallelIterator}, slice::ParallelSliceMut, }; use thread_local::ThreadLocal; @@ -49,7 +48,6 @@ pub struct RowMajorMatrix { impl RowMajorMatrix { pub fn new(num_rows: usize, num_col: usize, padding_strategy: InstancePaddingStrategy) -> Self { - // assert!(false); RowMajorMatrix { values: (0..num_rows * num_col) .into_par_iter() @@ -90,23 +88,22 @@ impl RowMajorMatrix { self, ) -> Vec> { let padding_row = match self.padding_strategy { - // If asked to repeat and actually have content to repeat + // Repeat last row if it exists InstancePaddingStrategy::RepeatLast if !self.values.is_empty() => { self.values[self.values.len() - self.num_col..].to_vec() } - // Otherwise zeros + // Otherwise use zeroes _ => vec![F::ZERO; self.num_col], }; let num_padding = self.num_padding_instances(); let result = (0..self.num_col) - .collect_vec() - .par_iter() + .into_par_iter() .map(|i| { self.values .iter() - .skip(*i) + .skip(i) .step_by(self.num_col) - .chain(&mut iter::repeat(&padding_row[*i]).take(num_padding)) + .chain(&mut iter::repeat(&padding_row[i]).take(num_padding)) .copied() .collect::>() .into_mle()