Add lightweight prove path and hint-free LogUp API #203
Add lightweight prove path and hint-free LogUp API #203
Conversation
…t prove, and configurable CPU count - Add `export_device_memories_unchecked()` for exporting device memories without state assertion, enabling memory optimization workflows where context is dropped before proving - Add `prove_lightweight()` to ExpanderNoOverSubscribe, allowing prove without holding computation_graph or prover_setup references - Add `final_check_with_query_count()` to LogUpSingleKeyTable and LogUpRangeProofTable for hint-free logup verification with externally provided query counts - Support `ZKML_NUM_CPUS` env var to override physical CPU detection for MPI process count Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Summary of ChangesHello @hczphn, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request introduces several optimizations aimed at improving the efficiency and memory footprint of the proving process, particularly for workloads without padding or hint functions. It provides new APIs to bypass redundant computation steps and allows for more flexible memory management by enabling the release of large data structures earlier in the proving pipeline. Additionally, it enhances configuration flexibility for parallel execution by allowing manual override of CPU detection. Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
The pull request introduces several useful features for optimizing the proving process, including a lightweight prove path and hint-free LogUp API. The addition of export_device_memories_unchecked() and prove_lightweight() provides flexibility for memory management. The support for ZKML_NUM_CPUS environment variable is a good enhancement for controlling parallel execution. One area for improvement is the error handling in LogUpSingleKeyTable::final_check_with_query_count.
| if self.table.is_empty() || self.query_keys.is_empty() { | ||
| panic!("empty table or empty query"); |
There was a problem hiding this comment.
Using panic! for empty table or query inputs can lead to an abrupt program termination. Consider returning a Result type to allow callers to handle this error gracefully, or at least logging a more informative error before panicking, especially in a library context where consumers might expect more robust error handling.
| if self.table.is_empty() || self.query_keys.is_empty() { | |
| panic!("empty table or empty query"); | |
| if self.table.is_empty() || self.query_keys.is_empty() { | |
| // TODO: Consider returning a Result<_, Error> instead of panicking | |
| // or logging a more specific error message. | |
| panic!("empty table or empty query"); | |
| } |
Summary
export_device_memories_unchecked()toContext— exports device memories without theWitnessDonestate assertion, keeping the originalexport_device_memories()unchanged and fully backward-compatible.prove_lightweight()toExpanderNoOverSubscribe— allows proving with onlydevice_memories, without holdingcomputation_graphorprover_setupreferences. This enables callers to release large data structures before the prove phase to reduce peak memory.final_check_with_query_count()toLogUpSingleKeyTableandLogUpRangeProofTable— supports hint-free logup verification with externally provided query counts.ZKML_NUM_CPUSenvironment variable to override physical CPU detection for MPI process count.Motivation
Related: #202
For workloads without padding and without hint functions, the current prove path (
copy_to_device→call_kernel→solve_witness→export_device_memories→prove) introduces significant overhead fromcall_kernel(redundant hashing, unnecessaryeval_safe_simd) andsolve_witness.With
export_device_memories_unchecked()+prove_lightweight(), callers can bypasscall_kernelandsolve_witnessentirely: justcopy_to_device→export_device_memories_unchecked→prove_lightweight. This is only applicable when no padding or hint functions are needed.