WorksComputer Science
Rewirable Circuits in Transformers with Loom Attention
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 3x compute and recent residual-stream baselines (HC/mHC, MUDDFormer, AttnRes) trained with ~1.7-2.8x. For example, trained on the same 300B tokens with only 2% extra FLOPs, LoomPythia-2.8B achieves ~1.6x the average downstream gain of mHC-Pythia-2.8B over Pythia-2.8B, and matches (0-shot) or surpasses (5-shot) Pythia-12B. Code is available at https://github.com/Caiyun-AI/LoomFormer
Introduction
Transformers solve tasks by composing attention heads across layers into circuits [11, 36, 50, 34]: 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) [36].
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 [11]. 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 [56]. 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 [37]; MUDDFormer [55] and Attention Residuals (AttnRes) [27] 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., [63]) and its manifold-constrained variant mHC (Xie et al., [57]) 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 1).
Figure 1. Conceptual sketch of loom attention. At each token, each head chooses which slots of that token’s matrix memory 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.
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. 1 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.
Figure 2. Downstream accuracy averaged over 10 tasks.
Rewirable Circuits
Writers, readers and circuits. Attention heads communicate through the residual stream (Elhage et al., [11]). Consider a Transformer with layers of heads of dim , and model dim . 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 adds its output to the residual stream through its block of the output projection, and reader of a later head reads the stream through its input projection (), so reaches through the virtual weight : the two communicate only if writes into a subspace that 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 receives
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.
where the per-token scalars form the wiring matrix from the earlier writers to the readers of one layer, and is the effective wiring from to . The two are connected at the token if their effective wiring is nonzero. 2 A wiring pattern is a set of writer-reader pairs, realized when each reader in is connected to exactly its writers in .
Definition 2.1. 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 that it admits at a token.
Transformers are node-gated. In a Transformer, pre-LN only rescales all writers of a token by a common factor (Theorem 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., [56]) outputs nearly nothing, turning off both its writer and, since what its readers receive has no effect, its readers.
Definition 2.2. An architecture is node-gated if, at every token, its wiring matrix has the form
with gate vectors and whose nonzero entries mark the writers and readers that are on.
We call the rank of 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.
Proposition 2.3. A Transformer with pre-LN is node-gated: at any token, it connects precisely the pairs with 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 , 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 (last column) also connects and : 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 (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 readers may be played by several heads, gated on and off per token, and at every token each reader must receive exactly one of writers, chosen independently of the other readers; the last pattern in Figure 3 is the smallest instance. Let denote the minimum size of a ground set carrying a -cover-free family of sets, i.e., sets none of which is covered by the union of others [26].
Theorem 2.4. To realize all such wiring patterns, a node-gated architecture needs at least heads per reader, and this number suffices, where , for and for .
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 writers chosen by the other readers (Theorem A.2 in Section A.2; bounds in Section A.3). With the readers of a layer choosing among its earlier writers, whenever , so at practical sizes node gating needs heads per reader.
Naive loom attention makes Transformers rewritable.
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:
where for a reader in layer , which has earlier writers. We call this naive loom attention: its virtual weights are identities and all the wiring is left to , unlike a Transformer, which wires heads through fixed virtual weights and only gates them through a rank-one . With one head per reader, it is rewritable w.r.t. all wiring patterns (cf. Figure 3, bottom row), but expensive: over the readers of all layers, generating the attention weights takes about parameters and multiply-adds per token, growing quadratically in the total number of heads and rivaling the whole model at practical sizes (Section A.4).
Method
From Naive to Affordable Loom Attention
As linear attention compresses a growing key–value cache into a fixed-size state (Katharopoulos et al., [25]; Schlag et al., [42]), we compress the head outputs of each token along depth into a matrix memory of slots of width . Writer writes its output to with a key , and reader reads with a query , so a reader attends over slots instead of all earlier writers, at a cost independent of depth. Since accumulates writes layer by layer, it is a second residual stream, the matrix stream, besides the original vector stream (Figure 4 left).
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 are in red and writes to in blue.
We call the interface through which a head reads from or writes to a stream a port. The two streams have dual ports:
where is the outer product. Data and ports swap shapes: a port shrinks from a matrix to a vector of length , small enough to be generated per token from the vector stream, which we keep as the control path.
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 Section C), with denoting a sub-layer’s pre-LN input.
MRead and MWrite. MRead and MWrite realize the matrix-stream ports of Eq. (4). MRead generates a query to read from , where with () is a low-rank feature shared by all MRead modules of a sub-layer to keep port generation cheap:
Here is projected by , normalized with RMSNorm and gated to get a dynamic query, which is summed with a static query (also gated) to obtain . The two scalar gates are computed from by projecting to scalars with and then applying sigmoid. Similarly, with a shared , MWrite generates a key and writes a vector into as their outer product:
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 with via a per-slot gate (), and MNorm RMS-normalizes the matrix into . Each head then reads four vectors from with separate MRead modules: query, key, value and output bypass :
where project to dimensions, to which rotary position embedding (RoPE) ((Su et al., 2024) is applied; the results are concatenated () with and read from . The value is read from alone: the vector stream supplies only ports and RoPE queries/keys for slot and token routing, while all content moved by attention comes from . Unlike MHA, LoomMHA has two outputs: the projected head outputs for the vector stream, and the writes of all heads summed into :
where , , , are given by Eq. (7) for head , and 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 instead. LoomMHA is where vertical and horizontal attention are interwoven: the vertical reads from feed the horizontal attention of head , and its output is written back to for later layers.
FFN with MWrite. The feed-forward network (FFN) sub-layer reads only and, like LoomMHA, returns a pair , where is a standard FFN module. A second, smaller computes the values to write, which are split into head-sized vectors and written to with the sub-layer’s MWrite modules. This write is the only channel through which content of the vector stream enters , since attention moves only content read from .
LoomFormer. The embedding initializes both residual streams; is written from the embedding in the same way as the FFN writes:
where is a value projection and . Each block then applies the two sub-layers with pre-LN, updating both streams residually (pairs are added element-wise):
for . Finally, is normalized and projected to produce the final output. As is not used, the last block does not write to . We typically set slots (so has size ) and (a compression bottleneck relative to ), matching the Transformer’s parameter budget by adjusting FFN widths at an approximately 2:1 ratio between and the write branch.
Rewiring Capacity
On the matrix stream without MShift, reader receives 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 , of rank at most , where the rows of and are the keys of the writers and the queries of the readers.
Proposition 3.1. (i) With ports fixed to , LoomFormer is a standard Transformer with residual stream , whose virtual weights absorb , hence node-gated. (ii) With ports generated per token, LoomFormer is rewritable with one head per reader w.r.t. the wiring patterns with at most writers, whatever the total number of writers .
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 heads per reader that node gating needs (Theorem 2.4) are thus replaced by a per-token assignment of slots; when more than 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 , selecting per token one Transformer from the continuum much as a mixture of experts selects experts ([16]), except that the experts are wirings, share all other weights, and cost only numbers per port to select.
Connections to Prior Work
Table 1 compares LoomFormer with residual-stream mechanisms (derivations in Section A.7; extended related work in Section B). In DenseFormer (Pagliardini et al., [37]), HC (Zhu et al., [63]), mHC (Xie et al., [57]), AttnRes (Kimi Team, [27]) and MUDDFormer (Xiao et al., [55]), 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 , i.e., by default, with a smaller state than HC ( against ).
| Effective wiring | Wiring rank | Granularity | Memory: slots × width = typical size | Residual stream |
| Transformer | 1 | – | vector | |
| DenseFormer | 1 | layer | vector | |
| HC / mHC | 1 | layer | matrix | |
| AttnRes (full) | 1 | layer | none | |
| MUDDFormer | 3 | layer × QKV | vector | |
| LoomFormer | head × QKV | matrix + vector |
Table 1. LoomFormer among residual-stream mechanisms. Ports , are indexed by heads , , or, when shared across a layer, by layers , (and Q/K/V input ), and marked or when computed from the vector stream or from the memory itself; normalizes over writer layers. Typical sizes assume in HC and in LoomFormer (+ for its vector stream).
Linear attention. Linear attention ([25, 42]) and its gated and delta-rule variants ([58, 60, 39] (Dao & Gu 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 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 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.
Experiments
We train all models on the Pile dataset (Gao et al., [18]) in JAX, initializing dynamic port gates near zero so training starts smoothly from static ports (Section D.1). We evaluate scaling laws (§ 5.1), large-scale pretraining and downstream performance (§ 5.2), mechanisms of the trained models (§ 5.3), computational efficiency (§ 6) and ablations (§ 7).
Scaling Laws
Settings. We train three model scales—Medium (432M), Large (778M) and XL (1.4B)—with sequence length , batch size 0.5M tokens (128 sequences), and token budgets proportional to non-embedding parameters following Hoffmann et al. [23] (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., [48]) (RoPE (Su et al., 2024), SwiGLU FFN (Shazeer, [43]), RMSNorm, no linear bias): DHC (dynamic HC with expansion rate 4; Zhu et al., [63]), mHC (Xie et al., [57]), AttnRes (full) (Kimi Team, [27]), and MUDDFormer (Xiao et al., [55]) (details in Section D.2).
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 (, 1.8× MUDDFormer’s 0.068) at 2.8% extra FLOPs (Table 3).
Figure 5. Scaling curves on Pile validation loss against training compute (total parameters × training tokens).
| Model | +FLOPs (%) | Train (%) v5p | Prefill (%) bs 1 / 8 | Decode (%) bs 1 / 16 / 64 |
| Medium | 3.70 | 90.5 | 87.4 / 90.4 | 91.7 / 89.2 / 92.3 |
| Large | 3.13 | 89.2 | 85.3 / 86.2 | 85.4 / 87.8 / 84.9 |
| XL | 2.77 | 92.3 | 83.8 / 85.3 | 86.9 / 84.6 / 86.6 |
| 2.8B | 1.95 | 92.4 | 87.5 / 90.5 | 86.4 / 87.6 / 88.9 |
Table 3. Analytical computational overhead (+FLOPs) and measured relative throughput of LoomFormer vs. matched-size Transformer at sequence length (absolute speeds in Section F).
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., [2]) on 30B Pile tokens (over 5× the Chinchilla budget of § 5.1; Hoffmann et al., [23]). 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–2. Except for using serial instead of parallel sub-layers,3 both LoomPythia and mHC-Pythia use the same architecture choices and training hyperparameters as
Pythia ([2 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).
| Model | Pile ppl↓ | FLAN ppl↓ | LAM BADA | PIQA | Wino Grande | ARC-E | ARC-C | SciQ | BoolQ | Hella Swag | RACE-M | RACE-H | Avg acc↑/∆acc | |
| Pythia-2.8B | 6.63 | 8.16 | 64.7 | 73.9 | 59.4 | 64.4 | 29.5 | 88.2 | 64.5 | 45.4 | 38.1 | 34.9 | 56.3 | |
| Pythia-6.9B | 6.29 | 7.85 | 67.3 | 75.2 | 60.9 | 67.3 | 31.3 | 89.7 | 63.7 | 48.0 | 40.6 | 37.0 | 58.1 | |
| mHC-Pythia-2.8B | 6.24 | 7.35 | 0-shot | 68.5 | 74.4 | 62.8 | 67.1 | 30.7 | 90.5 | 66.9 | 47.5 | 42.3 | 37.0 | 58.8/+2.5 |
| Pythia-12B | 6.01 | 7.26 | 70.5 | 76.0 | 63.9 | 70.2 | 31.8 | 90.2 | 67.4 | 50.3 | 40.6 | 38.3 | 59.9 | |
| LoomPythia-2.8B | 6.02 | 6.94 | 71.8 | 74.7 | 63.7 | 68.5 | 31.7 | 92.4 | 65.8 | 49.1 | 42.3 | 39.0 | 59.9/+3.6 | |
| Pythia-2.8B | - | - | 60.5 | 73.6 | 60.6 | 67.3 | 32.3 | 94.3 | 65.6 | 45.1 | 38.4 | 35.6 | 57.3 | |
| Pythia-6.9B | - | - | 63.8 | 75.5 | 63.7 | 70.2 | 35.6 | 95.1 | 65.7 | 48.1 | 39.0 | 36.5 | 59.3 | |
| mHC-Pythia-2.8B | - | - | 5-shot | 62.4 | 74.9 | 64.1 | 70.8 | 35.5 | 95.6 | 69.4 | 47.6 | 40.3 | 38.2 | 59.9/+2.6 |
| Pythia-12B | - | - | 67.3 | 76.0 | 64.2 | 71.0 | 36.5 | 95.3 | 68.0 | 50.3 | 40.1 | 38.8 | 60.8 | |
| LoomPythia-2.8B | - | - | 69.0 | 75.7 | 65.7 | 70.8 | 35.1 | 96.0 | 71.2 | 49.5 | 43.1 | 40.1 | 61.6/+4.3 |
Table 2. Zero/five-shot downstream evaluation results (acc is over Pythia-2.8B; best in bold within each block).
As an out-of-domain evaluation, Table 2 also reports target-span perplexities on a randomly sampled subset of the FLAN Collection ([32]), 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 § 5.3 traces to per-token rewiring freeing deep heads from attention sinks.
Mechanistic Analysis
We analyze Pythia-2.8B, mHC-Pythia-2.8B and LoomPythia-2.8B (§ 5.2) on held-out Pile validation sequences; metric definitions and additional visualizations are in Section H.
Per-token circuit rewiring. After subtracting each pair’s token-mean static component, the dynamic wiring matrix on the Q/K/V readers of layer has rank 0 under fixed ports (Theorem 3.1(i)), at most 1 in Transformer and mHC, at most 3 in MUDDFormer, and up to 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 . Figure 6(b) directly tests Theorem 3.1(i) vs. (ii) in : whereas static or scalar-gated ports have zero cross-token cosine distance, LoomPythia’s read ports average 0.33–0.46 (up to 0.68) and its attention and write ports average 0.36 and 0.56 (up to 0.75); Section H traces an in-context circuit rewiring across adjacent tokens).
Figure 6. Mechanistic comparison of 2.8B models across layers on Pile validation sequences (definitions in Section 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 () of read ports () and write ports () in (static/gated ). (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.
Head utilization and within-head specialization. In a node-gated model (§ 2, Theorem 2.4), heads whose
fixed inputs are not needed at a token turn themselves off by attending to sink tokens ([49, 56]). 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× and 4.2×), more than doubling content-token attention mass and accounting for its 5-shot and FLAN gains (§ 5.2). Finally, Figure 6(d) verifies head × 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 , , , are distinct.
Computational Complexity and Efficiency
Analytical computational overhead. Under a matched parameter budget, LoomFormer adds relative forward FLOPs from reading/writing and wider Q/K (, ; derived in Section 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; Section 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 , lower arithmetic intensity of per-token contractions, and smaller split projections and norms, and is far outweighed by the over 3× compute savings (§ 5.1 and § 5.2).
Ablation Studies
We ablate LoomFormer at the Medium scale (432M, 7B tokens; § 5.1), reallocating saved parameters to FFN to match the parameter budget, and report Pile validation loss and the retained gain Gain (Table 4; full suite in Section G).
| Variant | Loss↓ | ΔLoss | Gain |
| LoomFormer (full) | 2.266 | — | 100.0% |
| Transformer++ (baseline) | 2.443 | +0.177 | 0.0% |
| Dynamic rewiring (Theorem 3.1) | |||
| — Static write keys () | 2.283 | +0.017 | 90.3% |
| — Static read queries () | 2.310 | +0.043 | 75.4% |
| — Static read & write (, ) | 2.344 | +0.078 | 56.0% |
| Port normalization & gating (Eqs. (5)–(6)) | |||
| — dynamic port gates | 2.277 | +0.011 | 93.7% |
| — dynamic port Norm | 2.289 | +0.023 | 87.1% |
| — dynamic port gates & Norm | 2.283 | +0.017 | 90.3% |
| Sub-layer components (§ 3.2) | |||
| — FFN write | 2.300 | +0.034 | 80.7% |
| — output bypass | 2.299 | +0.032 | 81.8% |
| — vector-stream RoPE | 2.286 | +0.020 | 88.7% |
| — MShift | 2.277 | +0.010 | 94.2% |
Table 4. Ablations of LoomFormer at the Medium scale.
Dynamic rewiring. Replacing dynamic , dynamic , or both with learned static vectors (dropping their gates)
tests Theorem 3.1. Fixing both reduces LoomFormer to Tfm 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 hurts far more than fixing (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.
Sub-layer components. Removing FFN (Eq. (9)) hurts most, as the sole post-embedding path from the vector stream into , followed closely by removing the bypass and restoring self-attention to the current token (Eq. (8)). Applying RoPE to of the -read coordinates instead of (Eq. (7)) also hurts, supporting separate streams
for positions and content, whereas removing MShift still retains 94.2% of the gain.
Memory capacity. As we vary the slot count (Figure 7), validation loss drops sharply () from to 32 with diminishing returns beyond, placing our default at the knee given the linear growth of MRead/MWrite FLOPs (Section E) and I/O with . Even at ( total state), LoomFormer already outperforms DHC () and MUDDFormer (, averaging across layers), showing that head-level rewiring uses state memory far more effectively than layer-wise mechanisms.
Figure 7. Validation loss vs. per-token memory size and matrix slots at the Medium scale ().
Conclusion
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.
Theory of Rewirable Circuits
Normalization and proof of Proposition 2.3
Lemma A.1. In a Transformer with pre-LN (LayerNorm or RMSNorm), the contribution of earlier writers to reader ’s input is , where the scale is shared by all writers and the virtual weights are fixed.
Proof. Write , where sums the embedding and earlier FFN outputs. LayerNorm computes with (putting on the degenerate set ). Since centering is the fixed linear map ,
with fixed virtual weights absorbing the linear maps of the normalization (any projection bias adds to ). For RMSNorm, centering is omitted, and .
Proof of Proposition 2.3. By Theorem A.1, pre-LN rescales all writers of a token by the same . Within a token, what depends on the input is only this scale and which heads are on: let if the head of is on and 0 otherwise, and if the head of is on and 0 otherwise. Then , which is Eq. (2), and since , and are connected () if and only if both are on and .
Full statement and proof of Theorem 2.4
Setting. The role of reader (, ) is played by a set of heads, so a reader is here a role rather than one input of one head; by Eq. (2), head receives when its effective wiring is nonzero. A wiring task assigns to each reader a writer , and the tasks are all maps . Reader receives exactly if some receives and no receives any with . We require every head in that is on to be free of other writers because query and key inputs feed a softmax, so interference at one head cannot be cancelled downstream. Every writer in must therefore be on (), and turning others on can only add interference, so we may assume the writers that are on are . For a fixed reader , let . A family is -cover-free if for every and every with .
Theorem A.2 (full version of Theorem 2.4). For , a node-gated architecture with writers realizes all wiring tasks if and only if, for every reader, is an -cover-free family. Hence each reader needs at least heads, and this number suffices.
Proof. If. Given , turn on only the writers . For reader , let , so . Since is -cover-free, there is a head ; turn on and no other head of . Then receives and none of the other writers that are on.
Only if. Fix a reader , a writer and a set with . Choose with that maps the other readers onto , which is possible since , and different readers may share a writer (if , map them to ). Realizing requires a head that has and for all , i.e., . Hence , and the family is -cover-free.
Counting. The sets are subsets of , so . Conversely, given an -cover-free family of sets on a ground set of size for each reader, create one head per point and set if and 0 otherwise; this is realized in dimensions by assigning orthogonal -dimensional subspaces either to the writers or to the heads.
Remarks. (i) Attention sinks gate heads off only approximately; under the threshold of § 2, the counting argument is unchanged. (ii) Sufficiency at heads per reader holds in a Transformer when each of the readers belongs to a separate head (with its other two inputs fixed); when counts all Q, K and V inputs of heads, coupling Q, K and V inside the same physical head (and sink gate ) can only require more heads, while the lower bound still applies. Likewise, if several heads of a value reader share identical attention weights, their outputs add linearly and interference could in principle cancel, whereas our clean-head requirement is necessary for query and key inputs. (iii) The model excludes routing through FFNs, discussed in Section A.5.
Bounds on and remarks on Theorem 2.4
Bounds. A 1-cover-free family is an antichain, so by Sperner’s theorem [44] is the smallest with , about . For , [10, 40, 17] and [14]; for , Bassalygo’s bound [10] together with the singleton construction gives , reaching (one head per writer) once .
Group testing. Theorem A.2 is an instance of non-adaptive group testing: the heads of a reader are tests that must isolate the selected writer from up to other writers that are on.
Dense and sparse layouts. With a single head per reader (), the two layouts of Figure 3 are degenerate codes: (dense), which is not 1-cover-free and makes circuits interfere, and for some writer (sparse), which leaves unreachable.
Superposition. At layer scale (, ), separating writers as above takes dimensions ( with orthogonal writer subspaces). With writers sharing dimensions, writers across layers must overlap in superposition [12], so virtual weights are rarely exactly zero and in practice part of the price is paid as interference.
Cost of naive loom attention
Indexing layers by as in § 3.2, every reader of layer attends over earlier head writers. Over the readers of all layers, the projections of Eq. (3) take parameters, and as many multiply-adds per token. This grows quadratically in the total number of heads and rivals the of the whole model once (i.e., ), e.g., 70% of it for our XL configuration (, , ). Factorizing the weights into keys and queries removes , but still leaves attention weights per token to compute and store for backpropagation, plus multiply-adds to aggregate the ’s.
Routing through FFNs
An intermediate FFN between the writers and the reader layer can route any pattern by copying into a -dimensional subspace private to whenever . Concretely, suppose the residual stream carries binary indicators of ( iff ) and the writer outputs satisfy (ignoring pre-LN rescaling). Since ReLU equals when and when for every , a two-layer ReLU FFN can compute the gated copy coordinate-wise for each pair and sum over into ’s private subspace. However, this construction uses hidden units—hence parameters, or when routing writers to readers ( times the parameters of all preceding blocks)—requires an intervening FFN step, and needs disjoint subspaces for the writers, readers and control coordinates (). We give this construction only as an upper bound and do not prove a lower bound on FFN routing.
Proof of Proposition 3.1
Part (i). Flatten row by row into , so that entry of is entry of . For a static read port , . For a static write port , . Hence every read and write of is a fixed linear map between and the head, i.e., a Transformer projection with Kronecker structure, for reads and for writes, and the composition weight between and is the constant . The coupling is therefore fixed and belongs to the virtual weights, ; only gating heads through attention sinks (together with normalization scales) depends on the input, as in Eq. (2), so is node-gated. In the full architecture § 3.2, MNorm is
彩大发快三 RMSNorm over and rescales all matrix-stream writers by one shared factor (Theorem A.1), while the bypass and become a fixed linear skip and a standard FFN on . The per-head on LoomMHA writes (Eq. (8)) applies a fixed diagonal gain (absorbed into the write projection) and rescales writer by , and even if the scalar port gates , (Eqs. (5)–(6)) are retained on static port directions, they multiply whole rows or columns of , leaving of rank at most one (cf. Section G). With ports generated per token, the computation at each token and layer coincides with that of . The coincidence holds within a token; across tokens, attention mixes values computed by different members, so the model as a whole is not any single .
Part (ii). Let be the writers in a wiring pattern , with . Turn on only , pick an injection , give each the write key ( for ), and give reader the read query . Then if and otherwise for all , so if and only if ; since the virtual weights of the matrix stream are identities, the connected pairs are , with one head per reader and independent of . The RMSNorm of the actual ports rescales each key and each query by a constant, and the sigmoid gates set their magnitudes (turning off writers outside ), so the pattern is realized up to per-reader scales. In the full model, computing and from the vector stream is the role of the port generators on the control path.
Wiring matrices of residual-stream mechanisms
This section derives the entries of Table 1. As in § 2, we consider the wiring within a token from the earlier head writers () to the query, key and value readers () of one later layer. Other reads of the history—the FFN inputs of HC/mHC and AttnRes, the residual input of MUDDFormer and the bypass of LoomFormer—feed no head input and are not readers. We mark a port by if it is computed from the vector (residual) stream and by if it is computed from the memory itself. Per-token scales such as pre-LN are absorbed into the wiring matrix as in Theorem A.1, and the node-gating factors of Theorem 2.2 are common to all mechanisms, so we omit them from the tables. For LoomFormer we consider the matrix stream only and ignore MShift, which mixes neighbouring tokens (the -dimensional RoPE slice from belongs to the node-gated vector stream of Theorem 2.3). Ports are row vectors, as in § 3.1.
A common form. Each mechanism keeps at a token a memory of slots of width . Writer adds to , reader receives , and between layers may be updated linearly, ; here and are the write and read ports, and in the matrix stream of LoomFormer. Composing these steps gives
where is the product of the updates between the layer of and the layer of : the wiring matrix has entries and the virtual weights are . This representation is not unique: a change of slot basis by an invertible maps , and without changing . For mechanisms that keep the outputs of all earlier layers, we use the basis in which every stored output has its own slot, the write port is and ; residual copies then become part of the read port. Transitions can also be absorbed into the ports without adding slots: for a fixed reader layer , setting writes even when is singular (and when every is invertible, setting makes this split independent of via and ). Table 5 lists the parameterization of each mechanism, justified below; Table 1 omits factors equal to or .
| Write port | Read port | Update | |
| Transformer | |||
| DenseFormer | static | ||
| HC / mHC | |||
| AttnRes (full) | static, softmax | ||
| MUDDFormer | per Q/K/V, from | ||
| LoomFormer | per head, from | per head and Q/K/V, from |
Table 5. Ports of residual-stream mechanisms in the common form of Eq. (12).
Transformer. One slot of width with gives and the virtual weights , with the node gates, this is Eq. (2).
DenseFormer. The input of each block is a static weighted sum of the embedding and the outputs of all earlier blocks, and the block adds its own attention and FFN outputs to this input through its internal residual [37]. Unfolding these residual copies, the input of block is a static combination of the outputs of all earlier blocks, so with a static read port, so only node gating makes the wiring matrix input-dependent. DenseFormer keeps one slot per block, about slots at layer (size ).
HC and mHC. HC keeps parallel streams of width (we use , the main configuration of Zhu et al. [63]). Each sub-layer reads and updates the streams as , with , and all computed from in the dynamic version [63], and projected onto the Birkhoff polytope of doubly stochastic matrices in mHC [57]. Heads read and write through the attention sub-layer, with ports and , while the FFN and subsequent attention stream-mixing matrices between attention sub-layers and compose into . In the common form, —the unrolled weight of Eq. (27) of Zhu et al. [63], which Kimi Team [27] interpret as depth-wise linear attention with queries and keys . Since all factors are computed from the streams , absorbing into the write port as above (without requiring be invertible) gives the entry of Table 1, with -dimensional ports and state size .
AttnRes. Full AttnRes keeps the embedding and the outputs of all earlier sub-layers, without a residual connection, and gives sub-layer the input with a learned query [27]. In the slot basis of Eq. (12), writers of layer write to their attention sub-layer’s slot (, while FFN and embedding slots hold no head writer) and heads of layer read linearly with the softmax weight vector over all stored slots; Table 1 and Table 5 instead display the underlying softmax query (static) and key (from ), normalized by softmax across all stored sub-layer slots. Full AttnRes keeps one slot per sub-layer, about slots at layer (size ); its block variant sums the outputs within each block into one slot.
MUDDFormer. MUDDFormer keeps the embedding and the outputs of all earlier blocks, and gives the next block four inputs—for its queries, keys, values and residual—each a weighted sum of these outputs with weights generated from the latest hidden state [55]. The residual input carries dynamic combinations of earlier outputs into the next block output; unfolding these recursions expresses the effective read port of input as a function of the hidden states along the vector stream , giving . Like DenseFormer, MUDDFormer keeps about slots at layer (size ).
LoomFormer. The matrix stream keeps slots of width that accumulate writes () and passes content without fixed projections: absorbing the per-token RMS scales of and MNorm into and (and the learned diagonal gain of into the writer output ) leaves . Indexing a reader by its head and input as in Table 1 gives , with both ports generated per head and per token from the vector stream Theorem 3.1(ii). With , has size , plus for the vector stream.
Wiring ranks. Node gating multiplies entrywise by —equivalently —which cannot increase its rank. All readers of a layer share one read port in DenseFormer, HC/mHC and AttnRes, so has a single distinct column and rank at most 1; MUDDFormer has one read port per Q/K/V input, hence at most three distinct columns and rank at most 3 (reached once at least three earlier layers are present with linearly independent Q/K/V read ports). In LoomFormer every reader has its own query, so the rank is that of restricted to the readers of the layer, at most —hence once , reached whenever the writer keys and reader queries span a common -dimensional subspace.
Linear attention. The same form describes linear attention along the sequence instead of depth: the writers and readers are one head at different tokens, is the head’s private state, the ports are its keys and queries, and the update distinguishes the variants— for linear attention [25], a scalar decay in Mamba2 (Dao & Gu, 2024), a gated diagonal in gated linear attention [58], in DeltaNet [59], and in Gated DeltaNet [60]. It differs from LoomFormer in the axis and the sharing of the state (§ 4).
Extended Related Work
Cross-layer connections and residual-stream architectures. Beyond standard residual connections ((He et al., 2016)), early work strengthened depth-wise signal propagation through input-dependent gating in Highway Networks ([45]) and all-to-all layer aggregation with static or learnable weights in DenseNet ([24]), DLCL ([52]) and DenseFormer ([37]). Subsequent architectures introduced cross-layer attention over earlier layer representations ([13, 15, 51, 27]), multi-stream residual states with dynamic or manifold-constrained mixing in HC and mHC ([63, 57]), and decoupled Q/K/V/residual layer aggregation in MUDDFormer ([55]). As analyzed in § 4 and Section A.7, all of these mechanisms operate at the granularity of whole layers (or layer Q/K/V), summing the outputs of all heads within a layer before routing and restricting the within-token wiring rank to 1 (or 3).
The Residual Matrix Transformer (RMT) ([33]) replaces the vector residual stream entirely with a pure matrix residual stream, which heads and FFNs read and write through static key vectors so the stream can be widened cheaply. LoomFormer instead keeps a dual-stream architecture that separates control on the vector stream from content on the matrix stream: the compact vector stream generates per-token ports cheaply, whereas RMT’s static ports fall under Theorem 3.1(i) and remain node-gated however wide the matrix is made (4 in RMT’s main configuration vs. 2 + in LoomFormer).
Cross-layer token attention and KV sharing. OmniNet ([47]) lets every token attend directly to all tokens across all layers, incurring attention cost quadratic in ; loom attention instead factors cross-layer routing within each token through a fixed-size matrix memory in time and composes it with standard within-layer horizontal attention. Cross-Layer Attention (CLA) ([4]) shares key-value caches across adjacent layers to reduce inference memory at a modest quality trade-off, whereas loom attention dynamically composes earlier head outputs into distinct per-head queries, keys and values at every layer (§ 5.3).
Mechanistic interpretability and intra-layer advances. Circuit-level interpretability studies ([11, 36, 7, 21, 34] (Ni et al. 2025)) show that Transformers implement tasks by composing specific upstream and downstream heads across layers; loom attention turns this implicit, static composition into an explicit, per-token operation over . Orthogonal intra-layer advances—including improved horizontal attention ([31, 54] (Ye et al. 2024; Levithian et al. 2024)), sequence-axis linear attention and state-space models ([39, 59, 60] (Gu & Dao 2024; Dao & Gu 2024)), and sparse Mixture-of-Experts FFNs ([16, 8]})—modify horizontal mixing or FFN capacity within a layer and can be combined directly with loom attention along depth.
PyTorch-Style Pseudocode for LoomFormer
# b = batch size, t = seq len, n = num_heads, d = head_dim
# k = num_slots d_k, r = RoPE dim d // 4. M is of shape btkd
def MRead(M, x, xr):
qm = rearrange(xr @ W_r2, 'bt (nk)->btnk')
qm = rmsnorm(qm) * sigmoid(rearrange(x @ W_rg, 'btn->btn1'))
qm += q_bar * sigmoid(rearrange(x @ W_rg_bar, 'btn->btn1')) # nk,btn1->btnk
u = einsum('btnk,btkd->btnd', qm, M)
return u
def MWrite(o, x, xw):
km = rearrange(xw @ W_w2, 'bt (nk)->btnk')
km = rmsnorm(km) * sigmoid(rearrange(x @ W_wg, 'btn->btn1'))
dM = einsum('btnk,btnd->btkd', km, o)
return dM
def MShift(M, x):
M_prev = shift_right(M, 1, dim=1) # shift t dim of btkd
z = sigmoid(rearrange(x @ W_sg, 'btk->btk1'))
return z * M_prev + (1 - z) * M
def loom_mha(x, M, write_M=True):
M = RMSNorm(MShift(M, x), dim=(-2, -1))
xr, xw = gelu(x @ W_r1), gelu(x @ W_w1)
q, k, v, o = [MRead[s](M, x, xr) for s in ['q', 'k', 'v', 'o']]
qr = rope(rearrange(x @ W_q, 'bt(nr)->btnr'))
kr = rope(rearrange(x @ W_k, 'bt(nr)->btnr'))
q, k = concat([qr, q], dim=-1), concat([kr, k], dim=-1)
allow_mask = tril(ones(T, T), diagonal=-1) # strictly causal mask
o = o + MHA(q, k, v, allow_mask=allow_mask)
dx = rearrange(o, 'btnd->bt(nd)') @ W_o
dM = MWrite(RMSNorm(o, dim=-1), x, xw) if write_M else 0.
return dx, dM
def ffn(x, write_M=True):
xw = gelu(x @ W_w1)
dx = _ffn_x(x)
dM = MWrite(rearrange(_ffn_m(x), 'bt(nd)->btnd'), x, xw) if write_M else 0.
return dx, dM
def loomformer(input_ids):
x = embedding(input_ids)
o = rearrange(x @ W_e, 'bt(nd)->btnd')
M = MWrite(o, x, gelu(x @ W_w1))
for l in range(L):
write_M = l < L - 1
# pairs are added element-wise: (x, M) + (dx, dM) = (x + dx, M + dM)
(x, M) = (x, M) + loom_mha[l](ln_1[l](x), M, write_M=write_M)
(x, M) = (x, M) + ffn[l](ln_2[l](x), write_M=write_M)
return unembedding(ln_f(x))
Experimental Configurations, Baselines and Benchmarks
Model Configurations and Hyperparameters
Table 6 lists the architectural dimensions, peak learning rates and token budgets across all four LoomFormer scales (§ 5.1 and § 5.2). In blocks 0, . . . , , FFN and the FFN write branch (FFN plus its MWrite module) follow a 2:1 parameter ratio (rounded to multiples of 128 at 2.8B, giving 2.2:1), while block (last) omits unused writes to and widens FFN to match the baseline Transformer’s total parameter count. Table 7 lists the training hyperparameters for the scaling-law experiments (§ 5.1; weight decay is excluded on normalization scales and biases, including gate biases), while the 2.8B models (§ 5.2) follow Pythia-2.8B (Biderman et al., [2]). To improve training stability at the XL scale, LoomFormer-XL replaces SwiGLU in FFN with Kimi K3’s bounded SiTU-GLU activation (Kimi Team, [28]) with , .
| Model | Params | Tfm FFN | FFN (last) | FFN | LR | Tokens | ||||||
| Medium | 432M | 18 | 1200 | 66.7 | 16 | 75 | 256 | 3200 | 2510 (3904) | 1128 | 3.0e-4 | 7B |
| Large | 778M | 22 | 1536 | 69.8 | 16 | 96 | 256 | 4096 | 3317 (5083) | 1539 | 2.5e-4 | 14B |
| XL | 1.4B | 28 | 1920 | 68.6 | 20 | 96 | 400 | 5120 | 4048 (6277) | 1827 | 2.0e-4 | 26B |
| 2.8B | 2.8B | 32 | 2560 | 80 | 32 | 80 | 640 | 10240 | 7808 (9984) | 2944 | 1.6e-4 | 300B |
Table 6. Model configurations across scales. ; shared port-feature width , capped at at 2.8B.
| Hyperparameter | Value | Hyperparameter | Value |
| Optimizer | AdamW | Sequence length | 4096 |
| (0.9, 0.95) | Batch size (seqs) | 128 | |
| Vocab size | 50,432 | ||
| Weight decay | 0.1 | Tied embeddings | False |
| Gradient clipping | 1.0 | Linear bias | False |
| LR schedule | Cosine | Normalization | RMSNorm () |
| Min LR ratio | 0.1 | FFN activation | SwiGLU |
| Warmup fraction | 0.01 | Positional emb. | RoPE () |
| Dropout | 0.0 | Precision | BF16 |
Table 7. Training hyperparameters for the scaling-law experiments (§ 5.1).
Port and gate initialization. Each gate projection in Eqs. (5)–(7) includes a learnable bias (omitted in § 3.2 for brevity) that sets its initial opening. Specifically, the gate projection weights are initialized to zero, with biases setting initial gate values to 0.05 on the dynamic read branch, 0.9 on the static read branch, 0.1 on the write branch, and 0.5 on MShift (). For the static queries , value reads are initialized from , whereas , and start at so memory-read Q/K coordinates and the output bypass grow in gradually.
Scaling-Law Baselines
All baselines in § 5.1 are trained in JAX/MaxText on the identical data order, tokenizer and schedule as LoomFormer:
Transformer++: Llama-style pre-norm Transformer (Touvron et al., [48]) with RoPE (Su et al., 2024), SwiGLU FFN (Shazeer, [43]), RMSNorm and no linear biases.
DHC: Dynamic Hyper-Connections with expansion rate and tanh-bounded dynamic routing following Zhu et al. [63].
mHC: Manifold-constrained Hyper-Connections ( streams) projecting the stream-mixing matrix onto the Birkhoff polytope via Sinkhorn normalization (Xie et al., [57]).
AttnRes (full): Full Attention Residuals aggregating all preceding sub-layer outputs per sub-layer via learned depth-wise softmax queries (Kimi Team, [27]).
MUDDFormer: Multiway Dynamic Dense connections generating per-token depth-aggregation weights separately for the query, key, value and residual inputs of each block (Xiao et al., [55]).
Downstream Evaluation Benchmarks
In addition to the benchmarks used by Pythia (Biderman et al., [2])—LAMBADA (Paperno et al., [38]), PIQA (Bisk et al., [3]), WinoGrande (Sakaguchi et al., [41]), ARC-Easy/Challenge (Clark et al., [6]) and SciQ (Welbl et al., 2017)—we evaluate BoolQ (Clark et al., [5]) and HellaSwag (Zellers et al., [62]) for commonsense reasoning, and RACE-Middle/High (Lai et al., [29]) for reading comprehension (Table 2), all under LM Evaluation Harness (Gao et al., [19]) in zero-shot and five-shot settings.
Details of Complexity Analysis
We derive the forward-FLOP overhead in Table 3 under a matched parameter budget, following the counting convention of DCFormer (Xiao et al., [54]) and MUDDFormer (Xiao et al., [55]). Let be the number of layers, the sequence length, the model width, the number of heads, the head dimension, and the matrix memory. We report FLOPs per sequence at two FLOPs per multiply-add, omitting the shared token embedding and unembedding as well as normalization, nonlinearities, biases and other elementwise operations (such as gate activations and the elementwise mixing in MSShift). Causal attention has approximately query–key pairs; using a strictly rather than inclusively causal mask changes only the lower-order diagonal terms.
Parameter budget and tokenwise projections. The reference Transformer has attention and FFN weights per layer, for a total of (applying to both a GELU FFN of hidden width and a SwiGLU FFN of hidden width ). LoomFormer replaces the full Q/K/V projections with smaller RoPE projections and matrix reads, redistributing the saved parameter budget among the port generators, FFN and FFN, as well as the initial value projection and embedding MWrite (Eq. (10)), so that .
Every tokenwise dense matrix costs FLOPs, where is its number of entries. Consequently, to leading order, the combined projection and FFN cost is in both models. This includes both stages of the low-rank port generators, all projected gates (including in MShift), , FFN and FFN; a shared projection is counted once. Adding the port-generation or FFN FLOPs without subtracting the FFN FLOPs that paid for their weights would double-count them. Static ports, learned normalization scales and biases give only lower-order corrections to this dense-weight relation, and for the same reason the bottleneck width affects parameter allocation without entering the leading net FLOP overhead.
Reference Transformer FLOPs. In addition to the tokenwise projections and FFNs, each layer computes and attention-weighted values. Each costs FLOPs under the causal approximation. The reference forward cost is therefore
Reading and writing the matrix memory. A single MRead contracts a -dimensional port with , at a cost of FLOPs per token. Its dynamic and static ports are summed before this contraction (Eq. (5)), so they do not require two separate reads. With four reads per head and heads, the layers cost
For each writing sub-layer, MWrite sums outer products of shape , costing FLOPs. There are two such sub-layers per block, attention and FFN, except in the last block, which does not write to . The embedding adds one initial write of the same size (Eq. (10)). Hence
The last approximation neglects the small endpoint factor multiplying the memory-overhead term. Since has a fixed size, the read/write cost per layer does not increase with depth.
Wider query and key. In the reference Transformer, Q, K and V each have coordinates per head. LoomFormer concatenates RoPE coordinates to the coordinates of Q/K read from (Eq. (7)), while V retains width . Thus only the contraction is wider; the attention-weighted value contraction is unchanged. The extra cost is
Total overhead and scaling. Combining Eqs. (13)–(16) gives
where . With and , we have , giving the expression in § 6:
At fixed , the matrix read/write term scales as while the wider-Q/K term is independent of ; as grows, the first term falls from toward and the second rises toward , with both independent of at leading order. In Table 3 ( and for Medium, Large, XL and 2.8B, using at Medium/Large/XL and at 2.8B; Table 6), Large, XL and 2.8B have integer and follow Eq. (18) directly (3.13%, 2.77% and 1.95%), whereas Medium rounds its RoPE width to in Eq. (16), giving 3.70% instead of Eq. (18)’s unrounded 3.81% (retaining in Eq. (15) changes every row by < 0.01 percentage points). For a backbone with a different FFN parameter ratio, one can retain the general denominator instead of substituting . Wall-clock training and inference speeds are detailed in Section F.
Training and Inference Throughput Details
Training throughput. Table 8 reports paired training benchmarks in JAX/MaxText on TPU v5p pods at each model’s training configuration (§ 5.1 and § 5.2), with both Transformer and LoomFormer using Splash attention (1024-token blocks and fused backward). LoomFormer executes custom Pallas kernels (forward and backward) that fuse MShift, MNorm, port normalization and gating, and the four MReads of all heads into one per-token MXU matrix multiplication in VMEM, and likewise fuse MWrite’s -head outer-product accumulation, avoiding intermediate HBM traffic on . We compare median XPlane device step time under full activation rematerialization on both sides (Table 3). At 2.8B, LoomFormer uses 512-token cross-entropy chunking to fit v5p-128 HBM whereas Pythia-2.8B does not, making the 2.8B ratio slightly conservative.
| Model | Pod | Batch (seqs) | Tfm (ms) | Loom (ms) | Relative speed | |
| Medium | v5p-16 | 4096 | 128 | 1224 | 1352 | 90.5% |
| Large | v5p-32 | 4096 | 128 | 962 | 1078 | 89.2% |
| XL | v5p-32 | 4096 | 128 | 1590 | 1723 | 92.3% |
| 2.8B | v5p-128 | 2048 | 1024 | 2988 | 3233 | 92.4% |
Table 8. TPU v5p training step time and relative throughput of LoomFormer (Loom) vs. Transformer (Tfm).
Inference throughput on NVIDIA A800. Table 9 reports BF16 inference throughput on a single NVIDIA A800-80GB PCIe GPU (torch 2.14 / triton 3.8 / cuDNN 9.24) using trained checkpoints at all four scales, taking the median over five measurements. LoomFormer executes one fused Triton kernel per layer covering the preceding write, the MShift read view, the four MReads, RoPE and cache updates, together with grouped decode GEMVs for the small port projections; prefill uses each model’s fastest SDPA backend (FlashAttention for Transformer; cuDNN SDPA for LoomFormer, whose Q/K head width differs from V width ). Prefill measures one uncached forward pass of tokens, and decode measures single-token generation steps after a -token prompt under torch.compile(mode="max-autotune") with CUDA graphs.
| Model | Prefill bs 1 | Prefill bs 8 | Decode bs 1 | Decode bs 16 | Decode bs 64 |
| Medium | 87.4% (148.9k/170.3k) | 90.4% (166.0k/183.5k) | 91.7% (565/616) | 89.2% (2109/2365) | 92.3% (2499/2709) |
| Large | 85.3% (95.3k/111.7k) | 86.2% (104.0k/120.6k) | 85.4% (438/513) | 87.8% (1916/2183) | 84.9% (2311/2721) |
| XL | 83.8% (50.8k/60.6k) | 85.3% (55.3k/64.9k) | 86.9% (272/313) | 84.6% (1245/1472) | 86.6% (1452/1677) |
| 2.8B | 87.5% (30.4k/34.7k) | 90.5% (33.1k/36.6k) | 86.4% (171/198) | 87.6% (1248/1425) | 88.9% (1836/2066) |
Table 9. BF16 inference throughput on one NVIDIA A800-80GB GPU, reported as relative throughput and absolute tokens/s (Loom / Tfm); for Medium, Large and XL, and for 2.8B.
Extended Ablation Studies
Table 10 reports the complete 18-variant ablation suite at the Medium scale (, , , , , , RoPE dim , , 7B tokens), extending Table 4. In full LoomFormer, FFN has SwiGLU hidden width 1128, and FFN has width 2510 in blocks 0–16 and 3904 in block 17 (which omits unused writes to ). Whenever an ablation removes parameters, we widen FFN uniformly across blocks 0–16 and absorb any embedding or integer-rounding residual in block 17, matching the 432.11M parameter budget within ±1.4K (< 0.0004%).
| Variant | Specification (vs. full LoomFormer) | Loss↓ | ΔLoss | Gain |
| LoomFormer (full)† | — | 2.266 | — | 100.0% |
| Transformer++ (baseline)† | Standard MHA + SwiGLU FFN, no matrix stream | 2.443 | +0.177 | 0.0% |
| Dynamic rewiring & write-port gating (Theorem 3.1) | ||||
| Static LoomMHA , gated | Static in LoomMHA; write gate kept | 2.266 | 0.000 | 100.0% |
| Static LoomMHA | Static in LoomMHA; write gate dropped (≡ 1) | 2.282 | +0.016 | 91.1% |
| Static FFN , gated | Static in FFN; write gate kept | 2.268 | +0.001 | 99.3% |
| Static FFN | Static in FFN; write gate dropped (≡ 1) | 2.272 | +0.006 | 96.6% |
| Static write keys (), gated | Static in emb., LoomMHA, FFN; write gates kept | 2.274 | +0.008 | 95.6% |
| Static write keys ()† | Static in emb., LoomMHA, FFN; write gates dropped | 2.283 | +0.017 | 90.3% |
| Static read queries ()† | Only static in MReadQ,K,V,O; all read gates dropped | 2.310 | +0.043 | 75.4% |
| Static read & write (), gated | Static (no read gates), all ; write gates kept | 2.327 | +0.060 | 65.8% |
| Static read & write ()† | Static , all ; port gates dropped (TfmK,Q + MShift) | 2.344 | +0.078 | 56.0% |
| Static read & write (), − MShift | Static , all ; port gates, MShift dropped (Prop. 3.1(i)) | 2.348 | +0.082 | 53.6% |
| Port normalization & gating (Eqs. (5)–(6)) | ||||
| − dynamic port gates† | ; and MShift kept | 2.277 | +0.011 | 93.7% |
| − dynamic port Norm† | Drop Norm on dynamic ; Norm(), MNorm kept | 2.289 | +0.023 | 87.1% |
| − dynamic port gates & Norm† | Drop both and port Norm | 2.283 | +0.017 | 90.3% |
| Sub-layer components (§ 3.2) | ||||
| − FFN write† | Remove FFN and its MWrite (Eq. (9)) | 2.300 | +0.034 | 80.7% |
| − output bypass † | Drop MRead; restore self-attention to current token (Eq. (8)) | 2.299 | +0.032 | 81.8% |
| − vector-stream RoPE † | Drop ; RoPE on 18 of 75 dims of (Eq. (7)) | 2.286 | +0.020 | 88.7% |
| − MShift† | Set in Eq. (7) | 2.277 | +0.010 | 94.2% |
| − LoomMHA write Norm() | Drop Norm on in LoomMHA writes (Eq. (8)) | 2.268 | +0.002 | 98.8% |
Table 10. Complete Medium-scale (432M) ablation suite of LoomFormer under a matched parameter budget (432.11M ± 1.4K). †Included in Table 4.
Write-port gating vs. slot selection, and reduction to Tfm. Fixing write keys to learned static vectors while keeping their dynamic gates preserves nearly the full gain (100.0% for LoomMHA, 99.3% for FFN, and 95.6% across all three write sites including the embedding). Dropping the gate on static , however, hurts LoomMHA over three times as much as FFN (100.0% → 91.1% vs. 99.3% → 96.6%): LoomMHA normalizes its head outputs before writing (Eq. (8)), leaving the gate as the sole control of write magnitude (and whether a head is on), whereas FFN writes unnormalized slices (Eq. (9)) whose norms can still modulate write strength per token. When both and are static, retaining dynamic write gates gives a node-gated circuit on fixed slots (65.8%), dropping those gates leaves Tfm with MShift (56.0%), and further removing MShift yields the exact Tfm of Theorem 3.1(i) (53.6%)—which has no token-dependent port or shift gates on , yet still outperforms all layer-wise dynamic baselines at the same scale (Figure 5, where MUDDFormer reaches 48.5% of LoomFormer’s gain).
Attention write-value normalization. Removing Norm() from LoomMHA writes (Eq. (8)) loses only 1.2% of the gain (98.8% retained), as whole-matrix pre-normalization MNorm before reads (Eq. (7)) already bounds the scale of .
Mechanistic Analysis Details and Visualizations
Evaluation protocol and linear attribution. The statistics in § 5.3 and this section are computed on held-out Pile validation sequences of length at the 300B-token checkpoints of Pythia-2.8B, mHC-Pythia-2.8B and LoomPythia-2.8B (evaluating token positions to avoid sequence-boundary transients). Because MShift and MNorm act linearly on the accumulated writes at each layer (Equation (7)), absorbing the per-slot shift gate (or ) and the scalar MNorm factor into decomposes every MRead output as over all earlier writers (embedding, LoomMHA and FFN writes at and ; 0.4% median RMS difference from BF16 execution across layers). Projecting each term onto gives the additive writer attribution
Definitions for Figure 6. In Figure 6(a), to isolate dynamic port rewiring from both static virtual weights (Theorem 3.1(i)) and per-token scalar gate or writer-norm fluctuations, let and denote the unit port directions of reader and same-token writer , weighted by each writer’s corpus RMS norm . . We center across tokens, , and report the energy effective rank with , where the Q/K/V readers of layer (or the readers of a single Q, K or V input); under fixed-port Tfm with arbitrary positive scalar gates, . In Figure 6(b), for each read port () and write port (LoomMHA and FFN), we average over distinct token pairs () and over the heads of layer (embedding write ports remain near-static at 0.005, providing a sanity check). In Figure 6(c), following Xiao et al. (2025), a head is on at query position if falls neither in nor on a sink token (<|endoftext|>, ".", " .", "\n", "\n\n"); in layers 17–32, first-two-token sink mass drops from 26.4% (Pythia) and 27.2% (mHC) to 1.5% in LoomPythia while content-token attention mass rises from 22.7% and 31.2% to 65.4%, and masking the self-diagonal in Pythia and mHC to match LoomMHA’s strict causal mask (Equation (8)) leaves the gap unchanged (74.4% vs. 21.2% and 15.7%). In Figure 6(d), for each head in layers 3–32 and each pair among its four ports , we compute from token-averaged positive attributions over same-token writers: (i) Pearson correlation after summing attributions by writer group (Emb, each earlier LoomMHA layer, each earlier FFN layer), (ii) Pearson correlation across individual head/module writers, and (iii) for the top-32 writer sets , reporting the median across heads (in slot space , same-token cosine similarity between ports of the same head averages 0.01–0.07 outside Q–K and 0.27 on Q–K).
Writer composition and depth-to-depth routing. Averaged over layers 2–32 in LoomPythia-2.8B, positive attribution mass is shared across LoomMHA writes (53.4%–62.5% across ), FFN writes (27.5%–35.2%) and embedding writes (10.0%–11.7%), while previous-token MShift reads account for 13.7%–15.2% of (Figure 8(a)). FFN reaches its largest share (35.2%) on value reads , consistent with FFN serving as the sole post-embedding channel from the vector stream into (Equation (9)) and with its large effect in Table 4. Plotted with writer sources on the vertical axis (bottom to top) and reader layers on the horizontal axis, the column-max normalized routing map (Figure 8(b)) combines local relay along the diagonal with persistent horizontal bands from hub writer sources—most prominently the embedding at early layers and writer layers 13–14 and 19 across all subsequent layers.
Figure 8. Matrix-stream routing in LoomPythia-2.8B across Pile validation sequences. (a) Share of positive attribution from Embedding, LoomMHA and FFN writes, and share of from previous-token MShift (). (b) Column-max normalized positive attribution from each writer source (vertical, bottom to top) to each reader layer (horizontal; gray upper triangle: causally unreachable).
Adjacent-token rewiring on an in-context prompt. Figure 9 shows the head-writer attribution submatrix at hub layer 19 (selecting the top 6 readers per MRead arm and top 18 earlier LoomMHA head writers by peak across the two tokens) on "France: Paris\nJapan: Tokyo\nChina: Beijing\nSpain: Madrid\nGermany:", where LoomPythia-2.8B predicts " Berlin" top-1 with probability 0.65. At "Germany" (Figure 9(a)), writers route selectively to distinct MRead arms—L13.H11 feeds key reads (: K14,K23,K25) without feeding value or bypass reads, whereas L13.H12 and L08.H25 feed value and bypass reads (V10,O09,O22)—forming a non-rectangular within-token pattern (Theorem 2.3) that appears "Germany"’s horizontal keys, values and residual state. At the immediately following delimiter ":" (Figure 9(b)), LoomMHA’s strict causal mask (, Equation (8)) means that only (attending back to "Germany" and the few-shot capitals) and affect the " Berlin" prediction, whereas and at ":" serve only future tokens. Correspondingly, L13.H11 and L13.H12 switch off on layer 19, while layer 19 rewires its causal query reads onto L18.H25, L15.H32 and L14.H01 (Q06,Q07,Q17,Q22) and its bypass outputs onto L14.H06, L16.H29 and L14.H19 (O16,O21); causally freezing layer 19’s dynamic read ports at ":" to those at "Germany" alone drops from 0.65 to 0.54 (0.41 when frozen across all layers).

Figure 9. Attribution submatrix (rows: top-18 earlier head writers ; columns: top-6 layer-19 MRead outputs per arm ) of LoomPythia-2.8B at two consecutive tokens of an in-context prompt (next-token top-1: " Berlin", ), showing non-rectangular within-token wiring at "Germany" (a) and per-token rewiring onto causal and pathways at ":" (b; hatched columns affect only future tokens under ).
References
- [1]with pathways. Journal of Machine Learning Research, 24(240):1–113, 2023.arxiv.org/abs/2204.02311
- [2]Biderman, S., Schoelkopf, H., Anthony, Q. G., Bradley, H., O’Brien, K., Hallahan, E., Khan, M. A., Purohit, S., Prashanth, U. S., Raff, E., et al. Pythia: A suite for analyzing large language models across training and scaling. In International Conference on Machine Learning (ICML), pp. 2397–2430. PMLR, 2023.arxiv.org/abs/2304.01373
- [3]Bisk, Y., Zellers, R., Gao, J., Choi, Y., et al. Piqa: Reasoning about physical commonsense in natural language. In Proceedings of the AAAI conference on artificial intelligence, volume 34, pp. 7432–7439, 2020.arxiv.org/abs/1911.11641
- [4]Brandon, W., Mishra, M., Nrusimha, A., Panda, R., and Kelly, J. R. Reducing transformer key-value cache size with cross-layer attention. arXiv preprint arXiv:2405.12981, 2024.arxiv.org/abs/2405.12981
- [5]Clark, C., Lee, K., Chang, M.-W., Kwiatkowski, T., Collins, M., and Toutanova, K. BoolQ: Exploring the surprising difficulty of natural yes/no questions. arXiv preprint arXiv:1905.10044, 2019.arxiv.org/abs/1905.10044
- [6]Clark, P., Cowhey, I., Etzioni, O., Khot, T., Sabharwal, A., Schoenick, C., and Tafjord, O. Think you have solved question answering? try arc, the ai2 reasoning challenge. arXiv preprint arXiv:1803.05457, 2018.arxiv.org/abs/1803.05457
- [7]Conmy, A., Mavor-Parker, A., Lynch, A., Heimersheim, S., and Garriga-Alonso, A. Towards automated circuit discovery for mechanistic interpretability. In Advances in Neural Information Processing Systems (NeurIPS), volume 36, pp. 16318–16352, 2023.arxiv.org/abs/2304.14997
- [8]Dai, D., Deng, C., Zhao, C., Xu, R., Gao, H., Chen, D., Li, J., Zeng, W., Yu, X., Wu, Y., et al. DeepSeekMoE: Towards ultimate expert specialization in mixture-of-experts language models. arXiv preprint arXiv:2401.06066, 2024.arxiv.org/abs/2401.06066
- [10]D’yachkov, A. G. and Rykov, V. V. Bounds on the length of disjunctive codes. Problemy Peredachi Informatsii, 18 (3):7–13, 1982.
- [11]Elhage, N., Neel, N., Olsson, C., et al. A mathematical framework for transformer circuits. Transformer Circuits Thread, 2020. URL https://transformer-circuits.pub/2021/framework/index.html.
- [12]Elhage, N., Hume, T., Olsson, C., Schiefer, N., Henighan, T., Kravec, S., Hatfield-Dodds, Z., Lasenby, R., Drain, D., Chen, C., et al. Toy models of superposition. Transformer Circuits Thread, 2022.arxiv.org/abs/2209.10652
- [13]ElNokrashy, M., AlKhamissi, B., and Diab, M. Depth-wise attention (dwatt): A layer fusion method for data-efficient classification. arXiv preprint arXiv:2209.15168, 2022.arxiv.org/abs/2209.15168
- [14]Erdős, P., Frankl, P., and Füredi, Z. Families of finite sets in which no set is covered by the union of others. Israel Journal of Mathematics, 51:79–89, 1985.
- [15]Fang, Y., Cai, Y., Chen, J., Zhao, J., Tian, G., and Li, G. Cross-layer retrospective retrieving via layer attention. arXiv preprint arXiv:2302.03985, 2023.arxiv.org/abs/2302.03985
- [16]Fedus, W., Zoph, B., and Shazeer, N. Switch transformers: Scaling to trillion parameter models with simple and efficient sparsity. The Journal of Machine Learning Research, 23(1):5232–5270, 2022.arxiv.org/abs/2101.03961
- [17]Füredi, Z. On r-cover-free families. Journal of Combinatorial Theory, Series A, 73(1):172–173, 1996.
- [18]Gao, L., Biderman, S., Black, S., Golding, L., Hoppe, T., Foster, C., Phang, J., He, H., Thite, A., Nabeshima, N., et al. The pile: An 800gb dataset of diverse text for language modeling. arXiv preprint arXiv:2101.00027, 2020.
- [19]Gao, L., Tow, J., Abbasi, B., Biderman, S., Black, S., DiPofi, A., Foster, C., Golding, L., Hsu, J., Le Noac’h, A., Li, H., McDonnell, K., Muennighoff, N., Ociepa, C., Phang, J., Reynolds, L., Schoelkopf, H., Skowron, A., Sutawika, L., Tang, E., Thite, A., Wang, B., Wang, K., and Zou, A. A framework for few-shot language model evaluation, 12 2023. URL https://zenodo.org/records/10256836.
- [21]Hanna, M., Pezzelle, S., and Belinkov, Y. Have faith in faithfulness: Going beyond circuit overlap when finding model mechanisms. In Proceedings of Conference on Language Modeling (COLM), 2024.
- [23]Hoffmann, J., Borgeaud, S., Mensch, A., Buchatskaya, E., Cai, T., Rutherford, E., de Las Casas, D., Hendricks, L. A., Welbl, J., Clark, A., et al. An empirical analysis of compute-optimal large language model training. Advances in Neural Information Processing Systems, 35:30016–30030, 2022.
- [24]Huang, G., Liu, Z., Van Der Maaten, L., and Weinberger, K. Q. Densely connected convolutional networks. In Proceedings of the IEEE conference on computer vision and pattern recognition (CVPR), pp. 4700–4708, 2017.arxiv.org/abs/1608.06993
- [25]Katharopoulos, A., Vyas, A., Pappas, N., and Fleuret, F. Transformers are RNNs: Fast autoregressive transformers with linear attention. In Proceedings of the 37th International Conference on Machine Learning (ICML), 2020.arxiv.org/abs/2006.16236
- [26]Kautz, W. H. and Singleton, R. C. Nonrandom binary superimposed codes. IEEE Transactions on Information Theory, 10(4):363–377, 1964.DOI
- [27]Kimi Team. Attention residuals. arXiv preprint arXiv:2603.15031, 2026a.
- [28]Kimi Team. Kimi K3: Open frontier intelligence. arXiv preprint arXiv:2607.24653, 2026b.
- [29]Lai, G., Xie, Q., Liu, H., Yang, Y., and Hovy, E. Race: Large-scale reading comprehension dataset from examinations. arXiv preprint arXiv:1704.04683, 2017.
- [31]Liu, A., Feng, B., Wang, B., Wang, B., Liu, B., Zhao, C., Deng, C., Ruan, C., Dai, D., Guo, D., et al. Deepseek-v2: A strong, economical, and efficient mixture-of-experts language model. arXiv preprint arXiv:2405.04434, 2024.
- [32]Longpre, S., Hou, L., Vu, T., Webson, A., Chung, H. W., Tay, Y., Zhou, D., Le, Q. V., Zoph, B., Wei, J., et al. The flan collection: Designing data and methods for effective instruction tuning. arXiv preprint arXiv:2301.13688, 2023.arxiv.org/abs/2301.13688
- [33]Mak, B. and Flanigan, J. Residual matrix transformers: Scaling the size of the residual stream. In Proceedings of the 42nd International Conference on Machine Learning (ICML), pp. 42712–42729, 2025.arxiv.org/abs/2506.22696
- [34]Merullo, J., Eickhoff, C., and Pavlick, E. Talking heads: Understanding inter-layer communication in transformer language models. arXiv preprint arXiv:2406.09519, 2024.arxiv.org/abs/2406.09519
- [36]Olsson, C., Elhage, N., Nanda, N., Joseph, N., DasSarma, N., Henighan, T., Mann, B., Askell, A., Bai, Y., Chen, A., et al. In-context learning and induction heads. Transformer Circuits Thread, 2022.arxiv.org/abs/2209.11895
- [37]Paglialdini, M., Mohtashami, A., Fleuret, F., and Jaggi, M. Denseformer: Enhancing information flow in transformers via depth weighted averaging. In Proceedings of the Thirty-Eighth Annual Conference on Neural Information Processing Systems (NeurIPS), 2024.
- [38]Paperno, D., Kruszewski, G., Lazaridou, A., Pham, Q. N., Bernardi, R., Pezzelle, S., Baroni, M., Boleda, G., and Fernández, R. The lambda dataset: Word prediction requiring a broad discourse context. arXiv preprint arXiv:1606.06031, 2016.
- [39]Peng, B., Goldstein, D., Anthony, Q., Albalak, A., Alcaide, E., Biderman, S., Cheah, E., Du, X., Ferdinan, T., Hou, H., et al. Eagle and finch: Rwkv with matrix-valued states and dynamic recurrence. arXiv preprint arXiv:2404.05892, 2024.arxiv.org/abs/2404.05892
- [40]Ruszinkó, M. On the upper bound of the size of the r-cover-free families. Journal of Combinatorial Theory, Series A, 66(2):302–310, 1994.
- [41]Sakaguchi, K., Bras, R. L., Bhagavatula, C., and Choi, Y. Winogrande: An adversarial winograd schema challenge at scale. Communications of the ACM, 64(9):99–106, 2021.arxiv.org/abs/1907.10641
- [42]Schlag, I., Irie, K., and Schmidhuber, J. Linear transformers are secretly fast weight programmers. In Proceedings of the 38th International Conference on Machine Learning (ICML), 2021.arxiv.org/abs/2102.11174
- [43]Shazeer, N. GLU variants improve transformer. arXiv preprint arXiv:2002.05202, 2020.arxiv.org/abs/2002.05202
- [44]Sperner, E. Ein satz über untermengen einer endlichen menge. Mathematische Zeitschrift, 27:544–548, 1928.DOI
- [45]Srivastava, R. K., Greff, K., and Schmidhuber, J. Training very deep networks. Advances in neural information processing systems, 28, 2015.arxiv.org/abs/1507.06228
- [47]Tay, Y., Dehghani, M., Aribandi, V., Gupta, J., Pham, P. M., Qin, Z., Bahri, D., Juan, D.-C., and Metzler, D. Omninet: Omnidirectional representations from transformers. In International Conference on Machine Learning (ICML), pp. 10193–10202. PMLR, 2021.
- [48]Touvron, H., Lavril, T., Izacard, G., Martinet, X., Lachaux, M.-A., Lacroix, T., Rozière, B., Goyal, N., Hambro, E., Azhar, F., et al. Llama: Open and efficient foundation language models. arXiv preprint arXiv:2302.13971, 2023.arxiv.org/abs/2302.13971
- [49]Vig, J. and Belinkov, Y. Analyzing the structure of attention in a transformer language model. arXiv preprint arXiv:1906.04284, 2019.arxiv.org/abs/1906.04284
- [50]Wang, K., Variengien, A., Conmy, A., Shlegeris, B., and Steinhardt, J. Interpretability in the wild: a circuit for indirect object identification in gpt-2 small. In Proceedings of the Eleventh International Conference on Learning Representations (ICLR), 2023.arxiv.org/abs/2211.00593
- [51]Wang, K., Xia, X., Liu, J., Yi, Z., and He, T. Strengthening layer interaction via dynamic layer attention. arXiv preprint arXiv:2406.13392, 2024.arxiv.org/abs/2406.13392
- [52]Wang, Q., Li, B., Xiao, T., Zhu, J., Li, C., Wong, D. F., and Chao, L. S. Learning deep transformer models for machine translation. In Proceedings of the 57th Annual Meeting of the Association for Computational Linguistics (ACL), 2019.arxiv.org/abs/1906.01787
- [54]Xiao, D., Meng, Q., Li, S., and Yuan, X. Improving transformers with dynamically composable multi-head attention. 2024a.arxiv.org/abs/2405.08553
- [55]Xiao, D., Meng, Q., Li, S., and Yuan, X. MUDDFormer: Breaking residual bottlenecks in transformers via multiway dynamic dense connections. In Proceedings of the 42nd International Conference on Machine Learning (ICML), 2025.arxiv.org/abs/2502.12170
- [56]Xiao, G., Tian, Y., Chen, B., Han, S., and Lewis, M. Efficient streaming language models with attention sinks. In The Twelfth International Conference on Learning Representations (ICLR), 2024b.arxiv.org/abs/2309.17453
- [57]Xie, Z., Wei, Y., Cao, H., Zhao, C., Deng, C., Li, J., Dai, D., Gao, H., Chang, J., Yu, K., Zhao, L., Zhou, S., Xu, Z., Zhang, Z., Zeng, W., Hu, S., Wang, Y., Yuan, J., Wang, L., and Liang, W. mHC: Manifold-constrained hyper-connections. arXiv preprint arXiv:2512.24880, 2025.arxiv.org/abs/2512.24880
- [58]Yang, S., Wang, B., Shen, Y., Panda, R., and Kim, Y. Gated linear attention transformers with hardware-efficient training. In Proceedings of the 41st International Conference on Machine Learning (ICML), pp. 56501–56523, 2024a.arxiv.org/abs/2312.06635
- [59]Yang, S., Wang, B., Zhang, Y., Shen, Y., and Kim, Y. Parallelizing linear transformers with the delta rule over sequence length. In Proceedings of the Thirty-Eighth Annual Conference on Neural Information Processing Systems, 2024b.arxiv.org/abs/2406.06484
- [60]Yang, S., Kautz, J., and Hatamizadeh, A. Gated delta networks: Improving Mamba2 with delta rule. In Proceedings of the Thirteenth International Conference on Learning Representations (ICLR), 2025.arxiv.org/abs/2412.06464
- [62]Zellers, R., Holtzman, A., Bisk, Y., Farhadi, A., and Choi, Y. Can a machine really finish your sentence? arXiv preprint arXiv:1905.07830, 2019.arxiv.org/abs/1905.07830
- [63]Zhu, D., Huang, H., Huang, Z., Zeng, Y., Mao, Y., Wu, B., Min, Q., and Zhou, X. Hyper-connections. In Proceedings of the Thirteenth International Conference on Learning Representations (ICLR), 2025.arxiv.org/abs/2409.19606







