Skip to content

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

Aug 2026 · 0 citations · 58 references
Computer Science

TL;DR

Though the construction provably evaluates Boolean expressions -- a universal symbolic computation -- of arbitrary length perfectly, in other experiments it is demonstrated that the transformer variant can learn and generalize perfectly on other common length generalization benchmarks, including modular arithmetic and ListOps.

Abstract

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 \cdot 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.

View source

Similar papers

#machine learning Preprint Sep 2026

Length Generalization for Transformers via Compression

A polynomial length generalization bound for transformers if the authors adopt compressed strings, via a novel connection to power words is shown, which yields a fine-grained analysis of the C-RASP conjecture that resolves contradicting experimental evidence against it.

G. Zetzsche, Hong-Jian Jiang, Andy Yang et al. · 0 citations
Preprint Sep 2026

On the Turing Completeness of Transformers and Agents

It is shown that a single fixed finite precision transformer cannot memorize certain Turing machines with inputs of arbitrary length, such as the arithmetic; and a single fixed infinite precision transformer trained with a random algorithm is not Turing complete with probability one under reasonable conditions.

Y. Qiao, Li-Jia Yu, Rui-Chen Qiu et al. · 0 citations
#machine learning Preprint Sep 2026

Universality and Generalization of Causal Transformers Across Context Lengths

This work studies whether one masked transformer can approximate causal token-to-token maps uniformly over sequences of arbitrary length sampling a fixed normalized horizon, and characterizes the causal families admitting uniform approximation on these compact input classes by a single transformer with length-independe...

Takashi Furuya, Maarten V. de Hoop, Gabriel Peyré · 0 citations
#machine learning Preprint Aug 2026

Gated Recurrent Transformers: Expressive Depth through Recurrent Modulation

Scaling transformer language models creates an inherent tension between expressivity and memory efficiency. While unique weights across layers preserve functional specialization---from input-grounding to abstract refinement---they incur a substantial memory footprint. Conversely, standard depth-sharing enforces uniform...

Amr Hegazy, Amr Alanwar, Mostafa Elhoushi · 2 citations
Preprint Sep 2026

Unifying and Extending Strong Simulation of Quantum Circuits

We establish functional aggregate queries (FAQs) as a unifying language for exact classical simulation of quantum circuits. A circuit becomes a sum-product query: factors encode gates, internal wire variables are aggregated, and free boundary variables index transition amplitudes. The central insight is that distinct s...

F. Geerts, Rihan Hai, Matthias Lanzinger et al. · 0 citations
#machine learning Preprint Sep 2026

The Head Complexity of Boolean Functions in Single-Layer Attention

A compactness theorem shows that any function computable at all can be computed with embedding dimension and precision bounded by the discrete data of the task, namely, head count, alphabet size, and length.

R. Rajaraman, Ravi Sundaram, Amanuel Tesfaye · 1 citation

Related blog posts

We use cookies to run the site and, with your consent, for analytics and to show ads. See our Cookie Policy.