Rewirable Circuits in Transformers with Loom Attention

Da Xiao, Qingye Meng, Shengping Li, Xingyuan Yuan

arXiv:2611.30634 · 2026-11-25 공개 · arXiv · PDF

transformer model-scaling language-modeling few-shot-learning residual-stream efficient-attention dual-stream-architecture 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

한국어 요약

한 줄 요약

LoomFormer는 토큰 단위로 어텐션 회로를 동적으로 재구성하는 Loom Attention을 도입하여, 기존 Transformer보다 낮은 FLOPs로 높은 성능을 달성한다.

핵심 기여도

핵심 아이디어

기존 Transformer는 어텐션 헤드 간의 수직적 연결(예: K-composition)이 고정되어 있어, 입력에 따라 회로를 유연하게 재구성할 수 없다.
이에 반해, Loom Attention은 헤드가 토큰마다 이전 헤드를 선택적으로 참조할 수 있도록 하여, 회로를 동적으로 재구성한다.
이를 위해, 헤드는 이전 헤드의 출력을 저장한 per-token 행렬 메모리에서 query, key, value를 생성하고, 이 메모리는 두 번째 residual stream으로 작용한다.
이러한 수직적 어텐션(vertical attention)과 수평적 어텐션(horizontal attention)이 헤드 단위로 결합되어, 회로가 토큰마다 재구성된다.
이 구조는 직조기(loom)의 weft와 warp가 얽히듯, 수직과 수평의 정보 흐름을 결합한다는 의미에서 LoomFormer라는 이름이 붙었다.

기술적 접근법

주요 결과

의의 및 한계

LoomFormer는 기존 Transformer의 고정된 수직 연결 구조를 탈피하여, 토큰 단위로 회로를 재구성함으로써 더 유연하고 효율적인 정보 흐름을 가능하게 한다.
이를 통해, 동일한 compute 예산 내에서 더 높은 성능을 달성하거나, 동일한 성능을 낮은 compute로 달성할 수 있다.
또한, head-level의 메모리 활용이 layer-wise 메커니즘보다 훨씬 효과적임을 보여준다.
하지만, 메모리 크기 $d_k$가 너무 작으면 성능 저하가 발생하며, 메모리 관리와 정규화가 성능에 큰 영향을 미친다는 점은 한계로 작용할 수 있다.

실용적 활용

LoomFormer는 대규모 언어 모델의 학습 및 추론 효율성을 동시에 개선할 수 있어, 클라우드 기반 언어 서비스, 대화형 AI, 멀티모달 모델 등에서 활용 가능하다.
특히, compute 예산이 제한된 환경에서 성능을 유지하거나 향상시키는 데 유용하며, 모델 크기 대비 성능을 극대화해야 하는 연구 분야에도 적합하다.