-
Notifications
You must be signed in to change notification settings - Fork 98
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
MSM pre-computation #427
Merged
Merged
MSM pre-computation #427
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This is ready for review although I plan to push another commit with more documentation of internals and public interfaces. |
ChickenLover
approved these changes
Mar 9, 2024
ChickenLover
approved these changes
Mar 13, 2024
LeonHibnik
approved these changes
Mar 13, 2024
## Describe the changes Adds PrecomputeMSMBases into golang wrappers
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Brief description
This PR adds pre-computation to the MSM, for some theory see this timecode of Niall Emmart's talk.
In terms of public APIs, one method is added. It does the pre-computation on-device leaving resulting data on-device as well. No extra structures are added, only
precompute_factor
fromMSMConfig
is now activated.Performance
While performance gains are for now often limited by our inflexibility in choice of
c
(for example, very large MSMs get basically no speedup from pre-compute because currentlyc
cannot be larger than 16), there's still a number of MSM sizes which get noticeable improvement:2^20
MSM, ms.2^12
MSM, size2^10
batch, ms.2^20
MSM, ms.2^12
MSM, size2^10
batch, ms.Here for example pre-computation factor = 4 means that alongside each original base point, we pre-compute and pass into the MSM 3 of its "shifted" versions. Pre-computation factor = 1 means no pre-computation. GPU used for benchmarks is a 3090Ti.
TODOs and open questions
c
. One issue with this is that pre-compute will become dependent onc
. For now this is not the case asc
can only be a power of 2 and powers of 2 can always share the same pre-computation. So apparently we need to makec
a parameter of the precompute function to future-proof it from a breaking change. This is pretty unnatural and counterintuitive asc
is typically chosen in runtime after pre-compute is done but I don't really see another way, pls let me know if you do. UPD:c
is added into pre-compute function, for now it's unused and it's documented how it will change in the future.Resolves #147
Co-authored with @ChickenLover