-
Notifications
You must be signed in to change notification settings - Fork 118
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
SRS caching #1197
Merged
Merged
SRS caching #1197
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
Trivo25
approved these changes
Oct 31, 2023
Damn, it fails in the web version, I forgot to consider the weird worker-calling layer we have there 😞 Might need to refactor this a bit to work EDIT: it was just updating the "wasm spec" |
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.
Cache SRS and Lagrange basis
closes #1119
bindings: o1-labs/o1js-bindings#192
proof-systems: o1-labs/proof-systems#1300
Details. This is a follow-up to #1187, which expands caching to include the SRS and Lagrange bases. Most of the lift is in the bindings PR, which refactors basis creation to happen in TS, and try to read from a user-defined cache first. The cache is put in a global variable at the start of
compile()
and unset at the end. This completely bypasses the Pickles caching logic, to avoid yet more refactors of the Pickles API.In contrast to prover and verifier keys, SRS and Lagrange bases are very stable and won't need to be regenerated often. The SRS is a fixed list of curve points and exists once for both Pasta curves. So it will be generated once and not change after that. Lagrange bases have to be created once for every circuit size. The circuit size is a power of two and at most equal to the SRS size. In the typical case, a user will already have compiled a circuit of the same power of two, and will be able to read the Lagrange basis from cache.
In addition to enabling caching, the bindings PR uses a faster (multi-threaded) version of SRS creation. This brings a major speedup even on the first run, when the SRS isn't cached yet.
Results. Compiling the
simple_zkapp.ts
example becomes faster in various scenariosNote: Loading bases from cache is only 1s faster than regenerating them. The bottleneck is not reading the file, but conversion from the stored JSON format into the format needed by Rust. This should be easy to make faster and will be addressed in a future PR.
Cache directory now looks like this: