Skip to content

Bounded-width VE canonicalizer (representation preprocessing)#39

Merged
isPANN merged 1 commit into
mainfrom
representation-preprocessing
Jun 24, 2026
Merged

Bounded-width VE canonicalizer (representation preprocessing)#39
isPANN merged 1 commit into
mainfrom
representation-preprocessing

Conversation

@isPANN

@isPANN isPANN commented Jun 24, 2026

Copy link
Copy Markdown
Collaborator

Summary

Adds a static, width-aware constraint-network canonicalizer — bounded-width variable elimination — as a preprocessing step, plus the supporting selector and representation widening. Eliminating structurally-cheap variables before search shrinks the branch set and gives a several-fold end-to-end speedup on factoring (4.5–9.2× median at 16–20 bit), with answers read straight off the reduced network.

What's in src/

  • preprocessing/canonicalize.jlbounded_ve_canonicalize(cn; budget_B, protected, order=:weighted_min_fill). Generalizes precontract_degree2! from "eliminate any degree-2 variable" to "eliminate any variable whose elimination width stays ≤ budget_B, in weighted-min-fill order". budget_B is the single fine↔coarse knob. Unlike degree-2-greedy (which raised treewidth), min-fill ordering with a per-step width cap cuts the treewidth proxy 50–70%.
  • Protected read-out variables: protected variables (e.g. factor bits) are never eliminated, so they survive into the reduced network and their values are read directly via result.orig_to_newno variable-elimination back-substitution.
  • DiffLookaheadSelector (branch_table/selector.jl): difficulty-guided lookahead selector that cuts the search tree vs MostOccurrenceSelector.
  • TensorData config indices widened UInt16 → UInt32 (core/static.jl, branching/propagate.jl, branch_table/contraction.jl): lifts the per-tensor arity cap from 16 to 32 so the canonicalizer can use larger budgets.

budget_B is a plain hyperparameter.

Tests

  • New test/canonicalize.jl: canonicalizing a factoring instance preserves satisfiability, keeps the protected factor-bit variables alive, shrinks the branch set, and the factors are read off the solution (a*b == N). 16/16 pass. Runs early in runtests.jl so the suite reaches it before the cadical-dependent solve_factoring test.
  • The only local suite error is the pre-existing solve_factoring cadical path (missing libcadical_mine.dylib), unrelated to this branch.

🤖 Generated with Claude Code

Static, width-aware constraint-network preprocessing. `bounded_ve_canonicalize`
(src/preprocessing/canonicalize.jl) generalizes `precontract_degree2!` from
"eliminate any degree-2 variable" to "eliminate any variable whose elimination
width stays <= budget_B, in weighted-min-fill order". `budget_B` is the single
fine<->coarse knob; unlike degree-2-greedy (which raised treewidth), min-fill
ordering with a per-step width cap cuts the treewidth proxy 50-70%, shrinking
the branch set and giving a several-fold end-to-end speedup on factoring.

Protected read-out variables (e.g. factor bits) are never eliminated, so they
survive into the reduced network and are read directly off the solution via
`orig_to_new` -- no variable-elimination back-substitution.

Supporting changes:
- DiffLookaheadSelector (branch_table/selector.jl): difficulty-guided lookahead
  selector that cuts the search tree vs MostOccurrenceSelector.
- TensorData config indices widened UInt16 -> UInt32 (core/static.jl,
  branching/propagate.jl, branch_table/contraction.jl), lifting the per-tensor
  arity cap from 16 to 32 so the canonicalizer can use larger budgets.
- test/canonicalize.jl: canonicalizing a factoring instance preserves
  satisfiability, keeps protected factor-bit vars alive, shrinks the branch
  set, and reads correct factors off the solution (a*b==N). Runs early in
  runtests.jl so the suite reaches it before the cadical-dependent test.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@isPANN
isPANN force-pushed the representation-preprocessing branch from 5d2f732 to eb47a15 Compare June 24, 2026 19:41
@isPANN
isPANN merged commit 56e28c6 into main Jun 24, 2026
3 checks passed
@isPANN
isPANN deleted the representation-preprocessing branch June 25, 2026 05:59
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.

1 participant