TL;DR
A state space model (SSM) reads a sequence one step at a time, keeping a hidden state that is updated by a fixed linear rule. With the right state matrix the state can remember inputs thousands of steps back, but the previous way of computing such a model was too slow and memory-hungry to use in practice. S4 reparameterises the state matrix as a "normal plus low-rank" matrix. That makes the model's convolution kernel computable in near-linear time and memory, and the paper reports strong results on long-sequence benchmarks.
Builds on: State Space Model, HiPPO Matrix, Convolution · Leads to: Selective State Space Model, Transformers are SSMs: Generalized Models and Efficient Algorithms (Mamba-2)
Why it mattered
S4 showed that a model built on a linear state space could match or beat attention models on tasks with very long inputs, and it did so with a cost that grows roughly linearly with sequence length. It also made the model usable as a general layer. The paper applies it to image classification from raw pixels, autoregressive generation, speech and time-series forecasting, with the same architecture throughout. Later state space models such as Selective State Space Model and Transformers are SSMs: Generalized Models and Efficient Algorithms (Mamba-2) build on the same view of a sequence model as a linear recurrence that can also be run as a convolution.
The problem
The earlier Linear State Space Layer (LSSL) of Gu et al. had shown that deep SSMs can handle long-range dependencies, especially with the HiPPO Matrix as state matrix. The paper cites a case where that matrix lifted sequential MNIST from 60% to 98% accuracy. But the LSSL was impractical. For state dimension and sequence length , the paper states its computation as operations and memory, against a lower bound of . For a typical size of this uses orders of magnitude more memory than an RNN or CNN of the same size. The authors also show that the fast algorithm proposed for the LSSL is numerically unstable, because the HiPPO matrix is highly non-normal.
So the question is: can the same model be computed with the efficiency of a convolution, without losing the long-range memory that the HiPPO matrix provides?
How it works
Take the SSM in its three equivalent views and the job of each. A continuous system , is discretised with a step size into a recurrence, and unrolling the recurrence gives a convolution with a kernel . Training wants the convolution, because it parallelises. Inference wants the recurrence, because it costs constant time per step. The bottleneck is computing , which needs repeated powers of a matrix.
flowchart LR A[HiPPO matrix A] --> B[normal plus low rank: Lambda minus P Q star] B --> C[truncated generating function at roots of unity] C --> D[Woodbury identity removes the low-rank term] D --> E[Cauchy kernel, near-linear time] E --> F[inverse FFT gives kernel K bar] F --> G[convolve K bar with the input]
- Start with the HiPPO matrix and a discrete SSM. Each step of the recurrence multiplies the state by , so computing naively takes matrix products.
- Diagonalising would make powers easy, but the eigenvectors of the HiPPO matrix have entries as large as , so that route is numerically unusable. Check: with this bound is about ; at it is astronomically large.
- Split into a normal matrix and a rank-one term . Normal matrices diagonalise stably. The HiPPO matrix is not normal, but it is normal plus a rank-one term. Check: the paper's Theorem 1 gives rank for the HiPPO matrix of equation (2).
- Replace powers by a single inverse: evaluate the generating function at the roots of unity. This turns the problem into a resolvent, , not a power.
- Remove the low-rank term with the Woodbury identity. The inverse of becomes a sum of diagonal inverses. Check: the diagonal inverses are now Cauchy matrices, with entries .
- Evaluate the Cauchy kernel with a fast multipole-type algorithm, then apply an inverse FFT to get . The output is a convolution kernel that is used in the usual way, .
Concrete check: take a scalar toy SSM with , , , . Then , , . The kernel is . For the input the recurrence gives outputs , and the convolution gives , then , then . The two views agree. S4's contribution is computing this kernel for a large matrix without ever forming the powers.
The math
A continuous SSM , with in normal-plus-low-rank form. Discretised with the bilinear rule, its kernel is . S4 parameterises and learns , , , , .
Step 1 in symbols: the recurrence
With bilinear discretisation, and . The discrete system is , . Unrolling it from gives .
Step 2 in symbols: why diagonalising fails
For the HiPPO matrix, when , when , and when . The paper shows that the matrix with entries diagonalises (Lemma 3.2), and that has entries up to about . Working with therefore cannot be done stably for large .
Step 3 in symbols: normal plus low rank
Theorem 1 states that every HiPPO matrix from the earlier work has the form with unitary and diagonal, and rank or . Conjugating by an invertible matrix leaves the SSM's input-output map unchanged (Lemma 3.1), so one can work with the diagonal-plus-low-rank form directly.
Step 4 in symbols: generating function
Define . Then with , and the kernel values are recovered from at the roots of unity by one inverse DFT (Lemma C.2), which costs .
Step 5 in symbols: Woodbury and the Cauchy kernel
For , the Woodbury identity gives , so the low-rank part only needs small corrections. With , the generating function is . The needed quantities are entries of the Cauchy matrix , whose matrix-vector product costs in exact arithmetic and numerically (Proposition 5).
Step 6 in symbols: the cost
Theorem 3 gives the kernel with four Cauchy products in operations and space. The paper notes that its current implementation uses the naive Cauchy product on GPUs, which is simple and parallel but not the asymptotically fastest. Trainable parameters per S4 layer are (, , , , ), as stated in Section 3.4.
Results
All numbers are from the paper. Where the paper reports two versions, both are shown, because Appendix D.5 states that later reruns superseded some tables.
- Efficiency. Compared with the LSSL, S4 is "up to faster with less memory" (Section 1).
- Long Range Arena. The original paper reports an average of 80.48 for S4, against less than 60 for every baseline in Table 2 of that version. The updated S4 row (Appendix D.5, which replaces the original Table 2 numbers) averages 86.09, with Path-X 96.35, against 53.66 for the original Transformer and 59.37 for Luna-256. The introduction quotes the original Path-X result, 88%, against 50% for random guessing.
- Raw speech. S4 reaches 98.3% on the 10-class Speech Commands subset with raw length-16000 audio, and 96.3% when the sampling frequency is halved, without retraining. Appendix D.5 asks readers to cite a follow-up paper's table, on the full 35-class dataset, for Speech Commands results.
- Sequential CIFAR-10. Without data augmentation S4 gets 91.12% against 89.46% for a ResNet-18 with 11.0M parameters. With augmentation it gets 93.16% against 95.62%. Swapping batch norm for layer norm, S4 gets 90.46% and the ResNet gets 79.52%.
- Generative modelling. On CIFAR-10 density estimation S4 reaches 2.85 bits per dimension. On WikiText-103 it comes within 0.8 perplexity of a strong Transformer and sets a state of the art for attention-free models.
- Generation speed. S4 generates about faster than standard autoregressive models on both CIFAR-10 and WikiText-103.
- Forecasting. On the Weather dataset with horizon 720, S4 has MSE 0.245 against 0.359 for Informer. That is a reduction of about 32%. The text's figure of 37% matches the LogTrans number (0.388), not the Informer one.
- Ablations. With trained, every initialisation reaches perfect training accuracy, but validation accuracies differ by over 15%. With dropout 0.1 and 100K parameters the full S4 reaches 84.27% test accuracy on sequential CIFAR-10. The authors conclude that the HiPPO initialisation, not the low-rank parameterisation, is the source of the effect.
Limits. The authors say S4 still trails Transformers on language modelling. The released code uses the naive Cauchy product through pykeops. The authors expect a dedicated CUDA version to be faster. Several headline results were later revised, so cite the updated tables when quoting.
Reading guide
- Abstract and Section 1. The LRA and speech motivation. Needs State Space Model and Transformer as the point of comparison.
- Section 2.1 to 2.3. The continuous SSM, its discretisation and the recurrence. Needs Ordinary Differential Equation and State Space Model.
- Section 2.2. HiPPO and equation (2). Needs HiPPO Matrix and Legendre Polynomials.
- Section 2.4. The convolution kernel. Needs Convolution.
- Section 3.1 to 3.2. Diagonalisation, normal plus low rank, and the three techniques. Needs Low-Rank Matrix and Discrete Fourier Transform for the roots of unity.
- Section 3.3 to 3.4. Complexity and the layer. Table 1 compares the models. Needs Recurrent Neural Network.
- Section 4. Experiments. Use the appendix tables for exact figures.
- Appendix C. Full proofs of the kernel algorithm.
Check yourself
QuestionIn the scalar toy example with A = -1, B = 1, C = 1 and step size 0.5, what is the discrete state matrix A-bar?Show answer
Using A-bar = (I - (Delta/2) A)^(-1) (I + (Delta/2) A). Here (Delta/2) A = 0.25 times -1 = -0.25, so the first factor is 1 / 1.25 and the second is 0.75. Then A-bar = 0.75 / 1.25 = 0.6.
QuestionWhy does the paper not compute the kernel by diagonalising the HiPPO matrix?Show answer
The eigenvector matrix V of the HiPPO matrix has entries of magnitude up to about 2^(4N/3). For large state size N these numbers cannot be represented accurately, so the diagonalisation is numerically infeasible even though it is mathematically valid.
QuestionExplain in one sentence what the Woodbury identity buys in S4.Show answer
It converts the inverse of the diagonal-plus-low-rank matrix into the inverse of its diagonal part plus a correction on a rank-one term, so that the remaining work is a Cauchy kernel, which has fast stable algorithms.
QuestionThe paper reports 91.12% for S4 and 89.46% for ResNet-18 on sequential CIFAR-10 without augmentation. Compute the gap in percentage points, and say whether the paper's claim of competitiveness is consistent with it.Show answer
91.12 minus 89.46 is 1.66 percentage points in S4's favour. Without augmentation S4 is ahead. With augmentation it trails by 95.62 minus 93.16, which is 2.46 points. So the paper's word "competitive" fits both results, and S4 has fewer parameters (7.9M against the ResNet's 11.0M).
QuestionA user quotes the original Path-X result of 88% and the updated result of 96.35%. Which should a reader cite, and why?Show answer
Cite the updated table, but say which version. Appendix D.5 states that the Long Range Arena results in Table 2 were updated from follow-up work with minor hyperparameter changes, and the original numbers are kept in Table 4. Quoting one without the other can mislead.
Sources
- Gu, Goel, Ré (2021). Efficiently Modeling Long Sequences with Structured State Spaces. arXiv:2111.00396. https://arxiv.org/abs/2111.00396
- State-space representation. Wikipedia. https://en.wikipedia.org/wiki/State-space_representation
- Gu and Dao (2023). Mamba: Linear-Time Sequence Modeling with Selective State Spaces. arXiv:2312.00752. https://arxiv.org/abs/2312.00752