Skip to main content
Back

ColorfulClouds' LoomFormer Matches a 3x Bigger Transformer With 2.8% More Compute

A new dual-stream Transformer variant lets each attention head pick which earlier heads it reads from per token, matching 3x-compute baselines with 2% extra FLOPs.

Pro

  • LoomFormer adds per-token head-to-head rewiring via a second matrix residual stream at ~2% extra FLOPs.
  • LoomPythia-2.8B matches Pythia-12B 0-shot and beats it 5-shot after 300B Pile tokens.
  • Matches Transformer++ trained with 3.19 to 3.25 times the compute at Medium, Large and XL scales.
  • Dynamic wiring rank reaches 41 vs at most 1 in Pythia and mHC baselines.
  • Deep-layer active heads jump from 22.9% in Pythia to 74.4% in LoomPythia.
  • Code, JAX and PyTorch kernels available at Caiyun-AI/LoomFormer.

In a standard Transformer, attention heads communicate by writing vectors into the residual stream, the shared state passed from one layer to the next. Training fixes the projections that determine how later heads read those vectors. Researchers at Beijing University of Posts and Telecommunications and ColorfulClouds Technology propose LoomFormer, an architecture that dynamically selects earlier head outputs for each token’s query, key, and value inputs.

The authors report that this routing improves compute efficiency with modest additional FLOPs. Across models from 432 million to 1.4 billion parameters, scaling-law estimates place LoomFormer’s validation loss near Transformer++ baselines trained with roughly 3.2 times as much compute. A 2.8 billion-parameter model also approaches or exceeds Pythia-12B on the reported averages.

Fixed routes cap dynamic wiring

The paper represents communication between writer and reader heads as a wiring matrix. For each pair, the writer’s output projection and the reader’s input projection define a fixed connection after training. Token activations change at inference time, but the learned mapping between those heads remains constant.

Standard attention can reduce a head’s contribution by routing attention toward a sink token. The paper describes this behavior as node gating. Because one gate scales all of a head’s connections together, the input-dependent portion of the resulting wiring matrix has rank at most 1 under the authors’ formulation.

Residual-stream routing methods including Hyper-Connections, mHC, MUDDFormer, and AttnRes make layer aggregation depend on the input. Their routing ports remain shared across the heads in a layer, leaving the dynamic wiring rank at 1 for most methods and 3 for MUDDFormer, which provides separate ports for query, key, and value inputs.

The paper’s analysis finds that node gating would require a number of additional heads proportional to the available writer heads for every reader to express arbitrary per-token routes. That requirement grows quickly with model depth, making direct expansion impractical.

A matrix stream carries head outputs

Loom attention combines horizontal and vertical routing. Horizontal attention performs the familiar cross-token operation. Vertical attention selects information from earlier heads at the same token position, producing inputs for the subsequent horizontal attention step.

A direct implementation would compare every reader with every earlier writer, producing quadratic cost in the total head count. LoomFormer compresses those outputs into a token-local matrix memory M with shape d_k × d, where d is the model width and d_k is a small routing dimension. The default sets d_k to twice the number of heads per layer.

Each writer updates M with an outer product between a learned write key and its output vector. Each reader generates a query and retrieves a d-dimensional vector through normalized, gated linear attention. The updates accumulate across layers, creating a matrix stream alongside the conventional vector residual stream.

LoomFormer architecture with LoomMHA, feed-forward layers, and matrix read and write modules

The vector stream supplies routing controls, including which matrix slots to read and write. The matrix stream carries the head outputs being routed. Within LoomMHA, each head reads four vectors for its query, key, value, and output bypass, combines them with a small RoPE-conditioned component from the vector stream, performs causal horizontal attention, and writes its result back into M.

Matrix operations remain local to each token position, and cross-token attention retains a causal mask. This separation preserves autoregressive causality while allowing token-specific communication across depth.

Loss falls with a small FLOP increase

The experiments cover Pile pretraining at 432 million, 778 million, 1.4 billion, and 2.8 billion parameters. The three smaller configurations use Chinchilla-style compute budgets, while the 2.8 billion-parameter run processes 300 billion tokens. The authors measure language-model loss on a held-out Pile split.

Model or scale Added forward FLOPs Reported result
432M to 1.4B Up to 2.8% Matches Transformer++ loss at an estimated 3.19× to 3.25× compute and residual-stream baselines at 1.73× to 2.76× compute
1.4B 2.8% Reduces validation loss from 2.101 to 1.979
LoomPythia-2.8B 1.95% Improves the reported task average by 3.6 points zero-shot and 4.3 points five-shot over Pythia-2.8B

At 1.4 billion parameters, LoomFormer’s loss reduction is about 1.8 times the reduction reported for MUDDFormer under the same comparison. The compute multipliers are scaling-law estimates, so they describe fitted compute equivalence rather than direct wall-clock savings.

LoomPythia-2.8B reaches a zero-shot average of 59.9, matching the reported Pythia-12B average, and a five-shot average of 61.6, which exceeds it. On the paper’s out-of-domain FLAN subset, LoomPythia records perplexity of 6.94, compared with 7.26 for Pythia-12B. Relative to mHC-Pythia-2.8B, its average downstream gain is about 1.6 times larger.

Dynamic routes keep deep heads active

The authors analyze LoomPythia-2.8B to determine how its routing differs from the baselines. Three measurements characterize the change:

  • The dynamic wiring matrix across 96 query, key, and value readers in a layer reaches an effective rank of 41. Pythia and mHC are bounded by 1 under the same analysis.
  • In the deeper half of the network, 74.4% of heads remain active under the paper’s activation metric, compared with 22.9% for Pythia-2.8B and 17.7% for mHC-Pythia-2.8B.
  • Routing differs across the four read ports inside each head, allowing query, key, value, and output-bypass vectors to draw from distinct groups of writers.
Comparison of effective wiring rank, cross-token port distance, head activation, and writer routing across 2.8B models

A head routed toward a sink token contributes little useful computation, a pattern that appears frequently in deep layers with fixed wiring. LoomFormer’s higher activation rate is consistent with token-specific routing making more deep heads usable. The larger five-shot and FLAN gains support that interpretation, although these measurements establish an association rather than a causal mechanism.

Memory traffic sets the practical cost

The additional arithmetic remains below 3% in the reported configurations, but matrix-state movement through high-bandwidth memory adds overhead that FLOP counts omit. The token-local contractions also have lower arithmetic intensity than the large matrix multiplications that dominate conventional Transformers.

Custom TPU Pallas kernels sustain 89% to 92% of baseline Transformer training throughput. Triton kernels combined with CUDA graphs reach 84% to 92% of baseline throughput during prefill and autoregressive decoding. These measurements depend on fused kernels and the tested hardware, so implementations built from unfused framework operations may incur a larger penalty.

The routing width d_k controls the trade-off between capacity and cost. In the reported ablation, validation loss drops sharply as d_k increases from 16 to 32 and then flattens. The default value of twice the layer’s head count falls near that bend.

Code, checkpoints, and open questions

The authors provide source code with JAX/Pallas and PyTorch/Triton implementations. The released models include the 2.8B checkpoint and an mHC checkpoint for comparison.

Loom attention routes information along model depth at each token, allowing it to coexist conceptually with sequence mixers such as Mamba2 or Gated DeltaNet. The paper proposes such combinations but does not benchmark them. Its reported evidence covers decoder-only Pile pretraining up to 2.8 billion parameters, leaving broader datasets, larger models, alternative architectures, and kernel portability for future evaluation.