The Illusion of State in State-Space Models

William Merrill, Jackson Petty, Ashish Sabharwal

Introduction

Recent theoretical work (Merrill & Sabharwal, 2023a) has shown that models built upon the transformer architecture are incapable of expressing inherently sequential computation. These results reveal a surprising limitation of transformers: they cannot express simple kinds of state tracking problems, such as composing sequences of permutations, which even simple recurrent neural networks (RNNs) can naturally express. In a different line of work, state space model (SSM) architectures (Gu et al., 2021, 2022a; Fu et al., 2023; Gu & Dao, 2023; Wang et al., 2024) have been introduced as an alternative to transformers, with the goal of achieving similar expressive power to RNNs for handling problems that are naturally stateful and sequential (Gu et al., 2021, 2022b). But does the seemingly stateful design of SSMs truly enable them to solve sequential and state-tracking problems that transformers cannot? If so, this would be a promising property of SSMs because state tracking is at the heart of large language model (LLM) capabilities such as tracking entities in a narrative (Heim, 1983; Kim & Schuster, 2023), playing chess under certain notationThe hardness of chess state tracking holds with (source, target) notation, but standard notation may make state tracking easier., or evaluating code. This would motivate further research into SSM architectures and their deployment as the next generation of LLMs.

In this work, we show that the apparent stateful design of SSMs is an illusion as far as their expressive power is concerned. In contrast to the suggestion by Gu et al. (2021, 2022b) (and, perhaps, a broader belief in the community) that SSMs have expressive power for state tracking similar to RNNs, we prove theoretically that linear and Mamba-style SSMs, like transformers, cannot express inherently sequential problems, including state-tracking problems like composing permutations that RNNs can easily express. Further, our experiments confirm our formal predictions: both transformers and these SSMs cannot learn to compose permutations with a fixed number of layers, whereas RNNs can compose permutations with just a single layer. Our results imply that arguments that SSMs have an advantage over transformers due to being “more recurrent” or capable of tracking state are misguided. In fact, the SSM architectures we consider are just as theoretically unequipped for state tracking and recurrent computation as transformers are.

We first establish the theoretical weakness of linear SSMs and near generalizations by proving they are in the complexity class L\mathsf{L}-uniform TC0\mathsf{TC}^{0}, which has been previously shown for transformers (Merrill & Sabharwal, 2023a). This implies these SSMs cannot solve inherently sequential problems (formally, problems that are NC1\mathsf{NC}^{1}-hard), including state-tracking problems like permutation composition (Liu et al., 2023). Permutation composition is a fundamental problem at the heart of many real-world state-tracking problems such as playing chess, evaluating code, or tracking entities in a narrative (Figure 1), implying solutions to these problems, too, cannot be expressed by SSMs, at least in the worst case.

At first glance, our results may appear to contradict Gu et al. (2021)’s claim that linear SSMs can simulate general recurrent models, which can express permutation composition. But the contradiction is resolved by a difference in assumptions: Gu et al. (2021) relied on infinite depth (number of layers) to show that SSMs could simulate RNNs. We, on the other hand, analyze the realistic setting with a bounded number of layers, under which we find that SSMs cannot simulate the recurrent state of an RNN and, in fact, suffer from similar limitations as transformers for state tracking.

Our empirical investigation shows that, in practice, both SSMs with the Mamba architecture (Gu & Dao, 2023) and transformers do not learn to solve the permutation composition state-tracking problem with a fixed number of layers, while simple RNNs can do so with just one layer. This provides empirical support for our theoretical separation in expressive power for state tracking between SSMs and true recurrent models. We also find that both transformers and SSMs struggle compared to RNNs on state-tracking problems less complex than permutation composition where it is not known whether they can express a solution. Thus, in practice, SSMs may struggle not just on the hardest state-tracking problems like permutation composition but also on easier variants.

Finally, we propose two minimal extensions of linear SSMs that increase their expressive power for state tracking, allowing them to solve permutation composition. These extensions, however, may come with a cost: they may negatively impact parallelism as well as learning dynamics. We view it as an interesting open question whether it is possible to develop SSM-like models with greater expressivity for state tracking that also have strong parallelizability and learning dynamics, or whether these different goals are fundamentally at odds, as Merrill & Sabharwal (2023a) suggest.

Background

We first present the SSM architectures we will analyze (Section 2.1). Our analysis of the state tracking capabilities of SSMs borrows deeply from the circuit complexity and algebraic formal language theory literature. We thus review how circuit complexity can be used to analyze the power of neural networks (Section 2.3) and how state-tracking problems can be captured algebraically and analyzed within the circuit complexity framework (Section 3.1).

SSMs are a neural network architecture for processing sequences similar in design to RNNs or linear dynamical systems. SSMs have been suggested to have two potential advantages compared to transformers owing to their recurrent formulation: faster inference and, possibly, the ability to better express inherently sequential or stateful problems (Gu et al., 2021, 2022b). Several architectural variants of SSMs have been proposed, including S4 (Gu et al., 2022a) and Mamba (Gu & Dao, 2023). Recently, SSMs have been shown to achieve strong empirical performance compared to transformers in certain settings, particularly those involving a long context (Gu & Dao, 2023; Wang et al., 2024).

SSMs consist of state-space layers, which can be thought of as simplified RNN layers. We consider two variants of the state-space layer: the linear SSM layer (of which S4 is a special case; Gu et al., 2022a) and the extended S6 layer used by Mamba (Gu & Dao, 2023).

S4 chooses a specific parameterization of a linear layer. A full S4 model is a cascade of such layers and feedforward layers, analogous to how transformers alternate multihead-self-attention layers with feedforward layers.

The S6 layer used by Mamba (Gu & Dao, 2023) generalizes a linear SSM layer by adding a selection mechanism inspired by the dynamic gating in LSTMs (Hochreiter & Schmidhuber, 1997) and GRUs (Cho et al., 2014).

Finally, to compute yiy_{i}, CC is made input dependent CiC_{i} and computed via a projection in the same manner as BiB_{i}. The layer output is then yi=Cihi+xiy_{i}=C_{i}h_{i}+x_{i}.

In practice, a crucial detail for training SSMs is the initialization of the weight matrices. Our main results (Theorems 4.1 and 4.2) will apply for any linear SSM (including S4) as well as S6, independent of the specific values of its weights. In contrast to S4 and S6, H3 (Fu et al., 2023) is not a true SSM because the context is not represented by a single vector. Rather, its architecture resembles a transformer with SSM components. Analyzing H3 is beyond our focus, but we believe our ideas could be extended to H3 in future work.

2 Numeric Datatype

In Appendix A, we extend the arguments of Hesse (2001) and Mereghetti & Palano (2000) for integers to show that iterated product and matrix powering over log-precision floats are also computable in L\mathsf{L}-uniform TC0\mathsf{TC}^{0} (cf. Lemmas 2.3 and 2.4 in Appendix A).

Let ϕ1,,ϕz\phi_{1},\ldots,\phi_{z} be clognc\log n precision floats and znz\leq n. Then the iterated float product i=1zϕi\bigotimes_{i=1}^{z}\phi_{i} can be computed in L\mathsf{L}-uniform TC0\mathsf{TC}^{0}.

Combined with the result for iterated addition from Merrill & Sabharwal (2023a), this establishes that the three needed properties are met for log-precision floats.

3 Limits of Transformers via Circuit Complexity

A line of recent work has used circuit complexity and logic formalisms to identify the expressiveness limitations of transformers on reasoning problems (Angluin et al., 2023; Merrill & Sabharwal, 2023a; Liu et al., 2023; Chiang et al., 2023; Merrill & Sabharwal, 2023b; Hao et al., 2022); see Strobl et al., 2023 for a survey. In particular, Merrill & Sabharwal (2023a) showed that transformers can only solve problems in the complexity class TC0\mathsf{TC}^{0}, which is defined as the set of problems that can be recognized by constant-depth, polynomial-size threshold circuit families. Such circuits, in addition to having standard AND, OR, and NOT gates (of arbitrary fan-in), can also use threshold gates that output 11 iff at least kk of the inputs are 11, where kk is a parameter of the gate. Informally, TC0\mathsf{TC}^{0} can be thought of as the class of problems that can be solved with extremely parallelized (constant-depth) computation.We use TC0\mathsf{TC}^{0} to mean L\mathsf{L}-uniform TC0\mathsf{TC}^{0}, meaning the circuit family is constructible by a Turing machine that runs in space logarithmic in the size of the input (cf. Merrill & Sabharwal, 2023a; Strobl et al., 2023). We believe our results could be extended from L\mathsf{L}-uniform TC0\mathsf{TC}^{0} to DLOGTIME\mathsf{DLOGTIME}-uniform TC0\mathsf{TC}^{0} using techniques similar to Merrill & Sabharwal (2023b) for composing TC0\mathsf{TC}^{0} circuits in a way that preserves DLOGTIME\mathsf{DLOGTIME} uniformity.

Problems outside TC0\mathsf{TC}^{0}, corresponding to problems that are inherently sequential and thus cannot be parallelized, cannot be solved by transformers. No problems in polynomial time are known unconditionally to be outside TC0\mathsf{TC}^{0}, but unless the widely held conjecture that TC0NC1\mathsf{TC}^{0}\neq\mathsf{NC}^{1} is false, many simple NC1\mathsf{NC}^{1}-hard problems are outside TC0\mathsf{TC}^{0}. In particular, this includes simulating finite automata (NC1\mathsf{NC}^{1}-complete), evaluating boolean formulas (NC1\mathsf{NC}^{1}-complete), determining graph connectivity (L\mathsf{L}-complete), and solving linear equations (P\mathsf{P}-complete). These problems have already been shown to be inexpressible by transformers (Merrill & Sabharwal, 2023a). By showing that SSMs can be simulated in TC0\mathsf{TC}^{0}, we will establish that they also cannot be solved by SSMs.

State Tracking

Informally, a state-tracking problem is a problem where the text specifies some sequence of updates to the state of the world, and the goal of the problem is to say what the resulting world state is after the updates have been applied in sequence. This circuit complexity view on the power of neural networks can be combined with other insights from algebraic formal language theory to analyze the kinds of state tracking that SSMs can express. In particular, this theory comprehensively shows us which kinds of state-tracking problems are (likely) not in TC0\mathsf{TC}^{0}. This will, in turn, allow us to find examples of hard state tracking that models like SSMs will not be able to solve.

From the perspective of algebraic formal language theory, state tracking over a finite world can be captured as a word problem on a finite monoid (Liu et al., 2023).We consider only finite monoids for simplicity, but, in principle, it would be possible to extend this approach to infinite (e.g., finitely generated) monoids as well. Different updates to the world become different elements in the monoid, and resolving the final world state after all the updates have been applied is equivalent to computing the product of a sequence of elements (also called a “word”).

Let MM be a finite set, and (M,)(M,\cdot) a finite monoid (i.e., MM with identity and associative multiplication). The word problem for MM is to reduce sequences in MM^{*} under multiplication; that is, send m0m1mkm_{0}m_{1}\cdots m_{k} to m0m1mkMm_{0}\cdot m_{1}\cdot\ldots\cdot m_{k}\in M. Solving the word problem requires reducing sequences of arbitrary length.

Consider the monoid {0,1}\{0,1\} where \cdot is addition modulo 2. The word problem involves computing the parity of a string, e.g., 001100011\mapsto 0. From a state-tracking perspective, this monoid captures a world with a single light switch. The identity corresponds to no action whereas 11 is an update that flips the switch.

Modeling state tracking with word problems lets us draw connections between circuit complexity and abstract algebra to understand which word problems are “hard” to solve. Krohn & Rhodes (1965) established that not all word problems are created equal: some, like Example 3.2, are in TC0\mathsf{TC}^{0}, while others are NC1\mathsf{NC}^{1}-complete, requiring recurrent processing to solve (Immerman & Landau, 1989; Barrington, 1989). Because we will show SSMs can be simulated in TC0\mathsf{TC}^{0}, it follows that NC1\mathsf{NC}^{1}-complete state-tracking problems cannot be solved by SSMs (cf. Figure 2).

Whether or not a word problem is NC1\mathsf{NC}^{1}-complete depends on the algebraic structure of the underlying monoid.We focus on word problems on groups, which are monoids with inverses. Barrington (1989) showed that the word problem of every finite non-solvableFormally, a group GG is solvable exactly when there is a series of subgroups 1=G0<G1<<Gk=G1=G_{0}<G_{1}<\cdots<G_{k}=G such that Gi1G_{i-1} is normal in GiG_{i} and Gi/Gi1G_{i}/G_{i-1} is abelian. group is NC1\mathsf{NC}^{1}-complete. That non-solvable groups have NC1\mathsf{NC}^{1}-complete word problems is notable because of the ubiquity with which non-solvable groups show up in tasks involving state tracking. The canonical example of an NC1\mathsf{NC}^{1}-complete word problem is that of S5S_{5}, the symmetric group on five elements that encodes the permutations over five objects. As an immediate instantiation of this, consider a document describing arbitrarily many sequences of transpositions: “swap ball 1 and 3, swap ball 3 and 5, swap ball 4 and 2, …”Without less of generality, any permutation can be factored into a sequence of transpositions, or swaps. This means the transpositions over five elements are a generator for S5S_{5}.. Being able to answer the question “where does ball 5 end up?” requires solving the S5S_{5} word problem. Beyond permutations, Figure 1 shows how many natural state-tracking problems like tracking chess moves, evaluating code, or tracking entities also encode the structure of S5S_{5}, meaning these state-tracking problems also cannot be expressed by a model in TC0\mathsf{TC}^{0}. Rather, in order to solve these problems, the depth of the model would have to be expanded to accommodate longer inputs.

Figure 1 already gives some intuition into how state-tracking problems encode S5S_{5}. Out of these examples, the most intricated case is chess. We now give a proper reduction from S5S_{5} to tracking chess moves, showing formally that not just S5S_{5}, but chess state tracking as well, is NC1\mathsf{NC}^{1}-complete.

We define the chess state-tracking problem as follows:

Input: The state of a chessboard as well as a sequence of chess moves, where each move is specified as a tuple (source square, target square). Note that this differs from the standard notation that represents a move as a piece along with target square and potential disambiguating information.

Output: The resulting board state after starting in the initial board state and applying the sequence of moves one after another, ignoring draws. If any move is illegal given its intermediate board state, we enter a special null board state.

We show that S5S_{5} can be reduced to chess state tracking, establishing the NC1\mathsf{NC}^{1}-completeness of chess state tracking. In other words, we can map any S5S_{5} sequence to a sequence of chess moves and read off the answer to the S5S_{5} instance from the final chessboard state.

S5S_{5} can be reduced to chess state tracking via NC0\mathsf{NC}^{0} reductions.

The idea, as illustrated in Figure 1, is to map each S5S_{5} element to a sequence of chess moves that permutes five pieces on the chessboard. Then, the final chessboard state will allow us to determine the composition of the permutation sequence. We defer a detailed proof to Appendix B. ∎

Since S5S_{5} is NC1\mathsf{NC}^{1}-complete under AC0\mathsf{AC}^{0} reductions:

The chess state-tracking problem is NC1\mathsf{NC}^{1}-complete under AC0\mathsf{AC}^{0} reductions.

Similar reductions can be constructed for evaluating Python or tracking entities in a dialog, as suggested in Figure 1. For another example of a similar reduction used to prove NC1\mathsf{NC}^{1}-completeness, we refer the reader to Theorem 3.2 of Feng et al. (2023).

In this section, we show that the convolutional form of an SSM can be simulated in TC0\mathsf{TC}^{0}. Assuming the convolutional form of the model computes the same function as the recurrent form, this implies that SSMs, in whatever parameterization, cannot solve inherently sequential problems, despite their appearance of recurrence and statefulness. We first show containment in TC0\mathsf{TC}^{0} for the simple non-gated variant of generalized S4 models (Theorem 4.1), and then show that the proof goes through for generalized S6 models as well (Theorem 4.2). The main idea in both proofs is that matrix powering can be computed in TC0\mathsf{TC}^{0} (Mereghetti & Palano, 2000), and computing the convolutional form of an SSM can essentially be reduced to matrix powering.

For any log-precision SSM MM with the S4 architecture, there exists an L\mathsf{L}-uniform TC0\mathsf{TC}^{0} circuit family that computes the same function as MM’s convolutional form.

It suffices to construct an L\mathsf{L}-uniform TC0\mathsf{TC}^{0} circuit family to simulate a single layer. Then, the full SSM can be simulate by generating this circuit multiple times, routing the output bits from one layer as the inputs to the next. This can be done with log-space overhead by simply storing a counter that tracks the index of the current input gates.

Recall that the S4 convolutional form Eqn. (2) is hi=j=1iAijBxjh_{i}=\sum_{j=1}^{i}A^{i-j}Bx_{j}. Crucially, we use the fact that matrix powering over floats is in L\mathsf{L}-uniform TC0\mathsf{TC}^{0} (Lemma 2.4, extending Mereghetti & Palano, 2000) to print, for each i,ji,j, a TC0\mathsf{TC}^{0} circuit family that computes πijAij\pi_{ij}\triangleq A^{i-j}. Next, we use the fact that fixed-arity arithmetic over floats is in L\mathsf{L}-uniform TC0\mathsf{TC}^{0} to print, for each i,ji,j, a circuit that computes

Since iterated addition over floats is in L\mathsf{L}-uniform TC0\mathsf{TC}^{0} (Merrill & Sabharwal, 2023a, extending Hesse, 2001; Chiu et al., 2001 for integers), we can compute hij=1iτijh_{i}\triangleq\sum_{j=1}^{i}\tau_{ij}. Finally, we compute yiy_{i} from xix_{i} and hih_{i} in TC0\mathsf{TC}^{0} via simple arithmetic operations, completing the proof. ∎

For any log-precision SSM MM with the S6 architecture, there exists an L\mathsf{L}-uniform TC0\mathsf{TC}^{0} circuit family that computes the same function as MM’s convolutional form.

The convolutional form of the S6 layer is given in Eqn. (4). For each ii we print an L\mathsf{L}-uniform TC0\mathsf{TC}^{0} circuit computing δi,Bi\delta_{i},B_{i} and CiC_{i}. Since AA is diagonal, iterated matrix multiplication is reducible to iterated scalar multiplication, which is in L\mathsf{L}-uniform TC0\mathsf{TC}^{0} (Lemma 2.4). so we can compute the following in TC0\mathsf{TC}^{0}:

We then conclude analogously to Theorem 4.1, first computing τij\tau_{ij} from πij\pi_{ij} and BiB_{i}, then computing hi=j=1iτijh_{i}=\sum_{j=1}^{i}\tau_{ij}, and finally computing yiy_{i} from xi,hi,x_{i},h_{i}, and CiC_{i} in TC0\mathsf{TC}^{0}. ∎

3 Discussion

Theorems 4.1 and 4.2 establish that SSMs, like transformers, can only express solutions to problems in the class TC0\mathsf{TC}^{0}. This means that SSMs cannot solve NC1\mathsf{NC}^{1}-hard problems like evaluating boolean formulas or graph connectivity. In particular, it shows that they are limited as far as their state tracking capabilities as they are unable to compose permutations (solve the S5S_{5} word problem):

Assuming TC0NC1\mathsf{TC}^{0}\neq\mathsf{NC}^{1}, no log-precision SSM with the S4 or S6 architecture can solve the word problem for S5S_{5} or any other NC1\mathsf{NC}^{1}-hard problem.

In contrast, RNNs can easily express S5S_{5} via standard constructions that encode finite-state transitions into an RNN (Minsky, 1954; Merrill, 2019). This shows that SSMs cannot express some kinds of state tracking and recurrence that RNNs can. This tempers the claim from Gu et al. (2021, Lemma 3.2) that SSMs have the expressive power to simulate RNNs, which relied on the assumption that SSMs can have infinite depth. In a more realistic setting with a bounded number of layers, our results show SSMs cannot express many state-tracking problems, including those which can be solved by fixed-depth RNNs.

Extending the Expressive Power of SSMs

We have shown that S4 and S6, despite their seemingly “stateful” design, cannot express problems outside TC0\mathsf{TC}^{0}, which includes state tracking like S5S_{5}. We show how SSMs can be extended to close the gap in expressive power with RNNs, allowing them to express S5S_{5}. Two simple extensions can bring about this increase in expressive power: adding a nonlinearity to make the SSM more like an RNN or allowing the AA matrix to be input-dependent to make the SSM more like a weighted finite automaton (WFA; Mohri, 2009).

Concretely, an RNN-SSM layer with a step activation function can be defined as follows:

After this change, the SSM no longer has a straightforward convolutional form. However, its recurrent form is effectively an RNN, and can therefore solve S5S_{5}:

For any regular language LL (including the word problem for S5S_{5}), there exists a one-layer log-precision RNN-SSM that recognizes LL.

The standard constructions for simulating automata with RNNs (cf. Minsky, 1954; Merrill, 2019) apply. ∎

Note that adding nonlinearities to the output of an SSM layer (as in Mamba) is not the same thing as an RNN-SSM. Rather, an RNN-SSM has nonlinearities applied after each recurrent update to the state.

2 Via Input-Dependent Transition Matrices

Another completely different way to get greater expressive power is to let AA matrix to be input-dependent. To illustate this, we define and analyze the WFA-SSM layer. Let A(xi)=I+sA(xi)A(x_{i})=I+s_{A}(x_{i}). The recurrent form becomes:

This means the convolutional form computes an iterated product of a sequence of matrices rather than powering a matrix as for S4 and S6 (cf. Section 2.1):

Unlike matrix powers, iterated matrix products cannot, in general, be computed in TC0\mathsf{TC}^{0} (Mereghetti & Palano, 2000). This means that the argument from Theorem 4.1 will not go through for WFA-SSMs. In fact, we can show that WFA-SSMs gains expressive power beyond TC0\mathsf{TC}^{0}:

For any regular language LL over vocabulary Σ\Sigma (including the word problem for S5S_{5}), there exists a one-layer log-precision WFA-SSM that recognizes \L,where, where\∉Σ\not\in\Sigma is a special beginning-of-string symbol.

It suffices to show that an WFA-SSM can simulate a deterministic finite automaton (DFA). We do this via a transition monoid construction. For any wΣw\in\Sigma^{*}, let δw:QQ\delta_{w}:Q\to Q be the function mapping a state to its eventual destination state after ww is read from that state. For any DFA, this set of functions forms a finite monoid (the transition monoid) under composition, following from the Myhill-Nerode theorem (Hopcroft et al., 2001). Further, each monoid element δw\delta_{w} can be represented as a boolean transition matrix, making matrix multiplication isomorphic to monoid composition.

Computing the transition monoid of a DFA allows recognizing valid words: compute the monoid element for a word by multiplying the elements for its tokens and then check whether the initial state maps to an accepting state. In fact, a standard way to solve monoid word problems (e.g., for S5S_{5}) with a DFA is simply to construct a DFA whose transition monoid is the monoid of interest.

Fix a DFA and its transition monoid δ\delta. To complete the proof, we show that there exists an SSM that, for all wΣw\in\Sigma^{*}, computes δw\delta_{w} given input x=\w.Weviewindicesin. We view indices inh_{i}asstatesanddefineas states and defineB\$asas1ateachacceptingstate,andelsewhere.Forallotherat each accepting state, and elsewhere. For all other\sigma,welet, we letB\sigma=\vec{0}.Thisreducestheconvolutionalformof. This reduces the convolutional form ofh_{i}$ to have a single term:

Now, let A(σ)=δσA(\sigma)=\delta_{\sigma} for σΣ\sigma\in\Sigma. It follows that

Since x=\w,weconcludethat, we conclude thath_{\left\lvert x\right\rvert}isis\delta_{w}$. ∎

3 Discussion

Theorems 5.1 and 5.2 show that two minimal extensions of the SSM enable expressive power outside TC0\mathsf{TC}^{0}, allowing the model to solve hard state-tracking problems:

There exist a one-layer log-precision RNN-SSM and WFA-SSM that express the word problem for S5S_{5} (with a beginning-of-string symbol), and these these SSMs cannot be simulated in TC0\mathsf{TC}^{0}.

But would these variants of SSMs be feasible to use in practice? Besides expressive power, there are two competing practical concerns that might make these extensions problematic: parallelism and the impact on learning dynamics.

To be used effectively in an LLM, a model architecture must be parallelizable on practical hardware. Architectures in TC0\mathsf{TC}^{0} are parallelizable by design (Merrill & Sabharwal, 2023a), but architectures in NC1\mathsf{NC}^{1} may still be parallelizable to log depth even if they cannot be parallelized to constant depth. For the WFA-SSM, the bottleneck would be computing iterated matrix product with a log-depth computation graph. Similarly, for the RNN-SSM, the bottleneck would be computing the state updates with a log-depth binary tree rather than left to right. If this could be accomplished on practical hardware, these architectures could be parallelizable enough to scale on modern hardware.

Learning Dynamics.

Another potential concern for these SSM variants compared to the original SSM is whether the learning dynamics are as good. In particular, for the WFA-SSM, an iterated product of matrices may lead to vanishing gradient issues. However, this is already potentially an issue for the S6 architecture, where the selective gating involves computing an iterated product of scalars.

Can SSMs Learn Permutations in Practice?

Having established theoretical limitations of SSMs for state tracking, we now empirically test how well SSMs can learn such tasks, focusing on the word problem for A5A_{5}. Since this problem is NC1\mathsf{NC}^{1}-complete and both transformers and SSMs can only express functions in TC0\mathsf{TC}^{0}, to solve instances of this problem these models should require a dynamic depth that grows with the input length.

Results.

Figure 3 shows that single-layer RNN and IDS4 models learn the word problem for arbitrarily long sequences from all three groups. In contrast, transformer, S4, and Mamba models require depth monotonically increasing in sequence length to attain good accuracy on a validation set on non-commutative groups. We draw three main conclusions from this:

Mamba and S4 show the same qualitative limitations as transformers on the inherently sequential task A5A_{5}: longer A5A_{5} sequences require deeper models. This is consistent with both transformers, S4, and Mamba being in TC0\mathsf{TC}^{0}. On the other hand, RNNs (which resemble automata; Merrill, 2019) and IDS4 can solve NC1\mathsf{NC}^{1}-complete problems (McKenzie et al., 1991) including the A5A_{5} word problem.

Conclusion

We have shown that SSMs, like transformers, can only express computation in the complexity class L\mathsf{L}-uniform TC0\mathsf{TC}^{0}. This means they cannot solve inherently sequential problems like graph connectivity, boolean formula evaluation, and—of particular interest for state tracking—the permutation composition problem S5S_{5}. S5S_{5} can be naturally expressed by true recurrent models like RNNs and captures the essence of hard state tracking due to its NC1\mathsf{NC}^{1}-completeness. In practice, one-layer RNNs can easily learn a task capturing S5S_{5} SSMs require depth growing with the sequence length. These results reveal that SSMs cannot truly track state: rather, they can only solve simple state-tracking problems for which shallow shortcuts exist (Liu et al., 2023).

We also showed that simple extensions of SSMs can express S5S_{5}, although this comes with potential drawbacks as far as parallelism and learning dynamics. In future work, it would be interesting to more thoroughly explore the practical viability of our SSM extensions. Ultimately, this line of work has the potential to unlock new neural architectures that balance the parallelism of transformers and SSMs with full expressive power for state tracking, enabling LLMs that can benefit from scale while enjoying a greater capacity to reason about games, code, and language.

Broader Impact

This paper aims to advance the foundational understanding of state-space architectures for deep learning. Such work can affect the development and deployment of deep learning models in a variety of ways, which in turn can have societal impacts. However, we find it difficult to meaningfully speculate about or anticipate these downstream impacts here.

References

Appendix A Floating-Point Arithmetic

The idea is to convert (by scaling up) the sequence of ϕi\phi_{i} to another sequence of floats that are all representable as integers, apply Lemma A.2, reverse the scaling, and cast the result back to a clognc\log n precision float.

Let ee be the smallest exponent across all ϕi\phi_{i} and q=max{0,e}q=\max\{0,-e\}. Construct re-scaled floats ψi=ϕi2q\psi_{i}=\phi_{i}2^{q} by adding qq to the exponent of ϕi\phi_{i}, using up to clognc\log n additional bits in the exponent if necessary to keep the computation exact. Note that ee, qq, and all ψi\psi_{i} can easily be computed exactly by an L\mathsf{L}-uniform TC0\mathsf{TC}^{0} circuit as they involve fixed-arity arithmetic operations. Further, by construction, every ψi\psi_{i} has a non-negative exponent and thus represents an integer.

Finally, to compute the original iterated float product i=1zϕi\bigotimes_{i=1}^{z}\phi_{i}, we divide τ\tau by 2qz2^{qz}. This can be accomplished by subtracting qzqz from the exponent of τ\tau; again, we do this computation exactly, using up to (c+1)logn(c+1)\log n additional bits in the exponent if necessary. We then cast the resulting float back to a clognc\log n precision float. All this can be done in L\mathsf{L}-uniform TC0\mathsf{TC}^{0}, finishing the proof that i=1zϕi\bigotimes_{i=1}^{z}\phi_{i} can be computed in L\mathsf{L}-uniform TC0\mathsf{TC}^{0}. ∎

We now extend these notions and results to matrix powering.

The idea is to convert (by scaling up) MM to another float matrix all whose entries are representable as integers, apply Lemma A.5, reverse the scaling, and cast the result back to clognc\log n precision floats.

Hesse et al. (2002) state that polynomial division is in L\mathsf{L}-uniform TC0\mathsf{TC}^{0} in Corollary 6.5. For historical reasons, this claim is preceded by weaker claims in older papers. We briefly clarify this situation to show why the stronger claim is valid.

Reif & Tate (1992) establish that polynomial division can be done in P\mathsf{P}-uniform TC0\mathsf{TC}^{0}, whereas we state our results for L\mathsf{L}-uniform TC0\mathsf{TC}^{0}. However, the only issue preventing these results from going through in the L\mathsf{L}-uniform case is that, at the time of publication, it was not known whether integer division and iterated integer multiplication were computable in L\mathsf{L}-uniform TC0\mathsf{TC}^{0}. However, Hesse (2001) later proved exactly this. Combining the two results, Theorem 3.2 from Reif & Tate (1992) goes through with L\mathsf{L}-uniformity. Its Corollary 3.3 then allows us to conclude that integer polynomial division can be solved by L\mathsf{L}-uniform TC0\mathsf{TC}^{0} circuits because the output of integer polynomial division is an analytic function whose Taylor expansion has a finite number of terms (Reif & Tate, 1992).

Appendix B Chess Reduction

We let M\mathcal{M} denote the set of chess moves in (source square, target square) notation.

Without loss of generality, we consider the variant of S5S_{5} where the output is true if and only if the original first element returns to the first position after the given sequence of permutations has been applied. Given an S5S_{5} instance, we will construct an initial board state and sequence of moves such that the final chessboard state encodes the output of the S5S_{5} problem instance.

We construct a chessboard similar to Figure 1 but with a black rook at a8 and black queens at b8 to e8.

Chess Move Sequence.

We then construct a finite function f:S5Mf:S_{5}\to\mathcal{M}^{*} that encodes a permutation π\pi as a sequence of chess moves. We first factor each permutation π\pi to a sequence of transpositions τ1(π)τmπ(π)\tau_{1}(\pi)\cdots\tau_{m_{\pi}}(\pi). Each transposition τ\tau can in turn be expressed as a sequence of chess moves analogously to Figure 1. For example, transposing items 1 and 3 can be expressed as the move sequence: (a8, a7), (a1, b1), (c8, c6), (b1, a1), (a7, c7), (a1, b1), (c6, a6), (b1, a1), (c7, c8), (a1, b1), (a6, a8), (b1, a1), which has the crucial property that it transposes a8 with c8. We denote the mapping from transpositions to chess move sequences as f:TMf:\mathcal{T}\to\mathcal{M}^{*}. Putting it all together, we have that

To reduce a sequence of permutations wS5w\in S_{5}^{*}, we let

Putting It All Together.

We call our oracle for chess state tracking with the constructed initial board state and f(w)f(w) as the sequence of chess moves. By construction, we can then return true if and only if the rook is at a8. The reduction can be implemented in NC0\mathsf{NC}^{0} because it is a simple elementwise mapping of the input tokens, and decoding from the output chessboard is a finite table lookup. ∎

As a fun aside, we note that the chess board constructed in Proposition 3.3 is reachable in a standard chess game. The chess sequences encoding permutation sequences are all valid chess games, except that they ignore the fact that repeated board states in chess will technically lead to draws.