Explorerโ€บData Scienceโ€บMachine Learning
Research PaperResearchia:202609.01070

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

Takuya Ito

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 model...

Submitted: September 1, 2026Subjects: Machine Learning; Data Science

Description / Details

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)O(n) per-iteration complexity via linear attention. Combined with an autonomous halting criterion, the model terminates after dd iterations for problems of depth dd, yielding O(nโ‹…d)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.


Source: arXiv:2608.31067v1 - http://arxiv.org/abs/2608.31067v1 PDF: https://arxiv.org/pdf/2608.31067v1 Original Link: http://arxiv.org/abs/2608.31067v1

Please sign in to join the discussion.

No comments yet. Be the first to share your thoughts!

Access Paper
View Source PDF
Submission Info
Date:
Sep 1, 2026
Topic:
Data Science
Area:
Machine Learning
Comments:
0
Bookmark