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

FRI quotients y optimization #686

Merged
merged 1 commit into from
Jul 2, 2024

Conversation

spapinistarkware
Copy link
Contributor

@spapinistarkware spapinistarkware commented Jun 30, 2024

This change is Reviewable

Copy link
Contributor Author

spapinistarkware commented Jun 30, 2024

This stack of pull requests is managed by Graphite. Learn more about stacking.

Join @spapinistarkware and the rest of your teammates on Graphite Graphite

@codecov-commenter
Copy link

codecov-commenter commented Jun 30, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 90.19%. Comparing base (3b0a885) to head (bed00f8).

Additional details and impacted files
@@            Coverage Diff             @@
##              dev     #686      +/-   ##
==========================================
+ Coverage   90.02%   90.19%   +0.17%     
==========================================
  Files          75       75              
  Lines        9834     9862      +28     
  Branches     9834     9862      +28     
==========================================
+ Hits         8853     8895      +42     
+ Misses        900      886      -14     
  Partials       81       81              

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

@spapinistarkware spapinistarkware force-pushed the spapini/06-30-extension_fri_optimization branch from 6f9a25a to da6cb9d Compare June 30, 2024 13:29
@spapinistarkware spapinistarkware force-pushed the spapini/06-30-fri_quotients_y_optimization branch from 64af9ab to e5229a6 Compare June 30, 2024 13:29
Copy link
Collaborator

@ohad-starkware ohad-starkware left a comment

Choose a reason for hiding this comment

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

Reviewed all commit messages.
Reviewable status: 0 of 1 files reviewed, 1 unresolved discussion (waiting on @shaharsamocha7 and @spapinistarkware)


crates/prover/src/core/backend/simd/quotients.rs line 114 at r2 (raw file):

            let column = &columns[*column_index];
            let value = PackedSecureField::broadcast(*c) * column.data[vec_row];
            // The numerator is a line equation passing through

move the doc to the cpu code ?


crates/prover/src/core/backend/simd/quotients.rs line 125 at r2 (raw file):

                PackedSecureField::broadcast(*c) * column.data[(quad_row << 2) + i]
            });
            // y values are y,-y,-y,y.

Drop line,
also - this needs to be explained somewhere.
maybe we can implement in cpu also and doc there, this is less confusing without the interleaves.

@spapinistarkware spapinistarkware force-pushed the spapini/06-30-extension_fri_optimization branch from da6cb9d to d8f7e32 Compare July 1, 2024 10:11
@spapinistarkware spapinistarkware force-pushed the spapini/06-30-fri_quotients_y_optimization branch from e5229a6 to 0d2b522 Compare July 1, 2024 10:11
@spapinistarkware spapinistarkware force-pushed the spapini/06-30-extension_fri_optimization branch from d8f7e32 to 0287e62 Compare July 1, 2024 10:18
@spapinistarkware spapinistarkware force-pushed the spapini/06-30-fri_quotients_y_optimization branch from 0d2b522 to 84309f3 Compare July 1, 2024 10:18
Copy link
Collaborator

@ohad-starkware ohad-starkware 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 3 of 3 files at r3, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @shaharsamocha7)

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 all commit messages.
Reviewable status: all files reviewed, 3 unresolved discussions (waiting on @spapinistarkware)


crates/prover/src/core/backend/simd/quotients.rs line 103 at r3 (raw file):

/// Accumulates the quotients for 4 * N_LANES rows at a time.
/// spaced_ys - y values for N_LANES points in the domain, in jumps of 4.

Can you update that in the reverse order, each 4 consecutive rows are the points (P, P+H, -P, -P-H)?

Suggestion:

/// Accumulates the quotients for 4 * N_LANES rows at a time.
/// spaced_ys - y values for N_LANES points in the domain, in jumps of 4.

crates/prover/src/core/backend/simd/quotients.rs line 127 at r3 (raw file):

            // The numerator is the line equation:
            //   value - a * point.y - b;

?

Suggestion:

            // The numerator is the line equation:
            //   c * value - a * point.y - b;

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

        // Get from environment variable:
        let log_n_instances = env::var("LOG_N_INSTANCES")
            .unwrap_or_else(|_| "10".to_string())

Doesn't take too much time? (non-blocking)
is 8 less then minimal for a component?

Code quote:

"10"

@spapinistarkware spapinistarkware force-pushed the spapini/06-30-extension_fri_optimization branch from 0287e62 to 21492c9 Compare July 2, 2024 03:54
@spapinistarkware spapinistarkware force-pushed the spapini/06-30-fri_quotients_y_optimization branch 3 times, most recently from 712af54 to 600ce36 Compare July 2, 2024 04:04
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 3 files reviewed, 2 unresolved discussions (waiting on @ohad-starkware and @shaharsamocha7)


crates/prover/src/core/backend/simd/quotients.rs line 103 at r3 (raw file):

Previously, shaharsamocha7 wrote…

Can you update that in the reverse order, each 4 consecutive rows are the points (P, P+H, -P, -P-H)?

Added in the body.


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

Previously, shaharsamocha7 wrote…

Doesn't take too much time? (non-blocking)
is 8 less then minimal for a component?

Doesn't take too much time. 8 is too small.

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.

Reviewable status: 2 of 3 files reviewed, 4 unresolved discussions (waiting on @ohad-starkware and @spapinistarkware)


crates/prover/src/core/backend/simd/quotients.rs line 137 at r5 (raw file):

            // The numerator is the line equation:
            //   value - a * point.y - b;

Suggestion:

/   c * value - a * point.y - b;

crates/prover/src/core/backend/simd/quotients.rs line 155 at r5 (raw file):

                // Note that all summands were multiplied by coefficients (a, b or c).
                // These coefficients already hold the constraint coeff (random_coeff^i).
                // This is why we only add here.

move up

Code quote:

                // Note that all summands were multiplied by coefficients (a, b or c).
                // These coefficients already hold the constraint coeff (random_coeff^i).
                // This is why we only add here.

@spapinistarkware spapinistarkware force-pushed the spapini/06-30-fri_quotients_y_optimization branch from 600ce36 to b11de55 Compare July 2, 2024 10:05
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 3 files reviewed, 4 unresolved discussions (waiting on @ohad-starkware and @shaharsamocha7)


crates/prover/src/core/backend/simd/quotients.rs line 137 at r5 (raw file):

            // The numerator is the line equation:
            //   value - a * point.y - b;

Done.


crates/prover/src/core/backend/simd/quotients.rs line 155 at r5 (raw file):

Previously, shaharsamocha7 wrote…

move up

Done.

@spapinistarkware spapinistarkware force-pushed the spapini/06-30-extension_fri_optimization branch from 21492c9 to 411e2dc Compare July 2, 2024 12:22
@spapinistarkware spapinistarkware force-pushed the spapini/06-30-fri_quotients_y_optimization branch 2 times, most recently from 33cd9dc to 18edaa6 Compare July 2, 2024 12:29
@spapinistarkware spapinistarkware force-pushed the spapini/06-30-extension_fri_optimization branch 2 times, most recently from b2875a2 to 580b9cb Compare July 2, 2024 12:30
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 3 files at r3.
Reviewable status: 2 of 4 files reviewed, 2 unresolved discussions (waiting on @ohad-starkware and @spapinistarkware)


crates/prover/src/core/backend/simd/quotients.rs line 132 at r6 (raw file):

        {
            let column = &columns[*column_index];
            let values: [_; 4] = std::array::from_fn(|i| {

?

Suggestion:

let cvalues: [_; 4] = std::array::from_fn(|i| {

crates/prover/src/core/backend/simd/quotients.rs line 144 at r6 (raw file):

            //   G, -G, G + H, -G + H.
            // H being the half point (-1,0). The y values for these are
            //   y, -y, -y, y.

I would change that to P instead of G.
Not sure if it is better.

Suggestion:

//   P.y, -P.y, -P.y, P.y.

@spapinistarkware spapinistarkware force-pushed the spapini/06-30-fri_quotients_y_optimization branch from 18edaa6 to bed00f8 Compare July 2, 2024 12:42
@spapinistarkware spapinistarkware changed the base branch from spapini/06-30-extension_fri_optimization to dev July 2, 2024 12:42
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.

Reviewable status: 2 of 4 files reviewed, 1 unresolved discussion (waiting on @ohad-starkware and @spapinistarkware)


crates/prover/src/core/backend/simd/quotients.rs line 41 at r7 (raw file):

        let span = span!(Level::INFO, "Quotient accumulation").entered();
        // TODO(spapini): bit reverse iterator.
        for quad_row in 0..1 << (subdomain.log_size() - LOG_N_LANES - 2) {

Add the comment

Suggestion:

        // Accumulate the quotients on subdomain.
        for quad_row in 0..1 << (subdomain.log_size() - LOG_N_LANES - 2) {

@spapinistarkware spapinistarkware force-pushed the spapini/06-30-fri_quotients_y_optimization branch from bed00f8 to 03eb306 Compare July 2, 2024 13:00
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 1 of 2 files at r8, 1 of 1 files at r9, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @spapinistarkware)

@spapinistarkware spapinistarkware merged commit 6cef1fb into dev Jul 2, 2024
14 checks passed
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.

4 participants