Dynamic spread table width + Ch algebraic optimization#295
Merged
Conversation
added 2 commits
February 18, 2026 12:11
Bisht13
requested changes
Feb 18, 2026
Bisht13
approved these changes
Feb 18, 2026
dcbuild3r
pushed a commit
that referenced
this pull request
May 16, 2026
Dynamic spread table width + Ch algebraic optimization
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.
Summary
Replaces the hardcoded 8-bit spread table with a cost-model-driven dynamic width selection. A new
calculate_spread_witness_costfunction estimates total witness cost across table overhead, inline witnesses, and LogUp queries for each candidate width (2–20 bits), andget_optimal_spread_widthpicks the minimum. All spread internals are generalized from fixed 4-byte chunks to variable-width chunks (subchunks,spread_decompose,pack_chunks,spread_from_chunk_spreads). The chosen width is displayed incircuit_statsoutput.Reduces
Ch(e,f,g)from 3 spread_decompose calls to 2 + one algebraic constraint, using the identityCh = (e&f) + g - (e&g). Saves ~39 witnesses/round (~2,496/compression) from eliminated spread decomposition and lookups. Dead code removed:spread_not_terms,spread_from_chunk_spreads,SPREAD_ALL_ONES.Benchmarks
35 SHA256 compressions (spread width: 8-bit → 16-bit)
1 SHA256 compression (spread width: 8-bit → 11-bit)