Skip to content

Accept gate callbacks in the extractor - #33

Merged
0xddom merged 211 commits into
mainfrom
shankara/gate-callbacks-on-cli2
Oct 16, 2026
Merged

0xddom merged 211 commits into
mainfrom
shankara/gate-callbacks-on-cli2

Conversation

@shankarapailoor

@shankarapailoor shankarapailoor commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

Stacked on #15 (dani/cargo-haloumi-2). This replaces #28, which was based on #19.

This lets circuits pass gate callbacks to the extractor. The SHA3 demo needs it to replace the 27-ordering determinism() lookup axioms with one bootstrap axiom per enabled gate row.

  • Extractor::extract_circuit_with_callbacks(circuit, lookups, gates): IRGenParams already takes gate callbacks, but the extractor had no way to pass them in. extract_circuit now calls this with no gate callbacks.
  • GateScope::enabled_rows(poly): returns the rows where every selector multiplying the whole polynomial is enabled. It uses the same rule as the lookup row filter (find_selector_factors). This lets patterns outside ir-gen find where a gate is enforced, since region_rows is crate-private.

Results with the demo's BootstrapAxioms pattern on top of this:

Harness Bootstrap axioms Picus
keccakf 2,065 (was ~550K) all modules verified
sha3/digest_1 2,065 all modules verified

Each keccakf harness's LLZK output is ~17 MB, down from ~1 GB. Picus gives the same result with --no-solver and with cvc5.

It builds on dani/cargo-haloumi-2 @ 2aa4a22. cargo test -p haloumi-ir-gen --all-features passes, and clippy and nightly rustfmt report nothing on the changed files.

🤖 Generated with Claude Code

0xddom and others added 23 commits October 13, 2026 20:00
The runner always passed --llzk-field-name to LLZK as a builtin field, so
circuits over other primes could not be emitted and a mislabeled field was
silently accepted. For example, a circuit over BLS12-381's scalar field
labeled `bn254` produced LLZK over BN254's prime.

Builtin names are now checked against the circuit's prime and rejected on
a mismatch. Any other name defines a field with the circuit's prime.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Lookup IR was instantiated on every row of a group, including rows where
all lookup selectors are off, such as the rows of table regions. Those
copies fold away later, but only after being fully materialized; on the
packed SHA3 circuit IR generation ran out of memory (>22 GB).

A lookup is now vacuous on a row when a selector multiplying every one of
its inputs is disabled there, and rows where every lookup is vacuous are
skipped. A selector that only appears inside a sum, as in
`q * a + (1 - q) * b`, does not gate the lookup, and lookups without a
gating selector are kept on every row.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@0xddom
0xddom force-pushed the dani/cargo-haloumi-2 branch from 85524a8 to 2aa4a22 Compare October 13, 2026 18:01
IRGenParams already takes gate callbacks, but the extractor had no way to
pass them, so circuits could not customize how their gates are lowered.
Add Extractor::extract_circuit_with_callbacks, which takes gate callbacks
next to the lookup callbacks; extract_circuit delegates to it without any.

Add GateScope::enabled_rows, so that patterns outside ir-gen can find the
rows where a gate is enforced. Like the lookup row filter, a row counts as
enabled when every selector multiplying the whole polynomial is enabled.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@shankarapailoor
shankarapailoor force-pushed the shankara/gate-callbacks-on-cli2 branch from 2fd8ed6 to 2e979ea Compare October 13, 2026 18:37
Base automatically changed from dani/cargo-haloumi-2 to main October 16, 2026 12:51
@0xddom
0xddom merged commit 96f654a into main Oct 16, 2026
6 checks passed
@0xddom
0xddom deleted the shankara/gate-callbacks-on-cli2 branch October 16, 2026 13:04
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