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

Arrabiata: prepare constraints for cross-terms computation #2702

Merged
merged 5 commits into from
Dec 19, 2024

Conversation

dannywillems
Copy link
Member

@dannywillems dannywillems commented Oct 14, 2024

This pull request prepares the constraints to compute the cross-terms after the different columns and arguments have been computed. Challenges must be treated as a variable, and will be in a future PR.

Previous attempt: #2695

@dannywillems dannywillems self-assigned this Oct 14, 2024
@dannywillems dannywillems marked this pull request as draft October 14, 2024 07:45
Copy link

codecov bot commented Oct 14, 2024

Codecov Report

Attention: Patch coverage is 53.84615% with 30 lines in your changes missing coverage. Please review.

Please upload report for BASE (master@5b4ac14). Learn more about missing BASE report.
Report is 44 commits behind head on master.

Files with missing lines Patch % Lines
mvpoly/src/prime.rs 0.00% 11 Missing ⚠️
mvpoly/src/monomials.rs 83.33% 7 Missing ⚠️
arrabbiata/src/columns.rs 0.00% 6 Missing ⚠️
arrabbiata/src/main.rs 0.00% 6 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff            @@
##             master    #2702   +/-   ##
=========================================
  Coverage          ?   72.10%           
=========================================
  Files             ?      257           
  Lines             ?    61154           
  Branches          ?        0           
=========================================
  Hits              ?    44094           
  Misses            ?    17060           
  Partials          ?        0           

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

Base automatically changed from dw/remove-old-methods-in-interpreter to master October 14, 2024 15:57
@dannywillems dannywillems force-pushed the dw/mvpoly-arrabiata-convert-into branch 5 times, most recently from 4f07a8a to f713363 Compare October 15, 2024 06:56
@dannywillems dannywillems changed the base branch from master to dw/mvpoly-from-expr-generic-over-challenge October 15, 2024 08:26
@dannywillems dannywillems mentioned this pull request Oct 15, 2024
@dannywillems dannywillems force-pushed the dw/mvpoly-from-expr-generic-over-challenge branch from a35fa79 to 0ef15d6 Compare October 15, 2024 08:29
@dannywillems dannywillems force-pushed the dw/mvpoly-arrabiata-convert-into branch 4 times, most recently from 70addbd to 0129e25 Compare October 15, 2024 14:29
@dannywillems dannywillems force-pushed the dw/mvpoly-arrabiata-convert-into branch from 0129e25 to 32a4f93 Compare October 15, 2024 14:39
@dannywillems dannywillems changed the base branch from dw/mvpoly-from-expr-generic-over-challenge to dw/mvpoly-misc-changes October 15, 2024 14:39
@dannywillems dannywillems force-pushed the dw/mvpoly-arrabiata-convert-into branch from 32a4f93 to 97fbed5 Compare October 15, 2024 14:56
Base automatically changed from dw/mvpoly-misc-changes to master October 15, 2024 16:27
@dannywillems dannywillems force-pushed the dw/mvpoly-arrabiata-convert-into branch from 97fbed5 to 9eff145 Compare October 15, 2024 16:56
@dannywillems dannywillems changed the base branch from master to dw/improve-from-variable-implementation October 15, 2024 16:58
@dannywillems dannywillems force-pushed the dw/improve-from-variable-implementation branch 3 times, most recently from 0b6dd27 to 594f689 Compare October 16, 2024 12:52
@dannywillems dannywillems force-pushed the dw/mvpoly-arrabiata-convert-into branch 2 times, most recently from 6b94b8b to bb75668 Compare October 16, 2024 13:17
@dannywillems dannywillems marked this pull request as ready for review October 16, 2024 13:20
Comment on lines 299 to 307
polys: Vec<T>,
combiner1: F,
combiner2: F,
eval1: [F; N],
eval2: [F; N],
u1: F,
u2: F,
Copy link
Contributor

Choose a reason for hiding this comment

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

I m not sure I understand what is computed here ?
the text mentioned combining the polys with one combiner, and we have two of them here.
I understand that the two combiners are the alpha from each instances we fold ?
But then I don't get the assymetrical role ?

Copy link
Member Author

Choose a reason for hiding this comment

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


// This test is mostly an example to show to compute the cross-terms when we do
// have the expressions, and some evaluations.
// It doesn't test anything in particular. It is mostly an "integration" test.
Copy link
Contributor

Choose a reason for hiding this comment

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

A way to make this test test thing would be to checked the cross term property
poly(a +r*b) = poly(a) + r^n poly(b) + \sum_i r^i cross_term_i(a,b)
Also a nit: I wouldn't call that an integration test

Copy link
Member Author

@dannywillems dannywillems Oct 29, 2024

Choose a reason for hiding this comment

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

"Also a nit: I wouldn't call that an integration test"

That's the reason "integration" is double quoted.

// Computing α'^i * value, and adding it to the next power of r
let alpha_i = combiner2.pow([i as u64]);
// Handling 0^0 = 1
Copy link
Contributor

Choose a reason for hiding this comment

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

isn't combiner a random term that cannot be zero ?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, but it was monstly for the tests (see test directory). I didn't handle it initially. Even if the case is negligible, I think it is ok to have it. Maybe we should fail instead?

Copy link
Contributor

Choose a reason for hiding this comment

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

I'd ignore it to simplify the code, and remove the testing with zero, but do as you feel

/// It is useful when the number of nested loop is large and the size of the
/// loops is large as well. `filter_map` is used to avoid computing the indices
/// that are not needed and avoid a `capacity_overflow` error.
pub fn compute_indices_nested_loop_upper_bound(
Copy link
Contributor

Choose a reason for hiding this comment

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

I would not expose this function, keep this implementation, and expose compute_indices_nested_loop implemented with that implementation, while computing the upper bound on the fly with a max.
Then we have one function instead of two, which is the efficient variant, and only need one argument

@marcbeunardeau88
Copy link
Contributor

I could not convinced my self of the correctness of the algorithm, and there is no test that reassure me.
Otherwise only small remarks.

Copy link
Contributor

@marcbeunardeau88 marcbeunardeau88 left a comment

Choose a reason for hiding this comment

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

I'd like a test on the defining property of cross terms to convince me of the correctness of the algorithm, which I wasn't able to check manually

/// linearly combined using the power of a combiner, often called `α`.
/// Powers of the combiner are considered as an additional variable of the
/// multi-variate polynomials, therefore increasing the degree of the sum of all
/// polynomials by one. In other words, if we combine (M + 1) polynomials
Copy link
Member Author

Choose a reason for hiding this comment

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

See the comment just above:

/// Powers of the combiner are considered as an additional variable of the
/// multi-variate polynomials, therefore increasing the degree of the sum of all
/// polynomials by one.

Instead of having a power, we do consider them as a different variable.

/// cross-terms of the polynomial:
///
/// ```text
/// P(X_1, ..., X_N, α_1, ..., α_M) = P_1(X_1, ..., X_N)
Copy link
Member Author

Choose a reason for hiding this comment

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

@dannywillems
Copy link
Member Author

dannywillems commented Oct 29, 2024

I could not convinced my self of the correctness of the algorithm, and there is no test that reassure me.

See https://hackmd.io/@dannywillems/Syo5MBq90#Computation-of-cross-terms-for-shifted-polynomials. And we also discussed it in the past in person. Agreed to have more comments and more PBT.

@dannywillems dannywillems force-pushed the dw/mvpoly-arrabiata-convert-into branch 5 times, most recently from 1d283cd to b6a4e54 Compare December 18, 2024 19:50
@dannywillems dannywillems force-pushed the dw/mvpoly-arrabiata-convert-into branch from b6a4e54 to 00a6119 Compare December 18, 2024 19:55
impl From<Column> for usize {
fn from(val: Column) -> usize {
match val {
Column::X(i) => i,
_ => unimplemented!("Only the private inputs are supported for now"),
Column::PublicInput(i) => NUMBER_OF_COLUMNS + i,
Copy link
Contributor

Choose a reason for hiding this comment

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

Doesn't having (at least) a full columns for PI can create issue on the perfs of the verifier.
More importantely, this translate in the folder verifier which will handle a big PI.
We can use the PLONK way to handle PI to avoid a PI being linear in the number of rows

Since this is not the topic of the PR, we can see that later

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, I want to investigate other solutions to handle PI.

/// the polynomial `P`, i.e. `D`.
///
/// The output is a map of `D` values that represents the cross-terms
/// for each power of `r`.
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd add in the description of the funciton something like the following to summarize
let res = compute_cross_terms_scaled(P,eval1,eval2,u1,u2,scalar1,scalar2)
let P'[X_1, ..., X_n,U,Alpha] be P homogenised by U and scaled by Alpha
Then for all r,
P'(eval_1,u1,scalar1) + r^{D+1} P'(eval_2,u2,scalar2) + \sum_{i=1}^{D} r^i res[i] =
P'(eval_1 +reval_2, u1 + ru_2,scalar1+r*scalar2)

Copy link
Member Author

Choose a reason for hiding this comment

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

Sure, I'll do it in a follow-up.

Copy link
Member Author

Choose a reason for hiding this comment

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

Updated in the HackMD.

Copy link
Contributor

@marcbeunardeau88 marcbeunardeau88 left a comment

Choose a reason for hiding this comment

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

I did not check the maths but the test is convincing enough

@dannywillems dannywillems merged commit a87933c into master Dec 19, 2024
8 checks passed
@dannywillems dannywillems deleted the dw/mvpoly-arrabiata-convert-into branch December 19, 2024 11:11
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.

2 participants