Memory Determines Learning Direction: A Theory of Gradient-Based Optimization in State Space Models

JingChuan Guan, Tomoyuki Kubota, Yasuo Kuniyoshi, Kohei NakajimaNeurIPS 2026

TL;DR

State Space Models (SSMs) like Mamba are giving Transformers a serious run for their money, yet we still don't fully grasp how they learn. By rethinking gradient descent through the lens of a network's "memory," the authors prove that if an SSM isn't initialized to remember distant inputs on day one, gradient descent simply cannot recover that lost supervisory signal later. Surprisingly, this means you don't need to train the core recurrent weights of SSMs at all—freezing them at a good initialization actually makes training faster, more stable, and often more accurate.

What Problem Does This Paper Address?

For decades, training Recurrent Neural Networks (RNNs) has been haunted by the vanishing gradient problem: as error signals travel backward through time, repeated matrix multiplications cause them to shrink exponentially, leaving early steps in the dark.

Modern State Space Models (SSMs)—sleek, highly efficient cousins of RNNs—bypass many traditional bottlenecks using clever mathematical initializations (like HiPPO) and simplified diagonal matrices. Empirically, we know these initializations are crucial, and we suspect prioritizing memory length over step-by-step memory accuracy works best. What we've lacked is a rigorous theoretical explanation for why. Could gradient descent naturally stretch out a short-sighted initialization during training? And are simplified diagonal SSMs truly equivalent to dense ones?

Methods

Instead of looking at backpropagated error signals in isolation, the authors explicitly rewrite both the model's outputs and the supervisory target signals as functions of the input history.

To measure what the network actually retains, they borrow a tool from dynamical systems called the Memory Function (MF)—a metric quantifying how well a linear readout can reconstruct an input from $\tau$ steps ago using the network's current hidden state.

  1. Theoretical Reformulation: They analytically derive the gradient updates for linear and nonlinear readout layers, discovering that the MF matrix acts directly as a mathematical filter on the supervisory target signal during backpropagation.
  2. The Reservoir Computing (RC) Setting: Inspired by classical Reservoir Computing, they propose a dead-simple modification to standard SSM training: initialize the recurrent layer with long-memory eigenvalues, freeze them completely, and only train the surrounding readout/projection weights. They test this on both linear SSMs (S4D) and a flagship nonlinear SSM (Mamba).
Eigenvalue magnitudes and corresponding Memory Functions (MF) for five initialization schemes, showing structured HiPPO variants (S4Dinv, S4Dlin) maintain memory over much longer delays τ.

Datasets

No new benchmarks were introduced; the authors evaluated their theory on established sequence-modeling gauntlets:

  • Long Range Arena (LRA): All six tasks (ListOps, Text, Retrieval, Image, Pathfinder, and PathX), designed specifically to stress-test a model's ability to capture long-range dependencies in linear SSMs.
  • Language Modeling: A multi-billion-token autoregressive language modeling task used to test the nonlinear Mamba architecture.

Key Insights and Ideas

  • Vanishing gradients aren't the whole story: Even when an error signal is non-zero, learning can stall completely. The gradient direction depends on the overlap (inner product) between the memory supplied by the SSM and the memory demanded by the target label. If the SSM has zero memory at delay $\tau$, supervisory info from $\tau$ steps ago is multiplied by zero and permanently discarded before parameters can update.
  • Initialization is destiny: Because total memory capacity is upper-bounded by the state dimension $N$, stretching memory to cover long delays forces a trade-off with memory accuracy at individual steps. Prioritizing length at initialization is non-negotiable—even weak memory lets gradients flow, whereas zero memory blinds the optimizer.
  • Diagonal SSMs lose nothing: Because the Memory Function completely characterizes linear SSM information processing and depends solely on the recurrent matrix's eigenvalues, input weights and eigenvectors can be eliminated. Thus, diagonal S4D is theoretically equivalent to full-matrix S4.
  • Training recurrent weights is risky business: Long-memory eigenvalues live dangerously close to a magnitude of $1$ (beyond which states explode). Allowing gradient descent to nudge them risks destabilizing the network or cannibalizing long-term memory to boost short-term accuracy.
Figure 3: The supremum MF (left panels) and the linear readout weights Wout (right panels) at the last layer before and after training. In the left panels, the horizontal (vertical) axis shows the input delay τ (MF). The colors indicate the eigenvalue realizations. The state size N is 32, and the results are obtained by calculating Eq. 3 with T = 1024. In the right panels, the horizontal (vertical) axis represents the indices of SSMs from the following (preceding) layer. The preceding layer has twice as many indices as the following layer, owing to the bidirectional structure. As an example, we show the results for the Pathfinder task. The results of all layers are presented in Fig. 9 and Fig. 11 in the appendix.

Key Results

Freezing the recurrent weights (the RC setting) didn't just match standard training—it frequently beat it while cutting learnable parameters by up to 14% in LRA models:

  • Higher & More Robust LRA Accuracy: Using structured initializations (S4Dinv and S4Dlin), freezing eigenvalues yielded higher minimum accuracies across 6 random seeds on 5 out of 6 LRA tasks. On Retrieval, average accuracy jumped from 0.812 (trainable S4Dinv) to 0.904 (frozen RC S4Dinv). On PathX, RC S4Dlin reached 0.929 average accuracy versus 0.918 when trained.
  • Faster Convergence & Less Overfitting: Across Image, Retrieval, and PathX, frozen-eigenvalue models converged noticeably faster in test loss and showed smaller train-test gaps.
  • Smoother Mamba Training: In language modeling (up to ~4.5 billion tokens), freezing Mamba's recurrent parameters eliminated violent early-training loss spikes seen at higher learning rates (1e-2 and 5e-3) and converged to a lower final training loss across all tested learning rates.
Figure 2: Test loss and accuracy of three tasks. The top (bottom) row indicates test loss (accuracy), and each column corresponds to a different task. The horizontal axes represent epochs. Lines represent averages across seeds, with shaded regions indicating standard deviations. Solid lines represent models in the RC setting, while dotted lines indicate models with trainable eigenvalues. Each color represents a different eigenvalue realization.

Limitations and Future Work

  • Short-memory tasks: If a task only cares about the immediate past, keeping long-memory eigenvalues frozen wastes finite memory capacity on irrelevant history. On ListOps, for instance, allowing eigenvalue training slightly outperformed the frozen setup (0.592 vs. 0.576 mean accuracy).
  • Length vs. Accuracy entanglement: In standard linear SSMs, extending memory length also bumped up overall memory rank/accuracy, meaning the experiments couldn't cleanly isolate the benefit of length alone.
  • Designing optimal memory: While HiPPO-based initializations work great, there is no guarantee they produce the mathematically optimal Memory Function. Future work could focus on algorithms that explicitly sculpt custom MF profiles tailored to specific tasks before training even begins.

Summary updated

Abstract

State space models (SSMs) have shown strong potential to outperform Transformers, but their learning mechanisms remain poorly understood, particularly the conditions for successful parameter updates that preserve supervisory information. Prior work attributes the difficulty of such updates to the vanishing gradient problem during backpropagation through time, in which error signals decay exponentially through repeated gradient multiplication. In this work, by expressing error signals explicitly as functions of inputs, we show that the conventional vanishing gradient framework is insufficient to explain a loss of supervisory information. Using this representation of error, we reveal that the memory of the input encoded in supervisory information does not necessarily decay exponentially, and we analytically demonstrate that the loss of supervisory information cannot be alleviated through training. This result theoretically confirms the importance of the initial weights of SSMs and suggests that the recurrent layer does not require training. By performing experiments on both linear SSMs and a representative nonlinear SSM, including language modeling tasks, we confirm that appropriate initialization allows the recurrent parameters to remain fixed during training, leading to more stable training of the entire network and higher performance than the conventional training scheme. Our results partially elucidate the learning mechanisms of SSMs and are expected to contribute to the development of improved recurrent neural network models.
BibTeX
@inproceedings{guan2026memory,
  author = {JingChuan Guan and Tomoyuki Kubota and Yasuo Kuniyoshi and Kohei Nakajima},
  title = {{Memory Determines Learning Direction: A Theory of Gradient-Based Optimization in State Space Models}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2026},
  url = {https://openreview.net/forum?id=9hVb8yc7Jr},
}
Figure