← writing

Chunkwise Recurrence is Fast, Efficient, and Expressive

November 27, 2026

tl;dr: I modified the nonlinear M²RNN with a chunkwise parallel implementation that maintains the same level of expressivity while being faster and more memory efficient in training than most linear attention architectures.


I've been spending the past few months expanding on the research & work that led to the previous blog post, among other things. A lot has happened since that point - recurrence, in some form, has seen a significant uptick in discussion in the academic community. Tracing previous reasoning on the subject through what we know about the closed-source landscape, there's a plausible path from OpenAI's adoption of what they refer to as recurrent depth (likely through looped transformers), through their improved ability at zero-shot reasoning without chain of thought, to the mathematical results that we've seen over the past few months. The terminology that I used in the past has come to refer to similar but subtly different things, so I'll reiterate the precise goals of what I've been doing.

Many relevant types of problems have a hard minimum on the amount of time they take to complete, even with infinite parallelism - these problems are bottlenecked by serial depth. In the case of LLM training and inference, you can think about this as the longest path that a signal needs to travel from any one of its inputs in x<tx_{<t} to its output xtx_t.

It makes intuitive sense that the serial depth of an accurate model should be proportional to the length of the prefix itself, just due to the nature of how language is experienced in real life - one at a time, updating an internal world state via a complex operation. It's provable that this condition, which is not met by most LLMs today, including looped transformers, is necessary to meet the largest reasonable* class of expressible behaviors.

So why is this important? Well, it's already been shown that improved state tracking leads to improved capabilities in language models today, and there's no strong reason to believe that the trend would stop as we go further. The most consistent results come in the form of length generalization - a reasonable proxy for reliability in long-context work, especially considering evidence of catastrophic misalignment that has stemmed from failures of our current approach to handling long-context.


The M²RNN is a recently developed architecture that performs competitively with linear attention models in language and long-context benchmarks, improving on the RNN by using a matrix-valued recurrent state instead of a vector state, increasing sheer storage capacity. It has the desirable expressivity properties mentioned above, but is currently slower to train and much more memory intensive than the architectures it is meant to replace.

A common explanation for this is that being able to ingest every token in a sequence in parallel is an absolute necessity for good performance with modern training infrastructure. But inspection of the actual kernels in question shows that this is misleading. Let's take GDN-2 as an example:

97  NT = tl.cdiv(T, BT)
    # division of sequence length into chunks
...
175 for i_t in range(NT):
176	i_t_int64 = i_t.to(tl.int64)
177	o_t = i_t_int64 * BT + tl.arange(0, BT)
    # vector of token positions in current chunk

flash-linear-attention/fla/ops/common/chunk_delta_h.py

2290 chunk_size = 64

GatedDeltaNet-2/lit-gpt/gdn2_ops/chunk_gdn2.py

In no case is actually ingesting every token at once across a layer necessary for good performance. Rather, chunks of 32, 64, or 128 tokens are processed in parallel in sequence order.

We can achieve competitive performance by relaxing the implicit requirement that our algorithm be entirely independent of token index tt, and adding a nonlinear transition function every CC tokens. A straightforward way to do this is by replacing the input-dependent vectors in the nonlinear recurrence with matrices that we can accumulate in parallel.

We start from the M²RNN architecture. Its current formulation is:

Zt=tanh⁡(Ht−1W+ktvt⊤)Ht=ftHt−1+(1−ft)Ztyt=Ht⊤qt+wr⊙vtZ_t = \tanh(H_{t-1} W + k_t v_t^{\top}) \\ H_t = f_t H_{t-1} + (1 - f_t) Z_t \\ y_t = H_t^{\top} q_t + w_r \odot v_t

We replace that with:

Kc=stack⁡(k(C−1)c,…,kCc−1)Vc=stack⁡(v(C−1)c,…,vCc−1)fc=∏t∈[(C−1)c,Cc−1]ftZc=tanh⁡(Hc−1W+KcVc⊤)Hc=fcHc−1+(1−fc)Zcyt=H⌊t/C⌋⊤qtK_c = \operatorname{stack}(k_{(C-1)c}, \dots, k_{Cc-1}) \\ V_c = \operatorname{stack}(v_{(C-1)c}, \dots, v_{Cc-1}) \\ f_c = \prod_{t \in \left[(C-1)c, Cc-1\right]} f_t \\ Z_c = \tanh(H_{c-1} W + K_c V_c^{\top}) \\ H_c = f_c H_{c-1} + (1 - f_c) Z_c \\ y_t = H_{\lfloor t/C \rfloor}^{\top} q_t

While not as serially deep as the original formulation, our chunked M²RNN (hereafter CM²) performs 64 serial steps during pretraining, assuming a sequence length of 4096 and a chunk size of 64. This is before taking into account the fact that long-context pretraining should be more desirable, and stretches into thousands or more over plausible agentic work tasks.

Given that CM² has no mechanism to provide feedback based on information provided after the most recent chunk transition, it's ill-suited for use as a homogeneous architecture. The model is geared towards hybrid use with architectures capable at short context, while being able to accumulate summarized information in a dynamic way.

To demonstrate the savings provided by our change in formulation, I tested memory & throughput for CM² against a suite of competing models at training sizes typical for a ~1B parameter model (hidden size 2048, microbatch 8, sequence length 4096) on H100. Results are below:

Throughput comparison between linear architectures Memory comparison between linear architectures

As you can see, CM² performs comparably in both aspects to architectures that have much weaker state tracking capabilities.

I attempted some experiments on a set of synthetic & long-context tasks. Testing at the ~20M parameter scale yielded mostly inconsistent results, both with CM² and with controls. There were a few observations that were somewhat consistent:


Kernels for the architecture are uploaded here.

*We aim for L\mathsf{L}-completeness under FO reductions given the assumptions provided in Why Are Linear RNNs More Parallelizable?. This is the largest class that would allow for both total compute in training and inference that grows linearly with sequence length and constant memory.

CM² will be L\mathsf{L}-complete so long as M²RNN is, as padding out inputs such that each chunk only receives a single token at a time is an FO reduction that makes our new model essentially equivalent to the original M²RNN.