Repository navigation
Skip lookup rows where every lookup is disabled - #19
Merged
Merged
Conversation
Selective backport of core/src changes from e4df243.
0xddom
changed the base branch from
dani/cargo-haloumi
to
shankara/llzk-non-builtin-field
October 2, 2026 10:07
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>
0xddom
force-pushed
the
shankara/llzk-non-builtin-field
branch
from
October 13, 2026 18:00
f19a753 to
f42ac56
Compare
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
force-pushed
the
shankara/skip-vacuous-lookup-rows
branch
from
October 13, 2026 18:01
36e5db0 to
3e78151
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
codegen_lookup_invocationsclones the lookup template onto every row of a group and only then binds it to the row. Rows where every lookup selector is off still get a full copy, which is folded away much later. For circuits with large table regions this dominates memory: on the packed SHA3 circuit (sha3/digest_1/sha3/byte), IR generation ran out of memory (>22 GB). Its 12,287-row spread table region alone produced 3.9M lookup statements, none of them live.Gates already skip rows whose selectors are disabled; lookups did not.
Change
Before cloning, compute for each lookup the selectors that multiply every input (
find_selector_factors), and skip a row when every lookup has such a selector disabled on it. In that case all inputs of every lookup are zero, so each lookup only checks the all-zero tuple.The check is conservative:
a * b→ union of factors,a + b→ intersection), soq * a + (1 - q) * bis never skipped;Skipping only removes constraints, so the IR can only gain spurious solutions, never lose real ones. If a table lacked the all-zero tuple, disabled rows would be unsatisfiable in the circuit, and dropping them can only cause a false alarm downstream.
Results (SHA3 harness)
Testing
find_selector_factors(products, sums, negation/scaling,q * a + (1 - q) * b).cargo test -p haloumi-ir-gen --all-featurespasses.Notes
cargo clippy -p haloumi-ir-gen -- -Dwarningsandcargo +nightly fmt --checkalready fail ondani/cargo-haloumi, for code this PR does not touch (gates/rewrite.rs:104,ctx.rs:139,patterns.rs:86, and 12 formatting diffs). The files changed here are clippy- and fmt-clean.FallbackGateRewriterusesfind_selectors(any selector mentioned) together withgate_is_disabled, so it may skip a gate likeq * a + (1 - q) * bon rows whereqis off, and a gate with no selector on every row. That's not addressed here;find_selector_factorscould be reused for it.🤖 Generated with Claude Code