Rewirable Circuits in Transformers with Loom Attention
Da Xiao, Qingye Meng, Shengping Li, Xingyuan Yuan
cs.LG
2026-11-23
Loom attention lets each head pick which earlier heads to read at each token, via a per-token matrix memory. LoomPythia-2.8B adds ~2% FLOPs and ties or beats Pythia-12B downstream.
Mechanistic interpretability work views a Transformer as circuits: an early head writes a feature into a subspace of the residual stream, and a later head reads it back through its query, key or value. The strength of that connection is the product of the two heads' projections, a virtual weight that is fixed once training ends. Attention is input-dependent across tokens but static across layers: no head can choose which earlier heads to read.
A model that needs different circuits for different inputs therefore keeps all of them wired at once and gates them only indirectly, most crudely by dumping attention on a sink token. DenseFormer, HyperConnections/mHC, MUDDFormer and AttnRes enrich the vertical flow between layers, but at layer granularity: head outputs are summed before the next layer sees them, so a head can neither single out one upstream head nor be singled out. The paper asks whether the wiring itself can be chosen per token.
Loom attention gives every head a vertical attention over the outputs of earlier heads at the current token, which produces its query, key and value; the head then runs ordinary horizontal attention over tokens, and its output is in turn read vertically by later heads. The two directions feed each other at every head, warp and weft on a loom.
A theorem pins down what standard Transformers lack: under pre-LN, the per-token wiring matrix has rank at most 1, so heads can only be switched on and off whole (node-gated), and realizing arbitrary wiring patterns that way needs a number of spare heads on the order of the writer count per reader at practical sizes. Loom attention manages with one head per reader, as long as at most dk writers are active at once.
Naive vertical attention over all earlier heads costs parameters quadratic in total head count, so the implementation compresses head outputs along depth into a per-token matrix memory M (dk = 2n slots, total size 2D) read and written by normalized, gated linear attention. The architecture becomes dual-stream: the vector stream carries control (which tokens to attend, which slots to wire), the matrix stream carries content. Design choices that matter:
| Setting | Metric | Result |
| XL 1.4B, 26B tokens | Pile val loss | 1.979 vs 2.101 for the best baseline; drop of 0.122 is 1.8x MUDDFormer's 0.068, at 2.8% extra FLOPs |
| 2.8B, 300B tokens | 10-task avg, 0-shot | 59.9 (+3.6 over Pythia-2.8B), ties Pythia-12B |
| 2.8B, 300B tokens | 10-task avg, 5-shot | 61.6 (+4.3), beats Pythia-12B's 60.8 |
| 2.8B, 300B tokens | FLAN ppl | 6.94, ahead of Pythia-12B (7.26) and mHC (7.35) |
| 2.8B, 300B tokens | gain vs mHC | mean +3.95, 1.6x mHC-Pythia's +2.55 |
| 2.8B | throughput | 92.4% of Transformer in training, 86-91% in inference, +1.95% FLOPs |
In the scaling runs LoomFormer posts the lowest validation loss at all three scales, matching Transformer++ trained with 3.19-3.25x compute and the four residual-stream baselines at 1.73-2.76x; log-linear extrapolation puts the 2.8B x 300B point at 4.9x compute. The mechanistic analysis points to a cause: in layers 17-32, only 22.9% of Pythia-2.8B heads and 17.7% of mHC heads sit off attention sinks, versus 74.4% for LoomPythia, more than doubling attention mass on content tokens. The dynamic wiring matrix's effective rank climbs to 41 with depth, so the rewiring is real.
This is compute efficiency bought at the architecture level: about 2% extra FLOPs for the effect of roughly 3x training compute, close to free for anyone pretraining from scratch. The contrast with MoE is worth stating precisely: MoE routes between experts with separate weights, LoomFormer routes between wirings that share all other weights and cost dk numbers per port to select. For interpretability, circuits stop being a static post-training object and become something the model reconfigures per token. The catch is that it requires training from scratch; existing checkpoints cannot adopt it.
The paper has no dedicated limitations section, and a few claims deserve caution. The 3x-compute equivalence rests on log-linear interpolation along baseline scaling curves, and the 4.9x figure at 2.8B is an extrapolation. At 300B tokens only mHC was actually trained; the stronger MUDDFormer was compared only in the 1.4B/26B scaling runs, where LoomFormer leads by 0.054 loss. Training throughput drops to 89-92%, more than the FLOP overhead, which the authors attribute to HBM I/O on the matrix memory and the low arithmetic intensity of per-token contractions. Everything is evaluated on the Pile plus 10 standard benchmarks: no long-context, no code- or math-heavy corpora. The link from head utilization to 5-shot gains is correlational. And the largest model trained is 2.8B.