DeepCrossAttention (DCA) is a Google Research change to the transformer's residual connections: instead of adding every layer's output into one running sum, each layer learns, per token, how much to take from earlier layers, and it builds its attention queries, keys and values from separate mixes. Kimi's Attention Residuals and DeepSeek's mHC attack the same weakness in different ways, and all three now ship inside open weight models.
Google put DCA back in the news with a November 23, 2026 research blog post that reached about 456 points on Hacker News. The method comes from an ICML 2025 paper. Below: what each method does, how they differ, which models use them and what we saw training a tiny DCA model.
The problem with plain residual connections
Every transformer layer has a shortcut: its input skips past the attention or feed forward block and is added to its output. That addition is what makes very deep networks trainable.
The weak spot is that the sum weights every earlier layer equally. Google's authors call this information dilution: a sharp detail found early gets averaged into everything else, and later layers may have to compute it again. The Kimi team describes a related effect with PreNorm models, where the hidden state keeps growing with depth and each layer's own contribution shrinks.
What is DeepCrossAttention?
The DeepCrossAttention paper by Mike Heddes, Adel Javanmard, Kyriakos Axiotis, Gang Fu, MohammadHossein Bateni and Vahab Mirrokni builds DCA in two steps.
Step one is a generalized residual network (GRN). Each layer keeps a stack of earlier outputs and combines them with learned weights. The paper's most general version (GRN v3) uses a fixed learned weight per feature plus an input dependent term, so the mix changes from token to token. The input dependent weights start at zero, which means a fresh DCA model starts out behaving like a normal residual network.
Step two is the cross attention part. Each decoder block gets three separate GRNs. All three read the same stack of earlier layer outputs, but one produces the queries, one the keys and one the values for the attention block. A token can therefore look up its keys from one depth and its values from another. The attention mechanism itself is unchanged.
To save memory, the paper keeps only the model inputs, the last k layer outputs and one summed vector for the layers in between. With k set to 2, each GRN sees at most four vectors.
What Google reports
From the paper and the blog post:
- Same model quality up to 3x faster in training, and lower perplexity for the same training time.
- On LM1B, a standard transformer needed 42 layers to reach a perplexity under 14, while DCA got lower with 30 layers.
- On C4 and LM1B, DCA matched standard transformers in up to five times fewer training steps.
- The added parameters are under 0.2% of the model.
- Retrofitting DCA onto an already trained transformer and training a little longer cut LM1B perplexity by 0.19, compared with 0.02 for the same extra training without DCA.
These are Google's own research scale results.
What are Attention Residuals?
Attention Residuals (AttnRes) come from the Kimi team at Moonshot AI and were posted to arXiv on March 16, 2026. Each layer has one learned vector, a pseudo query, and uses softmax attention over the outputs of earlier layers to decide its own input. In other words, the residual sum becomes a weighted average whose weights depend on the content.
Attending over every earlier layer costs memory at scale, so the paper adds Block AttnRes. Layers are grouped into blocks, outputs inside a block are summed the usual way, and attention runs only over the block summaries plus the token embedding. The official repository says about 8 blocks recover most of the gain of the full version. With one block it falls back to a normal residual network.
The Kimi team trained AttnRes into a Kimi Linear model with 48B total and 3B active parameters on 1.4T tokens and reports more even output sizes and gradients across depth, plus better scores on every task they evaluated.
What are hyper connections and mHC?
Hyper connections, from a ByteDance team led by Defa Zhu (first posted in September 2024), widen the residual path instead of reweighting it. The model keeps several parallel residual streams, n of them, and learns small matrices that mix the streams, read from them into each layer and write the layer's output back. The attention and feed forward blocks still run at normal width, so compute barely moves.
The catch is stability. Unconstrained mixing matrices, multiplied across many layers, can blow signals up or shrink them toward zero. DeepSeek's mHC paper (manifold constrained hyper connections, December 31, 2025) fixes this by forcing the stream mixing matrix to be doubly stochastic: every entry is zero or positive, and every row and column sums to one. A few rounds of the Sinkhorn Knopp algorithm push a learned matrix into that shape. With n set to 1, the constraint reduces to the plain residual connection.
DeepSeek reports 6.7% extra training time for four streams with its fused kernels and scheduling. In its 27B test model, mHC beat the baseline on all eight listed benchmarks, for example BBH 51.0 against 43.8 and GSM8K 53.8 against 46.7.
DCA vs Attention Residuals vs mHC at a glance
| Item | DeepCrossAttention | Attention Residuals | mHC |
|---|---|---|---|
| From | Google Research | Moonshot AI (Kimi) | DeepSeek |
| Paper date | February 2025 (ICML 2025) | March 2026 | December 2025 |
| Core idea | Learned, per token mix of earlier layers, with separate mixes for queries, keys and values | Softmax attention over earlier layer outputs with one learned query per layer | Several parallel residual streams with a constrained mixing matrix |
| Direction | Across depth | Across depth | Across streams at the same depth |
| Memory trick | Keep inputs, last k layers and one summed middle | Block AttnRes with about 8 blocks | Fused kernels, recomputation |
| Reported cost | Under 0.2% more parameters | Small, per the paper | 6.7% more training time at n = 4 |
| Open code | Community PyTorch ports | Pseudocode in the official repo | Inside DeepSeek's model code |
| Open models using it | Inkling 2 (query, key, value split, per Google) | Inkling 2 Mini, Kimi Linear 48B test | DeepSeek V4 Pro, V4 Flash, V4.1 Flash |
Sebastian Raschka's architecture note on mHC gives a useful way to separate them: Attention Residuals choose and combine outputs from earlier depths, while mHC keeps and mixes several streams at the current depth. DCA belongs with Attention Residuals, with the extra twist of the query, key and value split.
Which open weight models already use these ideas
Inkling 2 Mini. Thinking Machines' launch post says the model uses attention residuals: each layer reads the outputs of earlier blocks and learns its own mix, which helps pass information between the three loops of its middle layers. Google's blog adds that Inkling 2 also adopted DCA's split of queries, keys and values. Our guide to running Inkling 2 Mini locally covers the files and runtimes.
DeepSeek V4 and V4.1 Flash. Raschka's note, based on DeepSeek's configs, says V4 Pro and V4 Flash use mHC with four residual streams and 20 Sinkhorn iterations, and that DeepSeek V4.1 Flash keeps four streams with a single pass variant that lets one kernel do the mixing.
For local users the practical point is that these are new layouts. A runtime such as llama.cpp needs explicit support before a GGUF of such a model works, which is why new releases often wait on a merged pull request.
What we saw when we trained a tiny DCA model
Google has not published official DCA code that we could find. The most used community port is lucidrains/deep-cross-attention (MIT license, about 111 stars on November 28), which ships a plain GPT class and a DCAGPT class with the same building blocks. Its author notes that it keeps only the first and last k layers and skips the paper's pooled middle layers, so it is a close cousin of the paper rather than an exact copy.
We trained both classes with PyTorch 2.15.0 on a CPU: 6 layers, width 128, 4 heads, bytes as tokens, sequences of 128, batches of 16, AdamW at 0.001, 600 steps, about 1.4 MB of text with 10% held out. Validation loss:
| Run | Parameters | Loss at step 300 | Loss at step 500 | Loss at step 600 |
|---|---|---|---|---|
| Plain GPT, seed A | 1,250,784 | 1.927 | 1.706 | 1.660 |
| DCAGPT k = 2, seed A | 1,263,840 | 1.844 | 1.646 | 1.611 |
| Plain GPT, seed B | 1,250,784 | 1.923 | 1.699 | 1.638 |
| DCAGPT k = 2, seed B | 1,263,840 | 1.875 | 1.671 | 1.613 |
DCA led at every checkpoint from step 200 on in both runs, and with seed A it passed the plain model's final loss about 100 steps early. The extra parameters were 1.04% at this tiny width, above the paper's under 0.2% for larger models. Step times on our shared box varied too much to compare speed. Two seeds on a 1.3M parameter model show a direction, not the size of the effect at scale.
The code is short:
from deep_cross_attention import GPT, DCAGPT
kw = dict(num_tokens=256, dim=128, depth=6, heads=4, dim_head=32)
baseline = GPT(**kw)
dca = DCAGPT(**kw, past_layers_k=2)
loss = dca(batch_of_token_ids, return_loss=True)
How to try these ideas yourself
- Start from a small training script such as nanoGPT or the setup in our guide to training a small LLM from scratch.
- Swap the residual sum for one method at a time. For Attention Residuals, the official repository's Block AttnRes pseudocode drops into a PyTorch block in a few dozen lines.
- Keep everything else fixed: data order, seed, learning rate and step count. Compare validation loss at the same steps, and run at least two seeds.
- Log the learned mixing weights. The DCA paper found that its weights favor the inputs and the last few layers, which is why keeping only those costs little.
Pros and cons
Pros
- Each paper reports better loss for the same compute at a small parameter cost.
- DCA can be retrofitted onto a trained model, according to Google.
- All three already appear in released open weight models.
Cons
- Gains are measured by each lab on its own setup, and the three have not been compared head to head in one study we could find.
- Extra memory traffic: mHC needs custom kernels to stay near 6.7% overhead, and full AttnRes needs blocking at scale.
- New layouts need runtime support before quantized local builds work.
Who this is for
It is for people who pretrain or study transformers, and for local model users who keep seeing these names in model cards. If you only run models, nothing changes for you; the runtime handles the architecture. If you pretrain small models, DCA and Block AttnRes are the cheapest to try, while mHC pays off once you can write fused kernels.
FAQ
Is DeepCrossAttention the same as cross attention?
No. Normal cross attention lets one sequence attend to another, such as a decoder reading an encoder. DCA works across depth: each token mixes its own representations from earlier layers to form the queries, keys and values that feed the usual self attention.
Can I add DCA to a model that is already trained?
Google says yes. Because the input dependent weights start at zero, DCA can begin as an exact copy of a normal residual network. In Google's test, adding it to a trained transformer and training briefly cut LM1B perplexity by 0.19, against 0.02 for extra training alone.
What is the difference between hyper connections and mHC?
Both keep several residual streams and learn how to mix them. Hyper connections leave the mixing matrix free, which DeepSeek found can make training unstable at scale. mHC forces that matrix to be doubly stochastic, with rows and columns that each sum to one, which keeps signals from growing or shrinking across layers.
Is there official code for DeepCrossAttention?
We did not find an official Google release. The paper gives the full method, and community PyTorch ports such as lucidrains' deep-cross-attention package can be installed with pip. Attention Residuals has official pseudocode from Moonshot, and mHC lives in DeepSeek's model code.
Do these methods make local models faster?
Not directly. They mainly help training reach a given quality with less compute or fewer layers. A model trained this way can be smaller for the same quality, which helps local use, but the extra mixing adds a little work to every token at inference time.


