TLDR: I tested 7.5M-parameter looped transformers on TinyStories, both by pretraining from scratch and by converting a pre-trained dense model through continued training. In these experiments, looping did not improve validation loss per unit of training compute over the dense baselines. I also used logit lensing to examine how predictions change across loops. Based on the results, I conjecture that looped transformers are useful for reasoning-heavy contexts, whereas dense transformers are more compute efficient in primarily knowledge-based tasks (E.g, TinyStories), though these are difficult to isolate in practice.

Experimental context

The experiments use TinyStories, a dataset of short stories generated using GPT-3.5 and GPT-4. The dense baselines span roughly 7.5M to 40M parameters. The shared training recipe uses batches of 64 sequences of 512 tokens and AdamW with a cosine-decay learning rate schedule. The loop-specific training runs and controls are described below.

The dense-model scaling analysis has its own article: Scaling Laws on TinyStories.

Exploring Looped Transformers

Looped transformers are a hot topic at the moment. Z.ai just released their latest model GLM-5.4, which is a looped mixture of experts transformer, trained by converting the base model GLM-5.0 into a looped transformer through continued training. Thinking Machines just released Inkling 2 Mini, another looped Mixture of Experts transformer with 26.4B total parameters, 3.4B active parameters, and 5.4B weight activations per token when accounting for looping. Both of these models perform incredibly well on reasoning tasks, beating dense models of several times the size.

Pasted image 20261127004855.png
Image generated by GPT-6. Inspired by the “Attention Is All You” need transformer diagram

A little bit of context on looped transformers. Looped transformers are just regular transformers as we know them, containing sequential layers of transformer blocks. The difference between a looped transformer and a regular one is that they loop a set amount of times around the middle layer, that is, passing the output of the middle layer on a particular loop back as input to the next loop times. The motivation is that this should enable looped transformers to perform comparably well to dense transformers of much larger size by imbuing added reasoning capabilities in a model without increasing parameter size.

Pre-training recipe for looped transformers

Looped transformers have a slightly different but intuitive pre-training algorithm. During the forward pass, we run several loops of the transformer, instead of simply applying the loops in inference time. This allows gradient descent to account for the loops.

The most intuitive pretraining approach for looped transformers is to pretrain them from scratch (randomly initialized weights), which indeed is one of the pretraining approaches I tried. However, in Z.ai’s GLM-5.4 technical blog announcement, they mentioned that converting an existing base model into a looped model via continued training, is more compute efficient than training a looped model from scratch. We will soon observe whether this is true contextually.

In terms of the models, I trained several 7.5M parameter looped transformers from scratch (with or loops) and converted the pretrained 7.5M base model into a looped transformer. I converted the base 7.5M model by training it on a further epoch of the dataset. To account for the possibility that added training may be the contributor to increased performance in the dense models, I trained the from-scratch 7.5M looped model on 3.70 epochs instead of 2.70 epochs (original pre-training recipe). I also further trained the base 7.5M model for an additional epoch to isolate the effects of loops.

The three model categories serve different roles in the comparison:

Model categoryWhy it matters
Looped (pretrained)Tests whether loops help when learned from the start, and provides a comparison with conversion to assess which approach is more compute efficient.
Dense (continued training)Isolates the effects of additional training, providing a control for gains that might otherwise be attributed to adding loops.
Looped (converted)Tests whether adding loops through continued training are valuable, and whether conversion is more compute efficient than training a looped model from scratch.

Looped Transformer Results

Figure 2.0: Validation loss against cumulative tokens or compute: from-scratch, converted, and dense continued-training models.

Interactive figure available on the website with JavaScript enabled. View the source data.

The results show that looped transformers add minimal benefit over the the control done variant when measuring validation loss. In the compute view, the dense version is also more compute efficient than the looped versions for a given target validation loss. In the tokens view, we find that looped transformers pre-trained from scratch outperform the base and converted variants by a small margin.

Figure 2.1: Comparing the compute efficiency of looped and dense models.

Interactive figure available on the website with JavaScript enabled. View the source data.

Dense models are much more compute efficient than the looped transformers for a given validation loss objective, including the 40.2M dense model. We observe that none of the looped transformers beat the next dense model increment(15.9M).

Logit Lensing (a little Mech Interp)

Figure 2.2: Logit lensing of looped models, averaged over 131,072 validation tokens. Each point reads the output after one transformer block (a fraction of a loop).

Interactive figure available on the website with JavaScript enabled. View the source data.

Intuitively, we observe that each of the model performances degrade after applying more loops than it was trained on. Conversely, the minima always occur at the loop count the models were trained on. The pre-trained looped model exhibit iterative computation, where each loop linearly decreases the validation loss. On the other hand, the converted models seem to arbitrarily use the loops. Most of the computation is performed within the final loop, whilst the middle loops are very stagnant. This is clearly visible in the variant, along with the variant — though slightly more difficult to observe.

Discussion

Looped models exhibit signs of iterative computation (as seen by the pre-trained from scratch model). However, on TinyStories, they provide insignificant performance advantages over dense models of the same parameter size, and do not achieve the same performance of dense models multiples larger. I honestly was a little skeptical of gains from looped transformers in this context, since the nature of the TinyStories dataset doesn’t involve much reasoning, but inherently tests a model’s knowledge of grammar syntax, vocabulary semantics, creativity, across moderately sized pieces of text. Looped transformers do not add more parameters, instead iteratively applying a fixed set of weights. Therefore, it seems reasonable to presume that larger dense models are able to “store / learn” more general english skills per unit of compute as opposed to looped models.

On this note, I think it is reasonable to conjecture that looped transformers add minimal gains per unit of compute on minimal reasoning tasks, making it more compute efficient to train larger dense models. And whilst less supported by the experiments here, I presume that the converse is true in reasoning heavy tasks, where I anticipate looped transformers perform better per unit of pre-training compute. This sets up well for a future work, where several domains can be explored categorized into non-reasoning and reasoning-heavy, and deduce whether the conjecture holds true at a larger scale. It may be useful to note that reasoning heavy tasks do not have to be necessarily numerical. For example, I anticipate looped-transformers may lead to better gains on legal benchmarks, since a lot of logic / reasoning underlies legal text, in comparison to those in children stories.

Further Reading