Skip to content

Commit

Permalink
fix lints
Browse files Browse the repository at this point in the history
  • Loading branch information
irakliyk committed Nov 19, 2024
1 parent aafc10d commit 548d9a5
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 34 deletions.
23 changes: 7 additions & 16 deletions air/src/options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand All @@ -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,
Expand All @@ -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
Expand Down
6 changes: 2 additions & 4 deletions prover/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -556,10 +556,8 @@ pub trait Prover {
log_domain_size = domain_size.ilog2()
)
.in_scope(|| {
let commitment = composed_evaluations.commit_to_rows::<Self::HashFn, Self::VC>(
self.options()
.partition_options(),
);
let commitment = composed_evaluations
.commit_to_rows::<Self::HashFn, Self::VC>(self.options().partition_options());
ConstraintCommitment::new(composed_evaluations, commitment)
});

Expand Down
4 changes: 2 additions & 2 deletions prover/src/matrix/row_matrix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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")]
Expand Down Expand Up @@ -203,7 +203,7 @@ impl<E: FieldElement> RowMatrix<E> {
);
} else {
let num_partitions = partition_options.num_partitions::<E>(self.num_cols());

// iterate though matrix rows, hashing each row
batch_iter_mut!(
&mut row_hashes,
Expand Down
16 changes: 4 additions & 12 deletions prover/src/trace/trace_lde/default/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,8 @@ where
) -> (Self, TracePolyTable<E>) {
// 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::<E, E::BaseField, H, V>(
main_trace,
domain,
partition_options,
);

build_trace_commitment::<E, E::BaseField, H, V>(main_trace, domain, partition_options);

let trace_poly_table = TracePolyTable::new(main_segment_polys);
let trace_lde = DefaultTraceLde {
main_segment_lde,
Expand Down Expand Up @@ -148,12 +144,8 @@ where
) -> (ColMatrix<E>, 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::<E, E, H, Self::VC>(
aux_trace,
domain,
self.partition_options,
);

build_trace_commitment::<E, E, H, Self::VC>(aux_trace, domain, self.partition_options);

// check errors
assert!(
usize::from(self.aux_segment_lde.is_some()) < self.trace_info.num_aux_segments(),
Expand Down

0 comments on commit 548d9a5

Please sign in to comment.