mlsanityData to 13 Oct 2026

Universal Transformers for Circuit Computations: Perfect Length Generalization in Tiny Transformers

arXiv 2608.31067 ↗First posted 31 Aug 2026cs.LGcited by 0

Not on the map. Why?

Abstract (arXiv)

Learning generalizable algorithmic computations remains a challenge for neural networks, as reflected in persistent failures on compositional and length generalization benchmarks. We present a provably correct, transformer parameterization (with only 280 learnable parameters for Boolean algebra tasks) capable of learning and evaluating problems of any depth or length. We assume inputs are fully parenthesized, well-formed expressions. Our approach conceptualizes algorithmic tasks as circuit models embedded in transformers, enabling depth-1 circuit reduction in a single forward pass. To achieve depth generalization, we introduce a positional encoding that tracks each gate's depth within the circuit, enabling the model to identify evaluable subexpressions at each iteration via masked hard attention, with O(n) per-iteration complexity via linear attention. Combined with an autonomous halting criterion, the model terminates after d iterations for problems of depth d, yielding O(n · d) total complexity. We show that training on shallow problem instances (depth 1 and depth 2) effectively recovers interpretable parameters that em snap into place, resulting in exact length generalization. Though we establish that our construction provably evaluates Boolean expressions -- a universal symbolic computation -- of arbitrary length perfectly, in other experiments we also demonstrate that our transformer variant can learn and generalize perfectly (100% accuracy) on other common length generalization benchmarks, including modular arithmetic and ListOps.

Key facts. No citing papers in the map yet (data through 13 Oct 2026). Builds on 42 of its 58 references that are in the map. First posted on arXiv 31 Aug 2026.

Builds on

42 of 58 references.

References · 42

  1. 2017Neural Discrete Representation Learningcited by 4,680
  2. 2021RoFormer: Enhanced Transformer with Rotary Position Embeddingcited by 4,628
  3. 2018How Powerful are Graph Neural Networks?cited by 4,373
  4. 2013Estimating or Propagating Gradients Through Stochastic Neurons for Conditional Computationcited by 2,056
  5. 2020Transformers are RNNs: Fast Autoregressive Transformers with Linear Attentioncited by 1,994
  6. 2021Show Your Work: Scratchpads for Intermediate Computation with Language Modelscited by 878
  7. 2022Recipe for a General, Powerful, Scalable Graph Transformercited by 709
  8. 2020A Generalization of Transformer Networks to Graphscited by 658
  9. 2020On the Bottleneck of Graph Neural Networks and its Practical Implicationscited by 629
  10. 2023Faith and Fate: Limits of Transformers on Compositionalitycited by 498
  11. 2019Analysing Mathematical Reasoning Abilities of Neural Modelscited by 333
  12. 2023The Impact of Positional Encoding on Length Generalization in Transformerscited by 322
30 more
  1. 2019Compositionality decomposed: how do neural networks generalise?cited by 264
  2. 2020COGS: A Compositional Generalization Challenge Based on Semantic Interpretationcited by 261
  3. 2023Looped Transformers as Programmable Computerscited by 228
  4. 2022Neural Networks and the Chomsky Hierarchycited by 216
  5. 2018Learning a SAT Solver from Single-Bit Supervisioncited by 198
  6. 2019What graph neural networks cannot learn: depth vs widthcited by 198
  7. 2023What Algorithms can Transformers Learn? A Study in Length Generalizationcited by 198
  8. 2021Thinking Like Transformerscited by 182
  9. 2018ListOps: A Diagnostic Dataset for Latent Tree Learningcited by 128
  10. 2021The Devil is in the Detail: Simple Tricks Improve Systematic Generalization of Transformerscited by 117
  11. 2023Randomized Positional Encodings Boost Length Generalization of Transformerscited by 116
  12. 2024Transformers Can Do Arithmetic with the Right Embeddingscited by 77
  13. 2021The Neural Data Router: Adaptive Control Flow in Transformers Improves Systematic Generalizationcited by 62
  14. 2023Positional Description Matters for Transformers Arithmeticcited by 56
  15. 2024Contextual Position Encoding: Learning to Count What's Importantcited by 54
  16. 2025A Little Depth Goes a Long Way: The Expressive Power of Log-Depth Transformerscited by 50
  17. 2023Masked Hard-Attention Transformers Recognize Exactly the Star-Free Languagescited by 48
  18. 2024A Formal Framework for Understanding Length Generalization in Transformerscited by 44
  19. 2024Learning to grok: Emergence of in-context learning and skill composition in modular arithmetic taskscited by 40
  20. 2024On Oversquashing in Graph Neural Networks Through the Lens of Dynamical Systemscited by 28
  21. 2025Lower Bounds for Chain-of-Thought Reasoning in Hard-Attention Transformerscited by 28
  22. 2024Universal Length Generalization with Turing Programscited by 25
  23. 2024Arithmetic Transformers Can Length-Generalize in Both Operand Length and Countcited by 18
  24. 2021Modeling Hierarchical Structures with Continuous Recursive Neural Networkscited by 15
  25. 2025Towards Combinatorial Interpretability of Neural Computationcited by 9
  26. 2024Transformers as Transducerscited by 8
  27. 2024ALTA: Compiler-Based Analysis of Transformerscited by 7
  28. 2024Quantifying artificial intelligence through algorithmic generalizationcited by 5
  29. 2023Efficient Beam Tree Recursioncited by 4
  30. 2024On the Design Space Between Transformers and Recursive Neural Netscited by 1

Built on by

Not cited yet.

Similar, not cited

Close in wording, no citation either way

  1. 2024Finding Transformer Circuits with Edge Pruning
  2. 2022Transformers Learn Shortcuts to Automata
  3. 2026A Sharper Picture of Generalization in Transformers
  4. 2026Barriers to Universal Reasoning With Transformers (And How to Overcome Them)
  5. 2024Principled Understanding of Generalization for Generative Transformer Models in Arithmetic Reasoning Tasks
  6. 2026Fixed Universal Transformers
  7. 2026Revisiting Padded Transformer Expressivity: Which Architectural Choices Matter and Which Don't
  8. 2021Saturated Transformers are Constant-Depth Threshold Circuits