Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Eval framework point and domain #713

Merged
merged 1 commit into from
Jul 14, 2024
Merged

Conversation

spapinistarkware
Copy link
Contributor

@spapinistarkware spapinistarkware commented Jul 9, 2024

This change is Reviewable

This was referenced Jul 9, 2024
@codecov-commenter
Copy link

codecov-commenter commented Jul 9, 2024

Codecov Report

Attention: Patch coverage is 78.88889% with 19 lines in your changes missing coverage. Please review.

Project coverage is 90.42%. Comparing base (5c9fb36) to head (fe24074).

Files Patch % Lines
...tes/prover/src/constraint_framework/simd_domain.rs 71.42% 16 Missing ⚠️
crates/prover/src/constraint_framework/point.rs 91.17% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##              dev     #713      +/-   ##
==========================================
- Coverage   90.48%   90.42%   -0.07%     
==========================================
  Files          77       79       +2     
  Lines       10184    10274      +90     
  Branches    10184    10274      +90     
==========================================
+ Hits         9215     9290      +75     
- Misses        886      901      +15     
  Partials       83       83              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@spapinistarkware spapinistarkware force-pushed the spapini/07-05-eval_framework branch from 55d0ff0 to 9994d77 Compare July 10, 2024 06:38
@spapinistarkware spapinistarkware force-pushed the eval_framework_point_domain branch from 5c6bc7a to 5408ff6 Compare July 10, 2024 06:38
Copy link
Collaborator

@shaharsamocha7 shaharsamocha7 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 1 of 5 files at r1, all commit messages.
Reviewable status: 1 of 5 files reviewed, 4 unresolved discussions (waiting on @spapinistarkware)


crates/prover/src/constraint_framework/domain.rs line 1 at r1 (raw file):

use std::ops::Mul;

Consider to rename to simd_domain.rs


crates/prover/src/constraint_framework/domain.rs line 17 at r1 (raw file):

use crate::core::utils::offset_bit_reversed_circle_domain_index;

/// Evaluates expressions at an evaluation domain rows.

shouldn't we use here constraint notation?

Suggestion:

/// Evaluates constraints at an evaluation domain points.

crates/prover/src/constraint_framework/domain.rs line 21 at r1 (raw file):

    pub trace_eval:
        &'a TreeVec<Vec<&'a CircleEvaluation<SimdBackend, BaseField, BitReversedOrder>>>,
    pub col_index: Vec<usize>,

rename as discussed

Code quote:

    pub col_index: Vec<usize>,

crates/prover/src/constraint_framework/domain.rs line 66 at r1 (raw file):

                return self.trace_eval[interaction][col_index].data[self.vec_row];
            }
            PackedBaseField::from_array(std::array::from_fn(|i| {

Add a comment to explain this

Code quote:

            // TODO(spapini): Optimize.
            if off == 0 {
                return self.trace_eval[interaction][col_index].data[self.vec_row];
            }
            PackedBaseField::from_array(std::array::from_fn(|i| {

@spapinistarkware spapinistarkware force-pushed the spapini/07-05-eval_framework branch from 9994d77 to b758587 Compare July 11, 2024 11:20
@spapinistarkware spapinistarkware force-pushed the eval_framework_point_domain branch from 5408ff6 to 58006ae Compare July 11, 2024 11:38
Copy link
Contributor Author

@spapinistarkware spapinistarkware left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: 1 of 5 files reviewed, 4 unresolved discussions (waiting on @shaharsamocha7)


crates/prover/src/constraint_framework/domain.rs line 1 at r1 (raw file):

Previously, shaharsamocha7 wrote…

Consider to rename to simd_domain.rs

Done.


crates/prover/src/constraint_framework/domain.rs line 17 at r1 (raw file):

Previously, shaharsamocha7 wrote…

shouldn't we use here constraint notation?

Done.


crates/prover/src/constraint_framework/domain.rs line 21 at r1 (raw file):

Previously, shaharsamocha7 wrote…

rename as discussed

Done.


crates/prover/src/constraint_framework/domain.rs line 66 at r1 (raw file):

Previously, shaharsamocha7 wrote…

Add a comment to explain this

Done.

Copy link
Collaborator

@shaharsamocha7 shaharsamocha7 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 2 of 5 files at r1, 1 of 3 files at r2.
Reviewable status: 2 of 5 files reviewed, 7 unresolved discussions (waiting on @spapinistarkware)


crates/prover/src/constraint_framework/mod.rs line 63 at r1 (raw file):

    /// Combines 4 base field values into a single extension field value.
    fn combine_ef(values: [Self::F; 4]) -> Self::EF;

SECURE_EXTENSION_DEGREE

In all places

Code quote:

4

crates/prover/src/examples/poseidon/mod.rs line 45 at r1 (raw file):

#[derive(Clone)]
pub struct PoseidonComponent {
    pub log_n_rows: u32,

Isn't it better to store log_n_instances?

Code quote:

pub log_n_rows: u32,

crates/prover/src/examples/poseidon/mod.rs line 131 at r1 (raw file):

        let denom = coset_vanishing(constraint_zero_domain, point);
        let denom_inverse = denom.inverse();
        let mut eval = PoseidonEval {

Rename

Suggestion:

let mut poseidon_eval = PoseidonEval {

crates/prover/src/examples/poseidon/mod.rs line 380 at r1 (raw file):

            .as_cols_ref()
            .map_cols(|col| col.evaluate_with_twiddles(eval_domain, &twiddles));
        let trace_eval_ref = trace_eval.as_ref().map(|t| t.iter().collect_vec());

Isn't this effectively a clone?

Code quote:

let trace_eval_ref = trace_eval.as_ref().map(|t| t.iter().collect_vec());

crates/prover/src/constraint_framework/simd_domain.rs line 22 at r2 (raw file):

        &'a TreeVec<Vec<&'a CircleEvaluation<SimdBackend, BaseField, BitReversedOrder>>>,
    pub column_index_per_interaction: Vec<usize>,
    pub vec_row: usize,

what's vec_row stands for?

Suggestion:

pub row_index: usize,

crates/prover/src/constraint_framework/simd_domain.rs line 27 at r2 (raw file):

    pub constraint_index: usize,
    pub domain_log_size: u32,
    pub eval_log_size: u32,

Rename

Suggestion:

pub eval_domain_log_size: u32,

crates/prover/src/constraint_framework/simd_domain.rs line 70 at r2 (raw file):

            // at the bit-reversed natural order index at an offset.
            PackedBaseField::from_array(std::array::from_fn(|i| {
                let index = offset_bit_reversed_circle_domain_index(

Rename

Suggestion:

let row_index = offset_bit_reversed_circle_domain_index(

@spapinistarkware spapinistarkware force-pushed the spapini/07-05-eval_framework branch from b758587 to f1b9436 Compare July 14, 2024 07:41
@spapinistarkware spapinistarkware force-pushed the eval_framework_point_domain branch from 58006ae to 5b06d1d Compare July 14, 2024 07:46
Copy link
Contributor Author

@spapinistarkware spapinistarkware left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: 2 of 5 files reviewed, 7 unresolved discussions (waiting on @shaharsamocha7)


crates/prover/src/constraint_framework/mod.rs line 63 at r1 (raw file):

Previously, shaharsamocha7 wrote…

SECURE_EXTENSION_DEGREE

In all places

Done.


crates/prover/src/examples/poseidon/mod.rs line 45 at r1 (raw file):

Previously, shaharsamocha7 wrote…

Isn't it better to store log_n_instances?

log_n_rows is a lot more useful. And log_n_instances is not always integer (e.g. if we have 3 repetitions).


crates/prover/src/examples/poseidon/mod.rs line 131 at r1 (raw file):

Previously, shaharsamocha7 wrote…

Rename

Done.


crates/prover/src/examples/poseidon/mod.rs line 380 at r1 (raw file):

Previously, shaharsamocha7 wrote…

Isn't this effectively a clone?

No. It's just references.


crates/prover/src/constraint_framework/simd_domain.rs line 22 at r2 (raw file):

Previously, shaharsamocha7 wrote…

what's vec_row stands for?

It's not the row, it's the row of the vector-of rows table. Since this is SIMD. We currently use vec_row everywhere in the project. We can change them all together in a PR if you like.


crates/prover/src/constraint_framework/simd_domain.rs line 27 at r2 (raw file):

Previously, shaharsamocha7 wrote…

Rename

Done.


crates/prover/src/constraint_framework/simd_domain.rs line 70 at r2 (raw file):

Previously, shaharsamocha7 wrote…

Rename

Done.

Copy link
Collaborator

@shaharsamocha7 shaharsamocha7 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:lgtm:

Reviewed 5 of 5 files at r3, all commit messages.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @spapinistarkware)


crates/prover/src/constraint_framework/mod.rs line 2 at r3 (raw file):

mod point;
/// ! This module contains helpers to express and use constraints for components.

shouldn't it be the first line?

Code quote:

/// ! This module contains helpers to express and use constraints for components.

crates/prover/src/constraint_framework/simd_domain.rs line 22 at r2 (raw file):

Previously, spapinistarkware (Shahar Papini) wrote…

It's not the row, it's the row of the vector-of rows table. Since this is SIMD. We currently use vec_row everywhere in the project. We can change them all together in a PR if you like.

Ok,
Let's consider changing it to packed_row (in a different pr as you said)

@spapinistarkware spapinistarkware force-pushed the eval_framework_point_domain branch 2 times, most recently from 4ab884e to 95d86d8 Compare July 14, 2024 08:45
@spapinistarkware spapinistarkware changed the base branch from spapini/07-05-eval_framework to dev July 14, 2024 08:45
@spapinistarkware spapinistarkware force-pushed the eval_framework_point_domain branch from 95d86d8 to fe24074 Compare July 14, 2024 11:46
Copy link
Collaborator

@shaharsamocha7 shaharsamocha7 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 1 of 1 files at r4, 1 of 1 files at r5, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @spapinistarkware)

@spapinistarkware spapinistarkware merged commit 4839cd8 into dev Jul 14, 2024
14 checks passed
Copy link
Contributor Author

Merge activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants