Two Layers of Attention Stability: A Koopman-Operator Analysis of Linear and Softmax Attention

zhenglong chenNeurIPS 2026

TL;DR

Why does standard softmax attention sail smoothly over long prediction horizons while unnormalized linear attention frequently explodes into NaNs? By viewing attention through the lens of dynamical systems, this paper untangles how tokens mix from how states evolve—revealing that softmax’s secret weapon isn’t positive weights or kernel tricks, but a subtle mathematical speed limit on its row sums.

What Problem Does This Paper Address?

Transformers rely on softmax attention, which scales quadratically with sequence length ($O(n^2)$). Researchers often swap it out for "linear attention" variants to speed things up. However, when you strip away the softmax denominator—leaving raw, unnormalized bilinear attention—models become notoriously unstable during long-horizon autoregressive rollouts, collapsing or diverging wildly.

Existing theories blame rank collapse or expressivity gaps, but none fully explain why unnormalized attention blows up when predicting far into the future, even on underlying systems that are inherently stable. The author tackles a fundamental question: what exact mathematical mechanism keeps softmax stable over time, and how do we isolate it without crippling the model's ability to learn complex dynamics?

Methods

The author introduces a Two-Object Framework that splits an attention layer into two distinct mathematical roles:

  1. Architectural stability ($n \times n$ token-mixing matrix, $A$): Governs how information blends across the sequence length $n$.
  2. Dynamical stability ($d \times d$ dual operator, $C$): Governs how the $d$-dimensional state features evolve step-by-step.

Under idealized, unmasked conditions, the author proves that unnormalized linear attention secretly solves Extended Dynamic Mode Decomposition (EDMD)—a classic physics technique for approximating the Koopman operator (a linear map of nonlinear dynamics). This means $C$ needs to be left completely unconstrained so it can track genuinely growing or chaotic systems.

To stabilize the network without handcuffing $C$, the author constrains only the token-mixing matrix $A$, designing two diagnostic testbeds (both $O(n^2)$ tools to test the theory, rather than new fast architectures):

  • Row-Normalized Linear Attention (RN-LA): Divides each row of $A$ by the sum of its absolute values, enforcing an induced $\ell_\infty$ norm bound ($\|A\|_\infty \le 1$) while still allowing negative attention weights.
  • Spectral-Normalized Linear Attention (SN-LA): Scales $A$ by its spectral radius (largest eigenvalue magnitude, $\rho(A)$) or spectral norm ($\|A\|_2$), tested via both power-iteration estimates and exact mathematical controls.

Datasets

  • Synthetic Linear-Gaussian Trajectories: A controlled 8-dimensional synthetic system where the true transition matrix's spectral radius ($\rho$) is tuned across $\{0.90, 0.95, 1.00, 1.05\}$ to cleanly separate model-induced explosions from genuinely unstable data.
  • Long-Horizon Time-Series Benchmarks: Standard real-world forecasting suites—ETTh1, ETTh2, ETTm1, ETTm2 (electricity transformer temperatures), and Weather—evaluated using a PatchTST backbone across prediction horizons from 96 to 720 steps, plus free-running autoregressive rollouts on ETTh1.

Key Insights and Ideas

  • Why Spectral Radius Fails Over Time: You might assume keeping eigenvalues at or below 1 ($\rho(A_t) \le 1$) prevents explosions. Not for time-varying matrices! Multiplying benign lower-triangular shear matrices like $\begin{pmatrix} 1 & 0 \\ 1 & 1 \end{pmatrix}$ $T$ times yields $\begin{pmatrix} 1 & 0 \\ T & 1 \end{pmatrix}$, growing linearly to infinity. Conversely, an induced operator norm like $\|A_t\|_\infty \le 1$ is submultiplicative—meaning products of matrices stay strictly bounded forever.
  • Positivity Is a Red Herring for Stability: Standard normalized linear attention uses positive feature maps so weights sum to 1 like probabilities. RN-LA proves that positivity isn't required for the stability certificate—bounding absolute row sums stops explosions even with negative weights. (Positivity is only needed if you want to factorize the math into $O(n)$ time!).
  • RMSNorm Beats LayerNorm for Identifiability: In the idealized EDMD setup, standard LayerNorm centers features, creating a zero-sum direction that makes the optimal linear operator mathematically non-unique. Non-affine RMSNorm rescales without centering, preserving full matrix rank.
  • No Silver Bullet: Bounding $\|A\|_\infty \le 1$ only certifies the token-mixing sub-layer. Because value projections ($W_V$), MLPs, and residual connections sit outside this bound, even softmax cannot guarantee whole-network stability.

Key Results

Across 120 synthetic training runs, methods with the $\ell_\infty$ row-sum certificate dominated:

Figure 1: Free-running output norm ∥ˆzk∥, five-seed median with ground truth in grey; non-finite values are displayed at 1012. The two sweep extremes are shown (all radii: Fig. 2). At ρ = 0.90 the transition is mean-square stable, so catastrophic output growth is model-generated. These curves measure magnitude, not prediction accuracy.
  • Synthetic Rollouts: RN-LA (18/20) and Causal Softmax (17/20) passed a strict joint test of 100-step rollout finiteness and training fit, with zero NaN/infinite rollouts. Vanilla LA (5/20), estimated SN-LA (3/20), exact-$\rho$ SN-LA (7/20), and exact-$\|A\|_2$ SN-LA (6/20) frequently diverged—even when the ground-truth system was stable ($\rho = 0.90$).
Table 1: Runs meeting the joint criterion, out of 5 seeds per cell (120 total): rollout stays below the stated threshold, training-window one-step relative error is below 0.5, and fitted ρ(Ceff) is within 30% of the target. The last two are training-fit screens, not held-out accuracy or non-collapse guarantees (App. G.3).
  • Real-World Free-Running Rollouts: On 100 free-running 96-step ETTh1 trajectories, Softmax and RN-LA stayed bounded in 100/100 cases, whereas Vanilla LA blew up to non-finite values in 92/100 runs.
  • Patch-Based Forecasting: On the 5-dataset benchmark at horizon $H=720$, SN-LA and RN-LA closed 85% and 96% of the accuracy gap between Vanilla LA and Softmax (with counterexamples noted on ETTh2, where softmax beat both, and ETTm2, where Vanilla LA surprisingly edged out softmax at $0.350$ vs. $0.363$).

Limitations and Future Work

The author is refreshingly candid about the scope of the math:

  • Partial Certificate: $\ell_\infty$ normalization prevents token-mixing products from expanding, and prevents numerical blowups in practice, but leaves $W_V$ and MLPs unconstrained—meaning models can still underfit or fail to track genuinely unstable modes ($\rho = 1.05$).
  • Quadratic Cost: Signed RN-LA must materialize the $n \times n$ matrix ($O(n^2)$) because absolute values break the associative trick needed for $O(n)$ linear attention.
  • Idealized Theory: The exact Koopman/EDMD equivalence only holds for single-head, unmasked, fixed-encoder setups; causal masking creates position-dependent operators that break the global identity. Extending these diagnostics to multi-head deep Transformers or recurrent state-space models like Mamba and RWKV remains an open frontier.

Summary updated

Abstract

We study long-horizon attention stability by separating the $n\times n$ token-mixing matrix from the $d\times d$ projected dynamical operator. Under a fixed shared encoder, full rank, one head with full-width square projections, and an unmasked full window, the optimal dual operator equals the EDMD estimator, giving a Koopman/Galerkin interpretation and an approximation-error floor. Causal masking generally precludes this global identity. Independently, softmax and absolute-row normalization supply an input-uniform induced-norm bound for compatible token-mixing products, regardless of entry signs. Per-step spectral radius alone does not provide this bound, and neither certificate guarantees complete-network rollout stability. Non-affine LayerNorm also makes the full-window least-squares solution non-identifiable under a generic-rank assumption, whereas non-affine RMSNorm preserves rank. Across $120$ synthetic runs, RN-LA and softmax meet a joint rollout-and-training-fit criterion in $18/20$ and $17/20$ runs, with no non-finite rollout. Exact spectral-radius and spectral-norm controls do not close this joint gap. Free-running ETTh1 and input-scale diagnostics complement the ETT/Weather forecasting experiments. The evaluated sign-general normalizers cost $O(n^2)$; structured spectral-radius constraints can be linear in sequence length, while the non-negative row-certified special case recovers existing normalized linear attention. The framework thus connects scoped projected-dynamics theory with token-mixing design criteria and finite-horizon empirical diagnostics.
BibTeX
@inproceedings{chen2026two,
  author = {zhenglong chen},
  title = {{Two Layers of Attention Stability: A Koopman-Operator Analysis of Linear and Softmax Attention}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2026},
  url = {https://openreview.net/forum?id=NakvgMzgsK},
}
Figure