Paper commentary
Efficiently Modeling Long Sequences with Structured State Spaces
- Problem Computing the latent state of the LSSL needs O(N^2 L) operations and O(NL) space, which makes deep state space models impractical for long sequences.
- Method S4 writes the HiPPO state matrix as a normal matrix plus a low-rank term, then evaluates the SSM convolution kernel with Cauchy-kernel computations and a Woodbury correction.
Why state space models were impractical for long sequences
Long-range dependencies (LRDs) are the central difficulty here: many real-world time series need reasoning over tens of thousands of steps, while few sequence models handle even thousands. On the Long Range Arena benchmark, current sequence models perform poorly on LRD tasks, and on Path-X no model does better than random guessing.
A state space model maps an input signal u(t) to an output y(t) through a hidden latent state x(t), with the matrices A, B, C and D learned by gradient descent when the model sits inside a deep network. The continuous form is \[ x'(t) = Ax(t) + Bu(t), \qquad y(t) = Cx(t) + Du(t) \] When A is chosen from the HiPPO family, the state can keep a record of the input history, and the LSSL used this property to address LRDs.
The authors also show that the efficient algorithms proposed for the LSSL are numerically unstable.
The HiPPO matrix is highly non-normal, which blocks the standard algorithmic techniques that would otherwise make the state update cheap. S4 is designed to remove this computational bottleneck while keeping the structure of the HiPPO matrices.
Why diagonalizing the HiPPO matrix fails
Diagonalizing A would be the natural shortcut, since the powers of a diagonal matrix are cheap to form. With a diagonal A, the kernel K becomes a Vandermonde product that needs only O((N+L) log^2(N+L)) arithmetic operations.
The difficulty is that the HiPPO matrix cannot be diagonalized in a numerically usable way. The authors give its diagonalization as V_{ij} = \binom{i+j}{i-j}, and the entries of this matrix grow exponentially with the state size N. At practical N the change of basis would therefore not be computable, so the naive route through diagonalization fails.
Normal plus low-rank as the structure to exploit
The ideal case is a matrix that a unitary change of basis diagonalizes, which means a normal matrix, but the HiPPO matrix is not normal. The key observation is that the HiPPO matrix splits into a normal part plus a low-rank part. Such a sum is still slow to raise to powers, so the decomposition alone does not solve the problem.
Theorem 1 states that the HiPPO matrices of Gu et al. [16] admit the form \[ A = V\Lambda V^{*} - PQ^{\top} = V(\Lambda - (V^{*}P)(V^{*}Q)^{*})V^{*} \] with unitary V, diagonal Lambda, and low-rank factors P and Q that have r columns. For HiPPO-LegS, LegT and LagT the rank r is 1 or 2, and the matrix of equation (2) has r = 1.
Once the matrix is conjugated, the same structure is written as a diagonal plus low-rank form over the complex numbers, so the parameters become Lambda, P, Q, B and C. An S4 layer starts from the HiPPO matrix, and the resulting SSM is unitarily equivalent to one with the form Lambda minus PQ* together with vectors B and C, which gives 5N trainable parameters.
Computing the convolution kernel through Cauchy products
Unrolling the recurrence gives a single convolution, \[ y = K * u, \qquad K = (CB, CAB, \ldots, CA^{L-1}B) \] Because the convolution is non-circular and can be computed with FFTs, the hard part is obtaining the kernel K itself.
Algorithm 1 never forms the powers of A directly. It evaluates the truncated generating function of K at the roots of unity and then applies an inverse FFT. The evaluation contains a matrix inverse rather than a power, and that inverse is handled in three stages: a Cauchy kernel for the diagonal part, a Woodbury correction for the low-rank term, and an evaluation at all roots of unity.
The Woodbury identity expresses the inverse of A + PQ* through the inverse of A, so the low-rank term is handled by the diagonal case. The diagonal case reduces to a Cauchy kernel 1/(omega_j - zeta_k), for which stable near-linear algorithms exist.
Theorem 3 states that, for any step size Delta, K can be computed with four Cauchy multiplies, using O(N+L) operations and O(N+L) space up to log factors. Theorem 2 gives one step of the recurrence in O(N) operations, because the inverse of a DPLR matrix is again DPLR. The authors call the Theorem 3 algorithm their core technical contribution and the reason for the NPLR parameterization.
Training as convolution, generation as recurrence
The continuous SSM is discretized with the bilinear method at step size Delta, giving \[ \bar{A} = (I - \tfrac{\Delta}{2}A)^{-1}(I + \tfrac{\Delta}{2}A), \quad \bar{B} = (I - \tfrac{\Delta}{2}A)^{-1}\Delta B, \quad \bar{C} = C \] The discrete state update becomes the recurrence \( x_k = \bar{A}x_{k-1} + \bar{B}u_k \) with output \( y_k = \bar{C}x_k \).
Training uses the convolutional form, which follows from unrolling the recurrence from an initial state of zero. A single convolution parallelizes well on modern hardware, whereas the recurrence has to advance one step after another.
At generation time the recurrence advances one step at a time, and each step costs a constant amount of computation and memory. The authors contrast this with standard autoregressive models, whose cost grows with the context length.
Delta sets the resolution of the input samples, so changing it at test time changes the sampling rate the model assumes. Reaching 96.3% accuracy at 0.5× frequency on Speech Commands 10 requires no retraining, only the change of the internal step size.
Stacking S4 into a deep layer
A single S4 module maps one one-dimensional sequence to another, so a layer runs H independent copies of it, one for each feature. A position-wise linear layer then mixes the H features, which adds O(H^2)+O(HN) parameters per layer, and nonlinear activations are placed between layers.
The core S4 module is a linear transformation, and the nonlinearity of the overall deep model comes from the depth of the network.
Table 1 compares parameter count, training cost, training space, parallelism and inference cost for convolution, recurrence, attention and S4. For S4 the parameter count is H^2, the training space is BLH, training is parallel, and inference costs H^2 per sample and time step, with the training cost carrying log factors.
Measured speed and memory against the LSSL and Transformers
Table 2 compares the LSSL and S4 at state dimensions 128, 256 and 512. The LSSL step takes 9.32, 20.6 and 140.7 ms, while S4 takes 4.77, 3.07 and 4.75 ms, and memory allocations are 1685 MB for the LSSL and 12.6 MB for S4 at dimension 256. At dimension 512 the ratio row gives 29.6× for training step time and 392× for memory allocation.
The introduction summarizes this as S4 being up to 30× faster than the LSSL with 400× less memory. The analysis gives O(N+L) cost up to log factors, while Tables 2 and 3 are measured timings, so the two kinds of evidence are kept apart here.
Long Range Arena results
LRA has six tasks with lengths from 1K to 16K, covering similarity, structural and visuospatial reasoning. Table 4 places S4 beside 11 Transformer variants from Tay et al. and follow-up models, with the original Transformer variants above the models reported in the literature.
The text says S4 outperforms every baseline on every task, and that every baseline averages less than 60%.
The introduction reports 88% accuracy on Path-X, whereas Table 4 lists 96.35 in the Path-X column for S4. The authors report that S4 is the first model to solve Path-X, and that earlier models stayed at the 50% random-guessing level because of memory or computation limits or an inability to learn such long dependencies.
The lower layers learn kernels that use only a few rows of local context, while the higher layers aggregate information across full columns at varying spatial frequencies, with filters spanning all 16384 pixels.
Raw speech classification
The SC10 subset of Speech Commands is classified from raw signals of length 16000, and the baselines use MFCC features of length 161. The introduction puts S4 test error at 1.7%, half that of specialized speech CNNs.
The WaveGAN discriminator reaches 96.25 on raw input, but the text says it has 90× more parameters than S4 and uses more architectural heuristics. The text also reports that all RNN and Transformer baselines fail to learn, with error of at least 70%.
The 0.5× column is a frequency change applied at test time, so the model is not retrained for it. S4 scores 96.30 in that column of Table 5, and the text reports 96.3% at 0.5× frequency.
Generative modeling and generation speed
CIFAR-10 density estimation flattens each image into a sequence of 3072 RGB subpixels, predicted one at a time. S4 (large) reaches 2.85 bits per dim, the same value as PixelSNAIL, and S4 (base) reaches 2.92, with no 2D inductive bias in either. PixelSNAIL uses 2D convolution and attention, which S4 does not.
Throughput is listed per checkpoint: S4 (base) generates 20.84 images per second (65.1×), S4 (large) 3.36 (10.5×), and the Transformer 0.32 (1×). The large model that matches the best bits per dim is therefore not the fastest row, which is why the two numbers are not read as one model's result.
The S4 model replaces the self-attention layers of that Transformer baseline, and the authors report it stays within 0.8 ppl of the Transformer and over 2 ppl ahead of earlier attention-free models.
Sequential image classification and time-series forecasting
Table 6 reports pixel-level sequential MNIST, permuted MNIST and sequential CIFAR-10 accuracies for prior models and S4. On sequential CIFAR-10 S4 reaches 91.13 in Table 6, the highest value in that column, while the LSSL reaches 84.65.
The authors also report 90.46% against 79.52% when BatchNorm is swapped for LayerNorm, and describe S4 as much more robust to such choices.
For forecasting, S4 treats the task as a masked sequence-to-sequence transformation and is compared with Informer and other baselines on five forecasting tasks. The authors report that S4 is better on 40 of 50 settings, and on the longest setting of each task, with MSE reduced by 37% when forecasting 30 days of weather data.
Where the HiPPO initialization matters
The ablations use sequential CIFAR-10 as a testbed, with models capped at 100K trainable parameters, a plateau learning rate schedule and no regularization. They compare a random Gaussian initialization, the HiPPO initialization and a random diagonal Gaussian matrix, with A either frozen or trained.
Training the SSM improves every initialization, and with A trained all initializations reach perfect training accuracy. Their validation accuracies still differ by over 15%, which is the large generalization gap the authors point to.
Random NPLR matrices still perform poorly, and the authors take this as evidence that S4's effectiveness comes mainly from the HiPPO initialization and not from the NPLR parameterization. Figure 4 compares NPLR with random and HiPPO initializations, and then all ablation methods with minor Dropout regularization.
With 0.1 Dropout, the full S4 method with HiPPO initialization reaches 84.27% test accuracy with 100K parameters. This ablation is capped at 100K parameters, so its 84.27% is not directly comparable with the 91.13 that Table 6 reports for S4 on sequential CIFAR-10.
Limitations
A follow-up study found that S4 can be numerically unstable when A has eigenvalues on the right half-plane. That follow-up changed the low-rank term from Lambda minus PQ* to Lambda minus PP*.
The ablations were run only on sequential CIFAR-10 under the 100K-parameter cap, and the authors state that this testbed transferred well to other settings.
The LRA table combines Transformer variants with numbers reported in the literature, so its rows do not form one controlled experiment. The throughput and bits-per-dim figures come from different checkpoints, so one row does not show both the best density and the fastest generation.
The general-purpose claim rests on the benchmarks listed in the paper, and the conclusion describes S4 as having the potential to be an effective general sequence modeling solution.
Paper info
- Authors
- Albert Gu, Karan Goel, Christopher Ré
- Venue
- arXiv · Preprint
- First published
- 2021-10-31
- Added
- 2026-10-20
- Updated
- 2022-8-5
- Version
- v3
- arXiv
- 2111.00396
- Category
- cs.LG
- Original paper terms
- arXiv non-exclusive 1.0
- What we show
- Paper info and commentary
AI commentary is a separate explanation from the original paper and may contain errors. The original paper and figures follow each source's terms of use and any rights noted separately.
Quote from the paper
Albert Gu, Karan Goel, Christopher Ré (2021). Efficiently Modeling Long Sequences with Structured State Spaces. arXiv:2111.00396v3. https://arxiv.org/abs/2111.00396v3
BibTeX
@misc{gu2021efficiently,
title = {{Efficiently Modeling Long Sequences with Structured State Spaces}},
author = {Albert Gu and Karan Goel and Christopher Ré},
year = {2021},
eprint = {2111.00396},
archivePrefix = {arXiv},
url = {https://arxiv.org/abs/2111.00396v3}
}