Skip to content

[2/6] Speed up IPA generator collapse with batched GLV - #5

Merged
ValarDragon merged 1 commit into
mainfrom
agent/halo2-ipa-generator-collapse
Aug 12, 2026
Merged

ValarDragon merged 1 commit into
mainfrom
agent/halo2-ipa-generator-collapse

Conversation

@ValarDragon

@ValarDragon ValarDragon commented Aug 12, 2026 •

Copy link
Copy Markdown
Contributor

Main-line stack position: 2 of 6
Base: agent/pasta-batch-same-scalar
Original base: zcash/halo2 main@cafc26e269e4b1b123af8f2a0aa36bff6474448e
Migrates: zcash/halo2#927

Summary

Batch the scalar multiplications in each IPA generator-collapse round:

g_lo[i] = g_lo[i] + challenge * g_hi[i]

Every element in a round shares one public Fiat-Shamir challenge, so the
prover delegates the high-half products to the same-scalar hook from main-line
PR 1, adds the low-half points, and retains the existing batch normalization.
No secret scalar enters this variable-time path.

Repository main includes the Rust 1.88 update from libraries#2. This layer
makes no MSRV change; it enables pasta_curves/glv through the existing local
path dependency.

Measured impact

Original single-worker ABBA measurements on arm64:

Workload Native Batched GLV Reduction Speedup
Orchard, 2 Actions, k = 11 3.925 s 3.779 s 3.73% 1.039x
Synthetic Halo proof, k = 13 2.554 s 1.804 s 29.36% 1.416x
k = 13 generator collapse only 1.144 s 395.4 ms 65.44% 2.893x

Transactional Orchard bundles are padded to at least two Actions, so this
historical measurement is not a one-Action result. The Orchard and synthetic
circuits are not directly comparable. There is no direct verifier benefit;
verification uses heterogeneous-scalar MSMs.

Validation

The original patch passed Rust 1.63 workspace checks, release tests and
doctests, Clippy, Pallas/Vesta collapse-equivalence tests, and proof/verification
preflights for the k = 11 and k = 13 workloads.

The Rust 1.88 main-line stack also passed:

  • cargo +1.88 test -p halo2_proofs --release --lib
  • cargo +1.88 test -p halo2_proofs --release --no-default-features --lib
  • all-target/all-feature Clippy with -D warnings and only existing
    baseline lint categories allowed
  • cargo +1.88 test -p orchard --release

API surface

No public or pub(crate) Rust item, signature, visibility, enum variant, or
constructor changes, and no MSRV change; this layer inherits Rust 1.88 from
its base. halo2_proofs enables the Pasta glv dependency feature. Because
Halo re-exports Pasta, the enabled glv module is reachable through that
re-export.

@ValarDragon
ValarDragon force-pushed the agent/halo2-ipa-generator-collapse branch from 11eb4d9 to ec8c403 Compare August 12, 2026 12:13
@ValarDragon ValarDragon changed the title [2/9] Speed up IPA generator collapse with batched GLV [2/6] Speed up IPA generator collapse with batched GLV Aug 12, 2026
@ValarDragon
ValarDragon force-pushed the agent/halo2-ipa-generator-collapse branch from ec8c403 to 6d66405 Compare August 12, 2026 12:18
@ValarDragon
ValarDragon marked this pull request as ready for review August 12, 2026 12:57
@ValarDragon ValarDragon changed the title [2/6] Speed up IPA generator collapse with batched GLV [2/5] Speed up IPA generator collapse with batched GLV Aug 12, 2026
@ValarDragon

Copy link
Copy Markdown
Contributor Author

@v12sec pls review

@v12-auditor

v12-auditor Bot commented Aug 12, 2026 •

Copy link
Copy Markdown

Note

Complete: Audit complete. V12 found one issue worth reviewing.

Open the full results here.

FindingSeverityDetails
F-214263 🟡 Medium
Unbounded GLV batches exhaust prover memory

parallel_generator_collapse passes each complete scheduler-sized generator chunk to the GLV-backed same-scalar hook, whose Pasta implementation materializes eight projective window entries, eight affine entries, and an eight-affine-point table for every input while the caller's scaled output remains live. This creates approximately 1,888 bytes of transient storage per collapsed generator, compared with 96 bytes in the replaced per-point implementation. In the first round of a supported k = 20 proof, the half-vector contains 524,288 generators, so the collapse scratch alone peaks at approximately 944 MiB instead of 48 MiB, before the parameter vectors and prover state are counted. parallelize does not impose a memory-oriented maximum batch size, and the supported single-worker configuration submits the entire half-vector in one batch. Because all allocations are infallible Vec allocations, a valid large proof request can abort or OOM-kill a proving worker rather than returning an error.

Analyzed one file, diff 4b767d3...6d66405.

@v12-auditor

v12-auditor Bot commented Aug 12, 2026

Copy link
Copy Markdown

Warning

A run is already in progress for this PR. View run

@ValarDragon ValarDragon changed the title [2/5] Speed up IPA generator collapse with batched GLV [2/6] Speed up IPA generator collapse with batched GLV Aug 12, 2026
Comment on lines +161 to +162
// The Fiat-Shamir challenge is public, so variable-time scalar
// multiplication is appropriate here.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Honestly, we don't really make these kinds of distinctions elsewhere in the API. I don't think it really matters.

Base automatically changed from agent/pasta-batch-same-scalar to main August 12, 2026 16:58
@ValarDragon
ValarDragon force-pushed the agent/halo2-ipa-generator-collapse branch from 6d66405 to 307f779 Compare August 12, 2026 16:58
@ValarDragon

Copy link
Copy Markdown
Contributor Author

Investigated v12 warning, it seems fine.

@v12-auditor

v12-auditor Bot commented Aug 12, 2026 •

Copy link
Copy Markdown

Caution

Cancelled: This audit was cancelled before completion.

Open the run details here.

Batch the public same-scalar multiplications in each IPA generator-collapse round so Pasta curves can reuse GLV decomposition and table setup.

Enable the vendored pasta_curves glv feature. The stack inherits Rust 1.88 from #2.

Co-Authored-By: OpenAI Codex <[email protected]>
@ValarDragon
ValarDragon force-pushed the agent/halo2-ipa-generator-collapse branch from 307f779 to d5f4036 Compare August 12, 2026 23:30
@ValarDragon
ValarDragon merged commit a6f3a2f into main Aug 12, 2026
35 checks passed
@ValarDragon
ValarDragon deleted the agent/halo2-ipa-generator-collapse branch August 28, 2026 18:50
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.

2 participants