Attention Residuals let a layer learn how much to use each earlier layer’s output. mHC widens the residual path by carrying several streams through the model. AttnRes uses attention scores to mix information from different depths.

In a regular transformer, residual connections add all earlier updates with a contribution weight of 1. Attention Residuals, or AttnRes for short, replace these fixed weights with learned ones. The Attention Residuals paper reports consistent (but modest) improvements in validation loss and downstream performance, with about 4% in training cost and 2% in inference cost.

Standard residuals compared with Full and Block Attention Residuals
Standard residuals (left), Full AttnRes (center), and Block AttnRes (right). Full AttnRes learns weights over all preceding outputs. The block version keeps regular additions within a block and attends over the block representations (Original source Moonshot AI Attention Residuals repository).

From a fixed sum to learned weights

In a standard PreNorm transformer, the input to sublayer \(l\) is the sum of the embedding and all preceding attention and feed-forward updates:

\[h_l = \sum_{i=0}^{l-1} v_i\]

The first value, \(v_0\), is the token embedding. Each later \(v_i\) is an output from an earlier sublayer. AttnRes uses the same values but learns how much each one should contribute:

\[h_l = \sum_{i=0}^{l-1} \alpha_{i \rightarrow l} \cdot v_i\]

Here, the earlier outputs are the values, and their RMS-normalized versions serve as keys.

As illustrated in the figure above, we compute each weight as the dot product between the normalized key and a learned pseudo-query for the destination sublayer. We normalize these weights by applying the softmax function across model depth, which gives us the normalized weights \(\alpha\).

Finally, the last step is to compute \(h_l\), which is an attention-weighted version of the embedding and earlier sublayer outputs.

The pseudo-query is shared across tokens for a given destination sublayer. The keys remain token-dependent, so the weights can still vary by token. Zero-initialized pseudo-queries give all available outputs the same weight at the beginning of training.

Full and Block AttnRes

For regular self-attention, the weights connect positions in the input sequence. AttnRes instead mixes earlier sublayer outputs for the same token across model depth. The regular sequence layer, such as Kimi Delta Attention or MLA, remains unchanged.

Full AttnRes keeps the embedding and every earlier sublayer output. This list grows with model depth. Block AttnRes keeps regular additions inside each block and stores one representation at the boundary. For \(L\) sublayers grouped into \(N\) blocks, the storage per token goes from \(O(Ld)\) to \(O(Nd)\). The large experiments use about eight blocks.

How Attention Residuals and mHC differ

Both methods change the residual path, but they act along different axes.

  • Attention Residuals: select and combine outputs from earlier depths.
  • mHC: maintain and mix several residual streams at the current depth.

In Attention Residuals, the learned pseudo-query vector decides how much each earlier depth contributes to the current representation. In mHC, the model keeps several residual streams alive at the same depth and learns constrained mappings between those streams.

Experiments

The released Kimi Linear 48B-A3B checkpoint uses ordinary residual addition after attention and after the MoE sublayer. Moonshot later tested Block AttnRes in a separate experiment. The authors trained two models with the Kimi Linear architecture from scratch, one with ordinary residuals and one with Block AttnRes. Both used 1 trillion pretraining tokens followed by about 400 billion higher-quality mid-training tokens. Released decoder · Experimental comparison

Training dynamics for the 48B Kimi Linear baseline and Block Attention Residuals model
Training dynamics over the first 1 trillion tokens (Original source Attention Residuals).

After the complete recipe, Block AttnRes matches or outperforms the regular-residual baseline on every reported downstream benchmark.

Table comparing benchmark scores for the Kimi Linear baseline and Attention Residuals model
Downstream benchmark comparison (Original source Attention Residuals).

Sources