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

Add wide fib lookup step constraint. #646

Merged
merged 1 commit into from
Jul 2, 2024

Conversation

alonh5
Copy link
Contributor

@alonh5 alonh5 commented May 28, 2024

This change is Reviewable

@alonh5 alonh5 force-pushed the 05-27-extract_constraint_code_into_functions branch from f1cf98b to 95c0db7 Compare May 28, 2024 12:52
@alonh5 alonh5 force-pushed the 05-28-add_wide_fib_lookup_step_constraint branch from 887ea74 to 90c09b3 Compare May 28, 2024 12:52
@alonh5 alonh5 force-pushed the 05-27-extract_constraint_code_into_functions branch from 95c0db7 to 32c879a Compare May 29, 2024 07:48
@alonh5 alonh5 force-pushed the 05-28-add_wide_fib_lookup_step_constraint branch from 90c09b3 to 22a4892 Compare May 29, 2024 07:48
@alonh5 alonh5 force-pushed the 05-27-extract_constraint_code_into_functions branch from 32c879a to 77a2633 Compare May 29, 2024 12:55
@alonh5 alonh5 force-pushed the 05-28-add_wide_fib_lookup_step_constraint branch from 22a4892 to 87a8ce5 Compare May 29, 2024 12:55
@alonh5 alonh5 force-pushed the 05-27-extract_constraint_code_into_functions branch from 77a2633 to ec3289d Compare May 30, 2024 13:37
@alonh5 alonh5 force-pushed the 05-28-add_wide_fib_lookup_step_constraint branch from 87a8ce5 to e2a05b2 Compare May 30, 2024 13:37
@alonh5 alonh5 force-pushed the 05-27-extract_constraint_code_into_functions branch from ec3289d to 9bc5a9c Compare June 2, 2024 08:54
@alonh5 alonh5 force-pushed the 05-28-add_wide_fib_lookup_step_constraint branch from e2a05b2 to a258294 Compare June 2, 2024 08:54
@alonh5 alonh5 changed the base branch from 05-27-extract_constraint_code_into_functions to 06-02-shift_mask_points June 2, 2024 08:55
@alonh5 alonh5 mentioned this pull request Jun 2, 2024
@alonh5 alonh5 force-pushed the 05-28-add_wide_fib_lookup_step_constraint branch from a258294 to 6d3ec5c Compare June 5, 2024 11:05
@alonh5 alonh5 changed the base branch from 06-02-shift_mask_points to 05-27-extract_constraint_code_into_functions June 5, 2024 11:05
@alonh5 alonh5 force-pushed the 05-28-add_wide_fib_lookup_step_constraint branch 2 times, most recently from 6b45a40 to 80031ba Compare June 13, 2024 08:31
@codecov-commenter
Copy link

codecov-commenter commented Jun 13, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 90.03%. Comparing base (a759ce0) to head (ae26ec4).
Report is 2 commits behind head on dev.

Additional details and impacted files
@@            Coverage Diff             @@
##              dev     #646      +/-   ##
==========================================
+ Coverage   89.95%   90.03%   +0.07%     
==========================================
  Files          75       75              
  Lines        9657     9730      +73     
  Branches     9657     9730      +73     
==========================================
+ Hits         8687     8760      +73     
  Misses        889      889              
  Partials       81       81              

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

@alonh5 alonh5 force-pushed the 05-28-add_wide_fib_lookup_step_constraint branch from d615ec9 to 6c72919 Compare June 23, 2024 13:35
@alonh5 alonh5 force-pushed the 05-27-extract_constraint_code_into_functions branch from f631952 to c6d22b6 Compare June 24, 2024 10:02
@alonh5 alonh5 force-pushed the 05-28-add_wide_fib_lookup_step_constraint branch from 6c72919 to fe6bf5b Compare June 24, 2024 10:02
@alonh5 alonh5 force-pushed the 05-27-extract_constraint_code_into_functions branch from c6d22b6 to 59f6ca2 Compare June 26, 2024 10:23
@alonh5 alonh5 force-pushed the 05-28-add_wide_fib_lookup_step_constraint branch from fe6bf5b to 4d92879 Compare June 26, 2024 10:23
Copy link
Contributor Author

@alonh5 alonh5 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: 0 of 7 files reviewed, 1 unresolved discussion (waiting on @shaharsamocha7 and @spapinistarkware)


crates/prover/src/core/utils.rs line 76 at r4 (raw file):

Previously, spapinistarkware (Shahar Papini) wrote…
  1. Do we need these in the long term? If not, add a TODO to remove. If yes, they are currently not efficient, and seem to only do things in the CPU, and not in a backend. Also, should the oeprate on Vec, and no on Evaluation or something?

Done.

@alonh5 alonh5 force-pushed the 05-27-extract_constraint_code_into_functions branch from 59f6ca2 to a9b0e6f Compare June 27, 2024 10:56
@alonh5 alonh5 force-pushed the 05-28-add_wide_fib_lookup_step_constraint branch from 4d92879 to 481218e Compare June 27, 2024 10:56
@alonh5 alonh5 force-pushed the 05-27-extract_constraint_code_into_functions branch from a9b0e6f to eb83ad6 Compare June 27, 2024 12:40
@alonh5 alonh5 force-pushed the 05-28-add_wide_fib_lookup_step_constraint branch from 481218e to 4dfe8ff Compare June 30, 2024 08:32
@alonh5 alonh5 changed the base branch from 05-27-extract_constraint_code_into_functions to dev June 30, 2024 08:32
@alonh5 alonh5 force-pushed the 05-28-add_wide_fib_lookup_step_constraint branch from 4dfe8ff to 3495fde Compare July 1, 2024 10:47
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 3 of 7 files at r2, 2 of 3 files at r5, 2 of 2 files at r6, all commit messages.
Reviewable status: all files reviewed, 6 unresolved discussions (waiting on @alonh5 and @spapinistarkware)


crates/prover/src/core/utils.rs line 71 at r6 (raw file):

        prev_index = (prev_index + half_size - 1) % half_size;
    } else {
        prev_index = ((prev_index + 1) % half_size) + half_size;

Does it work for constraint degree > 2?
I think that you need the extension degree as well

Suggestion:

        prev_index = ((prev_index + extension_degree / 2) % half_size) + half_size;

crates/prover/src/examples/wide_fibonacci/component.rs line 159 at r6 (raw file):

            .map(|eval| {
                let coset = CanonicCoset::new(trace[0].domain.log_size());
                CpuCircleEvaluation::new_canonical_ordered(coset, eval)

What is this change? Adding bit reverse?

Code quote:

                let coset = CanonicCoset::new(trace[0].domain.log_size());
                CpuCircleEvaluation::new_canonical_ordered(coset, eval)

crates/prover/src/examples/wide_fibonacci/constraint_eval.rs line 137 at r6 (raw file):

    }

    fn evaluate_lookup_step_constraints(

Let's add a TODO to try to simplify this function (moving parts to utility functions)
not for this pr

Code quote:

    fn evaluate_lookup_step_constraints(

crates/prover/src/examples/wide_fibonacci/mod.rs line 153 at r6 (raw file):

            .into_iter()
            .map(|eval| CpuCircleEvaluation::new_canonical_ordered(trace_domain, eval))
            .collect_vec();

This applies bit reverse on the entire trace.
It would be better to just bit reverse the lookup column?

Code quote:

        let trace = trace_values
            .into_iter()
            .map(|eval| CpuCircleEvaluation::new_canonical_ordered(trace_domain, eval))
            .collect_vec();

crates/prover/src/examples/wide_fibonacci/trace_gen.rs line 50 at r6 (raw file):

            circle_domain_order_to_coset_order(column)
        })
        .collect_vec();

Add a TODO, the better thing to do is to bit reverse only the expressions that relevant for the lookup
instead of bit reversing the entire trace which can be expensive

Code quote:

    let natural_ordered_trace = input_trace
        .iter_mut()
        .map(|column| {
            bit_reverse(column);
            circle_domain_order_to_coset_order(column)
        })
        .collect_vec();

@alonh5 alonh5 force-pushed the 05-28-add_wide_fib_lookup_step_constraint branch from 3495fde to ae26ec4 Compare July 2, 2024 07:52
Copy link
Contributor Author

@alonh5 alonh5 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: all files reviewed, 6 unresolved discussions (waiting on @shaharsamocha7 and @spapinistarkware)


crates/prover/src/core/utils.rs line 71 at r6 (raw file):

Previously, shaharsamocha7 wrote…

Does it work for constraint degree > 2?
I think that you need the extension degree as well

Yes I wrote it in the documentation, but i generalized it now.


crates/prover/src/examples/wide_fibonacci/component.rs line 159 at r6 (raw file):

Previously, shaharsamocha7 wrote…

What is this change? Adding bit reverse?

It reorders it in circle domain order and also bit reverses. This is needed for constraints between rows to be consistent.


crates/prover/src/examples/wide_fibonacci/constraint_eval.rs line 137 at r6 (raw file):

Previously, shaharsamocha7 wrote…

Let's add a TODO to try to simplify this function (moving parts to utility functions)
not for this pr

Done.


crates/prover/src/examples/wide_fibonacci/mod.rs line 153 at r6 (raw file):

Previously, shaharsamocha7 wrote…

This applies bit reverse on the entire trace.
It would be better to just bit reverse the lookup column?

I need to turn the trace order into circle domain and bit reverse for the same reason above.


crates/prover/src/examples/wide_fibonacci/trace_gen.rs line 50 at r6 (raw file):

Previously, shaharsamocha7 wrote…

Add a TODO, the better thing to do is to bit reverse only the expressions that relevant for the lookup
instead of bit reversing the entire trace which can be expensive

There's already a TODO to remove the cloning of the whole trace for this calculation. Only the relevant columns should be passed here after that change so this will stay the same. I edited to TODO to be clearer.

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


crates/prover/src/examples/wide_fibonacci/mod.rs line 153 at r6 (raw file):

Previously, alonh5 (Alon Haramati) wrote…

I need to turn the trace order into circle domain and bit reverse for the same reason above.

ok but we can also apply the todo here in order to reverse only the columns that are relevant for the lookup, right?

Copy link
Contributor

@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.

Reviewed 3 of 7 files at r2, 1 of 3 files at r5, 1 of 2 files at r6, 3 of 3 files at r7, all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @alonh5)

Copy link
Contributor Author

@alonh5 alonh5 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: all files reviewed, 1 unresolved discussion (waiting on @shaharsamocha7)


crates/prover/src/examples/wide_fibonacci/mod.rs line 153 at r6 (raw file):

Previously, shaharsamocha7 wrote…

ok but we can also apply the todo here in order to reverse only the columns that are relevant for the lookup, right?

First of all this is a test just making sure you noticed. Secondly in the actual trace I don't think we can only change the order of some of the columns because that would mess up the constraints in the same row.

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: :shipit: complete! all files reviewed, all discussions resolved (waiting on @alonh5)

Copy link
Contributor Author

alonh5 commented Jul 2, 2024

Merge activity

  • Jul 2, 8:47 AM EDT: @alonh5 started a stack merge that includes this pull request via Graphite.
  • Jul 2, 8:47 AM EDT: @alonh5 merged this pull request with Graphite.

@alonh5 alonh5 merged commit 42dfc02 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