Skip to content

feat: Compiled Gates for GKR#1676

Merged
Tabaie merged 145 commits intomasterfrom
feat/gkr/compiled-gates
Jan 21, 2026
Merged

feat: Compiled Gates for GKR#1676
Tabaie merged 145 commits intomasterfrom
feat/gkr/compiled-gates

Conversation

@Tabaie
Copy link
Copy Markdown
Contributor

@Tabaie Tabaie commented Jan 12, 2026

"Compile" GKR gates into a simple bytecode to reduce frontend.Variable conversions in the backend.

Compared to the baseline #1616 on a MiMC hash of length 65536:
2.9% faster (3.64s vs 3.75s)
5.0% less memory (1.73 GB vs 1.82 GB)
84.2% fewer allocations (696K vs 4.42M - 6.3x reduction)


Note

Introduces compiled gates and evaluator-based execution to reduce conversions and allocations across GKR.

  • Compile gate functions once (gkrtypes.CompileGateFunction) and store in registry; replace gateVerifier with curve-specific GateTester using compiled gates
  • Add stack-based gateEvaluator and gateEvaluatorPool for executing compiled gate bytecode; remove frontend.Variable-based gate evaluation paths
  • Update prover/verification paths (computeGJ, next, Complete, solver hints) to push inputs and evaluate via gateEvaluator, with memory pooling via polynomial.Pool
  • Adjust tests/templates to new GateTester API (IsAdditive, FindDegree, VerifyDegree, Equal) and compiled gates
  • Minor API changes: gkrtypes.NewGate now accepts compiled gate; registry enforces equality/degree via GateTester

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

@Tabaie Tabaie changed the base branch from perf/mem/gkr-exp17 to master January 13, 2026 02:16
@Tabaie Tabaie marked this pull request as ready for review January 14, 2026 02:34
Comment thread internal/generator/backend/template/gkr/gkr.go.tmpl Outdated
Comment thread internal/generator/backend/template/gkr/gkr.go.tmpl
Comment thread internal/gkr/bn254/gkr.go
Comment thread internal/gkr/bn254/gkr.go
@Tabaie Tabaie requested a review from gbotrel January 14, 2026 03:10
Comment thread internal/generator/backend/template/gkr/gkr.go.tmpl
cursor[bot]

This comment was marked as outdated.

cursor[bot]

This comment was marked as outdated.

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.

Comment thread internal/gkr/bls12-377/gkr.go
@Tabaie Tabaie merged commit de5d7ed into master Jan 21, 2026
13 checks passed
@Tabaie Tabaie deleted the feat/gkr/compiled-gates branch January 21, 2026 21:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feat: gkr PRs related to GKR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants