ARLoop’s mechanism: attention over depth

2. ARLoop’s mechanism: attention over depth#

ARLoop keeps the looped stack and changes only how each sublayer reads the residual stream [YDZS26] (§3), carrying over the Attention Residuals of [Kim26] to loops.

Attention residuals

Write \(z_0 := h_0\) for the embedding and \(z_j = f_j(\operatorname{Norm}(h_{j-1}))\) for the update of sublayer \(j\). Instead of adding all updates with weight 1, the state after sublayer \(i\) is a softmax mixture of all earlier sources (eq. 2–3):

\[ \alpha_{i,j} = \operatorname{softmax}_{j\in\{0,\dots,i\}}\big(q_i^\top \operatorname{Norm}(z_j)\big), \qquad h_i = \alpha_{i,0}\,h_0 + \sum_{j=1}^{i}\alpha_{i,j}\,z_j , \]

with a learned query \(q_i\) for each effective sublayer: in a loop, the same physical sublayer gets a different query in every pass. With all \(\alpha_{i,j} = 1\) (no softmax) this is exactly the unrolled PreNorm sum (exercise Attention residuals contain PreNorm). [paper]

Blocks

The number of sources grows with depth, so ARLoop uses block attention residuals (eq. 4): \(S\) consecutive sublayers form a residual block

\[ b_k = \sum_{j=(k-1)S+1}^{kS} z_j , \]

inside a block the updates add up as in PreNorm (the partial block), and across blocks the attention decides. Each sublayer attends over the embedding, the completed blocks and the current partial block. [paper]

The sliding window

With sources \(\mathcal B = \{b_0, b_1, \dots, b_m\}\) (\(b_0\) the embedding, \(b_m\) the most recent one), a window of size \(W\) keeps

\[ \mathcal B_W = \{b_0, b_{\max(1, m-W+1)}, \dots, b_m\}: \]

the embedding is always visible, older blocks drop out. The paper makes this the default for \(R > 2\); the window size of the released models and the exact order of the bookkeeping are computed in The window, block by block. How the window compares in accuracy, and its dependence on value residuals, are in The paper’s evidence (claim C2). [paper]

What the released code shows

Read in the released modeling code and configurations (digest §2) [code]:

  • each effective sublayer has a routing query and an RMSNorm of its own, and there is one more pair for the read-out that feeds the LM head (the paper’s eq. 2 shows only the query; its appendix A.1, on the controlled models, names per-sublayer normalisation parameters too, without counting them); in the score \(q_i^\top\operatorname{Norm}(z_j)\) the norm weight \(g_i\) only appears in the product \(q_i\odot g_i\), so there is one effective routing vector per routing call (every sublayer and the read-out);

  • the routed state is normalised with the block’s shared norm (attn_norm, mlp_norm) before the sublayer uses it;

  • the first residual block starts from the embedding (blocks = [h0], partial = h0), so the first committed block is \(b_1 = h_0 + \sum_{j=1}^{S} z_j\) rather than eq. (4)’s \(\sum_{j=1}^{S} z_j\) (finding F6 of the digest);

  • independently of F6, the very first routing call only ever sees the embedding (two copies of it in the code, one under eq. (4)), so its query and norm weight cannot act (finding F8).

The two sub-chapters compute what these rules mean for the released models: which sources every sublayer reads, and what the per-sublayer routing costs in parameters.

Sub-chapters