Simple Algorithm
Deep Learning · Emergence · 28 min

Recurrence Returns: xLSTM & Parallel RNNs

Exponential gating, matrix memories and recurrent networks that train in parallel.

Transformers won the late 2010s by training in parallel; recurrent networks keep the advantage at inference, with a fixed cost per token. A truce arrived in the 2020s: if the state update is linear in the state, a parallel scan trains the recurrence in logarithmic depth, and gates computed from the input alone keep much of the expressive power. Here you derive the scan, meet the minimal gated RNNs, take apart xLSTM's exponential gates and matrix memory, and see what is given up.

What you’ll learn

  • Compare the training and inference costs of nonlinear RNNs, transformers and linear recurrences, and identify the property that permits parallel training.
  • Derive the associative operator for ht=at⊙ht−1+bt\mathbf h_t=\mathbf a_t\odot\mathbf h_{t-1}+\mathbf b_t, prove associativity, and analyze the depth and work of the Hillis–Steele and Blelloch scans.
  • Explain QRNNs, SRUs and the minimal gated RNNs minGRU and minLSTM as recurrences whose gates ignore the state.
  • Write xLSTM's sLSTM and mLSTM cells, prove that their stabilizer leaves the output unchanged, relate RWKV and the RG-LRU to them, and state what is lost relative to nonlinear recurrence.

The trade-off

An LSTM layer must compute h1,h2,…,hT\mathbf h_1,\mathbf h_2,\dots,\mathbf h_T in order, because each gate reads ht−1\mathbf h_{t-1} through a nonlinearity: TT dependent steps per layer, each a small matrix product that leaves most of a GPU idle. A transformer computes all positions of a training sequence at once, but at inference it attends to a KV cache that grows with the context, so each new token costs more than the last. A recurrence that trains like a transformer and runs like an RNN needs one property: the new state must be an affine function of the old one, with coefficients that may depend on the input but not on the state.

ModelTraining: sequential steps per layerInference cost per tokenState kept at inference
Nonlinear RNN (LSTM, GRU)TTconstantfixed size
Transformer (causal)none: all positions in parallelgrows with the contextKV cache, grows with the context
Linear recurrence with a parallel scanabout log⁡2T\log_2Tconstantfixed size
Total work is another matter: attention costs O(T2d)\order{T^2d} per layer in training, a diagonal linear recurrence O(Td)\order{Td}. The fixed-size state that makes recurrences cheap is also their limit, as the last step of this lesson explains.

Linear does not mean ungated. In ht=at⊙ht−1+bt\mathbf h_t=\mathbf a_t\odot\mathbf h_{t-1}+\mathbf b_t the decay at\mathbf a_t can be a sigmoid gate computed from xt\mathbf x_t, and bt\mathbf b_t a gated candidate computed from xt\mathbf x_t; only the dependence on ht−1\mathbf h_{t-1} must stay linear. The nonlinearity moves between layers instead of within the recurrence, and depth supplies what the recurrence gives up.

Parallel scans

Each step of ht=at⊙ht−1+bt\mathbf h_t=\mathbf a_t\odot\mathbf h_{t-1}+\mathbf b_t applies an affine map h↦at⊙h+bt\mathbf h\mapsto\mathbf a_t\odot\mathbf h+\mathbf b_t, which we represent by the pair et=(at,bt)e_t=(\mathbf a_t,\mathbf b_t). Computing every ht\mathbf h_t means computing every prefix composition e1∙e2∙⋯∙ete_1\bullet e_2\bullet\cdots\bullet e_t: a prefix scan. Scans parallelize whenever the combining operation is associative (Blelloch, 1990).

DerivationThe scan operator and its associativity
  1. h↦a′⊙(a⊙h+b)+b′=(a′⊙a)⊙h+(a′⊙b+b′)⟹e∙e′=(a′⊙a, a′⊙b+b′)\mathbf h\mapsto\mathbf a'\odot(\mathbf a\odot\mathbf h+\mathbf b)+\mathbf b'=(\mathbf a'\odot\mathbf a)\odot\mathbf h+(\mathbf a'\odot\mathbf b+\mathbf b')\quad\Longrightarrow\quad e\bullet e'=(\mathbf a'\odot\mathbf a,\ \mathbf a'\odot\mathbf b+\mathbf b')

    Apply e=(a,b)e=(\mathbf a,\mathbf b) first and e′=(a′,b′)e'=(\mathbf a',\mathbf b') second. The composition is again an affine map, which defines the operator:

  2. (e∙e′)∙e′′=(a′′a′a, a′′a′b+a′′b′+b′′)=e∙(e′∙e′′)(e\bullet e')\bullet e''=\big(\mathbf a''\mathbf a'\mathbf a,\ \mathbf a''\mathbf a'\mathbf b+\mathbf a''\mathbf b'+\mathbf b''\big)=e\bullet(e'\bullet e'')

    Check associativity by expanding both groupings; elementwise products commute, so the results agree:

  3. ht=[e1∙e2∙⋯∙et]b\mathbf h_t=\big[e_1\bullet e_2\bullet\cdots\bullet e_t\big]_{\mathbf b}

    With h0=0\mathbf h_0=\mathbf 0, the state is the second component of the prefix composition. The identity element is (1,0)(\mathbf 1,\mathbf 0). (Composition of affine maps is associative in general, so matrix-valued transitions also scan, at the cost of matrix products.)

  4. Hillis–Steele: depth ⌈log⁡2T⌉, work O(Tlog⁡T);Blelloch: depth≈2log⁡2T, work O(T)\text{Hillis–Steele: depth }\lceil\log_2T\rceil,\ \text{work }\order{T\log T};\qquad\text{Blelloch: depth}\approx2\log_2T,\ \text{work }\order{T}

    Hillis–Steele (Hillis & Steele, 1986): in round rr, every position i≥2ri\ge2^r combines its pair with the pair 2r2^r positions earlier. After ⌈log⁡2T⌉\lceil\log_2T\rceil rounds every position holds its full prefix, at O(Tlog⁡T)\order{T\log T} total work. Blelloch's work-efficient scan uses an up-sweep and a down-sweep over a balanced tree: O(T)\order{T} work in about 2log⁡2T2\log_2T rounds.

python
import torch

def linear_scan(a, b):
    """All states of h_t = a_t * h_{t-1} + b_t with h_0 = 0, in ceil(log2 T) rounds.
    a, b: tensors of shape (T, ...); returns h of the same shape."""
    T, shift = a.shape[0], 1
    while shift < T:
        a_prev = torch.cat([torch.ones_like(a[:shift]), a[:-shift]])   # identity map
        b_prev = torch.cat([torch.zeros_like(b[:shift]), b[:-shift]])
        b = a * b_prev + b       # earlier segment first, then this one
        a = a * a_prev
        shift *= 2
    return b

A Hillis–Steele scan in a few lines: each round is a handful of elementwise operations over the whole sequence. Martin & Cundy (2018) implemented a work-efficient blocked scan as a CUDA kernel (each processor scans its own block of steps, and only the block summaries are combined across processors) and sped up the training of QRNN and SRU layers by up to 9×. Products of many gates below 1 can underflow, so practical kernels often work in log space.

Predict before you look

How many rounds does a Hillis–Steele scan need for a sequence of T=4,096T=4{,}096 steps?

Show the answer

12 rounds

⌈log⁡24096⌉=12\lceil\log_24096\rceil=12, against 4,095 sequential applications of the recurrence. The total work is larger: ∑r=011(T−2r)=45,057\sum_{r=0}^{11}(T-2^r)=45{,}057 combinations, of order Tlog⁡2TT\log_2T. Blelloch's scan brings it down to 2(T−1)=8,1902(T-1)=8{,}190 combinations over about 24 rounds. Either way, depth grows only logarithmically with length.

Gates that ignore the state

Several architectures took the step of computing every gate from the input alone. The quasi-recurrent neural network (QRNN; Bradbury, Merity, Xiong & Socher, 2017) computes candidates and gates with causal convolutions over a few past inputs, all positions at once, and keeps only a minimal recurrent "pooling", for example ht=ft⊙ht−1+(1−ft)⊙zt\mathbf h_t=\mathbf f_t\odot\mathbf h_{t-1}+(1-\mathbf f_t)\odot\mathbf z_t, with output- and input-gated variants. The simple recurrent unit (SRU; Lei, Zhang, Wang, Dai & Artzi, 2018) keeps a sliver of state dependence, but only elementwise:

ft=σ(Wfxt+vf⊙ct−1+bf),ct=ft⊙ct−1+(1−ft)⊙(Wxt)\mathbf f_t=\sigma(W_f\mathbf x_t+\mathbf v_f\odot\mathbf c_{t-1}+\mathbf b_f),\qquad\mathbf c_t=\mathbf f_t\odot\mathbf c_{t-1}+(1-\mathbf f_t)\odot(W\mathbf x_t)
All matrix products involve only xt\mathbf x_t, so they are batched over every time step at once; the remaining elementwise recurrence runs in one fused kernel, in parallel across dimensions. Lei et al. report 5–9× speed-ups over cuDNN's LSTM on classification and question answering. The vector vf⊙ct−1\mathbf v_f\odot\mathbf c_{t-1} makes the update nonlinear in the state, so the SRU is parallel across dimensions but still sequential in time.

Minimal gated RNNs. Feng, Tung, Ahmed, Bengio & Hajimirsadeghi (2024) strip the GRU and the LSTM down until a scan applies: gates and candidates depend on xt\mathbf x_t only. With the state gone from the gates, they also drop the candidate's tanh, as a further simplification. Written with ut\mathbf u_t for the share of the new candidate (in the GRU convention of LSTMs & GRUs, ut=1−zt\mathbf u_t=1-\mathbf z_t):

minGRU:  ht=(1−ut)⊙ht−1+ut⊙h~t,ut=σ(Linear⁡(xt)), h~t=Linear⁡(xt)minLSTM:  ht=ft⊙ht−1+it⊙h~tft+it\textbf{minGRU:}\ \ \mathbf h_t=(1-\mathbf u_t)\odot\mathbf h_{t-1}+\mathbf u_t\odot\tilde{\mathbf h}_t,\quad\mathbf u_t=\sigma(\operatorname{Linear}(\mathbf x_t)),\ \tilde{\mathbf h}_t=\operatorname{Linear}(\mathbf x_t)\qquad\textbf{minLSTM:}\ \ \mathbf h_t=\frac{\mathbf f_t\odot\mathbf h_{t-1}+\mathbf i_t\odot\tilde{\mathbf h}_t}{\mathbf f_t+\mathbf i_t}
In minLSTM, ft\mathbf f_t and it\mathbf i_t are sigmoid gates of xt\mathbf x_t and the division is elementwise, which keeps the state's scale independent of time; the output gate is dropped, so the cell and the hidden state merge. Both are scans of the form at⊙ht−1+bt\mathbf a_t\odot\mathbf h_{t-1}+\mathbf b_t.

A minGRU layer needs about 2nd2nd parameters against the GRU's 3n(n+d)3n(n+d), and a minLSTM about 3nd3nd against 4n(n+d)4n(n+d). Trained with a log-space scan, they reported training steps 175 (minGRU) and 235 (minLSTM) times faster than the sequential GRU and LSTM at length 512 on a T4 GPU, with the gap widening for longer sequences, and performance competitive with recent sequence models on their benchmarks. The recipe shared by all these models: compute gates and candidates from the input (often with a short convolution), run an elementwise linear recurrence, and stack layers with nonlinear mixing in between.

Check your understanding

Why can a minGRU layer be trained with a parallel scan while a GRU layer cannot?

  1. The minGRU has fewer parameters
  2. The minGRU has no gates
  3. The minGRU uses a ReLU instead of a tanh
  4. The GRU's gates and candidate read ht−1\mathbf h_{t-1} through sigmoids and a tanh, so ht\mathbf h_t is a nonlinear function of ht−1\mathbf h_{t-1}; the minGRU's coefficients depend only on xt\mathbf x_t, so ht\mathbf h_t is affine in ht−1\mathbf h_{t-1}
Show the answer

D. The GRU's gates and candidate read ht−1\mathbf h_{t-1} through sigmoids and a tanh, so ht\mathbf h_t is a nonlinear function of ht−1\mathbf h_{t-1}; the minGRU's coefficients depend only on xt\mathbf x_t, so ht\mathbf h_t is affine in ht−1\mathbf h_{t-1}

A scan needs each step to be an element of an associative family, here affine maps h↦at⊙h+bt\mathbf h\mapsto\mathbf a_t\odot\mathbf h+\mathbf b_t with at,bt\mathbf a_t,\mathbf b_t known in advance. Computing all at,bt\mathbf a_t,\mathbf b_t from the inputs first makes that possible.

xLSTM: exponential gates and matrix memory

xLSTM (Beck et al., 2024), from Hochreiter's group, revisits the LSTM with two changes: exponential gating, which lets a new, strongly gated input outweigh everything stored before, and new memory structures. It defines two cells. The scalar sLSTM keeps recurrent connections from ht−1\mathbf h_{t-1} into its gates ("memory mixing", restricted to blocks or heads) and adds a normalizer state:

ct=ft ct−1+it zt,nt=ft nt−1+it,ht=ot ctnt,it=exp⁡(ı~t),ft=σ(f~t) or exp⁡(f~t)c_t=f_t\,c_{t-1}+i_t\,z_t,\qquad n_t=f_t\,n_{t-1}+i_t,\qquad h_t=o_t\,\frac{c_t}{n_t},\qquad i_t=\exp(\tilde\imath_t),\quad f_t=\sigma(\tilde f_t)\ \text{or}\ \exp(\tilde f_t)
Per unit: zt=φ(z~t)z_t=\varphi(\tilde z_t) is the cell input and ot=σ(o~t)o_t=\sigma(\tilde o_t); every pre-activation has the form w⊤xt+r ht−1+b\mathbf w^\top\mathbf x_t+r\,h_{t-1}+b, with recurrent weights rr that make the sLSTM a genuinely nonlinear, sequential recurrence.
DerivationThe normalizer, and why stabilization is exact
  1. ctnt=∑j≤twt,j zj∑j≤twt,j,wt,j=ij∏k=j+1tfk\frac{c_t}{n_t}=\frac{\sum_{j\le t}w_{t,j}\,z_j}{\sum_{j\le t}w_{t,j}},\qquad w_{t,j}=i_j\prod_{k=j+1}^{t}f_k

    Unroll from c0=n0=0c_0=n_0=0: the cell is a weighted sum of past inputs and the normalizer the sum of the same weights, so ct/ntc_t/n_t is a weighted average of the zjz_j, however large the exponential input gates become:

  2. mt=max⁡(log⁡ft+mt−1, log⁡it),it′=elog⁡it−mt≤1,ft′=elog⁡ft+mt−1−mt≤1m_t=\max\big(\log f_t+m_{t-1},\ \log i_t\big),\qquad i'_t=e^{\log i_t-m_t}\le1,\qquad f'_t=e^{\log f_t+m_{t-1}-m_t}\le1

    Exponential gates can still overflow. Track a stabilizer mtm_t and rescale both gates by it:

  3. ct′nt′=e−mtcte−mtnt=ctnt\frac{c'_t}{n'_t}=\frac{e^{-m_t}c_t}{e^{-m_t}n_t}=\frac{c_t}{n_t}

    Run the recurrence with i′,f′i',f'. By induction ct′=e−mtctc'_t=e^{-m_t}c_t and nt′=e−mtntn'_t=e^{-m_t}n_t, since ft′ct−1′+it′zt=e−mt(ftct−1+itzt)f'_tc'_{t-1}+i'_tz_t=e^{-m_t}(f_tc_{t-1}+i_tz_t). The common factor cancels in the ratio, so the output, and every gradient, is unchanged while all stored numbers stay bounded:

The mLSTM gives each head a matrix memory written with the covariance update rule, which is a fast-weight write (Fast Weights & Test-Time Memory), gated by scalar input and forget gates per head and read with a query:

Ct=ft Ct−1+it vtkt⊤,nt=ft nt−1+it kt,ht=ot⊙Ctqtmax⁡{∣nt⊤qt∣, 1}C_t=f_t\,C_{t-1}+i_t\,\mathbf v_t\mathbf k_t^\top,\qquad\mathbf n_t=f_t\,\mathbf n_{t-1}+i_t\,\mathbf k_t,\qquad\mathbf h_t=\mathbf o_t\odot\frac{C_t\mathbf q_t}{\max\{\abs{\mathbf n_t^\top\mathbf q_t},\,1\}}
qt=Wqxt+bq\mathbf q_t=W_q\mathbf x_t+\mathbf b_q, kt=1dWkxt+bk\mathbf k_t=\tfrac1{\sqrt d}W_k\mathbf x_t+\mathbf b_k, vt=Wvxt+bv\mathbf v_t=W_v\mathbf x_t+\mathbf b_v, and the gates it=exp⁡(wi⊤xt+bi)i_t=\exp(\mathbf w_i^\top\mathbf x_t+b_i), ftf_t, ot\mathbf o_t depend on xt\mathbf x_t only. With no memory mixing the update is affine in Ct−1C_{t-1}, so the mLSTM can be computed in parallel, like gated linear attention with exponential input gates and a normalizer.

xLSTM stacks residual blocks built around the two cells, mixing mLSTM and sLSTM blocks in chosen ratios. The authors report that it performs favorably against transformers and state space models of similar size, both in performance and in how it scales; as with every architecture comparison at this scale, such results depend on training recipes and are best read as of 2024.

Relatives, and what is lost

RWKV (Peng et al., 2023) mixes information over time with a linear-attention-like operator whose contributions decay at a learned rate per channel, so the same model can be written as a transformer for parallel training or as an RNN for inference; it was scaled to 14 billion parameters and reported on par with similarly sized transformers. The RG-LRU of Griffin (De et al., 2024) is a gated diagonal linear recurrence in which, in the authors' words, "neither gate depends on the recurrent state":

rt=σ(Waxt+ba),it=σ(Wxxt+bx),at=ac rt,ht=at⊙ht−1+1−at2⊙(it⊙xt)\mathbf r_t=\sigma(W_a\mathbf x_t+\mathbf b_a),\quad\mathbf i_t=\sigma(W_x\mathbf x_t+\mathbf b_x),\quad\mathbf a_t=\mathbf a^{c\,\mathbf r_t},\quad\mathbf h_t=\mathbf a_t\odot\mathbf h_{t-1}+\sqrt{1-\mathbf a_t^2}\odot(\mathbf i_t\odot\mathbf x_t)
Here a=σ(Λ)\mathbf a=\sigma(\boldsymbol\Lambda) is a learned decay in (0,1)(0,1) and c=8c=8. The recurrence gate rt\mathbf r_t raises the decay to a power, so the input decides how fast to forget. The factor 1−at2\sqrt{1-\mathbf a_t^2} keeps the state's scale fixed: with a constant aa and uncorrelated unit-variance inputs, the stationary variance solves v=a2v+(1−a2)v=a^2v+(1-a^2), so v=1v=1. Hawk stacks RG-LRU blocks; Griffin mixes them with local attention.

Mamba belongs to the same family, with at=exp⁡(ΔtA)\mathbf a_t=\exp(\Delta_tA) for an input-dependent step size (Selective State Spaces: Mamba). All of these models buy parallel training by giving up one thing: the nonlinear dependence of the update on the previous state. The sLSTM keeps it and pays with sequential training. What it costs in power is concrete. A nonlinear RNN with saturating units can simulate any finite automaton, while diagonal linear recurrences with positive decays cannot even compute parity and, like transformers, cannot solve hard state-tracking problems unless TC0=NC1\mathsf{TC}^0=\mathsf{NC}^1 (What Recurrent Networks Can Compute). A fixed-size state also limits exact recall, the subject of Hybrid Models & the Limits of Fixed-Size Memory.

Can nonlinear recurrences be parallelized directly? DEER (Lim, Zhu, Selfridge & Kasim, 2024) treats the whole trajectory h1:T\mathbf h_{1:T} as the solution of a fixed-point equation and solves it with Newton's method. Each Newton step linearizes the recurrence around the current guess, ht(k+1)=Jt ht−1(k+1)+(f(ht−1(k),xt)−Jtht−1(k))\mathbf h^{(k+1)}_t=J_t\,\mathbf h^{(k+1)}_{t-1}+\big(f(\mathbf h^{(k)}_{t-1},\mathbf x_t)-J_t\mathbf h^{(k)}_{t-1}\big) with JtJ_t the Jacobian at the guess: a linear recurrence, solved by a parallel scan over matrices, with quadratic convergence near the solution. Dense Jacobians make each step cubic in the state size and the iteration can be unstable; Gonzalez, Warrington, Smith & Linderman (2024) use diagonal Jacobian approximations (quasi-DEER) and trust-region damping linked to Kalman smoothing (ELK) to scale it and stabilize it.

Key takeaways

  • Parallel training of a recurrence needs the update to be affine in the state, ht=at⊙ht−1+bt\mathbf h_t=\mathbf a_t\odot\mathbf h_{t-1}+\mathbf b_t, with input-dependent coefficients; inference keeps a fixed-size state and constant cost per token.
  • The pairs (a,b)(\mathbf a,\mathbf b) compose by the associative rule (a,b)∙(a′,b′)=(a′⊙a,a′⊙b+b′)(\mathbf a,\mathbf b)\bullet(\mathbf a',\mathbf b')=(\mathbf a'\odot\mathbf a,\mathbf a'\odot\mathbf b+\mathbf b'), so a scan computes all states in ⌈log⁡2T⌉\lceil\log_2T\rceil rounds (Hillis–Steele, O(Tlog⁡T)\order{T\log T} work) or about 2log⁡2T2\log_2T rounds with O(T)\order{T} work (Blelloch).
  • QRNN, SRU, minGRU and minLSTM compute gates from the input alone; minimal gated RNNs need far fewer parameters than GRUs and LSTMs and train orders of magnitude faster on long sequences.
  • xLSTM's sLSTM uses exponential input gates with a normalizer, so ct/ntc_t/n_t is a weighted average of past inputs, and a stabilizer mtm_t that rescales cell and normalizer by the same factor; the mLSTM's matrix memory Ct=ftCt−1+itvtkt⊤C_t=f_tC_{t-1}+i_t\mathbf v_t\mathbf k_t^\top has no memory mixing and trains in parallel.
  • RWKV, the RG-LRU (with its variance-preserving 1−at2\sqrt{1-a_t^2}) and Mamba share the recipe. The price is the loss of nonlinear state dependence, with provable limits on state tracking; Newton-based methods such as DEER attack nonlinear recurrences directly.

Check yourself

In the interactive lesson these are scored with your confidence, and what you miss comes back for review.

Question 1

Pairs et=(at,bt)e_t=(\mathbf a_t,\mathbf b_t) stand for the maps h↦at⊙h+bt\mathbf h\mapsto\mathbf a_t\odot\mathbf h+\mathbf b_t. Which operation, combining ee applied first and e′e' second, makes a parallel scan compute ht=at⊙ht−1+bt\mathbf h_t=\mathbf a_t\odot\mathbf h_{t-1}+\mathbf b_t?

  1. e∙e′=(a+a′, b+b′)e\bullet e'=(\mathbf a+\mathbf a',\ \mathbf b+\mathbf b')
  2. e∙e′=(a⊙a′, b⊙b′)e\bullet e'=(\mathbf a\odot\mathbf a',\ \mathbf b\odot\mathbf b')
  3. e∙e′=(a′⊙a, a′⊙b+b′)e\bullet e'=(\mathbf a'\odot\mathbf a,\ \mathbf a'\odot\mathbf b+\mathbf b')
  4. e∙e′=(a′⊙a, a⊙b′+b)e\bullet e'=(\mathbf a'\odot\mathbf a,\ \mathbf a\odot\mathbf b'+\mathbf b)
Show the answer

C. e∙e′=(a′⊙a, a′⊙b+b′)e\bullet e'=(\mathbf a'\odot\mathbf a,\ \mathbf a'\odot\mathbf b+\mathbf b')

Applying ee then e′e' gives a′⊙(a⊙h+b)+b′\mathbf a'\odot(\mathbf a\odot\mathbf h+\mathbf b)+\mathbf b'. The operation is associative, which is all a scan needs, though it is not commutative: order matters.

Question 2

For a sequence of length TT, how do the Hillis–Steele and Blelloch scans compare?

  1. Hillis–Steele: depth ⌈log⁡2T⌉\lceil\log_2T\rceil and work of order Tlog⁡TT\log T; Blelloch: depth about 2log⁡2T2\log_2T and work of order TT
  2. Both need TT sequential steps, like the recurrence itself
  3. Hillis–Steele: depth O(T)\order{T} and work O(log⁡T)\order{\log T}
  4. Blelloch has lower depth and lower work than Hillis–Steele
Show the answer

A. Hillis–Steele: depth ⌈log⁡2T⌉\lceil\log_2T\rceil and work of order Tlog⁡TT\log T; Blelloch: depth about 2log⁡2T2\log_2T and work of order TT

Hillis–Steele halves the remaining distance every round but makes every position work in every round; Blelloch's up-sweep and down-sweep do linear work at about twice the depth. Which is faster in practice depends on how much parallel hardware is available relative to TT.

Question 3

xLSTM replaces its exponential gates it,fti_t,f_t by stabilized versions it′=elog⁡it−mti'_t=e^{\log i_t-m_t} and ft′=elog⁡ft+mt−1−mtf'_t=e^{\log f_t+m_{t-1}-m_t}. Why does this not change the output ht=ot ct/nth_t=o_t\,c_t/n_t?

  1. Because mtm_t is always zero in practice
  2. Because the stabilized gates are clipped to 1, which never matters
  3. Because the output gate compensates for the rescaling
  4. Because, by induction, the cell and the normalizer are both multiplied by the same factor e−mte^{-m_t}, which cancels in the ratio ct/ntc_t/n_t
Show the answer

D. Because, by induction, the cell and the normalizer are both multiplied by the same factor e−mte^{-m_t}, which cancels in the ratio ct/ntc_t/n_t

ft′ct−1′+it′zt=e−mt(ftct−1+itzt)f'_tc'_{t-1}+i'_tz_t=e^{-m_t}(f_tc_{t-1}+i_tz_t) if ct−1′=e−mt−1ct−1c'_{t-1}=e^{-m_{t-1}}c_{t-1}, and the same holds for nn. The output depends only on the ratio, so values and gradients are unchanged while every stored number stays bounded.

Question 4

What do minGRU-, RG-LRU- and Mamba-style recurrences give up, compared with a GRU, in exchange for parallel training?

  1. Gating: their decay is a fixed constant
  2. The nonlinear dependence of the state update on the previous state, which limits what one layer can compute, for example tracking state through long sequences of permutations
  3. Constant-cost inference: they must reread the whole context for each new token
  4. Differentiability: they must be trained without backpropagation
Show the answer

B. The nonlinear dependence of the state update on the previous state, which limits what one layer can compute, for example tracking state through long sequences of permutations

Their gates depend on the input only, so each update is affine in the state. Depth and nonlinear layers in between recover much, but single-layer expressivity drops: diagonal linear recurrences with positive decays cannot do parity, and linear recurrences generally lie in TC0\mathsf{TC}^0.

Further reading

  • G. E. Blelloch, "Prefix sums and their applications," Technical Report CMU-CS-90-190, Carnegie Mellon University (1990).
  • E. Martin & C. Cundy, "Parallelizing linear recurrent neural nets over sequence length," ICLR (2018).
  • L. Feng, F. Tung, M. O. Ahmed, Y. Bengio & H. Hajimirsadeghi, "Were RNNs all we needed?," arXiv:2410.01201 (2024).
  • M. Beck, K. Pöppel, M. Spanring, A. Auer, O. Prudnikova, M. Kopp, G. Klambauer, J. Brandstetter & S. Hochreiter, "xLSTM: Extended long short-term memory," NeurIPS (2024).
  • B. Peng et al., "RWKV: Reinventing RNNs for the transformer era," Findings of EMNLP (2023).
  • S. De, S. L. Smith, A. Fernando, A. Botev, G. Cristian-Muraru, A. Gu et al., "Griffin: Mixing gated linear recurrences with local attention for efficient language models," arXiv:2402.19427 (2024).