Scaling up Test-Time Compute with Latent Reasoning: A Recurrent Depth Approach

Jonas Geiping 1 Sean McLeish 2 Neel Jain 2 John Kirchenbauer 2 Siddharth Singh 2 Brian R. Bartoldson 3 Bhavya Kailkhura 3 Abhinav Bhatele 2 Tom Goldstein 2

###### Abstract

We study a novel language model architecture that is capable of scaling test-time computation by implicitly reasoning in latent space. Our model works by iterating a recurrent block, thereby unrolling to arbitrary depth at test-time. This stands in contrast to mainstream reasoning models that scale up compute by producing more tokens. Unlike approaches based on chain-of-thought, our approach does not require any specialized training data, can work with small context windows, and can capture types of reasoning that are not easily represented in words. We scale a proof-of-concept model to 3.5 billion parameters and 800 billion tokens. We show that the resulting model can improve its performance on reasoning benchmarks, sometimes dramatically, up to a computation load equivalent to 50 billion parameters.

Model : huggingface.co/tomg-group-umd/huginn-0125 Code and Data : github.com/seal-rg/recurrent-pretraining

## 1 Scaling by Thinking in Continuous Space

Humans naturally expend more mental effort solving some problems than others. While humans are capable of thinking over long time spans by verbalizing intermediate results and writing them down, a substantial amount of thought happens through complex, recurrent firing patterns in the brain, before the first word of an answer is uttered.

Early attempts at increasing the power of language models focused on scaling model size, a practice that requires extreme amounts of data and computation. More recently, researchers have explored ways to enhance the reasoning capability of models by scaling test time computation. The mainstream approach involves post-training on long chain-of-thought examples to develop the model’s ability to verbalize intermediate calculations in its context window and thereby externalize thoughts.

However, the constraint that expensive internal reasoning must always be projected down to a single verbalized next token appears wasteful; it is plausible that models could be more competent if they were able to natively “think” in their continuous latent space. One way to unlock this untapped dimension of additional compute involves adding a recurrent unit to a model. This unit runs in a loop, iteratively processing and updating its hidden state and enabling computations to be carried on indefinitely. While this is not currently the dominant paradigm, this idea is foundational to machine learning and has been (re-)discovered in every decade, for example as recurrent neural networks, diffusion models, and as universal or looped transformers.

In this work, we show that depth-recurrent language models can learn effectively, be trained in an efficient manner, and demonstrate significant performance improvements under the scaling of test-time compute. Our proposed transformer architecture is built upon a latent depth-recurrent block that is run for a randomly sampled number of iterations during training. We show that this paradigm can scale to several billion parameters and over half a trillion tokens of pretraining data. At test-time, the model can improve its performance through recurrent reasoning in latent space, enabling it to compete with other open-source models that benefit from more parameters and training data. Additionally, we show that recurrent depth models naturally support a number of features at inference time that require substantial tuning and research effort in non-recurrent models, such as per-token adaptive compute, (self)-speculative decoding, and KV-cache sharing. We finish out our study by tracking token trajectories in latent space, showing that a number of interesting computation behaviors simply emerge with scale, such as the model rotating shapes in latent space for numerical computations.

## 2 Why Train Models with Recurrent Depth?

Recurrent layers enable a transformer model to perform arbitrarily many computations before emitting a token. In principle, recurrent mechanisms provide a simple solution for test-time compute scaling. Compared to a more standard approach of long context reasoning OpenAI (2024) ; DeepSeek-AI et al. (2025) , latent recurrent thinking has several advantages. • Latent reasoning does not require construction of bespoke training data. Chain-of-thought reasoning requires the model to be trained on long demonstrations that are constructed in the domain of interest. In contrast, our proposed latent reasoning models can train with a variable compute budget, using standard training data with no specialized demonstrations, and enhance their abilities at test-time if given additional compute.

• Latent reasoning models require less memory for training and inference than chain-of-thought reasoning models. Because the latter require extremely long context windows, specialized training methods such as token-parallelization Liu et al. (2023a) may be needed.

• Recurrent-depth networks perform more FLOPs per parameter than standard transformers, significantly reducing communication costs between accelerators at scale. This especially enables higher device utilization when training with slower interconnects.

• By constructing an architecture that is compute-heavy and small in parameter count, we hope to set a strong prior towards models that solve problems by “thinking”, i.e. by learning meta-strategies, logic and abstraction, instead of memorizing. The strength of recurrent priors for learning complex algorithms has already been demonstrated in the “deep thinking” literature Schwarzschild et al. (2021b) ; Bansal et al. (2022) ; Schwarzschild et al. (2023) .

On a more philosophical note, we hope that latent reasoning captures facets of human reasoning that defy verbalization, such as spatial thinking, physical intuition or (motor) planning. Over many iterations of the recurrent process, reasoning in a high-dimensional vector space would enable the deep exploration of multiple directions simultaneously, instead of linear thinking, leading to a system capable of exhibiting novel and complex reasoning behavior.

Scaling compute in this manner is not at odds with scaling through extended (verbalized) inference scaling ( Shao et al., 2024 ) , or scaling parameter counts in pretraining ( Kaplan et al., 2020 ) , we argue it may build a third axis on which to scale model performance.

#### ———————— Table of Contents ————————

• Section 3 introduces our latent recurrent-depth model architecture and training objective.

• Section 4 describes the data selection and engineering of our large-scale training run on Frontier, an AMD cluster.

• Section 5 reports benchmark results, showing how the model improves when scaling inference compute.

• Section 6 includes several application examples showing how recurrent models naturally simplify LLM usecases.

• Section 7 visualizes what computation patterns emerge at scale with this architecture and training objective, showing that context-dependent behaviors emerge in latent space, such as “orbiting” when responding to prompts requiring numerical reasoning.

## 3 A scalable recurrent architecture

In this section we will describe our proposed architecture for a transformer with latent recurrent depth, discussing design choices and small-scale ablations. A diagram of the architecture can be found in Figure 2 . We always refer to the sequence dimension as n n , the hidden dimension of the model as h h , and its vocabulary as the set V V .

### 3.1 Macroscopic Design

The model is primarily structured around decoder-only transformer blocks ( Vaswani et al., 2017 ; Radford et al., 2019 ) . However these blocks are structured into three functional groups, the prelude P P , which embeds the input data into a latent space using multiple transformer layers, then the core recurrent block R R , which is the central unit of recurrent computation modifying states 𝐬 ∈ ℝ n × h \mathbf{s}\in\mathbb{R}^{n\times h} , and finally the coda C C , which un-embeds from latent space using several layers and also contains the prediction head of the model. The core block is set between the prelude and coda blocks, and by looping the core we can put an indefinite amount of verses in our song.

Given a number of recurrent iterations r r , and a sequence of input tokens 𝐱 ∈ V n \mathbf{x}\in V^{n} these groups are used in the following way to produce output probabilities 𝐩 ∈ ℝ n × | V | \mathbf{p}\in\mathbb{R}^{n\times|V|} 𝐞 \displaystyle\mathbf{e} = P ⁡ ( 𝐱 ) \displaystyle=P(\mathbf{x}) 𝐬 0 \displaystyle\mathbf{s}_{0} ∼ 𝒩 ⁡ ( 𝟎 , σ 2 ​ I n ⋅ h ) \displaystyle\sim\mathcal{N}(\mathbf{0},\sigma^{2}I_{n\cdot h}) 𝐬 i \displaystyle\mathbf{s}_{i} = R ( 𝐞 , 𝐬 i − 1 ) for i ∈ { 1 , … , r } \displaystyle=R(\mathbf{e},\mathbf{s}_{i-1})\qquad\textnormal{for}\quad i\in\{1,\dots,r\} 𝐩 \displaystyle\mathbf{p} = C ⁡ ( 𝐬 r ) , \displaystyle=C(\mathbf{s}_{r}), where σ \sigma is some standard deviation for initializing the random state. This process is shown in Figure 2 . Given an init random state 𝐬 0 \mathbf{s}_{0} , the model repeatedly applies the core block R R , which accepts the latent state 𝐬 i − 1 \mathbf{s}_{i-1} and the embedded input 𝐞 \mathbf{e} and outputs a new latent state 𝐬 i \mathbf{s}_{i} . After finishing all iterations, the coda block processes the last state and produces the probabilities of the next token.

This architecture is based on deep thinking literature, where it is shown that injecting the latent inputs 𝐞 \mathbf{e} in every step ( Bansal et al., 2022 ) and initializing the latent vector with a random state stabilizes the recurrence and promotes convergence to a steady state independent of initialization, i.e. path independence ( Anil et al., 2022 ) .

#### Motivation for this Design.

This recurrent design is the minimal setup required to learn stable iterative operators. A good example is gradient descent of a function E ⁡ ( 𝐱 , 𝐲 ) E(\mathbf{x},\mathbf{y}) , where 𝐱 \mathbf{x} may be the variable of interest and 𝐲 \mathbf{y} the data. Gradient descent on this function starts from an initial random state, here 𝐱 0 \mathbf{x}_{0} , and repeatedly applies a simple operation (the gradient of the function it optimizes), that depends on the previous state 𝐱 k \mathbf{x}_{k} and data 𝐲 \mathbf{y} . Note that we need to use 𝐲 \mathbf{y} in every step to actually optimize our function. Similarly we repeatedly inject the data 𝐞 \mathbf{e} in our set-up in every step of the recurrence. If 𝐞 \mathbf{e} was provided only at the start, e.g. via 𝐬 0 = 𝐞 \mathbf{s}_{0}=\mathbf{e} , then the iterative process would not be stable 1 1 1 Stable in the sense that R R cannot be a monotone operator if it does not depend on 𝐞 \mathbf{e} , and so cannot represent gradient descent on strictly convex, data-dependent functions, ( Bauschke et al., 2011 ) , as its solution would depend only on its boundary conditions.

The structure of using several layers to embed input tokens into a hidden latent space is based on empirical results analyzing standard fixed-depth transformers ( Skean et al., 2024 ; Sun et al., 2024 ; Kaplan et al., 2024 ) . This body of research shows that the initial and the end layers of LLMs are noticeably different, whereas middle layers are interchangeable and permutable. For example, Kaplan et al. (2024) show that within a few layers standard models already embed sub-word tokens into single concepts in latent space, on which the model then operates.

###### Remark 3.1 (Is this a Diffusion Model?) .

This iterative architecture will look familiar to the other modern iterative modeling paradigm, diffusion models ( Song and Ermon, 2019 ) , especially latent diffusion models ( Rombach et al., 2022 ) . We ran several ablations with iterative schemes even more similar to diffusion models, such as 𝐬 i = R ⁡ ( 𝐞 , 𝐬 i − 1 ) + 𝐧 \mathbf{s}_{i}=R(\mathbf{e},\mathbf{s}_{i-1})+\mathbf{n} where 𝐧 ∼ 𝒩 ⁡ ( 𝟎 , σ i ​ I n ⋅ h ) \mathbf{n}\sim\mathcal{N}(\mathbf{0},\sigma_{i}I_{n\cdot h}) , but find the injection of noise not to help in our preliminary experiments, which is possibly connected to our training objective. We also evaluated and 𝐬 i = R i ​ ( 𝐞 , 𝐬 i − 1 ) \mathbf{s}_{i}=R_{i}(\mathbf{e},\mathbf{s}_{i-1}) , i.e. a core block that takes the current step as input ( Peebles and Xie, 2023 ) , but find that this interacts badly with path independence, leading to models that cannot extrapolate.

### 3.2 Microscopic Design

Within each group, we broadly follow standard transformer layer design. Each block contains multiple layers, and each layer contains a standard, causal self-attention block using RoPE ( Su et al., 2021 ) with a base of 50000 50000 , and a gated SiLU MLP ( Shazeer, 2020 ) . We use RMSNorm ( Zhang and Sennrich, 2019 ) as our normalization function. The model has learnable biases on queries and keys, and nowhere else. To stabilize the recurrence, we order all layers in the following “sandwich” format, using norm layers n i n_{i} , which is related, but not identical to similar strategies in ( Ding et al., 2021 ; Team Gemma et al., 2024 ) : 𝐱 l ^ = \displaystyle\hat{\mathbf{x}_{l}}= n 2 ​ ( 𝐱 l − 1 + Attn ​ ( n 1 ​ ( 𝐱 l − 1 ) ) ) \displaystyle n_{2}\left(\mathbf{x}_{l-1}+\textnormal{Attn}(n_{1}(\mathbf{x}_{l-1}))\right) 𝐱 l = \displaystyle\mathbf{x}_{l}= n 4 ​ ( 𝐱 l ^ + MLP ​ ( n 3 ​ ( 𝐱 l ^ ) ) ) \displaystyle n_{4}\left(\hat{\mathbf{x}_{l}}+\textnormal{MLP}(n_{3}(\hat{\mathbf{x}_{l}}))\right) While at small scales, most normalization strategies, e.g. pre-norm, post-norm and others, work almost equally well, we ablate these options and find that this normalization is required to train the recurrence at scale 2 2 2 Note also that technically n 3 n_{3} is superfluous, but we report here the exact norm setup with which we trained the final model. .

Given an embedding matrix E E and embedding scale γ \gamma , the prelude block first embeds input tokens 𝐱 \mathbf{x} as γ ​ E ​ ( 𝐱 ) \gamma E(\mathbf{x}) , and then to applies l P l_{P} many prelude layers with the layout described above.

Our core recurrent block R R starts with an adapter matrix A : ℝ 2 ​ h → ℝ h A:\mathbb{R}^{2h}\to\mathbb{R}^{h} mapping the concatenation of 𝐬 i \mathbf{s}_{i} and 𝐞 \mathbf{e} into the hidden dimension h h ( Bansal et al., 2022 ) . While re-incorporation of initial embedding features via addition rather than concatenation works equally well for smaller models, we find that concatenation works best at scale. This is then fed into l R l_{R} transformer layers. At the end of the core block the output is again rescaled with an RMSNorm n c n_{c} .

The coda contains l C l_{C} layers, normalization by n c n_{c} , and projection into the vocabulary using tied embeddings E T E^{T} .

In summary, we can summarize the architecture by the triplet ( l P , l R , l C ) (l_{P},l_{R},l_{C}) , describing the number of layers in each stage, and by the number of recurrences r r , which may vary in each forward pass. We train a number of small-scale models with shape ( 1 , 4 , 1 ) (1,4,1) and hidden size h = 1024 h=1024 , in addition to a large model with shape ( 2 , 4 , 2 ) (2,4,2) and h = 5280 h=5280 . This model has only 8 8 “real” layers, but when the recurrent block is iterated, e.g. 32 times, it unfolds to an effective depth of 2 + 4 ​ r + 2 = 132 2+4r+2=132 layers, constructing computation chains that can be deeper than even the largest fixed-depth transformers ( Levine et al., 2021 ; Merrill et al., 2022 ) .

### 3.3 Training Objective

#### Training Recurrent Models through Unrolling.

To ensure that the model can function when we scale up recurrent iterations at test-time, we randomly sample iteration counts during training, assigning a random number of iterations r r to every input sequence ( Schwarzschild et al., 2021b ) . We optimize the expectation of the loss function L L over random samples x x from distribution X X and random iteration counts r r from distribution Λ \Lambda . ℒ ⁡ ( θ ) = 𝔼 𝐱 ∈ X ​ 𝔼 r ∼ Λ ​ L ​ ( m θ ​ ( 𝐱 , r ) , 𝐱 ′ ) . \mathcal{L}(\theta)=\mathbb{E}_{\mathbf{x}\in X}\mathbb{E}_{r\sim\Lambda}L\left(m_{\theta}(\mathbf{x},r),\mathbf{x}^{\prime}\right). Here, m m represents the model output, and 𝐱 ′ \mathbf{x}^{\prime} is the sequence 𝐱 \mathbf{x} shifted left, i.e., the next tokens in the sequence 𝐱 \mathbf{x} . We choose Λ \Lambda to be a log-normal Poisson distribution . Given a targeted mean recurrence r ¯ + 1 \bar{r}+1 and a variance that we set to σ = 1 2 \sigma=\frac{1}{2} , we can sample from this distribution via τ \displaystyle\tau ∼ 𝒩 ⁡ ( log ⁡ ( r ¯ ) − 1 2 ​ σ 2 , σ ) \displaystyle\sim\mathcal{N}(\log(\bar{r})-\frac{1}{2}\sigma^{2},\sigma) (1) r \displaystyle r ∼ 𝒫 ⁡ ( e τ ) + 1 , \displaystyle\sim\mathcal{P}(e^{\tau})+1, (2) given the normal distribution 𝒩 \mathcal{N} and Poisson distribution 𝒫 \mathcal{P} , see Figure 3 . The distribution most often samples values less than r ¯ \bar{r} , but it contains a heavy tail of occasional events in which significantly more iterations are taken.

#### Truncated Backpropagation.

To keep computation and memory low at train time, we backpropagate through only the last k k iterations of the recurrent unit. This enables us to train with the heavy-tailed Poisson distribution Λ \Lambda , as maximum activation memory and backward compute is now independent of r r . We fix k = 8 k=8 in our main experiments. At small scale, this works as well as sampling k k uniformly, but with set fixed, the overall memory usage in each step of training is equal. Note that the prelude block still receives gradient updates in every step, as its output 𝐞 \mathbf{e} is injected in every step. This setup resembles truncated backpropagation through time, as commonly done with RNNs, although our setup is recurrent in depth rather than time ( Williams and Peng, 1990 ; Mikolov et al., 2011 ) .

## 4 Training a large-scale recurrent-depth Language Model

After verifying that we can reliably train small test models up to 10B tokens, we move on to larger-scale runs. Given our limited compute budget, we could either train multiple tiny models too small to show emergent effects or scaling, or train a single medium-scale model. Based on this, we prepared for a single run, which we detail below.

### 4.1 Training Setup

We describe the training setup, separated into architecture, optimization setup and pretraining data. We publicly release all training data, pretraining code, and a selection of intermediate model checkpoints.

#### Pretraining Data.

Given access to only enough compute for a single large scale model run, we opted for a dataset mixture that maximized the potential for emergent reasoning behaviors, not necessarily for optimal benchmark performance. Our final mixture is heavily skewed towards code and mathematical reasoning data with (hopefully) just enough general webtext to allow the model to acquire standard language modeling abilities. All sources are publicly available. We provide an overview in Figure 4 . Following Allen-Zhu and Li (2024) , we directly mix relevant instruction data into the pretraining data. However, due to compute and time constraints, we were not able to ablate this mixture. We expect that a more careful data preparation could further improve the model’s performance. We list all data sources in Appendix C .

#### Tokenization and Packing Details.

We construct a vocabulary of 65536 65536 tokens via BPE ( Sennrich et al., 2016 ) , using the implementation of Dagan (2024) . In comparison to conventional tokenizer training, we construct our tokenizer directly on the instruction data split of our pretraining corpus, to maximize tokenization efficiency on the target domain. We also substantially modify the pre-tokenization regex (e.g. of Dagan et al. (2024) ) to better support code, contractions and LaTeX. We include a <|begin_text|> token at the start of every document. After tokenizing our pretraining corpus, we pack our tokenized documents into sequences of length 4096. When packing, we discard document ends that would otherwise lack previous context, to fix an issue described as the “grounding problem” in Ding et al. (2024) , aside from several long-document sources of mathematical content, which we preserve in their entirety.

#### Architecture and Initialization.

We scale the architecture described in Section 3 , setting the layers to ( 2 , 4 , 2 ) (2,4,2) , and train with a mean recurrence value of r ¯ = 32 \bar{r}=32 . We mainly scale by increasing the hidden size to h = 5280 h=5280 , which yields 55 55 heads of size of 96 96 . The MLP inner dimension is 17920 17920 and the RMSNorm ε \varepsilon is 10 − 6 10^{-6} . Overall this model shape has about 1.5 1.5 B parameters in non-recurrent prelude and head, 1.5 1.5 B parameters in the core recurrent block, and 0.5 0.5 B in the tied input embedding.

At small scales, most sensible initialization schemes work. However, at larger scales, we use the initialization of Takase et al. (2024) which prescribes a variance of σ h 2 = 2 5 ​ h \sigma_{h}^{2}=\frac{2}{5h} . We initialize all parameters from a truncated normal distribution (truncated at 3 ​ σ 3\sigma ) with this variance, except all out-projection layers, where the variance is set to σ out 2 = 1 5 ​ h ​ l \sigma_{\textnormal{out}}^{2}=\frac{1}{5hl} , for l = l P + r ¯ ​ l R + l C l=l_{P}+\bar{r}l_{R}+l_{C} the number of effective layers, which is 132 for this model. As a result, the out-projection layers are initialized with fairly small values ( Goyal et al., 2018 ) . The output of the embedding layer is scaled by h \sqrt{h} . To match this initialization, the state s 0 s_{0} is also sampled from a truncated normal distribution, here with variance σ s 2 = 2 5 \sigma_{s}^{2}=\frac{2}{5} .

#### Locked-Step Sampling.

To enable synchronization between parallel workers, we sample a single depth r r for each micro-batch of training, which we synchronize across workers (otherwise workers would idle while waiting for the model with the largest r r to complete its backward pass). We verify at small scale that this modification improves compute utilization without impacting convergence speed, but note that at large batch sizes, training could be further improved by optimally sampling and scheduling independent steps r r on each worker, to more faithfully model the expectation over steps in Equation 1 .

#### Optimizer and Learning Rate Schedule.

We train using the Adam optimizer with decoupled weight regularization ( β 1 = 0.9 \beta_{1}=0.9 , β 2 = 0.95 \beta_{2}=0.95 , η = 5 × 10 − 4 \eta=$5\text{\times}{10}^{-4}$ ) ( Kingma and Ba, 2015 ; Loshchilov and Hutter, 2017 ) , modified to include update clipping ( Wortsman et al., 2023b ) and removal of the ε \varepsilon constant as in Everett et al. (2024) . We clip gradients above 1 1 . We train with warm-up and a constant learning rate ( Zhai et al., 2022 ; Geiping and Goldstein, 2023 ) , warming up to our maximal learning rate within the first 4096 4096 steps.

### 4.2 Compute Setup and Hardware

We train this model using compute time allocated on the Oak Ridge National Laboratory’s Frontier supercomputer. This HPE Cray system contains 9408 compute nodes with AMD MI250X GPUs, connected via 4xHPE Slingshot-11 NICs. The scheduling system is orchestrated through SLURM. We train in bfloat16 mixed precision using a PyTorch-based implementation ( Zamirai et al., 2021 ) .

#### Device Speed and Parallelization Strategy.

Nominally, each MI250X chip 3 3 3 Technically, each node contains 4 dual-chip MI250X cards, but its main software stack (ROCm runtime) treats these chips as fully independent. achieves 192 TFLOP per GPU ( AMD, 2021 ) . For a single matrix multiplication, we measure a maximum achievable speed on these GPUs of 125 TFLOP/s on our software stack (ROCM 6.2.0, PyTorch 2.6 pre-release 11/02) ( Bekman, 2023 ) . Our implementation, using extensive PyTorch compilation and optimization of the hidden dimension to h = 5280 h=5280 achieves a single-node training speed of 108.75 TFLOP/s, i.e. 87% AFU (“Achievable Flop Utilization”). Due to the weight sharing inherent in our recurrent design, even our largest model is still small enough to be trained using only data (not tensor) parallelism, with only optimizer sharding ( Rajbhandari et al., 2020 ) and gradient checkpointing on a per-iteration granularity. With a batch size of 1 per GPU we end up with a global batch size of 16M tokens per step, minimizing inter-GPU communication bandwidth.

When we run at scale on 4096 GPUs, we achieve 52-64 TFLOP/s per GPU, i.e. 41%-51% AFU, or 1-1.2M tokens per second. To achieve this, we wrote a hand-crafted distributed data parallel implementation to circumvent a critical AMD interconnect issue, which we describe in more detail in Section A.2 . Overall, we believe this may be the largest language model training run to completion in terms of number of devices used in parallel on an AMD cluster, as of time of writing.

#### Training Timeline.

Training proceeded through 21 segments of up to 12 hours, which scheduled on Frontier mostly in early December 2024. We also ran a baseline comparison, where we train the same architecture but in a feedforward manner with only 1 pass through the core/recurrent block. This trained with the same setup for 180B tokens on 256 nodes with a batch size of 2 per GPU. Ultimately, we were able to schedule 795B tokens of pretraining of the main model. Due to our constant learning rate schedule, we were able to add additional segments “on-demand”, when an allocation happened to be available.

### 4.3 Importance of Norms and Initializations at Scale

At small scales all normalization strategies worked, and we observed only tiny differences between initializations. The same was not true at scale. The first training run we started was set up with the same block sandwich structure as described above, but parameter-free RMSNorm layers, no embedding scale γ \gamma , a parameter-free adapter A ⁡ ( 𝐬 , 𝐞 ) = 𝐬 + 𝐞 A(\mathbf{s},\mathbf{e})=\mathbf{s}+\mathbf{e} , and a peak learning rate of 4 × 10 − 4 4\text{\times}{10}^{-4} . As shown in Figure 5 , this run (“Bad Run 1”, orange), quickly stalled.

While the run obviously stopped improving in training loss (left plot), we find that this stall is due to the model’s representation collapsing ( Noci et al., 2022 ) . The correlation of hidden states in the token dimension quickly goes to 1.0 (middle plot), meaning the model predicts the same hidden state for every token in the sequence. We find that this is an initialization issue that arises due to the recurrence operation. Every iteration of the recurrence block increases token correlation, mixing the sequence until collapse.

We attempt to fix this by introducing the embedding scale factor, switching back to a conventional pre-normalization block, and switching to the learned adapter. Initially, these changes appear to remedy the issue. Even though token correlation shoots close to 1.0 at the start (“Bad Run 2”, green), the model recovers after the first 150 steps. However, we quickly find that this training run is not able to leverage test-time compute effectively (right plot), as validation perplexity is the same whether 1 or 32 recurrences are used. This initialization and norm setup has led to a local minimum as the model has learned early to ignore the incoming state 𝐬 \mathbf{s} , preventing further improvements.

In a third, and final run (“Main”, blue), we fix this issue by reverting back to the sandwich block format, and further dropping the peak learning rate to 4 × 10 − 5 4\text{\times}{10}^{-5} . This run starts smoothly, never reaches a token correlation close to 1.0, and quickly overtakes the previous run by utilizing the recurrence and improving with more iterations.

With our successful configuration, training continues smoothly for the next 750B tokens without notable interruptions or loss spikes. We plot training loss and perplexity at different recurrence steps in Figure 6 . In our material, we refer to the final checkpoint of this run as our “main model”, which we denote as Huginn-0125 4 4 4 \textipa /hu: gIn/, transl. “thought”, is a raven depicted in Norse mythology. Corvids are surprisingly intelligent for their size, and and of course, as birds, able to unfold their wings at test-time. .

## 5 Benchmark Results

We train our final model for 800B tokens, and a non-recurrent baseline for 180B tokens. We evaluate these checkpoints against other open-source models trained on fully public datasets (like ours) of a similar size. We compare against Amber ( Liu et al., 2023c ) , Pythia ( Biderman et al., 2023 ) and a number of OLMo 1&2 variants ( Groeneveld et al., 2024 ; AI2, 2024 ; Team OLMo et al., 2025 ) . We execute all standard benchmarks through the lm-eval harness ( Biderman et al., 2024 ) and code benchmarks via bigcode-bench ( Zhuo et al., 2024 ) .

### 5.1 Standard Benchmarks

Overall, it is not straightforward to place our model in direct comparison to other large language models, all of which are small variations of the fixed-depth transformer architecture. While our model has only 3.5B parameters and hence requires only modest interconnect bandwidth during pretraining, it chews through raw FLOPs close to what a 32B parameter transformer would consume during pretraining, and can continuously improve in performance with test-time scaling up to FLOP budgets equivalent to a standard 50B parameter fixed-depth transformer. It is also important to note a few caveats of the main training run when interpreting the results. First, our main checkpoint is trained for only 47000 steps on a broadly untested mixture, and the learning rate is never cooled down from its peak. As an academic project, the model is trained only on publicly available data and the 800B token count, while large in comparison to older fully open-source models such as the Pythia series, is small in comparison to modern open-source efforts such as OLMo, and tiny in comparison to the datasets used to train industrial open-weight models.

Disclaimers aside, we collect results for established benchmark tasks ( Team OLMo et al., 2025 ) in Table 1 and show all models side-by-side. In direct comparison we see that our model outperforms the older Pythia series and is roughly comparable to the first OLMo generation, OLMo-7B in most metrics, but lags behind the later OLMo models trained larger, more carefully curated datasets. For the first recurrent-depth model for language to be trained at this scale, and considering the limitations of the training run, we find these results promising and certainly suggestive that further research into latent recurrence as an approach to test-time scaling is warranted.

### 5.2 Math and Coding Benchmarks

We also evaluate the model on math and coding. For math, we evaluate GSM8k ( Cobbe et al., 2021 ) (as zero-shot and in the 8-way CoT setup), MATH ( ( Hendrycks et al., 2021b ) with the Minerva evaluation rules ( Lewkowycz et al., 2022 ) ) and MathQA ( Amini et al., 2019 ) . For coding, we check MBPP ( Austin et al., 2021 ) and HumanEval ( Chen et al., 2021 ) . Here we find that our model significantly surpasses all models except the latest OLMo-2 model in mathematical reasoning, as measured on GSM8k and MATH. On coding benchmarks the model beats all other general-purpose open-source models, although it does not outperform dedicated code models, such as StarCoder2 ( Lozhkov et al., 2024 ) , trained for several trillion tokens. We also note that while further improvements in language modeling are slowing down, as expected at this training scale, both code and mathematical reasoning continue to improve steadily throughout training, see Figure 8 .

### 5.3 Where does recurrence help most?

How much of this performance can we attribute to recurrence, and how much to other factors, such as dataset, tokenization and architectural choices? In Table 4 , we compare our recurrent model against its non-recurrent twin, which we trained to 180B tokens in the exact same setting. In direct comparison of both models at 180B tokens, we see that the recurrent model outperforms its baseline with an especially pronounced advantage on harder tasks, such as the ARC challenge set. On other tasks, such as SciQ, which requires straightforward recall of scientific facts, performance of the models is more similar. We observe that gains through reasoning are especially prominent on GSM8k, where the 180B recurrent model is already 5 times better than the baseline at this early snapshot in the pretraining process. We also note that the recurrent model, when evaluated with only a single recurrence, effectively stops improving between the early 180B checkpoint and the 800B checkpoint, showing that further improvements are not built into the prelude or coda non-recurrent layers but encoded entirely into the iterations of the recurrent block.

Further, we chart the improvement as a function of test-time compute on several of these tasks for the main model in Figure 7 . We find that saturation is highly task-dependent, on easier tasks the model saturates quicker, whereas it benefits from more compute on others.

#### Recurrence and Context

We evaluate ARC-C performance as a function of recurrence and number of few-shot examples in the context in Figure 9 . Interestingly, without few-shot examples to consider, the model saturates in compute around 8-12 iterations. However, when more context is given, the model can reason about more information in context, which it does, saturating around 20 iterations if 1 example is provided, and 32 iterations, if 25-50 examples are provided, mirroring generalization improvements shown for recurrence ( Yang et al., 2024a ; Fan et al., 2025 ) . Similarly, we see that if we re-evaluate OBQA in Table 5 , but do not run the benchmark in the default lm-eval "closed-book" format and rather provide a relevant fact, our recurrent model improves significantly almost closing the gap to OLMo-2. Intuitively this makes sense, as the recurrent models has less capacity to memorize facts but more capacity to reason about its context.

### 5.4 Improvements through Weight Averaging

Due to our constant learning rate, we can materialize further improvements through weight averaging ( Izmailov et al., 2018 ) to simulate the result of a cooldown ( Hägele et al., 2024 ; DeepSeek-AI et al., 2024 ) . We use an exponential moving average starting from our last checkpoint with β = 0.9 \beta=0.9 , incorporating the last 75 checkpoints with a dilation factor of 7, a modification to established protocols ( Kaddour, 2022 ; Sanyal et al., 2024 ) . We provide this EMA model as well, which further improves GMS8k performance to 47.23 % 47.23\% flexible ( 38.59 % 38.59\% strict), when tested at r = 64 r=64 .

## 6 Recurrent Depth simplifies LLMs

Aside from encouraging performance in mathematical and code reasoning, recurrent-depth models turn out to be surprisingly natural tools to support a number of methods that require substantial effort with standard transformers. In the next section, we provide a non-exhaustive overview.

### 6.1 Zero-Shot Adaptive Compute at Test-Time

We have shown that the model is capable of varying compute on a per-query level, running the model in different recurrence modes. This is after all also how the model is trained, as in Equation 1 . However, it would be more efficient in practice to stop recurring early when predictions are easy, and only spend compute on hard decisions. Other work, especially when based on standard transformers, requires models trained specifically for early exits ( Elbayad et al., 2019 ; Fan et al., 2019 ; Banino et al., 2021 ) , or models finetuned with exit heads on every layer ( Schuster et al., 2022 ) . To test our model’s zero-shot exit abilities, we choose a simple exit criterion to evaluate convergence, the KL-divergence between two successive steps. If this divergence falls below 5 × 10 − 4 5\text{\times}{10}^{-4} , we stop iterating, sample the output token, and move to generate the next token.

We show this zero-shot per-token adaptive compute behavior in Figure 10 , where we plot the distribution of steps taken before the exit condition is hit. We do this for the first 50 questions from different MMLU categories, asked in free-form chat. Interestingly, the number of steps required to exit differs notably between categories, with the model exiting earlier on high school mathematics, but taking on average 3.5 steps more on moral scenarios. As a preliminary demonstration, we verify on MTBench that this adaptivity does not significantly impact performance in a conversational benchmark setting (standard: 5.63 5.63 , early exits: 5.56 5.56 see Appendix Table 6 ).

###### Remark 6.1 (What about missing KV-cache entries?) .

Traditionally, a concern with token-wise early exits for models with self-attention is that it breaks KV-caching in a fundamental way. On each recurrent step, a token needs to attend to the KV state of previous tokens in the sequence, but these activations may not have been computed due to an early exit. A naïve fix would be to pause generating and recompute all missing hidden states, but this would remove some of the benefit of early stopping. Instead, as in Elbayad et al. (2019) , we attend to the last, deepest available KV states in the cache. Because all recurrent KV cache entries are generated by the same K,V projection matrices from successive hidden states, they “match”, and therefore the model is able to attend to the latest cache entry from every previous token, even if computed at different recurrent depths.

### 6.2 Zero-Shot KV-cache Sharing

A different avenue to increase efficiency is to reduce the memory footprint of the KV-cache by sharing the cache between layers ( character.ai, 2024 ; Brandon et al., 2024 ) . Typically, transformers must be trained from scratch with this capability. However, as discussed in the previous section, we find that we can simply share KV-caches in our model with minimal impact to performance. We set a fixed KV-cache budget for the recurrence at every token k k , and at iteration i i , read and write the cache entry i mod k i\bmod k . For example, we set a maximum KV-cache budget of 16 steps, overwriting the KV-cache of the 1st step when executing the 17th step, and so forth. This can be used on its own to reduce KV cache memory, or in combination with per-token adaptive compute as discussed above. On MTBench, this does not reduce performance (cache budget of 4 4 : 5.86 5.86 , see Appendix Table 6 ).

### 6.3 Zero-Shot Continuous Chain-of-Thought

By attending to the output of later steps of previous tokens in the early steps of current tokens, as described in the KV-cache sharing section, we actually construct a computation that is deeper than the current number of recurrence steps. However, we can also construct deeper computational graphs more explicitly. Instead of sampling a random initial state 𝐬 0 \mathbf{s}_{0} at every generation step, we can warm-start with the last state 𝐬 r \mathbf{s}_{r} from the previous token. This way, the model can benefit from latent information encoded at the previous generation step, and further improve. As shown in Figure 10 , this reduces the average number of steps required to converge by 1-2. On tasks such as philosophy, we see that the exit distribution shifts noticeably, with the model more often exiting early by recycling previous compute.

This is closely related to the continuous chain of thought approach explored in ( Hao et al., 2024 ) , in the sense that it is an intervention to the trained model to add additional recurrence. To achieve a similar behavior in fixed-depth transformers, Hao et al. (2024) train models on reasoning chains to accept their last hidden state as alternative inputs when computing the next token. Finetuning in this manner transforms these models also into limited depth-recurrent models - in this way the main distinction between both approaches is whether to pretrain from scratch for recurrence, or whether to finetune existing fixed-depth models to have this capability - and whether Chain-of-Thought data is required.

### 6.4 Zero-Shot Self-Speculative Decoding

Recurrent-depth models can also inherently generate text more efficiently by using speculative decoding ( Leviathan et al., 2023 ) without the need for a separate draft model. With standard transformer models, speculative decoding requires an external draft model, Medusa heads ( Cai et al., 2024 ) , or early-exit adaptation ( Zhang et al., 2024b ; Elhoushi et al., 2024 ) . Zhang et al. (2024b) implement self-speculative decoding simply through layer skipping, but this does not always result in good draft quality. In comparison, our model can naturally be run with fewer iterations to draft the next N N tokens in the generated sequence, which can then be verified with any desired number of iterations M > N M>N later. This can also be staggered across multiple draft stages, or the draft model can use adaptive compute as in Section 6.1 . Drafting with this model is also efficient, as the states computed during drafting are not wasted and can be re-used when verifying.

## 7 What Mechanisms Emerge at Scale in Recurrent-Depth Models

Finally, what is the model doing while recurring in latent space? To understand this question better, we analyze the trajectories { 𝐬 i } i = 1 r \{\mathbf{s}_{i}\}_{i=1}^{r} of the model on a few qualitative examples. We are especially interested in understanding what patterns emerge, simply by training this model at scale. In comparison to previous work, such as Bai et al. (2019) , where the training objective directly encodes a prior that pushes trajectories to a fixed point, we only train with our truncated unrolling objective.

Figure 11 shows the norm distance ‖ 𝐬 i − 𝐬 ∗ ‖ ||\mathbf{s}_{i}-\mathbf{s}^{*}|| between each 𝐬 i \mathbf{s}_{i} in a trajectory and an approximate limit point 𝐬 ∗ \mathbf{s}^{*} computed with 128 iterations. We show the sentence top to bottom and iterations from left to right. We clearly see that convergence behavior depends on context. We see that key parts of the question, and the start of the model response, are “deliberated” much more in latent space. The context dependence can also be seen in the different behavior among the three identical tokens representing each of the three dots. Also note that the distance to 𝐬 ∗ \mathbf{s}^{*} does not always decrease monotonically (e.g. for school ); the model may also trace out complicated orbits in its latent trajectory while processing information, even though this is not represented explicitly in our training objective.

We look at trajectories for select tokens in more detail in Figure 12 . We compute a PCA decomposition of latent trajectories over all tokens in a sequence, and then show several individual trajectories projected onto the first six PCA directions. See the appendix for more examples. Many tokens simply converge to a fixed point, such as the token in the top row. Yet, for harder questions, such as in the 2nd row 5 5 5 This is the token ”3” in a GSM8k test question that opens with Claire makes a 3 egg omelette . , the state of the token quickly falls into an orbit pattern in all three pairs of PCA directions. The use of multi-dimensional orbits like these could serve a similar purpose to periodic patterns sometimes observed in fixed-depth transformers trained for arithmetic tasks ( Nanda et al., 2022 ) , but we find these patterns extend far beyond arithmetic for our model. We often also observe the use of orbits on tokens such as “makes” (see Figure 16 ) or “thinks” that determine the structure of the response.

Aside from orbits, we also observe the model encoding particular key tokens as “sliders”, as seen in the middle of the bottom row in Figure 12 (which is the token “wrong”, from the same message as already shown in Figure 11 ). In these motions the trajectory noticeably drifts in a single direction, which the model could use to implement a mechanism to count how many iterations have occurred.

The emergence of structured trajectories in latent space gives us a glimpse into how the model performs its computations. Unlike the discrete sequential chain of reasoning seen in verbalized chain-of-thought approaches, we observe rich geometric patterns including orbits, convergent paths, and drifts - means to organize its computational process spatially. This suggests the model is independently learning to leverage the high-dimensional nature of its latent space to implement reasoning in new ways.

#### Path Independence.

We verify that our models maintain path independence, in the sense of Anil et al. (2022) , despite their complex, learned dynamics, which we discussed prior (see also the additional examples in Appendix Figure 22 ). When re-initializing from multiple starting states 𝐬 0 \mathbf{s}_{0} , the model moves in similar trajectories, exhibiting consistent behavior. The same orbital patterns, fixed points, or directional drifts emerge regardless of initialization.

## 8 Related Work Overview

The extent to which recurrence is a foundational concept of machine learning is hard to overstate ( Amari, 1972 ; Hopfield, 1982 ; Braitenberg, 1986 ; Gers and Schmidhuber, 2000 ; Sutskever et al., 2008 ) . Aside from using recurrence to move along sequences, as in recurrent neural networks, it was understood early to also be the key to adaptive computation ( Schmidhuber, 2012 ; Graves, 2017 ) . For transformers, recurrence was applied in Dehghani et al. (2019) , who highlight the aim of recurrent depth to model universal , i.e. Turing-complete, machines ( Graves et al., 2014 ) . It was used at scale (but with fixed recurrence) in Lan et al. (2019) and an interesting recent improvement in this line of work are described in Tan et al. (2023) ; Abnar et al. (2023) , Mathur et al. (2024) and Csordás et al. (2024) . Schwarzschild et al. (2021b) ; Bansal et al. (2022) ; Bear et al. (2024) and McLeish et al. (2024) show that depth recurrence is advantageous when learning generalizable algorithms when training with randomized unrolling and input injections. Recent work has described depth-recurrent, looped , transformers and studied their potential benefits with careful theoretical and small-scale analysis ( Giannou et al., 2023 ; Gatmiry et al., 2024 ; Yang et al., 2024a ; Fan et al., 2025 ) .

From another angle, these models can be described as neural networks learning a fixed-point iteration, as studied in deep equilibrium models ( Bai et al., 2019 ; Bai et al., 2022 ) . They are further related to diffusion models ( Song and Ermon, 2019 ) , especially latent diffusion models ( Rombach et al., 2022 ) , but we note that language diffusion models are usually run with a per-sequence, instead of a per-token, iteration count ( Lee et al., 2018 ) . A key difference of our approach to both equilibrium models and diffusion models is in the training objective, where equilibrium methods solve the “direct” problem ( Geiping and Moeller, 2019 ) , diffusion models solve a surrogate training objective, and our work suggests that truncated unrolling is a scalable alternative.

More generally, all architectures that recur in depth can also be understood as directly learning the analog to the gradient of a latent energy-based model ( LeCun and Huang, 2005 ; LeCun, 2022 ) , to an implicitly defined intermediate optimization layer ( Amos and Kolter, 2017 ) , or to a Kuramoto layer ( Miyato et al., 2024 ) . Analogies to gradient descent at inference time also show the connection to test time adaptation ( Sun et al., 2020 ) , especially test-time adaptation of output states ( Boudiaf et al., 2022 ) .

Aside from full recurrent-depth architectures, there also exist a number of proposals for hybrid architectures, such as models with latent sub-networks ( Li et al., 2020a ) , LoRA adapters on top of weight-shared layers ( Bae et al., 2024 ) , or (dynamic) weight-tying of trained models ( Hay and Wolf, 2023 ; Liu et al., 2024b ) .

As mentioned in Section 6 , while we consider the proposed recurrent depth approach to be a very natural way to learn to reason in continuous latent space from the ground up, the works of Hao et al. (2024) ; Cheng and Durme (2024) and Liu et al. (2024a) discuss how to finetune existing fixed-depth transformers with this capability. These works have a similar aim to ours, enabling reasoning in latent space, but approach this goal from separate directions.

For additional discussions related to the idea of constructing a prior that incentivizes reasoning and algorithm learning at the expense of memorization of simple patterns, we also refer to Chollet (2019) , Schwarzschild (2023) , Li et al. (2020b) and Moulton (2023) .

## 9 Future Work

Aside from work extending and analyzing the scaling behaviors of recurrent depth models, there are many questions that remain unanswered. For example, to us, there are potentially a large number of novel post-training schemes that further enhance the capabilities of these models, such as fine-tuning to compress the recurrence or reinforcement learning with data with different hardness levels ( Zelikman et al., 2024 ) , or to internalize reasoning from CoT data into the recurrence ( Deng et al., 2024 ) .

Another aspect not covered in this work is the relationship to other modern architecture improvements. Efficient sequence mixing operations, especially those that are linear in sequence dimension, such as linear attention ( Katharopoulos et al., 2020 ; Yang et al., 2024b ) , are limited in the number of comparisons that can be made. However, with recurrent depth, blocks containing linear operators can repeat until all necessary comparisons between sequence elements are computed ( Suzgun et al., 2019 ) . For simplicity, we also focus on a single recurrence, where prior work has considered multiple successive recurrent stages ( Takase and Kiyono, 2023 ; Csordás et al., 2024 ) .

Finally, the proposed architecture is set up to be compute-heavy , with more “materialized” parameters than there are actual parameters. This naturally mirrors mixture-of-expert models (MoE), which are parameter-heavy , using fewer active parameters per forward pass than exist within the model ( Shazeer et al., 2017 ; Fedus et al., 2022 ) . We posit that where the recurrent-depth setup excels at learning reasoning patterns, the MoE excels at effectively storing and retrieving complex information. Their complementarity supports the hypothesis that a future architecture would contain both modifications. While in a standard MoE model, each expert can only be activated once per forward pass, or skipped entirely, a recurrent MoE model could also refine its latent state over multiple iterations, potentially routing to the same expert multiple times, before switching to a different one ( Tan et al., 2023 ; Csordás et al., 2024 ) . While MoE models are the currently leading solution to implement this type of “memory” in dense transformers, these considerations also hold for other memory mechanisms suggested for LLMs ( Sukhbaatar et al., 2019 ; Fan et al., 2021 ; Wu et al., 2022 ; He et al., 2024 ) .

## 10 Conclusions

The models described in this paper are ultimately still a proof-of-concept. We describe how to train a latent recurrent-depth architecture, what parameters we chose, and then trained a single model at scale. Future training runs are likely to train with more optimized learning rate schedules, data mixes and accelerators. Still we observe a number of interesting behaviors emerging naturally from recurrent training. The most important of these is the ability to use latent reasoning to dramatically improve performance on reasoning tasks by expending test-time computation. In addition, we also observe context-dependent convergence speed, path independence, and various zero-shot abilities. This leads us to believe that latent reasoning is a promising research direction to complement existing approaches for test-time compute scaling. The model we realize is surprisingly powerful given its size and amount of training data, and we are excited about the potential impact of imbuing generative models with the ability to reason in continuous latent space without the need for specialized data at train time or verbalization at inference time.

## Acknowledgements

This project was made possible by the INCITE program: An award for computer time was provided by the U.S. Department of Energy’s (DOE) Innovative and Novel Computational Impact on Theory and Experiment (INCITE) Program. This research used resources of the Oak Ridge Leadership Computing Facility at the Oak Ridge National Laboratory, which is supported by the Office of Science of the U.S. Department of Energy under Contract No. DE-AC05-00OR22725. Work on the LLNL side was prepared by LLNL under Contract DE-AC52-07NA27344 and supported by the LLNL-LDRD Program under Project No. 24-ERD-010 and 24-ERD-058 (LLNL-CONF-872390). This manuscript has been authored by Lawrence Livermore National Security, LLC under Contract No. DE-AC52-07NA27344 with the U.S. Department of Energy. The United States Government retains a non-exclusive, paid-up, irrevocable, world-wide license to publish or reproduce the published form of this manuscript, or allow others to do so, for United States Government purposes.

JG further acknowledges the support of the Hector II foundation. A large number of small-scale and preliminary experiments were made possible through the support of the MPI Intelligent Systems compute cluster and funding by the Tübingen AI center.

UMD researchers were further supported by the ONR MURI program, DARPA TIAMAT, the National Science Foundation (IIS-2212182), and the NSF TRAILS Institute (2229885). Commercial support was provided by Capital One Bank, the Amazon Research Award program, and Open Philanthropy. Finally, we thank Avi Schwarzschild for helpful comments on the initial draft.

## Appendix A Additional Information

## Potential Implications of This Work

This work describes a novel architecture and training objective for language modeling with promising performance, especially on tasks that require the model to reason. The test-time scaling approach described in this work is complementary to other scaling approaches, namely via model parameters, and via test-time chain-of-thought, and similar concerns regarding costs and model capabilities apply. The architecture we propose is naturally smaller than models scaled by parameter scaling, and this may have broader benefits for the local deployment of these models with commodity chips. Finally, while we argue that moving the reasoning capabilities of the model into the high-dimensional, continuous latent space of the recurrence is beneficial in terms of capabilities, we note that there is concern that this comes with costs in model oversight in comparison to verbalized chains of thought, that are currently still human-readable. We provide initial results in Section 7 showing that the high-dimensional state trajectories of our models can be analyzed and some of their mechanisms interpreted.

### A.1 Classical Reasoning Problems

We include a small study of the classical problem of multi-operand arithmetic in Figure 14 .

### A.2 Implementation Details

#### Device Speed Details

Nominally, each MI250X ( AMD, 2021 ) achieves 383 TFLOP in bfloat16, i.e. 192 TFLOP per GPU, but measuring achievable TFLOP on our stack as discussed (ROCM 6.2.0, PyTorch 2.6 pre-release 11/02) for arbitrary matrix multiplication shapes (i.e. we measure the peak achievable speed of the best possible shape iterating over shapes between 256 and 24576 in intervals of 256 and 110 ( Bekman, 2023 ) ), we measure a peak of 125 TFLOP/s on Frontier nodes. Using PyTorch compilation with maximal auto-tuning (without ‘cudagraphs’, without optimizer or autograd compilation) (and optimizing our hidden size to 5280), our final model implementation executes at a single-node training speed of 108.75 TFLOP/s, i.e. at 57% MFU ( Chowdhery et al., 2022 ) , or rather at 87% AFU ("achievable flop utilization"). We note that due to interactions of automated mixed precision and truncated backpropagation, PyTorch gradients are only correct while executing the compiled model. We further circumvent issues with the flash attention implementation shipped with PyTorch sdpa using the AMD fork of the original flash attention repository 6 6 6 https://github.com/Dao-AILab/flash-attention/ , which can be found at https://github.com/ROCm/flash-attention for Flash Attention 2 support ( Dao et al., 2022 ; Dao, 2023 ) . We experiment with fused head and loss implementations 7 7 7 https://github.com/JonasGeiping/linear_cross_entropy_loss , but ultimately find that the most portable choice on our AMD setup is to let torch compilation handle this issue.

#### Parallelization Strategy

As mentioned in the main body, because our depth-recurrent model is compute-heavy, it is optimal to run the model using only distributed data parallel training across nodes and zero-1 optimizer sharding within nodes ( Rajbhandari et al., 2020 ) , if we make use of gradient checkpointing at every step of the recurrent iteration. This allows us to eschew more communication-heavy parallelization strategies that would be required for models with the same FLOP footprint, but more parameters, which require substantial planning on this system ( Singh et al., 2024 ; Singh and Bhatele, 2022 ) . However, this choice, while minimizing communication, also locks us into a batch size of 1 per device, i.e. 4096 in total, and 16M tokens per step.

#### RCCL Interconnect Handling

Due to scheduling reasons, we settled on targeting 512 node allocation segments on Frontier, i.e. 4096 GPUs. However, this posed a substantial network interconnect issue. The connection speed between frontier nodes is only acceptable, if RCCL (AMD GPU communication collectives) commands are routed through open fabrics interface calls, which happens via a particular plugin 8 8 8 https://github.com/ROCm/aws-ofi-rccl . To achieve sufficient bus bandwidth above 100GB/s requires NCCL_NET_GDR_LEVEL=PHB , a setting that, on NVIDIA systems, allows packages to go through the CPU, and only uses direct interconnect if GPU and NIC are on the same (NUMA) node ( Wu and Stock, 2024 ) . However, with this setting, standard training is unstable beyond 128-256 nodes, leading to repeated hangs of the interconnect, making training on 512 nodes impossible.

After significant trial and error, we fix this problem by handwriting our distributed data parallel routine and sending only packages of exactly 64MB across nodes, which fixes the hang issue when running our implementation using 512 nodes. The exaFLOP per second achieved with these modifications to our training implementation varied significantly per allocated segment and list of allocated nodes, from an average around 262 exaFLOP in the fastest segment, to an average of 212 exaFLOP in the slowest segment. This is a range of 52-64 TFLOP/s per GPU, i.e. 41%-51% AFU, or 1-1.2M tokens per second.

#### Pretraining Metrics.

During the pretraining run, we run a careful tracking of optimizer and model health metrics, tracking effective Adam learning rates per layer, optimizer RMS ( Wortsman et al., 2023a ) , L 2 L^{2} and L 1 L^{1} parameter and gradient norms, recurrence statistics such as ‖ s k − s k − 1 ‖ ‖ s k ‖ \frac{||s_{k}-s_{k-1}||}{||s_{k}||} , ‖ s k ‖ ||s_{k}|| , ‖ s 0 − s k ‖ ||s_{0}-s_{k}|| . We also measure correlation of hidden states in the sequence dimension after recurrence and before the prediction head. We hold out a fixed validation set and measure perplexity when recurring the model for [ 1 , 4 , 8 , 16 , 32 , 64 ] [1,4,8,16,32,64] steps throughout training.

## Appendix B Latent Space Visualizations

On the next pages, we print a number of latent space visualizations in more details than was possible in Section 7 . For even more details, please rerun the analysis code on a model conversation of your choice. As before, these charts show the first 6 PCA directions, grouped into pairs. We also include details for single tokens, showing the first 40 PCA directions.

## Appendix C Pretraining Data

Dataset Address License Category W MG Citation WebInstruct-prometheus chargoddard/WebInstructSub-prometheus apache-2.0 generic-instruct 1.0 ✓ Kim et al. (2024) hercules Locutusque/hercules-v5.0 other generic-instruct 1.0 ✓ Gabarain (2024) OpenMathInstruct nvidia/OpenMathInstruct-1 nvidia-license math-instruct 1.0 ✓ Toshniwal et al. (2024b) MetaMathQA meta-math/MetaMathQA mit math-instruct 1.0 ✓ Yu et al. (2023) CodeFeedback m-a-p/CodeFeedback-Filtered-Instruction apache-2.0 generic-instruct 2.0 ✓ Zheng et al. (2024) Daring-Anteater nvidia/Daring-Anteater cc-by-4.0 generic-instruct 1.0 ✓ Wang et al. (2024b) Nvidia-Blender nvidia/sft_datablend_v1 cc-by-4.0 generic-instruct 1.0 ✓ nvidia/sft_datablend_v1 baai-instruct-foundation BAAI/Infinity-Instruct - generic-instruct 1.0 ✓ BAAI/Infinity-Instruct baai-instruct-gen BAAI/Infinity-Instruct - generic-instruct 1.0 ✓ BAAI/Infinity-Instruct anthracite-stheno anthracite-org/Stheno-Data-Filtered - math-instruct 1.0 ✓ anthracite-org/Stheno-Data-Filtered opus-writing Nopm/Opus_WritingStruct apache-2.0 writing-instruct 2.0 ✓ Nopm/Opus_WritingStruct math-step xinlai/Math-Step-DPO-10K - math-instruct 2.0 ✓ Lai et al. (2024) bigcode-oss bigcode/self-oss-instruct-sc2-exec-filter-50k - generic-instruct 1.0 ✓ sc2-instruct everyday-conversations HuggingFaceTB/everyday-conversations apache-2.0 writing-instruct 3.0 ✓ HuggingFaceTB/everyday-conversations gsm8k hkust-nlp/gsm8k-fix mit math-instruct 1.0 ✗ Cobbe et al. (2021) no-robots HuggingFaceH4/no_robots cc-by-nc-4.0 writing-instruct 3.0 ✗ Ouyang et al. (2022) longwriter THUDM/LongWriter-6k apache-2.0 writing-instruct 2.0 ✓ Bai et al. (2024) webglm-qa THUDM/webglm-qa - generic-instruct 1.0 - Liu et al. (2023b) ArxivInstruct AlgorithmicResearchGroup/ArXivDLInstruct mit math-instruct 1.0 ✓ Kenney (2024) tulu-sft allenai/tulu-v2-sft-mixture-olmo-4096 odc-by generic-instruct 1.0 ✓ Groeneveld et al. (2024) P3 bigscience/P3 apache-2.0 generic-instruct 1.0 ✗ Sanh et al. (2021) OrcaSonnet Gryphe/Sonnet3.5-SlimOrcaDedupCleaned mit writing-instruct 2.0 ✓ Gryphe/Sonnet3.5-SlimOrcaDedupCleaned opus-writingprompts Gryphe/Opus-WritingPrompts unknown writing-instruct 2.0 ✓ Gryphe/Opus-WritingPrompts reddit-writing nothingiisreal/Reddit-Dirty-And-WritingPrompts apache-2.0 writing-instruct 2.0 ✗ Reddit-Dirty-And-WritingPrompts kalomaze-instruct nothingiisreal/Kalomaze-Opus-Instruct-25k-filtered apache-2.0 writing-instruct 2.0 ✓ Kalomaze-Opus-Instruct-25k lean-github internlm/Lean-Github apache-2.0 math-instruct 3.0 ✗ Wu et al. (2024) lean-workbook pkuAI4M/LeanWorkbook apache-2.0 math-instruct 3.0 ✗ Ying et al. (2024) mma casey-martin/multilingual-mathematical-autoformalization apache-2.0 math-instruct 3.0 ✗ Jiang et al. (2023) lean-dojo-informal AI4M/leandojo-informalized - math-instruct 3.0 ✗ Yang et al. (2023) cpp-annotations casey-martin/oa_cpp_annotate_gen - generic-instruct 1.0 ✓ moyix lean-tactics l3lab/ntp-mathlib-instruct-st - math-instruct 2.0 ✗ Hu et al. (2024) college-math ajibawa-2023/Maths-College apache-2.0 math 1.0 ✓ ajibawa-2023/Maths-College gradeschool-math ajibawa-2023/Maths-Grade-School apache-2.0 math 1.0 ✓ ajibawa-2023/Maths-Grade-School general-stories ajibawa-2023/General-Stories-Collection apache-2.0 synthetic-text 1.0 ✓ ajibawa-2023/General-Stories-Collection amps-mathematica XinyaoHu/AMPS_mathematica mit math 1.0 ✗ XinyaoHu/AMPS_mathematica amps-khan XinyaoHu/AMPS_khan mit math-instruct 1.0 ✗ XinyaoHu/AMPS_khan Magpie-300k Magpie-Align/Magpie-Pro-MT-300K-v0.1 llama3 generic-instruct 1.0 ✓ Xu et al. (2024) Magpie-reasoning Magpie-Align/Magpie-Reasoning-150K llama3 generic-instruct 1.0 ✓ Xu et al. (2024) prox-fineweb gair-prox/FineWeb-pro odc-by generic-text 1.0 ✗ Zhou et al. (2024) prox-c4 gair-prox/c4-pro odc-by generic-text 1.0 ✗ Zhou et al. (2024) prox-redpajama gair-prox/RedPajama-pro odc-by generic-text 1.0 ✗ Zhou et al. (2024) prox-open-web-math gair-prox/open-web-math-pro odc-by math 1.0 ✗ Zhou et al. (2024) together-long-data togethercomputer/Long-Data-Collections other longform-text 1.0 ✗ TogetherAI (2023) project-gutenberg-19 emozilla/pg19 apache-2.0 longform-text 1.0 ✗ Rae et al. (2019) mathgenie MathGenie/MathCode-Pile apache-2.0 math 1.0 ✗ Lu et al. (2024) reasoning-base KingNish/reasoning-base-20k apache-2.0 math 1.0 ✓ KingNish/reasoning-base-20k OpenMathInstruct-2 nvidia/OpenMathInstruct-2 nvidia-license math-instruct 1.0 ✓ Toshniwal et al. (2024a) Txt360-DM LLM360/TxT360 odc-by math 1.0 ✗ Liping Tang (2024) Txt360-ubuntu-chat LLM360/TxT360 odc-by Q&A-text 1.0 ✗ Liping Tang (2024) markdown-arxiv neuralwork/arxiver cc-by-nc-sa-4.0 scientific-text 2.0 ✗ neuralwork/arxiver

## Instructions for reporting errors

We are continuing to improve HTML versions of papers, and your feedback helps enhance accessibility and mobile support. To report errors in the HTML that will help us improve conversion and rendering, choose any of the methods listed below:

Click the "Report Issue" ( ) button, located in the page header.

Tip: You can select the relevant text first, to include it in your report.

Our team has already identified the following issues . We appreciate your time reviewing and reporting rendering errors we may not have found yet. Your efforts will help us improve the HTML versions for all readers, because disability should not be a barrier to accessing research. Thank you for your continued support in championing open access for all.

Have a free development cycle? Help support accessibility at arXiv! Our collaborators at LaTeXML maintain a list of packages that need conversion , and welcome developer contributions .
