perf(gkr): apply Gru24 Section 3.2 to single-source sumcheck levels#1744
perf(gkr): apply Gru24 Section 3.2 to single-source sumcheck levels#1744peter941221 wants to merge 1 commit intoConsensys:masterfrom
Conversation
|
Thank you @peter941221 for the submission! This duplicates #1742 as far as I can see. |
|
Thanks for the feedback! I agree there is significant overlap with #1742. My intent here was to validate the narrower single-source-only path and keep the protocol / schedule surface area small. If you'd prefer to keep the main optimization consolidated in #1742, I'm happy to rework this into a supporting PR that contributes any useful pieces (for example tests, eligibility plumbing, or narrower verifier/prover scaffolding) rather than competing with it. On the benchmark side, the panic reproduces for me on clean HEAD as well, so I didn't want to treat it as a branch-specific signal. I haven't yet tried reducing the size constant, but I'm happy to do that and report back. |
Summary
This implements a narrow v1 of the optimization discussed in
#1724.For
GkrSumcheckLevels whose claims all refer to the same distinctGkrClaimSource, we switch the zero-check round relation from the legacy unweighted form to the weighted Section 3.2 recurrence from Gru24. This lets the prover send a degree-dround polynomial instead of degree-d+1for those eligible levels.Folded multi-source levels keep the legacy path unchanged.
What changes
constraint.GkrSumcheckLevel.SingleClaimSource()ZeroCheckDegree(...)only for eligible levelsWhy the scope is narrow
Section 3.2 is not just a local prover micro-optimization. It changes the round relation seen by the verifier.
In gnark's current GKR schedule, some levels fold claims coming from multiple distinct evaluation points. I did not try to force the new recurrence onto those shapes in this PR. Instead, the optimization is only enabled when the whole level collapses to one distinct source.
That keeps the patch aligned with the paper identity without widening into a larger schedule/protocol refactor.
Evidence
The regenerated test vectors show the expected proof-size reduction only on eligible levels. For example:
single_mul_gate_two_instances.json: total partial-sum coefficient count3 -> 2single_mimc_gate_two_instances.json:8 -> 7single_mimc_gate_four_instances.json:16 -> 14Non-eligible / legacy-only vector shapes stayed unchanged.
Validation
go test ./internal/gkr/... -count=1go run .frominternal/gkr/test_vectorsI also added a
TestZeroCheckDegreeDispatchassertion to the generated curve-test packages to check that:And I added direct
coeff == 1reconstruction tests for both verifier surfaces:Notes
BenchmarkGkrMimc17benchmark currently panics on my Windows setup on both cleanHEADand this branch, so it did not provide a trustworthy regression signal for this change.Note
Medium Risk
Touches core GKR sumcheck prover/verifier logic and changes proof serialization/verification semantics for a subset of levels, so subtle soundness or compatibility regressions are possible despite added tests.
Overview
Implements a single-claim-source fast path for GKR zero-check sumchecks:
GkrSumcheckLevel.SingleClaimSource()gates a Gru24 §3.2 recurrence that lets eligible levels send degree-dround polynomials instead of degree-d+1.This updates both prover and verifier (native backends, generator templates, and in-circuit verifier) to use a coefficient-aware reconstruction in
sumcheckVerify, adds an optimized proverroundPolynomialSingleSourceplus per-round eq-table factor stripping, and adjustsZeroCheckDegreeto return the reduced degree only for eligible levels.Adds targeted tests to ensure degree dispatch and coefficient-
1reconstruction correctness, and refreshes affected GKR test vectors to match the new proof shape.Written by Cursor Bugbot for commit 7ff05ef. This will update automatically on new commits. Configure here.