State Space Models for Language › Linear Time Invariance and the Convolution View

Michael BrenndoerferNovember 17, 20264 min read
Language AI HandbookAll chapters
Part 19 of 67Alternative Sequence and Generative Architectures
Chapter 133State Space Models for Language › Linear Time Invariance and the Convolution View
Reading section 5 of 13 · Linear Time Invariance and the Convolution View · 4 minSection 5 of 13 · 4 min

Section 5 of 13 · 4 min read

Reading settings

Definitions

Choose how many terms have tooltips.

Article links

Make inline references clickable

Notes & comments

Now set the initial state to zero, x−1=0x_{-1} = 0, and unroll the recurrence for a few steps to see the pattern.

x0=Bˉu0x1=AˉBˉu0+Bˉu1x2=Aˉ2Bˉu0+AˉBˉu1+Bˉu2\begin{aligned} x_0 &= \bar{B} u_0 \\ x_1 &= \bar{A}\bar{B} u_0 + \bar{B} u_1 \\ x_2 &= \bar{A}^2 \bar{B} u_0 + \bar{A}\bar{B} u_1 + \bar{B}u_2 \end{aligned}

At each step the state receives another input and propagates every earlier contribution through one more application of the transition. An input from jj therefore passes through k−jk-j transitions by position kk. The general form is

xk=∑j=0kAˉ k−jBˉ uj.x_k = \sum_{j=0}^{k} \bar{A}^{\,k-j} \bar{B}\, u_j .

Apply the readout to that state.

yk=∑j=0kCAˉ k−jBˉ uj+D uk.y_k = \sum_{j=0}^{k} C \bar{A}^{\,k-j} \bar{B}\, u_j + D\, u_k .

Define the state-mediated impulse response taps

Kˉj=CAˉ jBˉfor j≥0.\bar{K}_j = C \bar{A}^{\,j} \bar{B} \quad \text{for } j \ge 0 .

With zero initial state, a unit input at position zero produces the state-mediated response Kˉj\bar K_j at lag jj. An input of amplitude uju_j at position jj contributes ujKˉk−ju_j\bar K_{k-j} to the state-mediated output at position k≥jk\ge j. Summing these scaled, shifted responses gives the causal convolution. The direct path adds DukD u_k.

yk=∑j=0kKˉj uk−j+D uk.y_k = \sum_{j=0}^{k} \bar{K}_j\, u_{k-j} + D\, u_k .

Three things are doing work here.

Zero initial state. For x−1≠0x_{-1}\ne0, add CAˉk+1x−1C\bar A^{k+1} x_{-1} to the convolution output at position kk. This term propagates the existing state over the same k+1k+1 updates.

Causal truncation. The sum at kk includes only lags 00 through kk. For the first LL outputs, it is exact to build a length-LL kernel and retain the first LL entries of the full linear convolution. Later taps would apply only at later outputs.

The direct path. The direct contribution changes the lag-zero tap to CBˉ+DC\bar B+D. The later taps stay at CAˉjBˉC\bar A^j\bar B. The example below folds the direct path into the lag-zero tap.

For a known sequence, the convolution can evaluate the LL outputs together. During autoregressive decoding, an implementation can use the recurrence to update its last state as each new input arrives. For a diagonal transition, updating and reading a state of width NN uses O(N)O(N) arithmetic per channel.

The equality between convolution and recurrence holds in exact arithmetic. A numerical comparison needs a tolerance because the two evaluation orders accumulate rounding differently.

Building the Kernel and Applying It

Building a length-LL kernel and applying it are separate computations.

  • Build the taps. In a diagonal system of state size NN, you can start with Bˉ\bar B and multiply elementwise by the diagonal of Aˉ\bar A for each lag. A dot product with CC gives each tap. That uses O(NL)O(NL) arithmetic for one channel.
  • Apply the kernel. Direct convolution over the causal pairs takes O(L2)O(L^2) arithmetic per channel. FFT convolution with padding for a linear convolution takes O(Llog⁡L)O(L\log L) for that length. Keep the first LL outputs for the causal readout.

S4 builds its kernel by evaluating the finite generating function at the LL roots of unity and transforming those evaluations back to coefficients. For a complex evaluation point zz, the finite sum is

K^(z)=∑j=0L−1Kˉjzj=C(∑j=0L−1(zAˉ)j)Bˉ.\widehat K(z) = \sum_{j=0}^{L-1}\bar K_j z^j = C\left(\sum_{j=0}^{L-1}(z\bar A)^j\right)\bar B .

When I−zAˉI-z\bar A is invertible, summing the matrix geometric series gives

K^(z)=C(I−zAˉ)−1(I−(zAˉ)L)Bˉ.\widehat K(z) = C(I-z\bar A)^{-1}\bigl(I-(z\bar A)^L\bigr)\bar B .

At the roots of unity the last factor is I−AˉLI-\bar A^L. This factor preserves the exact finite kernel, including modes that still carry substantial weight at lag LL. It can be merged into the readout because it commutes with (I−zAˉ)−1(I-z\bar A)^{-1}. This leaves an expression that a structured matrix algorithm can compute across the evaluation points. See S4, section 3.2 and Appendix C.

Comments

Add to the conversation

A question, a correction, or an example from your own work.

No comments yet. Be the first to share your thoughts!

Newsletter

Stay up to date

Get new articles, book updates, and notes on AI and technology.

Unsubscribe at any time. Privacy policy