---
title: A Detailed Look at ARLoop in Transformer Architecture
url: https://www.emergentmind.com/topics/arloop
type: topic
---

# A Detailed Look at ARLoop in Transformer Architecture

ARLoop, or **Attention-Residual Looped Transformer**, is a recurrent-depth transformer architecture in which a shared transformer stack is applied multiple times while each effective sublayer selectively aggregates representations from earlier recurrent depths through learned attention residuals. It addresses the limitation of conventional residual connections, which combine preceding updates into a single stream with fixed unit coefficients. ARLoop introduces explicit control over which residual representations are reused, and reports improvements in validation perplexity, mathematical reasoning, and code-generation performance across controlled and large-scale pretraining experiments [2611.05234].

## 1. Recurrent-depth transformer architecture

A looped transformer repeatedly applies a parameterized stack $\mathcal S$:

$$
\bm y =
\operatorname{LMHead}\circ
\mathcal S^{(R)}\circ\cdots\circ
\mathcal S^{(1)}(\bm h_0),
$$

where $\mathcal S^{(1)}=\cdots=\mathcal S^{(R)}=\mathcal S$, $\bm h_0\in\mathbb R^{n\times d}$ is the token-embedding matrix, $n$ is sequence length, $d$ is hidden size, and $R$ is the number of recurrences. If the shared stack has $L$ physical transformer layers, the resulting network has effective depth $LR$ transformer layers, or $2LR$ attention and feed-forward sublayers, while retaining only $L$ distinct parameterized layers.

This parameter sharing increases computation and effective depth without a proportional increase in parameter count. It also provides an explicit recurrent computation axis. However, repeatedly applying the same stack introduces a distinction between **parameter depth**, determined by $L$, and **effective recurrent depth**, determined by $LR$.

In a conventional PreNorm transformer, an effective sublayer updates the hidden state as

$$
\bm h_i=
\bm h_{i-1}
+
f_i\!\left(\operatorname{Norm}(\bm h_{i-1})\right).
$$

Writing the sublayer update as

$$
\bm z_i=f_i\!\left(\operatorname{Norm}(\bm h_{i-1})\right),
$$

gives

$$
\bm h_i=\bm h_0+\sum_{j=1}^{i}\bm z_j.
$$

Every previous update therefore enters every later state with the same coefficient, namely $1$. At high recurrent depths, the residual stream repeatedly accumulates updates, without allowing later layers to explicitly select, suppress, or reweight individual earlier representations.

Prior looped-transformer designs, including Sandwich-Norm, DeepLoop, and Parcae, primarily address recurrent stability through normalization, residual scaling, or explicit state-transition mechanisms. ARLoop instead focuses on selective access to the residual history.

## 2. Attention residuals

ARLoop replaces fixed residual addition with attention over representations produced at earlier effective depths. The input embedding is treated as a permanent residual source:

$$
\bm z_0:=\bm h_0.
$$

For effective sublayer $i$, the newly computed update is

$$
\bm z_i=
f_i\!\left(\operatorname{Norm}(\bm h_{i-1})\right).
$$

A learned query vector $\bm q_i$ determines the importance of each available residual source. The attention weight for source $j$ is

$$
\alpha_{i,j}
=
\operatorname{Softmax}_{j\in\{0,\ldots,i\}}
\left(
\bm q_i^\top
\operatorname{Norm}(\bm z_j)
\right),
$$

with

$$
\alpha_{i,j}\geq 0,
\qquad
\sum_j\alpha_{i,j}=1.
$$

The residual state becomes

$$
\bm h_i=
\alpha_{i,0}\bm h_0+
\sum_{j=1}^{i}\alpha_{i,j}\bm z_j.
$$

In implementations, learned query and key projections are used for the depth-attention computation. Conceptually, the score can be written as

$$
s_{i,j}
=
(W_q\bm q_i)^\top
\left(W_k\operatorname{Norm}(\bm z_j)\right),
$$

followed by a softmax over the accessible depth sources.

The distinction is therefore:

$$
\text{PreNorm:}\qquad
\bm h_i=\bm h_{i-1}+\bm z_i,
$$

whereas

$$
\text{ARLoop:}\qquad
\bm h_i=\sum_{j\leq i}\alpha_{i,j}\bm z_j.
$$

The embedding $\bm h_0$ is always included as a special source. Each effective sublayer has its own depth-attention query and normalization parameters.

Depth attention is causal in the recurrent-depth direction. At depth $i$, the model can access the embedding and representations produced at depths $0,\ldots,i$, but not future residual sources. Token-level self-attention remains causal over sequence positions. A model trained only up to a specified recurrence range has depth-query parameters learned only through that effective depth; recurrence extrapolation therefore requires additional query parameters or an extrapolation rule.

## 3. Block residuals and depth-history windows

Maintaining a distinct residual source after every effective sublayer would make the number of depth-attention sources grow linearly with effective depth. ARLoop reduces this cost by grouping consecutive sublayers into residual blocks.

For a block containing $S$ consecutive sublayers,

$$
\bm b_k=
\sum_{j=(k-1)S+1}^{kS}\bm z_j.
$$

Within a block, residual updates are accumulated additively. Attention is applied across completed blocks and the current partial block. The embedding is represented as $\bm b_0=\bm h_0$.

The controlled configurations use two residual blocks per recurrence:

- At 140M parameters, $L=6$, each recurrence has $12$ sublayers, and $S=6$.
- At 370M parameters, $L=12$, each recurrence has $24$ sublayers, and $S=12$.
- ARLoop-0.6B uses $L=18$ and $S=18$.
- ARLoop-1.2B uses $L=24$ and $S=24$.

Two depth-history mechanisms are evaluated. **Full-history attention** exposes all available residual blocks,

$$
\mathcal B=\{b_0,b_1,\ldots,b_m\}.
$$

**Sliding-window attention** retains the embedding and only the $W$ most recent residual blocks:

$$
\mathcal B_W=
\left\{
b_0,\,
b_{\max(1,m-W+1)},\ldots,b_m
\right\}.
$$

The default configuration uses $W=3$, so the embedding and three recent blocks remain directly accessible.

The paper reports that, in a 140M model at $R=4$, the embedding and three most recent blocks receive approximately $96\%$ of the depth-attention mass at a representative late sublayer. Repeated applications of the same shared stack also produce residual blocks with high pairwise cosine similarity. This suggests that later recurrent representations are often refinements of earlier ones, making unrestricted access to distant blocks less useful and potentially introducing interference.

The matched-depth comparison illustrates the difference between recurrent and non-recurrent models:

| Architecture | Full-history PPL | Sliding-window PPL | Change |
|---|---:|---:|---:|
| $L=6$, $R=4$ looped | 16.07 | 16.03 | -0.04 |
| $L=24$, $R=1$ non-recurrent | 13.65 | 16.78 | +3.13 |

The sliding window slightly improves the looped model but substantially harms the ordinary deep transformer. The reported block-window ablation at 140M and $R=4$ gives perplexities of 16.17, 16.03, 16.07, and 16.14 for $W=2,3,4,5$, respectively. The authors use full history for $R\leq2$ and sliding-window attention for $R>2$.

The result is empirical rather than universal: full history is better than the windowed variant in some shallow settings, including the 140M model at $R=2$.

## 4. Controlled experiments and baseline comparisons

Controlled experiments use decoder-only models with 140M and 370M parameters. The models use causal multi-head attention, ReLU$^2$ MLPs, RoPE with $\theta=50{,}000$, RMSNorm with $\epsilon=10^{-5}$, tied input and output embeddings, BF16 mixed precision, AdamW, gradient clipping, cosine learning-rate decay, packed FineWeb-Edu sequences, and a context length of 2,048.

The principal baselines are:

- **PreNormLoop**, using ordinary residual addition.
- **Sandwich-Norm**, which normalizes the residual sum.
- **DeepLoop**, which uses recurrent-depth residual scaling and normalization.
- **Parcae**, which models recurrence as a stable state transition, evaluated with and without input injection.

All methods also use gated value residuals, in which token embeddings are injected into attention value vectors at alternating effective layers. An ablation indicates that ARLoop’s gains are not attributable solely to value residuals: ARLoop continues to outperform the other methods without them, although removing value residuals substantially damages the sliding-window variant and can destabilize Sandwich-Norm.

The main validation perplexities are:

| Model | 140M $R=1$ | 140M $R=3$ | 140M $R=5$ | 370M $R=1$ | 370M $R=3$ |
|---|---:|---:|---:|---:|---:|
| Sandwich-Norm | 18.98 | 17.19 | 16.59 | 13.92 | 12.97 |
| DeepLoop | 18.72 | 17.05 | 16.52 | 13.69 | 12.78 |
| Parcae, no injection | 18.37 | 16.60 | 16.01 | 13.55 | 12.31 |
| Parcae, injection | 18.37 | 16.55 | 15.96 | 13.55 | 12.30 |
| PreNormLoop | 18.37 | 16.91 | 16.34 | 13.55 | 12.48 |
| **ARLoop** | **18.26** | **16.38** | **15.84** | **13.32** | **12.17** |

Relative to PreNormLoop, ARLoop improves perplexity by 0.11 at 140M with $R=1$, 0.53 at $R=3$, 0.50 at $R=5$, 0.23 at 370M with $R=1$, and 0.31 at $R=3$. The larger improvements at higher recurrence support the interpretation that attention residuals enable more effective use of additional recurrent computation.

The full-history and sliding-window comparison shows that windowed attention generally becomes more competitive as recurrence increases. At 140M and $R=3$, full-history and windowed ARLoop obtain perplexities of 16.46 and 16.38, respectively, compared with 16.91 for PreNormLoop. At 140M and $R=4$, the corresponding values are 16.07, 16.03, and 16.59. At 370M and $R=3$, they are 12.27, 12.17, and 12.48.

The paper also compares fixed recurrence with Poisson-sampled recurrence,

$$
\tilde R\sim\operatorname{Poisson}(4),
\qquad
R=\min(4,\max(1,\tilde R)).
$$

For both model sizes, fixed $R=4$ training performs better when evaluated at $R=4`. At 140M, fixed recurrence achieves perplexity 16.07 and downstream average 44.09, compared with 16.69 and 43.24 for Poisson per-sequence sampling. At 370M, fixed recurrence achieves 12.01 and 50.93, compared with 12.33 and 49.62.

These results do not establish that dynamic recurrence is generally inferior; dynamic recurrence enables flexible compute allocation, whereas the reported main experiments use fixed recurrence.

## 5. Large-scale pretraining and downstream performance

The large-scale models use grouped-query attention, SwiGLU MLPs, RMSNorm, RoPE with $\theta=50{,}000$, a context length of 4,096, the SmolLM2 tokenizer with vocabulary size 49,152, tied input and output embeddings, BF16 training, fixed $R=3$, and sliding-window depth attention with the embedding plus three recent residual blocks.

The configurations are:

| Model | Parameters | Physical layers | Recurrences | Effective sublayers | Training tokens |
|---|---:|---:|---:|---:|---:|
| PreNormLoop-0.6B | 0.6B | 18 | 3 | 108 | 180B |
| ARLoop-0.6B | 0.6B | 18 | 3 | 108 | 180B |
| ARLoop-1.2B | 1.2B | 24 | 3 | 144 | 500B |

Training uses FineWeb-Edu, FineMath, Stack-Edu, coding data, and later-stage mathematical and reasoning data. The training recipe is divided into three stages: 60% of tokens in Stage 1, 20% in Stage 2, and 20% in Stage 3. Later stages increase the proportions of math, code, and reasoning-oriented data.

The matched 0.6B comparison is:

| Model | ARC-Challenge | HellaSwag | WinoGrande | OpenBookQA | GSM8K | MATH | MBPP | HumanEval |
|---|---:|---:|---:|---:|---:|---:|---:|---:|
| PreNormLoop-0.6B | 46.3 | 60.6 | 61.2 | 39.8 | 35.7 | 20.9 | 33.1 | 17.6 |
| ARLoop-0.6B | 45.5 | 62.5 | 61.8 | 40.8 | 40.9 | 26.3 | 36.2 | 20.1 |

ARLoop improves on seven of eight tasks. The largest improvements are on GSM8K, from 35.7 to 40.9; MATH, from 20.9 to 26.3; MBPP, from 33.1 to 36.2; and HumanEval, from 17.6 to 20.1. ARC-Challenge decreases from 46.3 to 45.5.

ARLoop-1.2B obtains:

| Task | Score |
|---|---:|
| ARC-Challenge | 56.3 |
| HellaSwag | 71.5 |
| WinoGrande | 66.8 |
| OpenBookQA | 45.5 |
| GSM8K | 63.1 |
| MATH | 37.8 |
| MBPP | 52.1 |
| HumanEval | 33.1 |

The reported ARLoop-1.2B model outperforms the listed Huginn-3.5B checkpoints on all eight evaluated tasks. It also matches or exceeds the listed Qwen3.5-2B scores on all eight tasks under the reported comparison. These comparisons are practical reference points rather than fully controlled architectural comparisons because the models differ in parameter count, tokenizer, training data, recurrence configuration, and training budget.

The 1.2B model is reported as being pretrained on 0.5T tokens with three recurrences. The supplied experimental configuration also lists 500B training tokens for ARLoop-1.2B. Training required approximately two weeks on 16 B200 GPUs, whereas the 0.6B runs required roughly one week on eight H100 GPUs.

## 6. Mechanistic interpretation, efficiency, and limitations

Causal interventions are used to examine the contribution of individual effective layers. If $\bm a_{\ell,t}$ and $\bm m_{\ell,t}$ denote attention and MLP outputs at effective layer $\ell$ and token position $t$, the local contribution is

$$
\bm c_{\ell,t}=\bm a_{\ell,t}+\bm m_{\ell,t}.
$$

After ablating layer $s$, the layer-to-layer influence on a later layer $\ell$ is

$$
E^{\mathrm{layer}}_{s\rightarrow\ell,t}
=
\frac{
\left\|
\bm c_{\ell,t}
-
\bar{\bm c}^{(s)}_{\ell,t}
\right\|_2
}{
\left\|\bm c_{\ell,t}\right\|_2
}.
$$

The output effect is

$$
E^{\mathrm{out}}_{s,t}
=
\left\|
\bm p_t-\bar{\bm p}^{(s)}_t
\right\|_2.
$$

On MATH and MBPP, later recurrences of ARLoop have larger effects on subsequent computation than corresponding later recurrences of PreNormLoop. This is consistent with ARLoop using additional effective depth more substantially, although the intervention results do not establish that attention residuals are the sole cause of downstream gains.

ARLoop has essentially the same training memory as PreNormLoop in the reported configurations because residual sources are already retained for backpropagation when activation checkpointing is not enabled. Its primary cost is additional memory traffic and depth-attention computation. At $R=4$, the paper reports approximately 15% lower throughput than PreNorm for full-history attention and roughly 10% lower throughput for sliding-window attention, with negligible additional memory in the tested setups.

Several conclusions remain conditional. The explanation that sliding windows work because recurrent representations are redundant is supported by attention-weight and cosine-similarity analyses, but redundancy is not established as the sole causal mechanism. Three residual blocks are an effective reported default, not a universal optimum. The large-model comparisons do not isolate architecture from data quantity or data quality. The experiments also do not establish useful recurrence extrapolation beyond the training range.

ARLoop’s central architectural claim is that parameter-efficient recurrent depth benefits from selective control over information flow across repetitions. Repeated shared layers alone provide additional computation, but attention residuals allow each effective sublayer to determine which earlier recurrent representations should be preserved, suppressed, or emphasized. The reported results indicate that this mechanism improves looped-transformer performance, particularly at larger recurrent depths, while a small recent-history window can preserve most of the benefit and reduce the cost of unrestricted residual-history attention.

Source: https://www.emergentmind.com/topics/arloop