🤗 Upvotes: 71 | cs.LG Authors: Da Xiao, Qingye Meng, Shengping Li, Xingyuan Yuan Title: Rewirable Circuits in Transformers with Loom Attention Arxiv: http://arxiv.org/abs/2611.30634v2 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
Audio and video play straight from the show's own hosting. PodSubs stores and serves no media.
Transcript
From the show. Tap a time to play from there.
Evan: Welcome to the Daily Paper Cast. Ashley: Today's paper is from the Hugging Face daily paper list of November 25, 2026, with 71 upvotes. Evan: It's titled 'Rewirable Circuits in Transformers with Loom Attention'. Ashley: This work is authored by Da Xiao from Beijing University of Posts and Telecommunications and Qingye Meng from ColorfulClouds Technology, with Da Xiao as the corresponding author. Evan: Let's dive into the introduction section. The background starts with how transformers solve tasks by composing attention heads across layers into circuits.
This idea has been discussed in several papers in recent years. Ashley: Yes, Evan. Earlier, heads write features into subspaces of the residual stream, and later heads read from these subspaces into their query, key, or value. For instance, induction heads read the output of a previous-token head through their keys, which is known as K-composition. Evan: However, the composition between two heads is determined by the product of their output and input projections. This virtual weight does not change after training, making it fixed.
Ashley: That’s right. Attention dynamically routes information across tokens depending on the input, but the vertical flow of information across layers remains fixed. A head cannot choose which heads from previous layers to read from, making the model keep all potential wiring at once. Evan: So, is the main problem that transformers can't adjust their circuits based on the input? Ashley: Exactly. A model that needs different circuits for different inputs must keep all the circuits wired simultaneously, letting them compete for the residual stream.
The only indirect way to gate them is by directing attention to a sink token. Evan: Interesting. So, what does this paper propose to address this limitation? Ashley: The authors propose a novel mechanism called loom attention. This mechanism allows a head to choose which earlier heads to read from in addition to selecting which tokens to attend to horizontally. Essentially, it's about interweaving the vertical attention across heads with the horizontal attention across tokens. Evan: And how is this vertical attention implemented efficiently?
Ashley: To achieve efficiency, the paper instantiates the vertical attention using normalized and gated linear attention over a per-token matrix memory. This memory stores compressed head outputs and acts as a second residual stream. Evan: So, they create a dual-stream architecture. Can you explain a bit more about this? Ashley: Sure, Evan. The dual-stream architecture, named LoomFormer, separates control and content. Control flows through a vector stream, while content flows through a matrix stream.
The vector stream decides how heads interact with the matrix memory and which tokens to attend to, while the matrix stream holds the actual content being processed. Evan: And what do their experiments show in terms of performance? Ashley: The experiments demonstrate that across various model sizes and training token budgets, LoomFormer matches the performance of transformers trained with over three times the compute. When compared with recent residual-stream baselines like HyperConnections, MUDDFormer, and Attention Residuals, LoomFormer offers significant improvements.
Evan: That sounds promising. Doesn't it require a lot of extra computation? Ashley: Surprisingly, no. The paper reports that LoomFormer adds only 2.0 to 3.7 percent extra FLOPs. For example, their LoomPythia-2.8B model, trained on the same 300 billion tokens, achieves approximately 1.6 times the average downstream gain of a comparable model, mHC-Pythia-2.8B. It even matches or surpasses much larger models in zero-shot and five-shot settings.
Evan: That brings us to the end of the Introduction section of the paper. Evan: Let's explore the Method section where the authors detail how they achieve dynamic rewiring in Transformers using loom attention. Ashley: Evan. The core of loom attention lies in combining vertical and horizontal attention mechanisms in a novel way. Let's break it down step-by-step. Evan: Alright. So, how do they start implementing loom attention? Ashley: They begin with the idea that linear attention compresses a growing key-value cache into a fixed-size state.
This compression is key to making the approach efficient even as the model scales. They extend this concept to compress head outputs along the depth dimension into a matrix memory. Evan: How does this matrix memory work exactly? Ashley: The matrix memory, denoted as M, is organized into slots, each of width d, the head dimension. Writers, which are outputs from the heads, write into this matrix memory using a key. Readers, which are inputs to the heads like queries, keys, and values, read from the matrix using a query.
This way, the matrix serves as an additional residual stream that accumulates these writes layer by layer. Evan: And how do these writes and reads get processed? Ashley: For writes, a writer's output is combined with the key using an outer product, creating ΔM which is then added to the memory M. For reads, a reader queries the memory using q, and the result is a vector obtained from the memory's slots that it attends to. Evan: So, these operations replace traditional attention mechanisms.
How do they ensure efficiency in these operations? Ashley: To maintain efficiency, normalization and gating play crucial roles. Both keys and queries are normalized and optionally gated to separate direction from magnitude. This ensures that which slots to write or read from can be dynamically chosen based on the query, while the magnitude of the write or read can be controlled independently. Evan: Got it. What about the network architecture? How does it all come together? Ashley: The architecture integrates these components seamlessly into Transformer blocks.
Each block starts with the standard residual and normalization structures but includes the matrix memory in its sub-layers. Let's consider the embedding process first. The embedding initializes both the vector residual stream and the matrix memory. The latter is updated similarly to how the feed-forward network updates its weights. Evan: And what happens within each block? Ashley: Within each block, the attention sub-layer first writes to and reads from the matrix memory. It takes the normalized key and write the product with the head output to update the memory.
The next sub-layer, which is the feed-forward network or FFN, reads from the residual stream and also writes updates to the matrix memory, combining its outputs. This looping structure ensures that all writes are interwoven effectively, creating dynamic circuits per token. Evan: That sounds quite modular. They also mention specific modules for reading and writing. Can you elaborate on these? Ashley: Sure, Evan. The paper describes two critical modules: MRead and MWrite. MRead is responsible for generating a query vector to access the matrix memory, and MWrite generates the key for writing the head output into the matrix.
To keep this efficient, they use a low-rank projection that reduces the dimensionality of the features shared by all heads. Evan: Interesting. And I see they also have a gating mechanism for dynamic query and key generation. Ashley: Yes, exactly. The gates are computed from token pre-processed features. For MRead, this involves normalizing the transformed input and then gating it to get a dynamic query. Similarly, MWrite normalizes the transformed input to produce a key before writing.
This separation of query/key direction and magnitude helps in dynamically routing attention. Evan: How does loom attention maintain the traditional Transformer structure? Ashley: LoomFormer retains the backbone of the Transformer block. However, it modifies the sub-layer operations to interweave matrix and vector streams. For instance, in the attention sub-layer, queries and keys are produced from the vector stream. Then, outputs from the matrix memory are concatenated with rotary positional embeddings applied to the vector transformations.
Meanwhile, feed-forward networks read and write only within their structures while contributing to the matrix memory. Evan: How does this approach impact the computational complexity? Ashley: Overall, LoomFormer adds minimal extra FLOPs. The model accounts for reduced overhead by efficiently compressing attention operations into fixed matrix memory. Despite a dual-stream architecture, computation scales linearly with sequence length and depth, affording it 2.0 to 3.7 percent extra FLOPs compared to its size-matched counterparts.
Evan: That's impressive. Wrapping up the Method section today, they seem to successfully create dynamic circuits that allow fine-grained reading and writing operations without major computational burdens. Ashley: And that concludes the Method section overview from the 'Rewirable Circuits in Transformers with Loom Attention' paper. Evan: Now, let's dive into the Experiment and Results section to see how LoomFormer performs in practice. Ashley: Sure, Evan. The authors conducted extensive experiments on various aspects like scaling laws, large-scale pretraining, downstream task performance, computational efficiency, and ablations to validate their approach.
Evan: Alright, let's start with the scaling laws. How do LoomFormer's models scale across different sizes? Ashley: The authors trained three model scales—Medium with 432 million parameters, Large with 778 million parameters, and XL with 1.4 billion parameters—using sequences of length 4096 and a batch size of 128 sequences, corresponding to 0.5 million tokens. Evan: What were their key findings in terms of validation loss comparison?
Ashley: Across the Medium, Large, and XL scales, LoomFormer achieved the lowest validation loss at every scale, outperforming recent residual-stream baselines like dynamic HyperConnections (DHC), manifold-constrained HC (mHC), full Attention Residuals (AttnRes), and Multiway Dynamic Dense connections (MUDDFormer). Evan: Indeed. They reported that LoomFormer matched or surpassed traditional Transformers trained with more compute, right?
Ashley: Yes, Evan. LoomFormer matched Transformers trained with 3.19 to 3.25 times more compute, and all residual-stream baselines at 1.73 to 2.76 times the compute. The validation loss for LoomFormer dropped significantly, marking it as more efficient in computational overhead. Evan: How about their large-scale pretraining and evaluation? I remember they compared it against the Pythia suite. Ashley: Correct. LoomFormer was tested on the Pile dataset with 300 billion tokens, using Pythia-2.8B, mHC-Pythia-2.8B, and others in the suite for comparison.
Specifically, they trained LoomPythia-2.8B and mHC-Pythia-2.8B, and compared them to Pythia models ranging from 2.8 billion to 12 billion parameters. Evan: What were the results of this comparison? Ashley: LoomPythia-2.8B achieved a notable increase in downstream task performance, improving average accuracy by 3.6 points in zero-shot settings and by 4.3 points in five-shot settings over Pythia-2.8B. It matched the performance of Pythia-12B in zero-shot and surpassed it in five-shot settings, equivalent to nearly five times the compute.
Evan: That’s impressive. Did this increase in performance carry over into pretraining metrics as well? Ashley: Yes, indeed. LoomPythia-2.8B reached a perplexity of 6.02 on the Pile dataset, on par with Pythia-12B, which had a perplexity of 6.01. It outperformed mHC-Pythia-2.8B, which had a perplexity of 6.24. Additionally, on out-of-domain evaluations like the FLAN Collection, LoomPythia reported even better metrics, reflecting better instruction following and in-context learning.
Evan: What about their computational efficiency? How did LoomFormer fare in terms of speed and overhead? Ashley: The computational overhead for LoomFormer was small, adding only 2.0 to 3.7 percent extra FLOPs. Despite the minimal increase, the training and inference speeds remained efficient. For instance, training maintained up to 92.3 percent of the baseline Transformer’s speed, while inference sustained around 84 to 92 percent depending on the batch size. Evan: So, the model retained high efficiency despite the additional operations introduced by loom attention.
What insights did their ablation studies provide? Ashley: Their ablation studies were crucial for understanding the impact of various components. The results showed that dynamic port generation and read/write mechanisms contributed significantly to the model's performance. Even when certain gates or normalization steps were removed, the model maintained a substantial portion of its performance gains. Specific elements like FFNM and output bypasses were identified as critical to maintaining high efficiency and performance.
Evan: Fascinating. It seems their method is robust across different configurations and setups. Is there any visual analysis in their study? Ashley: Yes, Evan. They provided detailed mechanistic analysis, including dynamic wiring rank and port cosine distance. For example, LoomPythia’s dynamic wiring rank increased with depth, reaching up to 41.0, and port rewiring was evident across adjacent tokens, demonstrating the model’s flexibility in rewiring circuits per token. Evan: That brings us to the end of the Experiment and Results section of the paper.
Evan: Alright, now let's delve into the Related Work section of the paper. This will help us understand the existing research that 'Rewirable Circuits in Transformers with Loom Attention' builds upon and differentiates itself from. Ashley: Evan. This section highlights prior advancements in transformer architectures, cross-layer connections, and residual-stream mechanisms. These form the foundation on which the loom attention mechanism improves. Evan: So, what does the paper identify as key areas in existing research?
Ashley: Several significant streams of related work are discussed. One key area is the development of cross-layer connections and residual-stream architectures. Early models like Highway Networks and DenseNet paved the way by enabling depth-wise signal propagation through input-dependent gating and static or learnable weights for layer aggregation. Evan: Right, these models enhanced the vertical flow but kept it rather static, correct? Ashley: Exactly. Transformers traditionally aggregate layer outputs using fixed connections, which limits their flexibility.
More recent innovations, such as DenseFormer, introduced all-to-all layer aggregation, strengthening the vertical signal flow. However, they still operated at the granularity of whole layers. Evan: What about mechanisms that aimed to introduce dynamic depth-wise attention? Were there any notable advancements? Ashley: Yes. Mechanisms like depth-wise linear attention in DenseFormer and cross-layer attention models such as Attention Residuals and multi-stream residual architectures evolved the concept further.
Attention Residuals, for example, leveraged learned depth-wise softmax queries to aggregate earlier sub-layer outputs dynamically. Evan: And how do LoomFormer’s contributions differ from these approaches? Ashley: LoomFormer builds on these ideas by proposing a dual-stream architecture. While Attention Residuals and DenseFormer still sum outputs of all heads within a layer prior to routing, thus limiting granularity, LoomFormer allows for dynamic per-token rewiring at the head level. Its combination of vertical and horizontal attention enables fine-grained selection of writer and reader pairs at each token.
Evan: That sounds like a key distinction. How does this compare to the more recent multi-stream approaches like Hyper-Connections? Ashley: Hyper-Connections (HC) and their manifold-constrained variant mHC introduced multiple residual streams with dynamic or learnable mixing, aiming to enhance flexibility and control. Yet, they still operate at whole-layer granularity. LoomFormer, in contrast, generates ports for each head and each token using the vector stream, allowing it to reach high wiring ranks of up to 2n heads.
Evan: What about cross-layer token attention methods? Were they able to achieve fine-grained control? Ashley: Cross-layer token attention, like that in OmniNet, connected tokens across all layers directly, but faced quadratic growth in compute with depth and sequence length. LoomFormer, using a fixed-size matrix memory per token for vertical attention, maintains linear complexity. This enables efficient fine-grained control and scalability. Evan: And how does looming attention relate to linear attention models, which are known for sequence modeling?
Ashley: Linear attention models compress attention operations into a fixed-size state along the sequence axis. They share similarities with loom attention in that both use matrix representations to manage scalability. However, loom attention applies this concept within the depth dimension, integrating it into traditional transformer blocks seamlessly. This permits dynamic rewiring across layers, which is not targeted by sequence-focused linear attention. Evan: That’s an insightful perspective. Finally, how does loom attention draw from mechanistic interpretability studies?
Ashley: From interpretability research, loom attention gains structural insights into how transformers solve tasks via implicit head composition across layers. By explicitly enabling per-token rewiring, it transforms static circuits into dynamic ones, offering improved adaptability and performance. This break from fixed routing paradigms into flexible, adaptive configurations is inspired by findings on how different transformer heads serve various functions. Evan: And that concludes the Related Work section of the paper.
Understanding these foundations clarifies how LoomFormer innovates and advances transformer architectures. Evan: Let's summarize the key contributions and takeaways from the 'Rewirable Circuits in Transformers with Loom Attention' paper. Ashley: The central contribution of this paper is loom attention, a novel mechanism that allows transformers to dynamically rewire their circuits at a fine-grained level. This approach combines vertical and horizontal attention, enabling heads to select which earlier heads to read from, alongside the usual token-level attention.
Evan: A key innovation is the dual-stream architecture called LoomFormer. By separating control and content between a vector stream and a matrix stream, LoomFormer significantly enhances how transformers handle the flow of information without requiring substantial additional computation. Ashley: Exactly. Their experiments demonstrate that LoomFormer matches the performance of transformers trained with over three times the compute, effectively utilizing normalized and gated linear attention over matrix memory. This design results in considerable downstream task performance improvements with only modest increases in FLOPs.
Evan: And what about their practical impact on model training and inference efficiency? Ashley: Despite these enhancements, LoomFormer maintains high efficiency during training and inference. The computational overhead is minimal, and it upholds competitive speeds compared to traditional transformers, even when scaled across different model sizes. Evan: Their ablation studies further solidify the importance of dynamic port generation and write-read mechanisms, ensuring robustness across various configurations and setups.
This highlights the versatility and potential broad applicability of loom attention in future transformer models. Ashley: That's right, Evan. And with that, we conclude today's discussion. Thank you for tuning in to Daily Paper Cast. Evan: We hope you found this episode insightful. Be sure to join us again for more deep dives into the latest AI research papers from Hugging Face’s daily paper list. Ashley: Until next time, keep exploring the fascinating world of AI and Machine Learning. Goodbye!
🤗 Upvotes: 52 | cs.AI Authors: Richmond Sin Jing Xuan, Peilin Feng, Wenbin Wang, Soujanya Poria Title: Lazy Agents Answer Against Their Own Beliefs: Reinforcement Learning with Verifiable Beliefs Teaches Them to Act on...