diff --git a/ceno_zkvm/src/instructions/riscv/blt.rs b/ceno_zkvm/src/instructions/riscv/blt.rs index da077023b..30f4cc333 100644 --- a/ceno_zkvm/src/instructions/riscv/blt.rs +++ b/ceno_zkvm/src/instructions/riscv/blt.rs @@ -60,6 +60,7 @@ impl BltInput { &self, config: &InstructionConfig, instance: &mut [MaybeUninit], + lk_multiplicity: &mut LkMultiplicity, ) { assert!(!self.lhs_limb8.is_empty() && (self.lhs_limb8.len() == self.rhs_limb8.len())); // TODO: add boundary check for witin @@ -108,12 +109,12 @@ impl BltInput { lhs: self.prev_rs1_ts as u64, rhs: self.ts as u64, } - .assign(instance, &config.lt_rs1_cfg); + .assign(instance, &config.lt_rs1_cfg, lk_multiplicity); ExprLtInput { lhs: self.prev_rs2_ts as u64, rhs: (self.ts + 1) as u64, } - .assign(instance, &config.lt_rs2_cfg); + .assign(instance, &config.lt_rs2_cfg, lk_multiplicity); } pub fn random() -> Self { @@ -223,12 +224,12 @@ impl Instruction for BltInstruction { fn assign_instance( config: &Self::InstructionConfig, instance: &mut [std::mem::MaybeUninit], - _lk_multiplicity: &mut LkMultiplicity, + lk_multiplicity: &mut LkMultiplicity, _step: &ceno_emul::StepRecord, ) -> Result<(), ZKVMError> { // take input from _step let input = BltInput::random(); - input.assign(config, instance); + input.assign(config, instance, lk_multiplicity); Ok(()) } } diff --git a/ceno_zkvm/src/scheme/mock_prover.rs b/ceno_zkvm/src/scheme/mock_prover.rs index 3b9a8afcc..55386ce8f 100644 --- a/ceno_zkvm/src/scheme/mock_prover.rs +++ b/ceno_zkvm/src/scheme/mock_prover.rs @@ -487,12 +487,11 @@ mod tests { expression::{ToExpr, WitIn}, instructions::riscv::config::{ExprLtConfig, ExprLtInput}, set_val, - witness::RowMajorMatrix, + witness::{LkMultiplicity, RowMajorMatrix}, }; use ff::Field; use goldilocks::{Goldilocks, GoldilocksExt2}; use multilinear_extensions::mle::{IntoMLE, IntoMLEs}; - use rayon::iter::{IndexedParallelIterator, IntoParallelIterator, ParallelIterator}; #[derive(Debug)] #[allow(dead_code)] @@ -649,6 +648,7 @@ mod tests { &self, instance: &mut [MaybeUninit], input: AssertLtCircuitInput, + lk_multiplicity: &mut LkMultiplicity, ) -> Result<(), ZKVMError> { set_val!(instance, self.a, input.a); set_val!(instance, self.b, input.b); @@ -656,7 +656,7 @@ mod tests { lhs: input.a, rhs: input.b, } - .assign(instance, &self.lt_wtns); + .assign(instance, &self.lt_wtns, lk_multiplicity); Ok(()) } @@ -665,14 +665,16 @@ mod tests { &self, num_witin: usize, instances: Vec, + lk_multiplicity: &mut LkMultiplicity, ) -> Result, ZKVMError> { let mut raw_witin = RowMajorMatrix::::new(instances.len(), num_witin); - let raw_witin_iter = raw_witin.par_iter_mut(); + let raw_witin_iter = raw_witin.iter_mut(); raw_witin_iter - .zip_eq(instances.into_par_iter()) - .map(|(instance, input)| self.assign_instance::(instance, input)) - .collect::>()?; + .zip_eq(instances.into_iter()) + .try_for_each(|(instance, input)| { + self.assign_instance::(instance, input, lk_multiplicity) + })?; Ok(raw_witin) } @@ -685,6 +687,7 @@ mod tests { let circuit = AssertLtCircuit::construct_circuit(&mut builder).unwrap(); + let mut lk_multiplicity = LkMultiplicity::default(); let raw_witin = circuit .assign_instances::( builder.cs.num_witin as usize, @@ -692,6 +695,7 @@ mod tests { AssertLtCircuitInput { a: 3, b: 5 }, AssertLtCircuitInput { a: 7, b: 11 }, ], + &mut lk_multiplicity, ) .unwrap(); @@ -713,6 +717,7 @@ mod tests { let mut builder = CircuitBuilder::::new(&mut cs); let circuit = AssertLtCircuit::construct_circuit(&mut builder).unwrap(); + let mut lk_multiplicity = LkMultiplicity::default(); let raw_witin = circuit .assign_instances::( builder.cs.num_witin as usize, @@ -726,6 +731,7 @@ mod tests { b: u32::MAX as u64 - 2, }, ], + &mut lk_multiplicity, ) .unwrap(); @@ -765,6 +771,7 @@ mod tests { &self, instance: &mut [MaybeUninit], input: LtCircuitInput, + lk_multiplicity: &mut LkMultiplicity, ) -> Result<(), ZKVMError> { set_val!(instance, self.a, input.a); set_val!(instance, self.b, input.b); @@ -772,7 +779,7 @@ mod tests { lhs: input.a, rhs: input.b, } - .assign(instance, &self.lt_wtns); + .assign(instance, &self.lt_wtns, lk_multiplicity); Ok(()) } @@ -781,14 +788,16 @@ mod tests { &self, num_witin: usize, instances: Vec, + lk_multiplicity: &mut LkMultiplicity, ) -> Result, ZKVMError> { let mut raw_witin = RowMajorMatrix::::new(instances.len(), num_witin); - let raw_witin_iter = raw_witin.par_iter_mut(); + let raw_witin_iter = raw_witin.iter_mut(); raw_witin_iter - .zip_eq(instances.into_par_iter()) - .map(|(instance, input)| self.assign_instance::(instance, input)) - .collect::>()?; + .zip_eq(instances.into_iter()) + .try_for_each(|(instance, input)| { + self.assign_instance::(instance, input, lk_multiplicity) + })?; Ok(raw_witin) } @@ -801,6 +810,7 @@ mod tests { let circuit = LtCircuit::construct_circuit(&mut builder).unwrap(); + let mut lk_multiplicity = LkMultiplicity::default(); let raw_witin = circuit .assign_instances::( builder.cs.num_witin as usize, @@ -808,6 +818,7 @@ mod tests { LtCircuitInput { a: 3, b: 5 }, LtCircuitInput { a: 7, b: 11 }, ], + &mut lk_multiplicity, ) .unwrap(); @@ -830,6 +841,7 @@ mod tests { let circuit = LtCircuit::construct_circuit(&mut builder).unwrap(); + let mut lk_multiplicity = LkMultiplicity::default(); let raw_witin = circuit .assign_instances::( builder.cs.num_witin as usize, @@ -843,6 +855,7 @@ mod tests { b: u32::MAX as u64 - 5, }, ], + &mut lk_multiplicity, ) .unwrap();