Princeton University / Research talk

Linear Attention,
State Spaces, and RLT

Memory updates and computation across tokens

Based on A Note on Linear Attention and State Space Models
and Recurrent Looped Transformer

Arrow keys to navigate / O overview / N speaker notes

01 / 14

01 / A common language

The state-space view

\[h_t=\mathcal F_\theta(h_{t-1};u_t),\qquad y_t=\mathcal G_\theta(h_t;u_t)\]
ObjectMeaningQuestion to ask
State \(h_t\)Information carried into the next updateWhat must persist?
Input \(u_t\)New data and conditioning featuresWhat is available before the update?
Transition \(\mathcal F_\theta\)The rule that transforms the stateAffine or nonlinear in the old state?

The recurrence index can represent token position or network depth.

Note: Yifan Zhang and Sun-Yuan Kung
RLT: Yifan Zhang, Jichen Feng, Shihan Qin, Sun-Yuan Kung, and Mengdi Wang

Note / State-space representations / RLT / Sequence and state

02 / 14

02 / Linear attention

Linear attention as recurrent memory

Key features \(a_t=\phi(k_t)\), query features \(b_t=\phi(q_t)\). Read after writing the current token.

\[S_t=S_{t-1}+a_tv_t^\top,\qquad z_t=z_{t-1}+a_t,\qquad y_t=\frac{S_t^\top b_t}{z_t^\top b_t+\varepsilon}\]

State size \(O(md_v)\) stays fixed as the sequence grows. The vector \(z_t\) supplies the normalizer.

Note / Linear attention and original figure / Katharopoulos et al., 2020

03 / 14

03 / Exact dual views

The same computation in attention form

\[S_t=\sum_{j\le t}a_jv_j^\top\quad\Longrightarrow\quad S_t^\top b_t=\sum_{j\le t}(b_t^\top a_j)v_j\]
\[Y=(M\odot\Phi_Q\Phi_K^\top)V,\qquad M_{tj}=\mathbf 1\{j\le t\}\]

Same outputs, different evaluation: a running state or a causal \(T\times T\) score matrix.

Unnormalized outputs shown. Normalized attention also divides each row by its kernel sum.

Note / Original recurrent and parallel views / Katharopoulos et al., 2020

04 / 14

04 / Decay and selectivity

Selective SSMs and state-space duality

The SSM core

\[h_t=\bar A_t h_{t-1}+\bar B_t x_t\]
\[y_t=C_t^\top h_t\]

Mamba selects \(\Delta_t,B_t,C_t\) from layer inputs.
\(\bar A_t=\exp(\Delta_t A)\).

Scalar-transition SSD, with zero initial state

\[\begin{aligned} S_t&=\rho_t S_{t-1}+B_t x_t^\top,\qquad y_t=S_t^\top C_t\\[3pt] Y&=(L\odot CB^\top)X,\qquad L_{tj}=\mathbf 1\{j\le t\}\,\textstyle\prod_{r=j+1}^{t}\rho_r \end{aligned}\]

\(C\): queries, \(B\): keys, \(X\): values. Setting \(\rho_t=1\) recovers causal linear attention.

Note / Selective SSMs and SSD / Gu and Dao / Mamba, Fig. 1 / Dao and Gu / SSD

05 / 14

05 / Corrective memory

DeltaNet writes the retrieval error

\[\begin{aligned} S_t&=S_{t-1}+\eta_ta_t\bigl(v_t-S_{t-1}^\top a_t\bigr)^\top\\[3pt] &=\bigl(I-\eta_ta_ta_t^\top\bigr)S_{t-1}+\eta_ta_tv_t^\top \end{aligned}\]

Write the retrieval error. The update is affine in the old state when the inputs are fixed.

Green arrows: writes. Dashed red arrows: key-dependent edits to the old memory.

Note / Delta Networks and original figure / Yang et al., 2024

06 / 14

06 / The algebra of parallel evaluation

Why affine updates admit a scan

Fix a layer’s input sequence. Represent one transition by \((A_t,c_t)\):

\[h_t=A_t h_{t-1}+c_t\]
\[\underbrace{(A_2,c_2)\circ(A_1,c_1)}_{\text{two consecutive updates}}=(A_2A_1,\ A_2c_1+c_2)\]

Closed under composition

A segment of updates is still one affine map. Prefix composition is associative.

Structure controls cost

Additive, diagonal, scalar, and low-rank forms support efficient implementations.

A general nonlinear recurrence has no comparable fixed-size affine summary.

Note / Structured transitions / Mamba / Parallel scan / DeltaNet / Parallelization

07 / 14

07 / Recurrent Looped Transformer

RLT: a Transformer decoder as the recurrent cell

Causal encoder

Known tokens produce \(e_t\) and prefix memory \(M_{\le t}\).

Gated feedback

Merge \(e_t\) with the previous final decoder output \(s_{t-1}\).

Full decoder update

SWA, cross-attention, and an FFN transform the merged input.

SWA = sliding-window attention.
Every output predicts the next token.

RLT / Encoder, gated merge, and decoder blocks

08 / 14

08 / A nonlinear state-space system

RLT’s explicit state-transition function

Complete decoder state: \(H=(s,C^D)\), including the feedback vector and local KV cache.

\[\boxed{\mathcal F_\Theta(H;e,M,t):=D_\phi\bigl(\operatorname{Merge}(e,s);M,C^D,t\bigr)}\]
\[\begin{aligned} r&=\operatorname{Norm}_s(s),\qquad g=\sigma\bigl(W_g[e;r]+b_g\bigr),\\ \operatorname{Merge}(e,s)&=e+\alpha\,g\odot W_s r \end{aligned}\]
\[H_t=\mathcal F_\Theta(H_{t-1};e_t,M_{\le t},t),\qquad H_0=(s_\star,\varnothing)\]
\[\mathcal G_\Theta(H)=\operatorname{softmax}\bigl(W_o\operatorname{Norm}_o(s)\bigr),\qquad p_\Theta(\cdot\mid x_{1:t})=\mathcal G_\Theta(H_t)\]

One transition updates both \(s_t\) and \(C_t^D\), conditioned on encoder features and memory.

RLT / Method, with the current manuscript’s explicit state-space notation

09 / 14

09 / RNN interpretation

Feedback extends the computation across tokens

\[H_T=F_T\circ\cdots\circ F_1(H_0),\qquad F_t(H)=\mathcal F_\Theta(H;e_t,M_{\le t},t)\]

Per token

\(L_E+L_D\) Transformer blocks.
The merge connects successive updates.

Across \(T\) tokens

The feedback path traverses \(T L_D\) decoder blocks with parameters reused.

Known-token encoding is parallel. RLT-1 decoder updates follow token order.

RLT / Prompt-state composition and depth accounting

10 / 14

10 / RLT evidence

Length generalization depends on the depth split

Eight-layer models. Test accuracy at length 256, mean ± sample SD over three seeds.

TaskRLT-1 allocationGPT Layer 8RLT-1
Parity
Train: 3–40 bits
Layer 5 + 3
or Layer 7 + 1
50.07 ± 1.63%100.00 ± 0.00%
Swaps-\(S_5\)
Train: 32 operations
Layer 4 + 40.85 ± 0.30%97.30 ± 2.76%

Parity favors a shallow decoder. Swap tracking benefits from more decoder layers.

2,000 training steps, seeds 42–44, 1,024 shared test examples per length.
Each run selects its checkpoint using minimum in-distribution validation loss.

Layer counts match. Parameters and compute differ: RLT-1 has 26.10–28.73M parameters, versus GPT’s 25.31M.

RLT / Algorithmic experiments and length extrapolation

11 / 14

11 / RLT-1 and RLT-2

Feedback frequency and parallelism

At Layer 4 + 4Feedback intervalParity / 64 bitsSwaps-\(S_5\) / 64 ops
RLT-11 token100.00 ± 0.00%100.00 ± 0.00%
RLT-24 tokens98.99 ± 1.66%19.60 ± 6.54%

RLT-2 shares the previous boundary state within each chunk.
Known positions in a chunk run in parallel, then its last output updates feedback.

Final-answer/state accuracy, mean ± sample SD, seeds 42–44. Same checkpoint protocol as the previous slide.

RLT / Feedback frequency / RLT-2 / Chunk semantics

12 / 14

12 / Comparing the mechanisms

State size and parallel evaluation

Model coreUpdate in the previous statePersistent memory*Known-token evaluation
Linear attentionAdditive / affineFixed matrix and normalizerPrefix sums or chunked contraction
Selective SSMInput-conditioned affineFixed stateStructured scan or SSD
DeltaNetAffine rank-one editFixed matrixStructured chunk algorithm
RLT-1Nonlinear decoder cellBounded decoder state,
growing encoder memory
Parallel encoder,
sequential decoder

*At fixed width, depth, and local window. State sizes refer to inference, excluding training activations.

Note / Linear attention, SSD, and Delta Networks / RLT / State and execution

13 / 14

13 / Connection to RLT

The transition determines the computation

Structured recurrent memory

\[h_t=A_t h_{t-1}+c_t\]

Linear attention, SSMs, and DeltaNet compress history through structured affine updates.

Nonlinear recurrent computation

\[H_t=\mathcal F_\Theta(H_{t-1};e_t,M_{\le t},t)\]

RLT reuses a complete decoder cell across tokens and retains explicit context memory.

The state-space view connects the models.
The transition’s structure determines what can be composed efficiently.

Open question: can a structured transition retain RLT’s state-tracking gains?

Zhang and Kung / Linear Attention and SSMs / Zhang et al. / RLT

14 / 14

Slide navigator 14 slides / Esc to close

Keyboard & controls

→ / Space / Page Down
Next slide
← / Page Up
Previous slide
Home / End
First / last slide
O
Slide overview
N
Speaker notes for the current slide
F
Fullscreen
?
Help
Esc
Close a dialog
Print
One 16:9 slide per page

Speaker notes

Figure

Open figure ↗