Skip to content

perf: Factor Eq in ZeroCheck when possible#1742

Open
Tabaie wants to merge 18 commits intomasterfrom
perf/gkr/factor-eq
Open

perf: Factor Eq in ZeroCheck when possible#1742
Tabaie wants to merge 18 commits intomasterfrom
perf/gkr/factor-eq

Conversation

@Tabaie
Copy link
Copy Markdown
Contributor

@Tabaie Tabaie commented Mar 31, 2026

When a Zero-Check has only one "evaluation point", at every round a prefix of the eq term (containing an indeterminate) can be factored out and computed by the verifier. This reduces the number of Fiat-Shamir hashes benefitting the verifier directly (at the cost of a trivial amount of extra work to compute the eq terms at the end of a sum-check run). For the prover, 1/d+1 of the work each round will be saved.

BenchmarkGkrPoseidon2 was benchmarked on an hpc6a.48xlarge machine with the following results:

  ┌─────────────┬───────────────┬────────────────────┬──────────────────┬─────────────────┐
  │   Metric    │    master     │ perf/gkr/factor-eq │      Delta       │   Improvement   │
  ├─────────────┼───────────────┼────────────────────┼──────────────────┼─────────────────┤
  │ ns/op       │ 1,791,523,877 │ 1,522,833,929      │ -15.0%           │ 1.18x speedup   │
  ├─────────────┼───────────────┼────────────────────┼──────────────────┼─────────────────┤
  │ Constraints │ 3,547,650     │ 3,324,843          │ -6.3% (-222,807) │ 1.07x reduction │
  ├─────────────┼───────────────┼────────────────────┼──────────────────┼─────────────────┤
  │ B/op        │ 736,144,887   │ 724,871,928        │ -1.5% (-11.3 MB) │ 1.02x reduction │
  ├─────────────┼───────────────┼────────────────────┼──────────────────┼─────────────────┤
  │ allocs/op   │ 298,196       │ 281,781            │ -5.5% (-16,415)  │ 1.06x reduction │
  └─────────────┴───────────────┴────────────────────┴──────────────────┴─────────────────┘

Note

High Risk
Touches core GKR proving/verification and transcript-binding behavior; any mistake could break proof soundness or cause verifier/prover divergence despite being a performance-focused change.

Overview
Introduces constraint.GkrSingleSourceZeroCheckLevel and wires it into schedule serialization (marshal.go) and level dispatch in generated and curve-specific GKR backends.

Implements a new single-source zerocheck sumcheck variant that factors out the eq polynomial (precomputing suffix eq tables and adjusting prover/verifier round polynomials), while refactoring shared zerocheck setup into zeroCheckBase and consolidating verifier setup logic.

Also changes gateEvaluatorPool from a map-backed set to a slice-based stack for cheaper reuse, and moves the bulky zerocheck/sumcheck claim implementations out of gkr.go into sumcheck.go templates/generated code.

Written by Cursor Bugbot for commit ed90cd5. This will update automatically on new commits. Configure here.

@Tabaie Tabaie changed the title Perf/gkr/factor eq Factor Eq in ZeroCheck Mar 31, 2026
@Tabaie Tabaie linked an issue Mar 31, 2026 that may be closed by this pull request
@Tabaie Tabaie changed the title Factor Eq in ZeroCheck perf: Factor Eq in ZeroCheck Mar 31, 2026
@Tabaie Tabaie changed the title perf: Factor Eq in ZeroCheck perf: Factor Eq in ZeroCheck when possible Mar 31, 2026
@Tabaie Tabaie marked this pull request as ready for review March 31, 2026 04:45
Copy link
Copy Markdown

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

This reverts commit 3ce291a.
@Tabaie Tabaie requested review from ThomasPiellard and gbotrel April 1, 2026 00:52
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.

perf: GKR - Section 3.2 of Gru24

1 participant