Chunk 11.1

This chunk documents the implementation and GPU E2E validation of Phase 3 (cross-sector batching) for the **cuzk** pipelined SNARK proving engine. The core architectural addition is a `BatchCollector` that accumulates same-circuit-type (PoRep, SnapDeals) proof requests, flushing them when `max_batch_size` is reached or `max_batch_wait_ms` expires. A new `synthesize_porep_c2_multi()` function in the pipeline layer takes N sectors' C1 outputs, builds all N×10 partition circuits, and performs a single combined synthesis pass. After GPU proving, `split_batched_proofs()` separates the concatenated proof bytes back into per-sector results, and each caller receives its individual proof with accurate timings. Non-batchable proof types (WinningPoSt, WindowPoSt) preempt-flush any pending batch and process immediately, ensuring no latency impact on priority-critical proofs. GPU E2E testing on an RTX 5070 Ti with real 32 GiB PoRep data validated the implementation with detailed memory monitoring. The baseline (batch_size=1, single proof) completed in 88.9s total (synthesis 59.3s, GPU 28.8s) with ~5.5 GiB RSS memory. With batch_size=2 and two concurrent proofs, the daemon accumulated both requests and processed them as a single batched pass: total time 121.6s for both proofs (60.8s per proof steady-state), with peak RSS ~7.5 GiB (only ~2 GiB above baseline). This represents a **1.46x throughput improvement** over sequential single proofs (2 proofs in 121.6s vs 177.8s), with memory overhead far lower than the theoretical 2x because the SRS (47 GiB pinned) is shared and only the compressed auxiliary assignments grow linearly with batch size. The implementation is fully backward compatible — `max_batch_size=1` preserves Phase 2 behavior exactly. All 25 unit tests pass with zero warnings, and the commit is clean on the `feat/cuzk` branch (9 commits total). The roadmap now advances to Phase 4 (compute optimizations: SmallVec, parallel B_G2 MSMs, pinned memory transfers) and Phase 5 (Pre-Compiled Constraint Evaluator), with cross-sector batching already delivering measurable throughput gains on production hardware.

From Architecture to Throughput: The Complete Story of Phase 3 Cross-Sector Batching 2715 words

Message Articles

Subagent Sessions