Learn Locally, Recurse Globally: Neural Circuit Synthesis Beyond Training Depth

Emile R RichardNeurIPS 2026

TL;DR

Neural networks are notoriously bad at extrapolating to problems harder or deeper than what they saw during training. Instead of fighting this limitation with bigger models or trickier training, this paper embraces it—wrapping a tiny, locally accurate Transformer inside a classical algebraic loop that breaks hard logical problems into bite-sized pieces. Tested on Boolean circuit synthesis, a model trained only on shallow circuits (depth $\le 2$) solves circuits $5\times$ deeper with 100% accuracy, offering a crisp blueprint for neuro-symbolic reasoning harnesses.

What Problem Does This Paper Address?

If you train a Transformer by gradient descent on problems up to a certain complexity, it generalizes wonderfully within that boundary, and falls apart just outside it. Even when a globally valid rule can technically be represented by the architecture, gradient descent prefers "simple" smooth shortcuts that match the training depth rather than discovering the true recursive rule.

Instead of asking "How do we force a neural network to extrapolate?", author Emile Richard flips the question: Accepting that neural networks only generalize locally, how do we design a system around them that extrapolates globally?

To study reasoning without the messy confounds of natural language, the paper uses Boolean circuit synthesis from truth-tables—turning a table of $0$s and $1$s into a working arrangement of AND, OR, XOR, and NOT gates. Here, verification is exact, and circuit depth (how many layers of gates a signal passes through) is a clean dial for compositional difficulty.

Methods

The paper introduces the learn locally, recurse globally paradigm, pairing a standard neural model with two symbolic outer loops rooted in classical hardware design.

  1. The Local Learner (New Encoding, Standard Training): A compact 2.2M-parameter encoder-decoder Transformer reads a truth-table and autoregressively emits a circuit. Its clever trick is a strided positional encoding, which keeps cell indices consistent regardless of how many inputs ($n \le 5$) or outputs ($m \le 5$) are active—letting one model handle sub-tables of varying sizes seamlessly. Strided positional encoding allows one model to handle truth-tables of varying input/output sizes without re-indexing.
Strided positional encoding allows one model to handle truth-tables of varying input/output sizes without re-indexing.
  1. XOR Residual Refinement (Extrapolating in Depth): When given a deep circuit's truth-table, the shallow-trained model makes a decent guess, leaving some rows wrong. Because Boolean functions form a vector space over $\text{GF}(2)$ (where XOR, written $\oplus$, acts as both addition and subtraction), the exact error is simply the residual truth-table $R = Y \oplus \hat{Y}$. The outer loop feeds this sparse residual back into the same model, accepting steps that shrink the error count, and XORs all the resulting shallow circuits together. The XOR residual refinement loop iteratively feeds remaining truth-table errors back into the shallow-trained Transformer.
The XOR residual refinement loop iteratively feeds remaining truth-table errors back into the shallow-trained Transformer.
  1. Projection Loop (Extrapolating in Width/Arity): What if a truth-table has more than 5 input variables ($n > 5$)? The encoder literally cannot read it. Inspired by classical Ashenhurst-Curtis decomposition, the outer loop searches subsets of 5 variables, collapses the wider table onto them using a majority vote (majority marginal), synthesizes a sub-circuit for that 5-variable view, and subtracts it out.

Both loops finish with a guaranteed safety net (SOP completion), which writes any stubbornly remaining 1s as brute-force minterms, guaranteeing exactness and termination.

Datasets

  • Synthetic Training Corpus: $2 \times 10^7$ randomly sampled, greedily simplified circuits of depth $q \in \{1, 2\}$ across 20 input/output shapes ($n \in \{2..5\}, m \in \{1..5\}$).
  • Decontaminated Depth Test Sets: ~900–964 unseen random circuits per depth at $q_{\text{test}} \in \{2, 4, 6, 8, 10\}$.
  • Structured & Real-World Logic: Four structured circuit families (parity, multiplexer, adder, cryptographic S-box), 4 full EPFL combinational benchmarks (those small enough to have readable truth-tables), and 10,340 single-output logic cones ($8 \le n \le 13$ inputs) extracted from 16 EPFL chip designs.

Key Insights and Ideas

  • Boosting over $\text{GF}(2)$: XOR refinement is essentially gradient boosting in binary logic! A "weak" shallow learner chips away at the residual error, and because residual errors get sparser at each step, they effectively look like simpler, in-distribution functions to the Transformer.
  • Flat Depth Scaling: Because the final circuit is an XOR tree of $T$ shallow circuits, its depth grows logarithmically ($\approx q_{\text{train}} + \lceil \log_2 T \rceil$), staying remarkably shallow even when synthesizing deeply nested target functions.
  • Circuit Size Doesn't Dictate Reachability at High Width: When projecting wide tables down to 5 variables, structure matters more than gate count. A single wide AND gate ($x_1 \wedge \dots \wedge x_N$) has only one 1 in its entire truth-table—so every 5-variable majority vote comes up 0, paralyzing the loop! Conversely, an XOR chain of arbitrarily many 5-variable blocks is recovered cleanly step-by-step.

Key Results

  • Perfect Depth Extrapolation: At training depth ($q=2$), single-pass error is 0.00%. At depths $4$ to $10$, single-pass error jumps to 5.87%–7.61%, whereas XOR refinement achieves 0.00% error across all depths in just 2.24 to 2.62 iterations on average.
  • Shallower Circuits: Counting unbounded fan-in gates, XOR refinement at depth 10 produces circuits of depth 3.89 (20.23 gates) vs. 7.79 (24.27 gates) for the standard academic synthesis tool ABC (resyn2). (Note: Measured in ABC's native 2-input And-Inverter Graph units, the neural outputs are 1.9–2.7$\times$ larger).
  • Higher-Arity Real Logic: On 8-to-13-input real design cones, a parity projection solves 0 cones, while the majority projection removes 82% of residual errors, producing circuits 2.9$\times$ smaller than brute-force SOP fallback.
  • Speed Trade-off: This is a reasoning study, not an EDA speed demon—XOR refinement takes ~620–710 ms per circuit on Apple Silicon, compared to ~1.2 ms for ABC.

Limitations and Future Work

  • The Truth-Table Bottleneck: Requiring a full truth-table caps the entire framework at roughly $n \le 20$ inputs ($2^{20}$ rows), leaving 16 of 20 full EPFL benchmarks out of reach.
  • System vs. Model Credit: 100% exactness is guaranteed by the deterministic SOP fallback, meaning exactness is a property of the harness, while the neural network determines how compact the result is. Furthermore, early attempts to replace the outer loop with looped Transformers (ACT) or RL policies (PPO) for variable selection failed to beat simple greedy heuristics.
  • Future Directions: Extending the framework to partial or noisy truth-tables—where exact verification on all rows is impossible, turning the neural network's learned prior from a mere compressor into the primary engine of generalization.

Summary updated

BibTeX
@inproceedings{richard2026learn,
  author = {Emile R Richard},
  title = {{Learn Locally, Recurse Globally: Neural Circuit Synthesis Beyond Training Depth}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2026},
  url = {https://openreview.net/forum?id=3Q6vM6CNIM},
}
Figure