perf: non-native multilinear polynomial evaluation #1087
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 partitionsx1, .., x_{n/2}
andx_{n/2+1}, ..., xn
. We then compute recursively all possible combinationsprod({x1, (1-x1)}, ..., {x_{n/2}, 1-x_{n/2}})
andprod({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
How has this been tested?
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:
golangci-lint
does not output errors locally