diff --git a/air/src/options.rs b/air/src/options.rs index 657a6381d..a043d70db 100644 --- a/air/src/options.rs +++ b/air/src/options.rs @@ -346,15 +346,15 @@ impl Deserializable for FieldExtension { /// Defines the parameters used to calculate partition size when committing to the traces /// generated during the protocol. -/// +/// /// Using multiple partitions will change how vector commitments are calculated: /// - Input matrix columns are split into at most num_partitions partitions /// - For each matrix row, a hash is calculated for each partition separately /// - The results are merged together by one more hash iteration -/// +/// /// This is especially useful when proving with multiple GPU cards where each device holds /// a subset of data and allows less data reshuffling when generating commitments. -/// +/// /// Hash_rate parameter is used to find the optimal partition size to minimize the number /// of hash iterations. It specifies how many field elements are consumed by each hash iteration. #[derive(Debug, Clone, Copy, Eq, PartialEq)] @@ -366,17 +366,11 @@ pub struct PartitionOptions { impl PartitionOptions { /// Returns a new instance of `[PartitionOptions]`. pub const fn new(num_partitions: usize, hash_rate: usize) -> Self { - assert!(num_partitions >= 1, "number of partitions must be greater than or eqaul to 1"); + assert!(num_partitions >= 1, "number of partitions must be greater than or equal to 1"); assert!(num_partitions <= 16, "number of partitions must be smaller than or equal to 16"); - assert!( - hash_rate >= 1, - "hash rate must be greater than or equal to 1" - ); - assert!( - hash_rate <= 256, - "hash rate must be smaller than or equal to 256" - ); + assert!(hash_rate >= 1, "hash rate must be greater than or equal to 1"); + assert!(hash_rate <= 256, "hash rate must be smaller than or equal to 256"); Self { num_partitions: num_partitions as u8, @@ -396,10 +390,7 @@ impl PartitionOptions { // the number of `E` elements that can be consumed in one hash iteration. let min_partition_size = self.hash_rate as usize / E::EXTENSION_DEGREE; - cmp::max( - num_columns.div_ceil(self.num_partitions as usize), - min_partition_size, - ) + cmp::max(num_columns.div_ceil(self.num_partitions as usize), min_partition_size) } /// The actual number of partitions, after the min partition size implied diff --git a/prover/src/lib.rs b/prover/src/lib.rs index c72c0c766..6854ae818 100644 --- a/prover/src/lib.rs +++ b/prover/src/lib.rs @@ -556,10 +556,8 @@ pub trait Prover { log_domain_size = domain_size.ilog2() ) .in_scope(|| { - let commitment = composed_evaluations.commit_to_rows::( - self.options() - .partition_options(), - ); + let commitment = composed_evaluations + .commit_to_rows::(self.options().partition_options()); ConstraintCommitment::new(composed_evaluations, commitment) }); diff --git a/prover/src/matrix/row_matrix.rs b/prover/src/matrix/row_matrix.rs index ef146643e..91c5c04aa 100644 --- a/prover/src/matrix/row_matrix.rs +++ b/prover/src/matrix/row_matrix.rs @@ -3,9 +3,9 @@ // This source code is licensed under the MIT license found in the // LICENSE file in the root directory of this source tree. -use air::PartitionOptions; use alloc::vec::Vec; +use air::PartitionOptions; use crypto::{ElementHasher, VectorCommitment}; use math::{fft, FieldElement, StarkField}; #[cfg(feature = "concurrent")] @@ -203,7 +203,7 @@ impl RowMatrix { ); } else { let num_partitions = partition_options.num_partitions::(self.num_cols()); - + // iterate though matrix rows, hashing each row batch_iter_mut!( &mut row_hashes, diff --git a/prover/src/trace/trace_lde/default/mod.rs b/prover/src/trace/trace_lde/default/mod.rs index 850ce0d90..afc3734a6 100644 --- a/prover/src/trace/trace_lde/default/mod.rs +++ b/prover/src/trace/trace_lde/default/mod.rs @@ -68,12 +68,8 @@ where ) -> (Self, TracePolyTable) { // extend the main execution trace and build a commitment to the extended trace let (main_segment_lde, main_segment_vector_com, main_segment_polys) = - build_trace_commitment::( - main_trace, - domain, - partition_options, - ); - + build_trace_commitment::(main_trace, domain, partition_options); + let trace_poly_table = TracePolyTable::new(main_segment_polys); let trace_lde = DefaultTraceLde { main_segment_lde, @@ -148,12 +144,8 @@ where ) -> (ColMatrix, H::Digest) { // extend the auxiliary trace segment and build a commitment to the extended trace let (aux_segment_lde, aux_segment_oracles, aux_segment_polys) = - build_trace_commitment::( - aux_trace, - domain, - self.partition_options, - ); - + build_trace_commitment::(aux_trace, domain, self.partition_options); + // check errors assert!( usize::from(self.aux_segment_lde.is_some()) < self.trace_info.num_aux_segments(),