Theoretical Constraints on the Expressive Power of $\mathsf{RoPE}$-based Tensor Attention Transformers
Xiaoyu Li, Yingyu Liang, Zhenmei Shi, Zhao Song, Mingda Wan
Introduction
Large Language Models (LLMs), such as OpenAI’s ChatGPT , Google’s Gemini , Anthropic’s Claude 3.5 , and Meta’s LLaMA 3.3 have reshaped a wide range of fields by demonstrating unprecedented advancements. These advancements are primarily due to their capability to efficiently process long-context inputs, a crucial feature for tasks like summarizing lengthy documents (e.g., medical reports, legal analyses, technical briefs), enabling superior reasoning and problem-solving performance at a level comparable to expert human analysis. At the core of these advancements lies the Transformer architecture , driven by its self-attention mechanism. Understanding computational primitives that Transformer components enable is pivotal for principled interpretations and exposing limitations in Transformer-based systems.
Previous research has investigated these questions by analyzing the expressiveness of Transformers. As an illustration, the work in showed that constant-depth threshold circuit families can effectively emulate Transformers with precision and depth-. This holds true in both non-uniform and -uniform computational models. This result highlights Transformers’ computational efficiency and structural adaptability when analyzed through circuit complexity theory’s lens. Expanding on these results, showed that Transformers with precision belong to -uniform , even when the absolute error is bounded by .
To augment the capabilities of Transformers, innovations such as Rotation Position Embedding () have been proposed. Through the rotation matrices, improves the sequence length adaptability while enhancing the efficacy of attention mechanisms. Meanwhile, multi-view approaches are increasingly recognized for capturing high-order correlations in diverse data types, including mathematical data , graph structures , and multi-modality datasets . Models like GPT-4o and Google’s Project Astra exemplify this trend, integrating reasoning across multi-modality in real-time. Despite these advancements, classical attention mechanisms face representational limitations. Specifically, demonstrated that matrix attention can only capture pairwise correlations, falling short in modeling triple-wise or higher-order interactions. Addressing such limitations typically requires multiple layers or carefully designed architectures, complicating the integration of multi-view information.
To overcome these constraints, and proposed Tensor Attention, a higher-order extension of matrix attention. Tensor Attention intrinsically captures high-order correlations, defined as (see Definition 3.30), where denotes the column-wise Kronecker product (see Definition 3.21). Here, , , and represent inputs from different views or modalities. This raises a natural question:
Does the and tensor attention enhance the expressiveness of the -based tensor attention Transformer?
This work addresses this question through the lens of circuit complexity, advancing the theoretical understanding of tensor attention and -based tensor attention mechanisms.
We present a rigorous analysis of tensor attention Transformers and -based tensor attention Transformers, delineating their intrinsic computational limitations. Our approach methodically evaluates the circuit complexity of each architectural component, ranging from basic trigonometric operations to the comprehensive -based tensor attention Transformers. Specifically, it is demonstrated that uniform circuits are amenable to simulating the components mentioned above. Furthermore, it is proven that, unless , tensor attention Transformers, as well as -enhanced tensor attention Transformers with layers, -precision, and a feature dimension are incapable of solving fixed membership problems or closure problems. This finding underscores fundamental expressivity constraints inherent to tensor attention and -based tensor attention architectures.
The summary of our contributions to the theoretical understanding of these architectures and their computational boundaries, rooted in circuit complexity theory, showed as follows:
Unless , we demonstrate that a -uniform circuit family can simulate a tensor attention Transformer or a -based tensor attention Transformer, with constant depth, size, and precision (Based on Theorem 4.7 and Theorem 5.7).
We demonstrate that, unless , a tensor attention Transformer or a -based tensor attention Transformer with layers, precision, and a feature dimension are incapable of accomplishing the fixed membership problems (Based on Theorem 6.6 and Theorem 6.7).
We demonstrate that, unless , a tensor attention Transformer or a -based tensor attention Transformer with layers, precision, and a feature dimension are incapable of accomplishing the closure problems (Based on Theorem 6.8 and Theorem 6.9).
Related Work
Circuit complexity, a specialized domain within computational complexity theory, investigates the properties of circuit families as computational models. Numerous circuit complexity classes are relevant to the study of machine learning, with characterizing problems solvable by highly parallel circuits utilizing elementary logic gates. The class generalizes this concept by incorporating circuits that feature threshold gates, while encompasses problems solvable by circuits with a depth of and bounded gate arity . It is well-established that , although the question of whether remains unresolved. Assuming this inequality holds, demonstrates that, when simulating certain non-solvable semiautomata, the depth of Transformers must necessarily increase with the input sequence length. The circuit complexity is also used to measure some other popular architectures such us Mamba and Hopfield networks .
Computation of Transformers.
Transformers have undeniably revolutionized the field of natural language processing, yet their performance significantly deteriorates when tasked with mathematical computations . This observation has led to a surge in research aimed at identifying the computational boundaries of Transformer models, particularly in two distinct categories: (1) average-head attention Transformers, which assign a value of 1 to the highest probability in the vector while setting all other probabilities to 0, and (2) softmax-attention Transformers, which utilize the softmax function. Merrill, Sabharwal, and Smith demonstrate that average-head attention Transformers are capable of recognizing languages that surpass the computational power of the class, yet they remain simulable by threshold circuits with constant-depth, belonging to non-uniform complexity class. In a similar vein, establish that softmax-attention Transformers also belong to the non-uniform class. Subsequent work by builds upon these findings by introducing a similarity function to demonstrate that softmax-attention Transformers fall within the -uniform class. Further advancements by employ first-order logic and quantifiers to show that -uniform circuits can simulate the behavior of these Transformers. In the context of practical applications, such as arithmetic operations and decision-making tasks, establish that unless , Transformers with log-precision cannot efficiently solve arithmetic problems, equation-solving tasks, or context-free grammar (CFG) membership testing . These results underscore the limitations that Transformers face when applied to mathematical problems. However, recent efforts have aimed to overcome these constraints, introducing innovations such as looper Transformers , acceleration techniques , and other related approaches . These contributions aim to address some of the foundational limitations of Transformer architectures, allowing them to handle increasingly complex and mathematically intensive tasks.
Tensor Computation for High-order Representation.
Tensors outperform matrices in capturing higher-order relationships within data. Computing low-rank factorizations or approximations of tensors is critical in various computer science applications, including natural language processing , computer vision , computer graphics , security , and data mining . Tensors also play a key role in numerous machine learning tasks and other diverse domains .
Roadmap.
In Section 3, we introduce essential computational techniques and key definitions of Transformers that serve as the foundation for the discussions in the following sections. Section 4 discusses the computational complexity of conventional tensor attention Transformers. Section 5 provides a detailed -based tensor attention circuit complexity analysis. Section 6 presents the hardness of tensor attention Transformers and -based tensor attention Transformers derived from our study. We conclude in Section 7.
Preliminary
This section establishes the essential concepts and definitions. Section 3.1 introduces the fundamental notations that form the basis of analysis. Section 3.2 provides an in-depth exploration of float point number computation. Section 3.3 offers a comprehensive overview of computational complexity classes. Then, Section 3.4 presents essential techniques employed in tensor operations. Finally, Section 3.5 explores the fundamental components that constitute the -based tensor attention Transformers.
2 Float Point Operations
We present basic concepts of the computational foundation. Initially, the exact definitions of float point numbers and the corresponding operations are outlined, which are indispensable in efficient tensor attention computations.
Given any real number or float point value , the notation denotes the -bit float point number closest to . In cases where we have different numbers equidistant from , the tie-breaking convention dictates that will be the even significand one.
Based on the foundational concepts mentioned above, we now introduce the key operations involved in tensor attention.
Let and represent two integers, then defined as follows:
Let and all denoted as -bit float points, then we have:
The operations mentioned above are capable of efficient hardware implementation, as demonstrated by the following lemmas:
If integer , then we say the conditions below are satisfied:
Part 2. We can execute -bit float point numbers repeated multiplication using a constant depth size uniform threshold circuit. The required depth for this iterated multiplication process is denoted as .
Part 3. We can approximate -bit float point numbers sequential addition and rounding using a constant depth size uniform threshold circuit. The depth needed for iterated addition is represented by .
For any integer and any -bit float point number , it is computable to approximate most relative error using size constant depth uniform threshold circuit. The depth required for this computation is denoted by .
3 Circuit Complexity
In computational theory, a Boolean circuit, constructed using basic gates such as , , and , represents a core model of computation. A precise mathematical definition of this structure comes below.
An variables Boolean circuit is defined as and is depicted by a directed acyclic graph (DAG). In this representation, logical gates such as , , and correspond to the vertices of the graph. The input vertices, each linked to one of the Boolean variables, have an in-degree of 0, whereas non-input vertices derive their values from the outputs of preceding gates in the structure.
A Boolean circuit family is said to recognize language if a Boolean circuit with variables exists, s.t., , iff , for every string .
The class is defined as the set of languages that are recognizable using Boolean circuits of size and depth , with logical gates of bounded fan-in, including , , and gates.
When Boolean circuits are permitted to incorporate gates such as and with unbounded fan-in, their ability to process languages becomes significantly enhanced. This development leads to the introduction of the complexity class .
Languages which can be computed by the Boolean circuit of depth , size , unbounded fan-in gates, including , , , are contained in the class .
The gates can simulate , , gates, which yield an output of 1 if the majority of inputs are 1, and 0 otherwise. By incorporating gates, one can define a broader complexity class known as .
If we have languages are recognizable by size Boolean circuits of depth, and unbounded fan-in gates, including , , , and gates. If half of the inputs are 1, the gate will output 1.
The class contains languages that are recognizable by Boolean circuits of size , depth , and gates with unbounded fan-in, including , , , and gates. A gate outputs one if more than half of its inputs are one.
As Definition 3.12 shows, or gates (for prime moduli) can replace gates. Boolean circuits employing such gates are collectively referred to as threshold circuits.
Next, we formally introduce the class .
A language is considered to be in if it can be decided by a deterministic Turing machine within polynomial time of input size.
The hierarchical relationships among certain circuit families are encapsulated in the following well-known result.
Non-uniform circuit families, characterized by their lack of consistent structural design across varying input sizes, are theoretically capable of addressing undecidable problems. Nevertheless, their impracticality arises from the infinite length required for their description. In contrast, uniform circuit families, which adhere to a systematic computational model, hold greater relevance in the study of complexity and formal language theory. We begin with the definition of -uniformity.
Then, the -uniformity and examine its correspond to -uniformity will be introduced.
The concept of -uniformity aligns with that of -uniformity, except in smaller circuit classes that do not have the capability to imitate the constructing machine. Further exploration of uniformity concepts can be found in . Within this paper, references to uniform pertain specifically to -uniform .
4 Tensor Operation Analysis Techniques
We first define operations such as the Kronecker product, a matrix operation that takes two matrices of any size and produces a block matrix. Unlike standard matrix multiplication, it is useful for introducing and analyzing tensor attention. Then, we introduce some key techniques for applying tensor attention to RoPE.
Fact 3.23 indicates that the order of tensor operation and matrix multiplication can be swapped, enabling computation in the lower dimension first to reduce complexity.
For any , we have
where the initial step involves the application of matrix multiplication, followed by the utilization of Definition 3.21 in the second step. Subsequently, the third step employs Definition 3.20, while the fourth step simplifies the expression through fundamental algebraic principles. The fifth step re-engages matrix multiplication, and the concluding step leverages Definition 3.21 once more. ∎
5 Transformer Block
With the mathematical foundation in place, this section outlines the key components of the -based tensor attention Transformers architecture, starting with the softmax operation, a fundamental element of Transformer.
One of the pivotal advancements in contemporary Transformer architectures is , which employs a rotation matrix as its foundation:
This fundamental rotation matrix is generalized to encode the relative positions within a sequence, facilitating the embedding of positional context.
Noted represents position index within input sequence and denotes token index. The relative rotation matrix is then expressed as:
where the angular frequencies are all predefined. More about selecting , consult Equation (15) from .
Leveraging rotation matrices mentioned above, -based tensor attention embeds positional relation intrinsically within the computational process of attention. Now, we are about to introduce the -based tensor attention. First, we introduce the parameters and input.
Then, based on Definition 3.21, we define -based tensor attention matrix in the following way.
by applying Fact 3.23, we finally define the -th tensor attention layer as
Then, we introduce a single tensor attention layer.
Next, we can also integrate multi-layer attention and the additional mechanism mentioned above to construct a comprehensive Transformer.
where denotes the composition of functions.
Subsequently, we define two categories of functions. Start with the layer normalization.
where , and .
The second category is the multilayer perceptron.
The foundation of modern Transformer is built upon these layered architectures, which integrate float point computations, attention, and rotation matrix to an exceptionally efficient framework for sequential computation.
Complexity of Tensor Attention Transformer
We now formally turn our attention to investigating the circuit complexity of the tensor attention layer and the multi-layer tensor attention Transformer, emphasizing their computability within the complexity class . Section 4.1 delves into matrix operations. Section 4.2 addresses the computation of a single tensor attention layer. Section 4.3 provides an in-depth examination of the entire tensor attention mechanism. Lastly, Section 4.4 presents our principal findings regarding the circuit complexity bounds for the tensor attention Transformer. These results establish the foundation for the main theorem concerning Transformer expressiveness.
We demonstrate that fundamental matrix multiplication is efficiently evaluatable within .
The circuit size is polynomial in , as each operation uses a polynomial-sized circuit, and .
The circuit size remains polynomial in because and every operation utilizes a polynomial-sized circuit.
The circuit size is polynomial in because , and each individual operation can be evaluated by a polynomial-sized circuit.
2 Single Tensor Attention Layer
Here, we examine the complexity of the single layer of the tensor attention.
As per Part 3 of Lemma 3.4, is evaluated with size uniform threshold circuit of depth .
The total depth required for computing is therefore:
3 Multi-layer Tensor Attention
This section analyzes the computation of multi-layer tensor attention in a Transformer.
4 Circuit Complexity Bound of Tensor Attention
The subsequent discussion focuses on presenting the main result regarding the circuit complexity bound for tensor attention Transformers.
Assume that for every , the function in is evaluatable by size uniform threshold circuit of constant depth. As described in Definition 3.31, we can approximate the -based tensor attention Transformer by a uniform circuit family, when , , and .
With constant , and Lemma 4.6, the depth of the circuit computing is
and the circuit size. Thus, a uniform circuit family can simulate this computation.
Above Theorem 4.7, we establish that, unless , a constant depth tensor attention with size, and -precision can be approximated by a -uniform circuit family. While tensor attention Transformers exhibit strong empirical performance, this result indicates inherent limits in their expressivity when viewed through the framework of circuit complexity. These constraints are examined further in Section 6, in tandem with the analysis from Section 5.
Complexity of 𝖱𝗈𝖯𝖤𝖱𝗈𝖯𝖤\mathsf{RoPE}-based Tensor Attention Transformer
This section presents key results concerning the circuit complexity of fundamental operations within -based tensor attention computations. Section 5.1 investigates trigonometric functions, which play a crucial role in rotary position embeddings, while Section 5.2 focuses on the -based tensor attention matrix computation. Section 5.3 delves into the individual -based tensor attention layer, whereas Section 5.4 explores other components beyond the attention layer. In Section 5.5, the complete -based tensor attention mechanism is detailed. Finally, Section 5.6 presents the primary results regarding the circuit complexity bounds for -based tensor attention, forming the foundation for the essential theorem on -based Tensor Attention Transformer expressiveness.
Here, we outline the efficient calculation of fundamental trigonometric functions that are critical for embeddings via threshold circuits. The next lemma plays a central role:
For any , the values of and for a float point number of bits with a relative error bounded by are evaluatable by size uniform threshold circuit with constant depth. Let denote the maximum depth required to calculate both and .
2 𝖱𝗈𝖯𝖤𝖱𝗈𝖯𝖤\mathsf{RoPE}-based Tensor Attention Matrix
The following section builds on what we already know about the computation of the -based tensor attention matrix.
For every , the matrix element is evaluated according to the formula in Definition 3.28.
As indicated by Lemma 5.1, the entries of are evaluatable by a size depth uniform threshold circuit. Since is polynomial, all entries of are evaluatable simultaneously with the same circuit size and depth. This holds true for and as well.
The exponential function can be evaluated using Lemma 3.6 by a size depth uniform threshold circuit.
Thus, the total required depth to compute the matrix is:
3 Single 𝖱𝗈𝖯𝖤𝖱𝗈𝖯𝖤\mathsf{RoPE}-based Tensor Attention Layer
This section provides a detailed examination of the -based tensor attention layer, with an emphasis on tracking the circuit depth requirements throughout the computation process.
Because parallel operations can be conducted for each element, the attention operation can be evaluated by a uniform threshold circuit with the required depth and size.
4 Building Blocks other than 𝖱𝗈𝖯𝖤𝖱𝗈𝖯𝖤\mathsf{RoPE}-based Tensor Attention Layer
According to Definition 3.31, the definition of the Multi-layer -based Transformer is provided, which integrates -based self-attention layers together with supplementary components, such as layer normalization and MLP. This section subsequently addresses the circuit complexity associated with these mechanisms.
The analysis begins with an investigation of the complexity pertaining to the MLP layer.
Next, we will turn our attention to the complexity of the LN layer.
5 Multi-layer 𝖱𝗈𝖯𝖤𝖱𝗈𝖯𝖤\mathsf{RoPE}-based Tensor Attention
We now describe the computation of the multi-layer -based tensor attention Transformer.
Under the given assumption, for every , can be evaluated by size uniform threshold circuit having constant depth.
6 Circuit Complexity of 𝖱𝗈𝖯𝖤𝖱𝗈𝖯𝖤\mathsf{RoPE}-based Tensor Attention
Here, we present the central contribution of this paper, which establishes the circuit complexity for the -based tensor attention.
Assume that , in can be computed using size uniform threshold circuit of constant depth . The -based tensor attention , as defined in Definition 3.31, is simulatable by uniform circuit family when and .
According to Lemma 5.6, we have , the bounded circuit used to compute has a depth given by
which bounded by . Thus, based on the definition of , it follows that the uniform circuit family can approximate -based tensor attention Transformer.
In Theorem 4.7 and Theorem 5.7, unless , a -uniform circuit family can emulate both tensor attention Transformers and -based tensor attention Transformers, which are defined by constant depth, precision, and size. This finding suggests that, notwithstanding the empirical success of these models, their expressive capabilities are intrinsically constrained when analyzed through the lens of circuit complexity. The subsequent section will delve deeper into these limitations.
Hardness
This section delineates two fundamental problems, accompanied by their respective hardness results. The fixed membership problem is introduced in Section 6.1, while the closure problem is defined in Section 6.2. Section 6.3 presents the four principal hardness results.
The fixed membership problem, as originally formulated in , is thoroughly defined in this section. A formal exposition of its definition is provided as the foundation for subsequent analysis.
The fixed membership problem is defined as follows:
Input: A fixed morphism : , a fixed set and finite words
denotes the collection of finite subsets of .
The fixed membership problem for recognizing morphisms over finite words is -complete.
In this section, attention is shifted to the closure problem, as introduced in .
Let be a language, the kleene star of , denoted by , is the set of all finite concatenations of strings from , defined as:
Let denote a finite monoid.For convenience, is abbreviated as . A natural homomorphism maps each word to its corresponding valuation in the monoid . Let and be a positive integer. The language is characterized by . The closure problem refers to the decision problem aimed at determining whether a given string belongs to .
Assume that is a nonsolvable monoid. Then, there exists a group and a constant such that the closure problem is -complete.
3 Hardness Result
This part presents four crucial findings concerning tensor attention Transformers and -based tensor attention Transformers.
If , layers -based tensor attention Transformer with hidden dimension, precision is incapable of solving the fixed membership problem.
The proof follows from the combination of Theorem 5.7, which provides a circuit complexity bound for -based tensor attention Transformers, and Proposition 6.2, which establishes that the fixed membership problem for recognizing morphisms over finite words is -complete. Additionally, Fact 3.15, which outlines the hierarchy of circuit families, is also applied here. This completes the proof. ∎
Unless , it is not possible for a layers tensor attention Transformer with hidden dimension and precision to address the fixed membership problem.
The result is derived by combining Theorem 4.7 (which provides the circuit complexity bound for tensor attention Transformers), Proposition 6.2 (demonstrating the -completeness of the fixed membership problem), and Fact 3.15 (pertaining to the structure of circuit families). As a result, this proof is complete. ∎
Assuming , a layers tensor attention Transformer with hidden dimension, and precision is not capable of solving the closure problem.
This follows directly from Theorem 5.7, which establishes the circuit complexity bound for -based tensor attention Transformers, and Theorem 6.5, which asserts that the closure problem is -complete. Additionally, Fact 3.15 concerning the hierarchy of circuit families is also utilized. Thus, the proof is complete. ∎
Unless , it is not possible for a tensor attention Transformer with layers, -precision, and hidden dimension to solve the closure problem.
Theorem 4.7 provides this result upon application, which provides the circuit complexity bound for tensor attention Transformers, Theorem 6.5, which proves the -completeness of the closure problem, and Fact 3.15, which discusses the hierarchy of circuit families. Therefore, the proof is concluded. ∎
Conclusion
It is important to note that our analysis is primarily confined to forward computations and assumes constant-depth nonlinear activation functions. This leaves the impact of training dynamics, alternative activation functions, and different formulations of tensor attention unexplored. Future work could expand on this analysis to investigate alternative positional encoding schemes, more advanced attention models, or different activation functions, potentially uncovering whether these complexity boundaries hold for other Transformer variants. Ultimately, the findings presented here reveal a fascinating discrepancy between tensor attention models’ theoretical limitations and their empirical performance. Understanding how these models achieve practical effectiveness despite their theoretical shortcomings could stimulate the development of new, theoretically robust design principles. Such insights are essential for advancing neural network architectures that maintain a balance between rigorous theoretical foundations and empirical success, fostering the creation of more scalable and powerful models.