Transformers in Uniform TC$^0$

David Chiang

TL;DR

This paper proves that transformer encoders remain strictly bound within the circuit complexity class $\mathsf{TC}^0$ even when granted exponentially more arithmetic precision than previously analyzed. By showing that average-hard attention with exact rational arithmetic and softmax attention with polynomial bits of precision (or $2^{-O(\text{poly}(n))}$ error) cannot escape $\mathsf{DLOGTIME\text{-}uniform\ TC}^0$, the author firmly establishes that transformers cannot solve $\mathsf{NC}^1$-complete problems (like Boolean formula evaluation) unless $\mathsf{TC}^0 = \mathsf{NC}^1$.

What Problem Does This Paper Address?

Prior work in formal language theory established that transformer encoders—both average-hard attention transformers (AHATs) and standard softmax-attention transformers (SMATs)—fall within $\mathsf{TC}^0$ (the class of problems solvable by constant-depth, polynomial-size circuits with majority gates). This has significant implications: if $\mathsf{TC}^0 \neq \mathsf{NC}^1$ (a widely believed conjecture in computational complexity), transformers cannot solve inherently sequential or tree-structured problems, such as evaluating balanced Boolean formulas.

However, earlier proofs relied heavily on a restrictive assumption: arithmetic operations were performed using low-precision floating-point numbers with only $O(\log n)$ bits. This left open a critical question: Does the $\mathsf{TC}^0$ bottleneck stem from the architectural nature of attention, or is it merely an artifact of coarse precision?

Methods

The author demonstrates that transformers can be simulated within $\mathsf{DLOGTIME\text{-}uniform\ TC}^0$ across multiple computational settings:

  1. Exact Rational Arithmetic for AHATs: Instead of floating-point approximations, intermediate values in an AHAT without layer normalization are tracked exactly as rational pairs $\langle a, b \rangle$. Using known constant-depth threshold circuit algorithms for iterated integer multiplication and division, the author shows that through $L$ layers, numbers grow to at most $O(p n^L)$ bits—still polynomial in $n$—and remain computable in $\mathsf{TC}^0$.
  2. High-Precision Floating-Point Iterated Addition: For SMATs, adding $n$ numbers with $O(\text{poly}(n))$ precision in $\mathsf{TC}^0$ is challenging. The author introduces a block-partitioning algorithm: summands with close exponents are grouped into blocks that are evaluated exactly, while blocks with vastly smaller exponents are safely truncated or examined purely to break rounding ties.
  3. Taylor Approximations for Non-Linearities: Operations like $\sqrt{x}$ (for layer normalization) and $\exp(x)$ (for softmax) are evaluated via truncated Taylor series up to $N = O(\text{poly}(n))$ terms, yielding relative errors bounded by $2^{-p}$.
  4. Error Propagation Analysis: The paper shifts from hardware-specific precision models to an analytical error-margin formulation. By computing Lipschitz bounds for transformer operations (addition, multiplication, inverse square root, softmax), the author shows that errors compound predictably, requiring only $O(\text{poly}(n))$ internal precision to guarantee a final absolute error of at most $2^{-O(\text{poly}(n))}$.

Datasets

Not discussed in the paper (this is a theoretical paper in computational complexity with no empirical datasets).

Key Insights and Ideas

  • Precision Isn’t a Loophole: Scaling precision from logarithmic ($O(\log n)$ bits) to polynomial ($O(\text{poly}(n))$ bits) does not increase the computational complexity class of transformers.
  • Complete Regular Language Characterization for AHATs: Every regular language is either in $\mathsf{ACC}^0$ or is $\mathsf{NC}^1$-complete. Because AHATs can express all regular languages in $\mathsf{ACC}^0$ (via linear temporal logic with counting) and cannot compute $\mathsf{NC}^1$-complete languages, this work effectively finalizes the boundary of regular languages recognizable by AHATs.
  • Margin-Based Expressivity: Instead of debating whether hardware rounds after every operation or accumulates floating-point sums, expressivity can be cleanly phrased in terms of separation margins: any language recognizable by an exact SMAT with an acceptance margin of at least $2^{-O(\text{poly}(n))}$ resides in $\mathsf{TC}^0$.

Key Results

  • Theorem 7: AHATs with rational weights, $O(\text{poly}(n))$-bit positional encodings, and no layer normalization compute languages in $\mathsf{DLOGTIME\text{-}uniform\ TC}^0$ with zero approximation error.
  • Theorem 13: SMATs with $O(\text{poly}(n))$ bits of floating-point precision fall within $\mathsf{DLOGTIME\text{-}uniform\ TC}^0$.
  • Theorem 14 & Corollary 16: A SMAT can be approximated within absolute error $2^{-O(\text{poly}(n))}$ in $\mathsf{TC}^0$. Consequently, any language recognized by an exact SMAT with margin $\epsilon(n) \in 2^{-O(\text{poly}(n))}$ is in $\mathsf{DLOGTIME\text{-}uniform\ TC}^0$.

Limitations and Future Work

  • Unrealistic Precision: Polynomial bit-precision ($n^k$ bits) far exceeds standard machine precision (16-, 32-, or 64-bit floats), serving primarily as a theoretical upper bound rather than a practical model of implementation.
  • Layer Normalization in AHATs: The exact-arithmetic result for AHATs excludes layer normalization, as square roots generally produce irrational numbers.
  • Tighter Margin Bounds: The author suggests that an analogous error analysis could show that achieving $1/O(\text{poly}(n))$ error requires only $O(\log n)$ bits of precision. Investigating the expressivity of SMATs restricted to inverse-polynomial margins represents an intriguing direction for future research.

Summary updated

BibTeX
@article{chiang2024transformers,
  author = {David Chiang},
  title = {{Transformers in Uniform TC$^0$}},
  journal = {Accepted by TMLR},
  year = {2024},
  url = {https://openreview.net/forum?id=ZA7D4nQuQF},
}
Figure