논문 풀이

시험판입니다. 검색에는 나오지 않고, AI 질문은 꺼져 있어 마인드맵에는 예시 답이 나옵니다.

Rewirable Circuits in Transformers with Loom Attention

분류: 원문 읽기 · 논문 원문 · 가져온 날 2026-11-25 · Hugging Face 화제 논문 (추천 22, 2026-11-22)에서 고름

원문 저자가 쓴 글을 그대로 옮겼습니다. 용어 설명과 마인드맵의 AI 답은 따로 확인을 거치지 않았습니다.

원문 정보

Rewirable Circuits in Transformers with Loom Attention
Da Xiao, Qingye Meng, Shengping Li, Xingyuan Yuan
출처: arXiv 2611.30634 · 라이선스: CC BY 4.0 · 발표 2026-11-23

원문 본문을 그대로 옮기고 용어 링크와 난이도 색을 더했습니다. 그림, 표의 본체, 부록은 옮기지 않고 원문 링크로 대신했습니다.

기초중간심화 어려운 말은 난이도에 따라 색을 달리했습니다. 궁금한 문장은 옆에 나오는 ?를 누르면 마인드맵에서 물어볼 수 있습니다.

1. 이 글을 읽으려면

이 글에 나오는 용어를 먼저 알아야 할 것부터 늘어놓았습니다. 이미 아는 것은 건너뛰세요.

  1. 벤치마크여러 AI나 방법의 실력을 같은 조건에서 비교하려고 만든 공통 시험 문제 모음입니다.
  2. 토큰언어 모델이 글을 읽고 쓸 때 쓰는 가장 작은 단위입니다.
  3. 임베딩토큰이나 영상 조각을 숫자 목록으로 나타낸 것입니다. 비슷한 것끼리는 숫자도 비슷합니다.

1.1. 이 글에 나오는 말, 난이도별로

2. Abstract

We propose loom attention, which allows a Transformer to dynamically rewire its circuits at every token by interweaving a head’s vertical attention over the outputs of earlier heads (to obtain its query, key and value) with its horizontal attention over tokens. We instantiate vertical attention efficiently with normalized and gated linear attention over a per-token matrix memory, which stores the compressed head outputs and serves as a second residual stream. This yields LoomFormer, a dual-stream architecture that splits control and content between the vector and matrix streams. Across model sizes and training token budgets in language modeling and downstream tasks, LoomFormer matches Transformers trained with over 3× compute and recent residual-stream baselines (HC/mHC, MUDDFormer, AttnRes) trained with ~1.7–2.8×. For example, trained on the same 300B tokens with only 2% extra FLOPs, LoomPythia-2.8B achieves ~1.6× the average downstream gain of mHC-Pythia-2.8B over Pythia-2.8B, and matches (0-shot) or surpasses (5-shot) Pythia-12B.

이 절에서 궁금할 만한 질문

3. Introduction

원문 1절에서 보기

그림 Figure 1: Conceptual sketch of loom attention. At each token, each head chooses which slots of that token’s matrix memory M to read and write (i.e., vertical attention, every head does both; only one is shown per layer) and which tokens to attend to (horizontal attention), so a different circuit is woven for each token. 원문에서 보기

Transformers solve tasks by composing attention heads across layers into circuits (Elhage et al., 2020; Olsson et al., 2022; Wang et al., 2023; Merullo et al., 2024): an earlier head writes a feature into a subspace of the residual stream, and a later head reads from that subspace into its query, key or value. Induction heads, for example, read the output of a previous-token head through their keys (K-composition) (Olsson et al., 2022).

The composition between two heads, however, is determined by the product of their output and input projections, a virtual weight that does not change after training (Elhage et al., 2020). Attention makes the horizontal flow of information across tokens input-dependent: a head chooses which tokens to attend to. In contrast, the vertical flow across layers is fixed: a head cannot choose which heads to read from. A model that needs different circuits for different inputs therefore keeps all of them wired at once, lets them compete for the residual stream, and can gate them only indirectly, e.g., by sending a head’s attention to a sink token (Xiao et al., 2024b). We ask whether the wiring itself can be chosen per token, i.e., whether circuits can be made rewirable.

Recent work has enriched the vertical flow. Dense connections let a layer aggregate the outputs of all earlier layers (Pagliardini et al., 2024); MUDDFormer (Xiao et al., 2025) and Attention Residuals (AttnRes) (Kimi Team, 2026a) make this aggregation input-dependent, turning it into a depth-wise (i.e., vertical) attention (separate for the query, key, value and residual inputs in MUDDFormer); and Hyper-Connections (HC) (Zhu et al., 2025) and its manifold-constrained variant mHC (Xie et al., 2025) maintain several residual streams with learnable or dynamic mixing. In all of them, however, the vertical channel meets horizontal attention only through the hidden state of a layer, in which the outputs of all heads have already been summed and mixed together: a head can neither single out a particular earlier head nor be singled out by a later one. The vertical and horizontal flows run side by side, never woven together.

To make circuits rewirable, we propose loom attention, in which a head chooses which earlier heads to read from just as it chooses which tokens to attend to. By attending vertically over the outputs of these heads at the same token, the head obtains its query, key and value to perform the standard horizontal attention over tokens, and its output is in turn attended to vertically by later heads. Vertical and horizontal attention are thus interwoven, each feeding the other at every head, like the warp and weft of a loom (Figure 2).

Naive vertical attention over the outputs of all earlier heads is, however, expensive. We therefore instantiate it with normalized and gated linear attention over a per-token matrix memory, which stores the compressed head outputs and serves as a second residual stream. We call the resulting dual-stream architecture LoomFormer, after a drawloom---a loom in which a separate stored pattern selects which warp threads to lift at each pick, rather than repeating one fixed pattern. Here the ordinary vector stream plays the pattern, carrying control—which memory slots each head writes and reads (weaving a different circuit per token) as well as which tokens to attend to—while the matrix stream carries the content moved across tokens. The two streams are coupled through attention outputs and FFN writes.

Extensive experiments on language modeling and downstream tasks across model sizes and training token budgets show that LoomFormer adds only 2.0–3.7% FLOPs while matching Transformers trained with over 3× compute and recent residual-stream baselines (HC/mHC, MUDDFormer, AttnRes) trained with ~1.7–2.8×. For example, trained on the same 300B tokens, LoomPythia-2.8B achieves ~1.6× the average downstream gain of mHC-Pythia-2.8B over Pythia-2.8B, and matches (0-shot) or surpasses (5-shot) Pythia-12B (Figure 2). We also analyze the trained 2.8B models to understand how and why LoomFormer works—e.g., by rewiring head outputs to inputs per token, it keeps over three times as many deep-layer heads off attention sinks as Pythia and mHC.

이 절에서 궁금할 만한 질문

4. Rewirable Circuits

원문 2절에서 보기

Writers, readers and circuits.

Attention heads communicate through the residual stream (Elhage et al., 2020). Consider a Transformer with L layers of n heads of dim d, and model dim D=nd. We call the output of a head a writer and each of its inputs (query, key and value) a reader, so a head has one writer and three readers. Writer \mathsf{W}_{i} adds its output o_{i}\in\mathbb{R}^{d} to the residual stream through its block W^{O}_{i}\in\mathbb{R}^{d\times D} of the output projection, and reader \mathsf{R}_{j} of a later head reads the stream through its input projection W^{s}_{j}\in\mathbb{R}^{D\times d} (s\in\{Q,K,V\}), so \mathsf{W}_{i} reaches \mathsf{R}_{j} through the virtual weight \bar{C}_{ij}=W^{O}_{i}W^{s}_{j}\in\mathbb{R}^{d\times d}: the two communicate only if \mathsf{W}_{i} writes into a subspace that \mathsf{R}_{j} reads. Heads composed in this way form circuits whose nodes are the writers and readers.

A task may need different circuits at different tokens, i.e., different pairs of writers and readers to be connected (Figure 3). To describe how the wiring can change, we give it a dynamic part besides the static virtual weights: at a token, reader \mathsf{R}_{j} receives

u_{j}=\textstyle\sum_{i}o_{i}\,c_{ij}\bar{C}_{ij},

where the per-token scalars c_{ij} form the wiring matrix C\in\mathbb{R}^{w\times r} from the w earlier writers to the r readers of one layer, and c_{ij}\bar{C}_{ij} is the effective wiring from \mathsf{W}_{i} to \mathsf{R}_{j}. The two are connected at the token if their effective wiring is nonzero. A wiring pattern P\subseteq[w]\times[r] is a set of writer-reader pairs, realized when each reader in P is connected to exactly its writers in P.

.

An architecture with fixed virtual weights is rewirable w.r.t. a set of wiring patterns if every pattern in the set is realized by some wiring matrix C that it admits at a token.

그림 Figure 3: Effective wiring for three wiring patterns. Transformers (top two rows) can only gate whole heads, i.e., rows and columns, on and off, so they connect only rectangles within the fixed support of their virtual weights. LoomFormer (bottom row) connects exactly the required pairs. 원문에서 보기

Transformers are node-gated.

In a Transformer, pre-LN only rescales all writers of a token by a common factor (Lemma A.1 in Section A.1). Within a token, nodes can thus only be gated through whole heads: a head that attends to a sink token (Xiao et al., 2024b) outputs nearly nothing, turning off both its writer and, since what its readers receive has no effect, its readers.

.

An architecture is node-gated if, at every token, its wiring matrix has the form

C=g\,g^{\prime\top},

with gate vectors g\in\mathbb{R}^{w} and g^{\prime}\in\mathbb{R}^{r} whose nonzero entries mark the writers and readers that are on.

We call the rank of C the wiring rank; a node-gated architecture has wiring rank at most one, so existing connections can be gated on and off, but not rewired.

.

A Transformer with pre-LN is node-gated: at any token, it connects precisely the pairs with \bar{C}_{ij}\neq 0 whose writer and reader are both on, a rectangle within the fixed support of the virtual weights.

Gating a writer or a reader acts on its whole row or column of C, so a wiring pattern is realized only if it is such a rectangle, as in the first column of Figure 3; other patterns fail in one of two ways. With dense virtual weights, where heads share subspaces, every pair can be connected, but a non-rectangular pattern such as \{\mathsf{W}_{1}\to\mathsf{R}_{1},\mathsf{W}_{3}\to\mathsf{R}_{3}\} (last column) also connects \mathsf{W}_{1}\to\mathsf{R}_{3} and \mathsf{W}_{3}\to\mathsf{R}_{1}: the two circuits interfere. With sparse virtual weights, where groups of heads use separate subspaces, circuits in different groups do not interfere, but pairs across groups such as \mathsf{W}_{3}\to\mathsf{R}_{2} (second column) are unreachable.

The price of rewiring by node gating.

Can a node-gated architecture overcome this by spending more heads? Suppose the role of each of r\geq 2 readers may be played by several heads, gated on and off per token, and at every token each reader must receive exactly one of w writers, chosen independently of the other readers; the last pattern in Figure 3 is the smallest instance. Let N(w,t) denote the minimum size of a ground set carrying a t-cover-free family of w sets, i.e., w sets none of which is covered by the union of t others (Kautz & Singleton, 1964).

.

To realize all such wiring patterns, a node-gated architecture needs at least N(w,r-1) heads per reader, and this number suffices, where N(w,1)\approx\log_{2}w, N(w,t)=\Omega(t^{2}\log w/\log t) for 2\leq t\leq\sqrt{w} and N(w,t)=\Theta(w) for t>\sqrt{w}.

Intuitively, a head receives every writer that is on and has a nonzero virtual weight to it, so a reader must hold in reserve a head that sees its chosen writer and none of the up to r-1 writers chosen by the other readers (Theorem A.2 in Section A.2; bounds in Section A.3). With the r=3n readers of a layer choosing among its w=nl earlier writers, r-1>\sqrt{w} whenever l\leq 9n-6, so at practical sizes node gating needs \Theta(w) heads per reader.

Naive loom attention makes Transformers rewirable.

To rewire with one head per reader, the wiring matrix must be chosen entry by entry at each token. The most direct way is to let every reader attend over the outputs of all earlier heads of the same token, with attention weights generated from the token itself:

u_{j}=\textstyle\sum_{i}\alpha_{ij}(x)\,o_{i},\qquad\alpha_{\cdot j}(x)=\operatorname{softmax}(xW^{\alpha}_{j}),

where W^{\alpha}_{j}\in\mathbb{R}^{D\times nl} for a reader in layer l, which has nl earlier writers. We call this naive loom attention: its virtual weights are identities and all the wiring is left to C=[\alpha_{ij}], unlike a Transformer, which wires heads through fixed virtual weights and only gates them through a rank-one C. With one head per reader, it is rewirable w.r.t. all wiring patterns (cf. Figure 3, bottom row), but expensive: over the 3n readers of all L layers, generating the attention weights takes about \frac{3}{2}n^{2}L^{2}D parameters and multiply-adds per token, growing quadratically in the total number of heads nL and rivaling the whole model at practical sizes (Section A.4).

이 절에서 궁금할 만한 질문

5. Method

원문 3절에서 보기

그림 Figure 4: LoomFormer architecture: the model (left), the LoomMHA and FFN sub-layers of a block (middle), and the MRead (MR) and MWrite (MW) modules (right). Vertical attention: reads from M are in red and writes to M in blue. 원문에서 보기

5.1. From Naive to Affordable Loom Attention

As linear attention compresses a growing key-value cache into a fixed-size state (Katharopoulos et al., 2020; Schlag et al., 2021), we compress the head outputs of each token along depth into a matrix memory M\in\mathbb{R}^{d_{k}\times d} of d_{k} slots of width d. Writer \mathsf{W}_{i} writes its output to M with a key k^{m}_{i}\in\mathbb{R}^{d_{k}}, and reader \mathsf{R}_{j} reads with a query q^{m}_{j}\in\mathbb{R}^{d_{k}}, so a reader attends over d_{k} slots instead of all earlier writers, at a cost independent of depth. Since M accumulates writes layer by layer, it is a second residual stream, the matrix stream, besides the original vector stream (Figure 4 left).

We call the interface through which a head reads from or writes to a stream a port. The two streams have dual ports:

\begin{split}&\textrm{vector stream: }u_{j}=xW^{s}_{j},\quad\Delta x=o_{i}W^{O}_{i}\\ &\textrm{matrix stream: }u_{j}=q^{m}_{j}M,\quad\Delta M=k^{m}_{i}\otimes o_{i}\end{split}

where k^{m}_{i}\otimes o_{i}=(k^{m}_{i})^{\top}o_{i} is the outer product. Data and ports swap shapes: a port shrinks from a D\times d matrix to a vector of length d_{k}, small enough to be generated per token from the vector stream, which we keep as the control path.

5.2. Architecture

LoomFormer keeps the backbone of the Transformer block and changes how sub-layers interface with the two streams: the vector stream carries control, i.e., where to attend and how to wire, and the matrix stream carries the content that is moved (Figure 4). We describe the architecture bottom up, from ports to sub-layers to the model (pseudocode in Appendix C), with x denoting a sub-layer’s pre-LN input.

MRead and MWrite.

MRead and MWrite realize the matrix-stream ports of Eq. (4). \operatorname{MRead}(M,x,x^{r}) generates a query q^{m}\in\mathbb{R}^{d_{k}} to read u\in\mathbb{R}^{d} from M, where x^{r}=\operatorname{GELU}(xW^{R}_{1})\in\mathbb{R}^{D_{r}} with W^{R}_{1}\in\mathbb{R}^{D\times D_{r}} (D_{r}\ll D) is a low-rank feature shared by all MRead modules of a sub-layer to keep port generation cheap:

\begin{split}&q^{m}=\operatorname{Norm}(x^{r}W^{R}_{2})\odot\sigma(xW^{R}_{g})+\bar{q}\odot\sigma(xW^{R}_{\bar{g}})\\ &u=q^{m}M\end{split}

Here x^{r} is projected by W^{R}_{2}\in\mathbb{R}^{D_{r}\times d_{k}}, normalized with RMSNorm and gated to get a dynamic query, which is summed with a static query \bar{q} (also gated) to obtain q^{m}\in\mathbb{R}^{d_{k}}. The two scalar gates are computed from x by projecting to scalars with W^{R}_{g},W^{R}_{\bar{g}}\in\mathbb{R}^{D\times 1} and then applying sigmoid. Similarly, with a shared x^{w}=\operatorname{GELU}(xW^{W}_{1})\in\mathbb{R}^{D_{r}}, \operatorname{MWrite}(o,x,x^{w}) generates a key k^{m}\in\mathbb{R}^{d_{k}} and writes a vector o\in\mathbb{R}^{d} into M as their outer product:

\begin{split}&k^{m}=\operatorname{Norm}(x^{w}W^{W}_{2})\odot\sigma(xW^{W}_{g})\\ &\Delta M=k^{m}\otimes o\end{split}

Normalization and gating separate a port’s direction from its magnitude: the normalized vector selects which slots to read or write, and the gate alone sets how much.

LoomMHA.

To access the previous token’s memory without horizontal attention, MShift first mixes M_{[t]} with M_{[t-1]} via a per-slot gate z_{[t]}=\sigma(x_{[t]}W^{S}_{g})\in\mathbb{R}^{d_{k}} (W^{S}_{g}\in\mathbb{R}^{D\times d_{k}}), and MNorm RMS-normalizes the matrix into \widetilde{M}_{[t]}. Each head then reads four vectors from \widetilde{M} with separate MRead modules: query, key, value and output bypass o^{m}:

\begin{split}&\widetilde{M}_{[t]}=\operatorname{MNorm}\big(z_{[t]}\odot M_{[t-1]}+(1-z_{[t]})\odot M_{[t]}\big)\\ &\tilde{q},\tilde{k},v,o^{m}=\operatorname{MRead}^{Q,K,V,O}(\widetilde{M},x,x^{r})\\ &q,k=\operatorname{RoPE}(xW^{Q,K})\,\|\,(\tilde{q},\tilde{k})\end{split}

where W^{Q},W^{K}\in\mathbb{R}^{D\times d/4} project x to d/4 dimensions, to which rotary position embedding (RoPE) (Su et al., 2024) is applied; the results are concatenated (\|) with \tilde{q} and \tilde{k} read from M. The value is read from M alone: the vector stream supplies only ports and RoPE queries/keys for slot and token routing, while all content moved by attention comes from M. Unlike MHA, LoomMHA has two outputs: the projected head outputs for the vector stream, and the writes of all heads i\in\{1,\dots,n\} summed into \Delta M:

\begin{split}&o_{i}=o^{m}_{i}+\operatorname{Attention}(q_{i},k_{i},v_{i})\\ &\Delta M=\textstyle\sum_{i=1}^{n}\operatorname{MWrite}_{i}(\operatorname{Norm}(o_{i}),x,x^{w})\\ &\operatorname{LoomMHA}(x,M)=\big(\operatorname{Concat}_{i=1}^{n}[o_{i}]W^{O},\,\Delta M\big)\end{split}

where q_{i},k_{i},v_{i},o^{m}_{i} are given by Eq. (7) for head i, and \operatorname{Attention} is scaled dot-product attention over tokens with a strictly causal mask that excludes the current token: a token’s own content reaches the head’s output through the bypass o^{m}_{i} instead. LoomMHA is where vertical and horizontal attention are interwoven: the vertical reads from M feed the horizontal attention of head i, and its output o_{i} is written back to M for later layers.

FFN with MWrite.

The feed-forward network (FFN) sub-layer reads only x and, like LoomMHA, returns a pair (\operatorname{FFN}_{x}(x),\Delta M), where \operatorname{FFN}_{x} is a standard FFN module. A second, smaller \operatorname{FFN}_{M} computes the values to write, which are split into n head-sized vectors (\operatorname{split}_{i}) and written to M with the sub-layer’s MWrite modules. This write is the only channel through which content of the vector stream enters M, since attention moves only content read from M.

\Delta M=\textstyle\sum_{i=1}^{n}\operatorname{MWrite}_{i}(\operatorname{split}_{i}(\operatorname{FFN}_{M}(x)),x,x^{w})

LoomFormer.

The embedding initializes both residual streams; M_{0} is written from the embedding x_{0} in the same way as the FFN writes:

\begin{split}&x_{0}=\operatorname{Embedding}(X)\\ &M_{0}=\textstyle\sum_{i=1}^{n}\operatorname{MWrite}_{i}(\operatorname{split}_{i}(x_{0}W^{E}),x_{0},x^{w}_{0})\end{split}

where W^{E}\in\mathbb{R}^{D\times D} is a value projection and x^{w}_{0}=\operatorname{GELU}(x_{0}W^{W}_{1}). Each block l then applies the two sub-layers with pre-LN, updating both streams residually (pairs are added element-wise):

\begin{split}&(x^{\prime}_{l},M^{\prime}_{l})=(x_{l},M_{l})+\operatorname{LoomMHA}(\operatorname{LN}_{1}(x_{l}),M_{l})\\ &(x_{l+1},M_{l+1})=(x^{\prime}_{l},M^{\prime}_{l})+\operatorname{FFN}(\operatorname{LN}_{2}(x^{\prime}_{l}))\end{split}

for l=0,\dots,L-1. Finally, x_{L} is normalized and projected to produce the final output. As M_{L} is not used, the last block does not write to M. We typically set d_{k}=2n slots (so M has size 2D) and D_{r}=nd_{k}/2=n^{2} (a 2\times compression bottleneck relative to nd_{k}), matching the Transformer’s parameter budget by adjusting FFN widths at an approximately 2{:}1 ratio between \operatorname{FFN}_{x} and the \operatorname{FFN}_{M} write branch.

5.3. Rewiring Capacity

On the matrix stream without MShift, reader \mathsf{R}_{j} receives u_{j}=q^{m}_{j}M=\sum_{i}\langle q^{m}_{j},k^{m}_{i}\rangle\,o_{i} by Eq. (4). The matrix stream thus keeps the division of roles of naive loom attention: its virtual weights are identities, and its wiring matrix is C=KQ^{\top}, of rank at most d_{k}, where the rows of K and Q are the keys k^{m}_{i} of the writers and the queries q^{m}_{j} of the readers.

.

(i) With ports fixed to (K,Q), LoomFormer is a standard Transformer \operatorname{Tfm}_{K,Q} with residual stream (x,\operatorname{vec}(M))\in\mathbb{R}^{D+d_{k}d}, whose virtual weights absorb KQ^{\top}, hence node-gated. (ii) With ports generated per token, LoomFormer is rewirable with one head per reader w.r.t. the wiring patterns with at most d_{k} writers, whatever the total number of writers w.

In (ii), only the writers in the pattern are on, each taking a slot through a one-hot key while each reader’s query selects the slots of its writers (Section A.6). The N(w,r-1) heads per reader that node gating needs (Theorem 2.4) are thus replaced by a per-token assignment of d_{k} slots; when more than d_{k} writers are on, slots are shared and writers interfere, as in linear attention. By (i), this rewiring capacity comes from generating ports per token, not from the matrix memory itself. Together, (i) and (ii) give a model-level view of LoomFormer’s expressiveness: within each token, LoomFormer wires heads as \operatorname{Tfm}_{K(x),Q(x)}, selecting per token one Transformer from the continuum \{\operatorname{Tfm}_{K,Q}\} much as a mixture of experts selects experts (Fedus et al., 2022), except that the experts are wirings, share all other weights, and cost only d_{k} numbers per port to select.

표 Table 1: LoomFormer among residual-stream mechanisms. Ports k^{m}, q^{m} are indexed by heads {\color{#e00000}\boldsymbol{i}}, {\color{#e00000}\boldsymbol{j}} or, when shared across a layer, by layers {\color{#0000e0}l_{i}}, {\color{#0000e0}l_{j}} (and Q/K/V input {\color{#7f00ff}s}), and marked (x) or (M) when computed from the vector stream or from the memory itself; \operatorname{softmax}_{{\color{#0000e0}l_{i}}} normalizes over writer layers. Typical sizes assume d_{k}=4 in HC and d_{k}=2n in LoomFormer ({+}D for its vector stream). 원문에서 보기

이 절에서 궁금할 만한 질문

6. Connections to Prior Work

원문 4절에서 보기

Table 1 compares LoomFormer with residual-stream mechanisms (derivations in Section A.7; extended related work in Appendix B). In DenseFormer (Pagliardini et al., 2024), HC (Zhu et al., 2025), mHC (Xie et al., 2025), AttnRes (Kimi Team, 2026a) and MUDDFormer (Xiao et al., 2025), the ports are shared by all heads of a layer: apart from node gating and the fixed projections, their wiring depends on a writer only through its layer and on a reader only through its layer (and Q/K/V input in MUDDFormer). Their wiring rank is therefore 1, or 3 in MUDDFormer, one per Q/K/V input, whereas LoomFormer generates its ports per head and per token and reaches \min(d_{k},3n), i.e., 2n by default, with a smaller state than HC (2D+D against 4D).

Linear attention.

Linear attention (Katharopoulos et al., 2020; Schlag et al., 2021) and its gated and delta-rule variants (Dao & Gu, 2024; Yang et al., 2024a; Yang et al., 2024b; Yang et al., 2025; Peng et al., 2024) also read and write a fixed-size matrix state per head with keys and queries from the vector stream, but differ in axis and sharing. Their state accumulates across tokens and its read is the head output, replacing horizontal attention, whereas M accumulates along depth and its reads feed the query, key and value of horizontal attention. Their state is also private to one head across tokens, so heads still compose through the static ports of the vector stream, whereas M is shared by all heads of all layers at a token, as a channel through which heads read each other. The two are thus orthogonal and can be combined.

이 절에서 궁금할 만한 질문

7. Experiments

원문 5절에서 보기

We train all models on the Pile dataset (Gao et al., 2020) in JAX, initializing dynamic port gates near zero so training starts smoothly from static ports (Section D.1). We evaluate scaling laws (Section 5.1), large-scale pretraining and downstream performance (Section 5.2), mechanisms of the trained models (Section 5.3), computational efficiency (Section 5.4) and ablations (Section 5.5).

7.1. Scaling Laws

Settings. We train three model scales—Medium (432\textrm{M}), Large (778\textrm{M}) and XL (1.4\textrm{B})—with sequence length T=4096, batch size 0.5\textrm{M} tokens (128 sequences), and token budgets proportional to non-embedding parameters following Hoffmann et al. (2022) (architectural dimensions and optimizer hyperparameters in Section D.1).

Baselines. We compare LoomFormer against recent residual-stream baselines on the same Transformer++ backbone (Touvron et al., 2023) (RoPE (Su et al., 2024), SwiGLU FFN (Shazeer, 2020), RMSNorm, no linear bias): DHC (dynamic HC with expansion rate 4; Zhu et al., 2025), mHC (Xie et al., 2025), AttnRes (full) (Kimi Team, 2026a), and MUDDFormer (Xiao et al., 2025) (details in Section D.2).

그림 Figure 5: Scaling curves on Pile validation loss against training compute (total parameters \times training tokens). 원문에서 보기

Results. Across the Medium, Large and XL scales (Figure 5), mHC, AttnRes and DHC improve over Transformer++, and MUDDFormer improves further, while LoomFormer achieves the lowest loss at every scale. Interpolating log-linearly along each baseline curve across Medium and Large, LoomFormer matches Transformer++ trained with 3.19–3.25× compute (3.10× net at Large after the 3.1% FLOP overhead in Table 3) and all four residual-stream baselines at 1.73–2.76×. At XL, where LoomFormer lies below the largest model of every baseline, it lowers validation loss from 2.101 to 1.979 (\Delta L=0.122, 1.8× MUDDFormer’s 0.068) at 2.8% extra FLOPs (Table 3).

표 Table 2: Zero/five-shot downstream evaluation results (\Deltaacc is over Pythia-2.8B; best in bold within each block). 원문에서 보기

그림 Figure 6: Mechanistic comparison of 2.8B models across layers l=1,\dots,32 on Pile validation sequences (definitions in Appendix H). (a) Energy effective rank of the token-centered dynamic Q/K/V wiring matrix (band: 10th–90th percentiles) and per single Q, K or V input, vs. the bounds of Table 1. (b) Cross-token cosine distance (1-\cos) of read ports (\tilde{q},\tilde{k},v,o^{m}) and write ports (k^{m}_{\mathrm{MHA}},k^{m}_{\mathrm{FFN}}) in \mathbb{R}^{d_{k}} (static/gated =0). (c) Percentage of heads that are on (non-sink; legend: 32-layer mean). (d) Within-head writer routing similarity across port pairs in layers 3–32. 원문에서 보기

7.2. Large-Scale Pretraining and Evaluation

Settings. To test whether LoomFormer’s gains persist under extended training, we compare against the Pythia suite (Biderman et al., 2023) on 300B Pile tokens (over 5× the Chinchilla budget of Section 5.1; Hoffmann et al., 2022). Specifically, we train LoomPythia-2.8B and mHC-Pythia-2.8B—the residual-stream baseline that also keeps a depth-independent state size (Table 1)---and compare them with Pythia 2.8B--12B. Except for using serial instead of parallel sub-layers, both LoomPythia and mHC-Pythia use the same architecture choices and training hyperparameters as Pythia (Biderman et al., 2023, Appendix E). We evaluate zero- and five-shot accuracy across 10 standard benchmarks.

Results. As shown in Table 2 and Figure 2, LoomPythia-2.8B improves average accuracy over Pythia-2.8B by +3.6 in 0-shot and +4.3 in 5-shot (+3.95 on their mean), achieving 1.6× the gain of mHC-Pythia-2.8B (+2.5 / +2.6, mean +2.55). Its 0-shot average (59.9) matches Pythia-12B (59.9), its 5-shot average (61.6) exceeds Pythia-12B (60.8), and its 0/5-shot mean (60.75) matches a log-linear extrapolation of Pythia at ~4.9× compute. On pretraining metrics, LoomPythia-2.8B reaches Pile ppl 6.02, on par with Pythia-12B (6.01) and well ahead of mHC-Pythia-2.8B (6.24).

As an out-of-domain evaluation, Table 2 also reports target-span perplexities on a randomly sampled subset of the FLAN Collection (Longpre et al., 2023), which features instruction following, chain-of-thought and in-context few-shot data. The advantage of LoomPythia on FLAN is even larger than on Pile: FLAN ppl 6.94 is best in the table, beating both Pythia-12B (7.26) and mHC-Pythia-2.8B (7.35). Whereas mHC’s gain barely changes from 0-shot to 5-shot (+2.5 vs. +2.6), LoomPythia’s widens from +3.6 to +4.3, indicating stronger in-context learning that Section 5.3 traces to per-token rewiring freeing deep heads from attention sinks.

7.3. Mechanistic Analysis

We analyze Pythia-2.8B, mHC-Pythia-2.8B and LoomPythia-2.8B (Section 5.2) on held-out Pile validation sequences; metric definitions and additional visualizations are in Appendix H.

Per-token circuit rewiring. After subtracting each pair’s token-mean static component, the dynamic wiring matrix on the 3n=96 Q/K/V readers of layer l has rank 0 under fixed ports (Proposition 3.1(i)), at most 1 in Transformer and mHC, at most 3 in MUDDFormer, and up to \min(d_{k},3n)=64 in LoomFormer (Table 1). In Figure 6(a), LoomPythia-2.8B’s dynamic effective rank rises with depth to 41.0 (26.4 mean), placing 71.0\% of dynamic wiring energy (90.7\% at layer 32) outside rank 1, and averages 14.3 (20.9 at layer 32) within a single Q, K or V input where MUDDFormer also has rank \leq 1. Figure 6(b) directly tests Proposition 3.1(i) vs. (ii) in \mathbb{R}^{d_{k}}: whereas static or scalar-gated ports have zero cross-token cosine distance, LoomPythia’s read ports \tilde{q},\tilde{k},v,o^{m} average 0.33–0.46 (up to 0.68) and its attention and \operatorname{FFN}_{M} write ports average 0.36 and 0.56 (up to 0.75; Appendix H traces an in-context circuit rewiring across adjacent tokens).

Head utilization and within-head specialization. In a node-gated model (Section 2, Theorem 2.4), heads whose fixed inputs are not needed at a token turn themselves off by attending to sink tokens (Vig & Belinkov, 2019; Xiao et al., 2024b). Counting non-sink heads as on (Xiao et al., 2025), Figure 6(c) shows that in layers 17–32, only 22.9\% of heads are on in Pythia-2.8B and 17.7\% in mHC-Pythia-2.8B—whose four streams still merge into one shared input per layer—whereas LoomPythia-2.8B keeps 74.4\% on (3.3\times and 4.2\times), more than doubling content-token attention mass and accounting for its 5-shot and FLAN gains (Section 5.2). Finally, Figure 6(d) verifies \text{head}\times\text{QKV} specialization (Table 1): although routing looks correlated at the layer level (0.92–0.96), per-writer correlation within the same head drops to 0.71–0.84 and top-32 writer overlap is 0.38–0.49, so over half of the top writers read by a head’s \tilde{q},\tilde{k},v,o^{m} are distinct.

표 Table 3: Analytical computational overhead (+\textrm{FLOPs}) and measured relative throughput of LoomFormer vs. matched-size Transformer at sequence length T (absolute speeds in Appendix F). 원문에서 보기

7.4. Computational Complexity and Efficiency

Analytical computational overhead. Under a matched parameter budget, LoomFormer adds ~\frac{1}{d(1+\rho/12)}+\frac{1}{8(1+12/\rho)} relative forward FLOPs from reading/writing M and wider Q/K (d_{k}=2n, \rho=T/D; derived in Appendix E), totaling 1.95\%–3.70\% across our four scales (Table 3).

Wall-clock training and inference throughput. Table 3 reports relative throughput for JAX training on TPU v5p pods (with fused Pallas kernels) and BF16 PyTorch inference on an NVIDIA A800 GPU (with a fused Triton kernel and torch.compile; Appendix F). LoomFormer sustains 89\%–92\% of Transformer training speed and 84\%–92\% of inference speed across prefill and decode batch sizes; the gap beyond the 2.0\%–3.7\% FLOPs reflects HBM I/O on M, lower arithmetic intensity of per-token M contractions, and smaller split projections and norms, and is far outweighed by the over 3× compute savings (Sections 5.1 and 5.2).

7.5. Ablation Studies

We ablate LoomFormer at the Medium scale (432M, 7B tokens; Section 5.1), reallocating saved parameters to \operatorname{FFN}_{x} to match the parameter budget, and report Pile validation loss and the retained gain \textrm{Gain}=(L_{\textrm{Tfm++}}-L)/(L_{\textrm{Tfm++}}-L_{\textrm{Loom}}) (Table 4; full suite in Appendix G).

표 Table 4: Ablations of LoomFormer at the Medium scale. 원문에서 보기

Dynamic rewiring. Replacing dynamic k^{m}, dynamic q^{m}, or both with learned static vectors (dropping their gates) tests Proposition 3.1. Fixing both reduces LoomFormer to \operatorname{Tfm}_{K,Q} and cuts the gain to 56.0%—still ahead of layer-wise dynamic baselines (Figure 5)—so the static head-level dual-stream backbone and per-token rewiring contribute roughly equal halves. Fixing q^{m} hurts far more than fixing k^{m} (75.4% vs. 90.3% retained): writers can use stable slots if readers select among them per token.

Port normalization and gating. Removing either the dynamic-branch gates or port RMSNorm hurts, yet removing both beats removing RMSNorm alone (90.3% vs. 87.1%): an unnormalized projection already varies in norm, making a separate gate redundant. Pairing RMSNorm with gating works best by separating slot direction from read/write magnitude.

그림 Figure 7: Validation loss vs. per-token memory size and matrix slots d_{k} at the Medium scale (L=18). 원문에서 보기

Sub-layer components. Removing \operatorname{FFN}_{M} (Eq. 9) hurts most, as the sole post-embedding path from the vector stream into M, followed closely by removing the bypass o^{m} and restoring self-attention to the current token (Eq. 8). Applying RoPE to d/4 of the M-read coordinates instead of xW^{Q,K} (Eq. 7) also hurts, supporting separate streams for positions and content, whereas removing \operatorname{MShift} still retains 94.2% of the gain.

Memory capacity. As we vary the slot count d_{k} (Figure 7), validation loss drops sharply (-0.026) from d_{k}=16 to 32 with diminishing returns beyond, placing our default d_{k}=2n at the knee given the linear growth of MRead/MWrite FLOPs (Appendix E) and I/O with d_{k}. Even at d_{k}=16 (2D total state), LoomFormer already outperforms DHC (4D) and MUDDFormer (lD, averaging 9D across L=18 layers), showing that head-level rewiring uses state memory far more effectively than layer-wise mechanisms.

이 절에서 궁금할 만한 질문

8. Conclusion

원문 6절에서 보기

Viewing Transformer circuits through their dynamic wiring matrix shows that standard Transformers and layer-wise residual-stream mechanisms are restricted to low-rank gating, requiring many heads per reader to avoid circuit interference. Loom attention lifts this bottleneck by interweaving vertical linear attention over a per-token matrix memory with horizontal attention over tokens, making circuits rewirable per token at one head per reader and 2.0\%–3.7\% extra forward FLOPs. Across model scales and 300B-token pretraining, LoomFormer matches Transformers trained with over 3× compute and recent residual-stream baselines with ~1.7–2.8×, while keeping over three quarters of its attention heads on and rewiring its ports from token to token. Because the matrix memory operates along depth at each token, combining loom attention with linear or sparse attention along the sequence is a natural direction for future foundation models.

이 절에서 궁금할 만한 질문