Skip to content

Comments

feat: reduce CRS and polynomial memory for non-ZK proofs#20731

Open
johnathan79717 wants to merge 2 commits intomerge-train/barretenbergfrom
jh/crs-memory-optimization-v2
Open

feat: reduce CRS and polynomial memory for non-ZK proofs#20731
johnathan79717 wants to merge 2 commits intomerge-train/barretenbergfrom
jh/crs-memory-optimization-v2

Conversation

@johnathan79717
Copy link
Contributor

Summary

  • Size the CRS at max_end_index (actual data extent) rather than dyadic_size for non-ZK proofs
  • Make Shplonk quotient polynomial round_up_power_2 conditional on having non-dyadic claims (Libra/sumcheck), which only exist in the ZK path
  • Size PolynomialBatcher's temporary polynomials (batched_unshifted, batched_to_be_shifted, A_0_pos, A_0_neg) at actual_data_size rather than full_batched_size

Benchmark results

Chonk AMM flow (ecdsar1+amm_add_liquidity_1_recursions+sponsored_fpc), max_end_index=278,429 vs dyadic_size=524,288:

bb prove --scheme chonk --ivc_inputs_path .../ecdsar1+amm_add_liquidity_1_recursions+sponsored_fpc/ivc-inputs.msgpack -o /tmp/out
Run 1 (KB) Run 2 (KB) Run 3 (KB) Avg (MiB)
Before 702,660 704,044 691,328 682.7
After 657,096 672,916 677,508 654.8
Savings 45,564 31,128 13,820 ~28 MiB (~4.1%)

Test plan

  • ultra_honk_bench at 2^20 passes (no crash)
  • ultra_honk_tests: 260 passed, 5 skipped
  • commitment_schemes_tests: 82 passed, 2 skipped
  • CI passes

Size the CRS at max_end_index (actual data extent) rather than
dyadic_size for non-ZK proofs. The Shplonk quotient polynomial
round_up_power_2 is now conditional on having non-dyadic claims
(Libra/sumcheck), which only exist in the ZK path.

Also size PolynomialBatcher's temporary polynomials (batched_unshifted,
batched_to_be_shifted, A_0_pos, A_0_neg) at actual_data_size rather
than full_batched_size, reducing transient memory allocations.

Measured ~16-18 MiB peak RSS savings on Chonk AMM flow
(max_end_index=278,429 vs dyadic_size=524,288).
The previous commit accidentally changed get_polynomial_size() from
virtual_size() to size(), which breaks relation correctness checks
that iterate over the full dyadic circuit size.
@johnathan79717 johnathan79717 requested review from ledwards2225 and removed request for ledwards2225 February 20, 2026 16:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant