上一代的问题:RNNs have O(L) complexity but fixed-size memory (can't recall long-range). Transformers have O(L2) cost. SSMs existed but couldn't handle long-range dependencies — they either failed on the Copy task or needed prohibitively large state dimensions.
这代改了什么:S4 introduces the HiPPO theory for structured state matrices (Legendre polynomials) that capture long-range memory. Combined with Normal Plus Low-Rank (NPLR) decomposition for efficient computation. Shows that a properly parameterized SSM can match or exceed Transformers on long-range tasks.
效果:First SSM to achieve Transformer-level performance on Long Range Arena (LRA) benchmark. Average score 86.09 vs Transformer 62.05. Direct predecessor to Mamba.
State Space Models (SSMs) originate from control theory. They model a system's dynamics through a latent state that evolves over time:
Where A is the state transition matrix (N x N), B is the input projection (N x 1), and C is the output projection (1 x N). The state h(t) is a vector that compresses the entire history of the input signal.
To use SSMs in a discrete deep learning setting, we discretize using the Zero-Order Hold (ZOH) method with step size Δt:
This gives us the recurrent form used in neural networks:
Since the SSM is linear and time-invariant, the recurrence can be unrolled into a convolution, enabling parallel training:
This dual representation is key: recurrent for fast inference, convolutional for parallel training.
Previous SSMs struggled with long-range dependencies because the state matrix A was either diagonal (exponential decay, no memory retention) or dense (prohibitively expensive O(N2) computation). The Copy task was the litmus test: can the model remember a token from position 1 and reproduce it at position L?
Traditional SSMs either failed entirely (diagonal A loses signal exponentially) or required state dimension N proportional to sequence length L (defeating their efficiency advantage).
The key insight of S4: certain structured matrices have ideal properties for capturing long-range dependencies. The HiPPO (High-Order Polynomial Projection Operators) framework provides a theoretical foundation for designing state matrices that compress history optimally.
The HiPPO matrix (also called the Legendre matrix) is defined as:
This matrix encodes a sliding window of the input history using orthogonal polynomial basis functions. The state vector h(t) stores coefficients of the projection of the input signal's history onto Legendre polynomials. As new input arrives, the coefficients update to maintain the projection over a sliding window.
The HiPPO matrix is special: it can be decomposed into a normal matrix (unitarily diagonalizable) plus a low-rank term:
This decomposition is the computational key that makes S4 tractable:
For training, S4 uses the convolution view: the entire kernel K is computed in one shot using the SSM's structure, and then the output is computed via FFT convolution (O(L log L)):
# S4 training: compute kernel once, convolve
# N = state dimension, L = sequence length
K = compute_ssm_kernel(A_bar, B_bar, C, L) # O(N log N + L)
y = FFT_convolve(x, K) # O(L log L)
At inference time, the SSM unrolls as a recurrence, requiring O(1) per step regardless of past history:
# S4 inference: constant-time per step
h = zeros(N) # state initialization
for t in range(T):
y_t = C @ h # output from current state
h = A_bar @ h + B_bar * x_t # state update
S4 was the first SSM to achieve competitive results on all LRA tasks:
| Task | Transformer | LSTM | S4 | Improvement vs Transformer |
|---|---|---|---|---|
| ListOps | 36.37 | 49.23 | 58.35 | +21.98 |
| Text (IMDb) | 64.23 | 65.93 | 86.82 | +22.59 |
| Retrieval (AAN) | 89.79 | 55.99 | 90.90 | +1.11 |
| Image (CIFAR-10) | 42.44 | 55.80 | 87.26 | +44.82 |
| Pathfinder | 70.72 | 61.33 | 86.05 | +15.33 |
| Path-X | 88.69 | 67.58 | 87.12 | -1.57 |
| Average | 62.05 | 64.84 | 86.09 | +24.04 |
S4 is a Linear Time-Invariant (LTI) system. Its parameters A, B, C, and Δ are learned during training but fixed at inference. This means:
This is the fundamental weakness that Mamba would later address.
上一篇:HiPPO (Gu et al., 2020) — introduced the polynomial projection theory for memory. S4 is the practical application of HiPPO theory to deep learning.
下一篇:Mamba (Gu & Dao, 2023) — S4 + input-dependent selectivity (B, C, Δ become functions of x). Inherits HiPPO initialization, NPLR decomposition, and the convolutional-recurrent duality from S4.
引用/采用:S4 spawned the entire structured SSM family: S4D (diagonal S4), DSS, Mega (simplified gated SSM), and ultimately Mamba and Mamba-2. It is also a key building block in state-space vision models.
S4 is a pivotal paper not because it achieved the best numbers (Mamba later surpassed it), but because it proved the SSM hypothesis: that a well-designed recurrent model can match Transformers on long-range tasks. Before S4, the community largely believed that attention was necessary for long-range reasoning. S4 showed that the bottleneck was not the architecture but the parameterization of the state transition.
The NPLR decomposition is the most technically beautiful part: it's a textbook example of using mathematical structure (normal matrix theory + Woodbury identity) to turn an O(N2) algorithm into O(N). This type of "structure-aware algorithm design" is what separates groundbreaking ML papers from incremental ones.
The lesson for future researchers: don't blame the architecture class, fix the parameterization.