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

perf: non-native multilinear polynomial evaluation #1087

Merged
merged 5 commits into from
Apr 10, 2024
Merged

Conversation

ivokub
Copy link
Collaborator

@ivokub ivokub commented Mar 19, 2024

Description

This PR optimizes evaluation of multilinear polynomials.

Previously, we folded the multilinear polynomial one variable at a time, but this is sub-optimal approach when using non-native arithmetic as we have to perform many modular multiplications.

Now, instead, we split the variables x1, ..., xn into two similar size partitions x1, .., x_{n/2} and x_{n/2+1}, ..., xn. We then compute recursively all possible combinations prod({x1, (1-x1)}, ..., {x_{n/2}, 1-x_{n/2}}) and prod({x_{n/2+1}, (1-x_{n/2+1})}, ..., {x_n, 1-x_n}) first and then compute the corresponding evaluated coefficients (1-x1)*...*(1-xn) f0 ... x1*...*xn f_{2^n} one by one with the combinations using non-reducing multiplication and addition chains.

With doing the addition chains and non-reducing multiplications, we can save significantly on modular reductions. Additionally, we can reuse the computations when we're computing several ML evaluations which is useful later for the sumcheck verifier.

Type of change

  • New feature (non-breaking change which adds functionality)

How has this been tested?

  • TestEvalMultiLin2 -- checks consistency with the previous implementation (which is kept for testing purposes)
  • TestPartialMultilinearEval

How has this been benchmarked?

Ran the tests from the local scalar multiplication with sumcheck -- for MLE of size 2^17 the reduction is from 33039039 constraints to 4502862 constraints.

Checklist:

  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have added tests that prove my fix is effective or that my feature works
  • I did not modify files generated from templates
  • golangci-lint does not output errors locally
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

@ivokub ivokub added the perf label Mar 19, 2024
@ivokub ivokub requested a review from Tabaie March 19, 2024 00:17
@ivokub ivokub self-assigned this Mar 19, 2024
@Tabaie Tabaie merged commit acd3529 into master Apr 10, 2024
7 checks passed
@Tabaie Tabaie deleted the perf/nna-mle-eval branch April 10, 2024 17:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants