Zero Labs
Industry News / AI

From KV Cache to Depth Attention: The Bottlenecks Kimi K3 Had to Break

Source · Towards AI By Neel Shah

From the publisher’s feed, collected in the ZeroLabs newsroom.

Part 2 of Inside Kimi K3 — how Moonshot rebuilt long-context memory with Kimi Delta Attention, why it still kept global attention, and how the same idea was extended across 93 layersPreviously in Part 1, we looked at the first problem created by scaling Kimi K3 to 2.8 trillion parameters: you cannot afford to activate or move all of that capacity for every token. Sparse MoE made only a small set of experts active, while Stable Latent MoE compressed the representation before shipping it across accelerators.But making the model enormous was only half the problem. K3 was also designed for a context window reaching one million tokens, while growing from 61 layers in K2 to 93 layers. Those two decisions create two very different bottlenecks. One runs across the sequence: how do you remember a million tokens without attention and KV-cache costs becoming absurd? The other runs through depth: how do you stop useful representations from getting buried after passing through dozens of layers? Kimi K3 needed an answer to both.When Attention Stops ScalingThe million-token problem starts with a very good mechanismStandard causal attention is powerful because every new token can directly compare itself with the tokens that came before it. Its query looks across previous keys, decides what matters, and retrieves information from the corresponding values. That gives full attention an extremely useful property: individual pieces of history remain separately addressable. A fact from much earlier in the sequence still has its own key and value, and a later token can try to retrieve that specific information.The problem is what happens when the sequence becomes enormous. During prefill, more tokens mean dramatically more token-to-token interactions. During autoregressive inference, the model also keeps the keys and values of previous tokens in the KV cache, so it does not need to recompute them every time another token is generated — and the cache therefore grows with the conversation. A 10K-token conversation is manageable, but a coding agent carrying source files, tool outputs, logs, reasoning traces and hundreds of previous actions — potentially approaching one million tokens — is a different problem entirely. Running conventional global attention at every layer would make that context window extremely expensive to serve. Moonshot needed another kind of memory.Linear attention: stop storing every originalLinear attention changes what the model keeps around. Full attention behaves roughly like this:KV₁, KV₂, KV₃ ... KVₙEvery historical association remains separately available. Linear attention instead folds the sequence into a running state:past tokens → SNew tokens update the same state rather than extending a growing list of individual key-value entries. The important part is simple: the shape of S does not keep growing with sequence lengthFull attention keeps an expanding, individually addressable KV history. KDA folds history into a fixed-size recurrent state.That is exactly the property you want at very long context, but there is an obvious trade-off. If hundreds of thousands of different associations are compressed into one finite state, they start interfering with each other — old information can be mixed, overwritten or weakened as new information arrives. Linear attention solves the storage problem by creating a memory-quality problem. Kimi Delta Attention is Moonshot’s answer to that second problem.Rebuilding Memory with KDAKDA changes the way memory is writtenImagine the simplest possible memory update: new information arrives, so you add it to memory. Do that forever and eventually everything starts piling on top of everything else. The delta rule takes a smarter approach. Before writing the new value, the state first asks what it already predicts for this key, then compares that prediction with the incoming value. The difference between them is the delta, and instead of blindly writing the entire value again, the memory writes the correction.Suppose memory currently predicts: 0.8and the incoming target says: 1.0The useful new information is not another 1.0 - it is the missing: 0.2That sounds almost trivial, but it changes the nature of the update. The model is correcting an existing association instead of continuously stacking new copies into the same finite state. KDA builds on this family of delta-rule recurrent attention mechanisms.Different parts of memory should live for different amounts of timeWriting is only half of the problem — the other half is forgetting, and this is where KDA makes an important refinement. The useful mental model is not that KDA stops information from decaying. It does almost the opposite: KDA makes retention and decay learned, controlled and channel-specific. Different feature channels inside the state can operate at different timescales. One might mostly represent temporary local information, another might carry a persistent constraint, and another might preserve structural context for much longer. KDA therefore gives different channels their own retention behaviour instead of forcing them all to forget at the same rate.There are two controls worth keeping separate: α — retention, how much of the old state should survive, and β — update strength, how strongly the incoming information should rewrite the relevant memory.KDA reads what the state already predicts, writes only the correction, and lets different memory channels retain information for different lengths of time.This is the core improvement — not a larger memory, not infinite memory, but a better-managed fixed-size memory.The catch: better compression is still compressionThis is the part that matters most. KDA does not magically turn a fixed-size state into unlimited memory. Once hundreds of thousands of tokens have been folded into a finite recurrent state, the original key-value pairs are no longer sitting there independently. Their influence survives inside the state, but not with the same retrieval properties as full global attention. If one exact detail appeared 400,000 tokens ago and nothing reinforces it afterward, KDA cannot promise that the detail remains perfectly recoverable. That is not some unfinished bug — it is the structural cost of compressing a growing history into fixed-size recurrent memory. And K3’s response is interesting because Moonshot does not pretend the cost disappeared. It keeps global attention too.Why K3 Still Keeps Global AttentionThree KDA layers, then pay for the expensive operationK3 uses a hybrid attention stack. The recurring pattern is:KDA → KDA → KDA → Gated MLA → repeat69 KDA · 24 Gated MLA · 93 layersThe two mechanisms have different jobs. KDA provides cheap, recurrent long-context memory, while Gated MLA periodically gives the model global token-to-token interaction again. It is worth being precise here: MLA is not simply an uncompressed version of standard attention — it compresses its own KV representation into a latent form. What it restores is something KDA’s recurrent state cannot provide in the same way: global interaction across individual token positions.So K3 is not really doing “replace attention with KDA.” It is doing something more interesting: split one overloaded job between two specialized mechanisms. Most layers use the cheaper recurrent mechanism, and periodically the model pays for the more expressive global operation. Moonshot tested different interleaving ratios, and the 3:1 pattern gave the best trade-off among the configurations they evaluated.Where did positional encoding go?There is another unusual detail in the hybrid design. K3’s global attention layers do not use conventional explicit positional encoding — no RoPE, no ALiBi. The recurrent KDA path is already inherently order-sensitive: if you processA → B → Cyou do not end up with the same recurrent state asC → B → Abecause every token updates the memory created by everything before it. So sequence order already affects the representation flowing into the global attention layers, which lets the hybrid architecture carry order information without asking every global MLA layer to independently reconstruct position through a conventional positional-encoding mechanism.But reaching one million tokens still required training the model progressively on longer contexts — that belongs to Part 3. For now, the important sequence-memory story is complete: KDA makes long-running memory cheap, and Gated MLA periodically restores global interaction. But K3 still has another bottleneck, and it runs in the opposite direction.The Bottleneck Moves Into DepthA 93-layer model creates another kind of recurrenceEverything so far has been about information moving across token positions. Now turn the architecture ninety degrees. K3 is 93 layers deep. In an ordinary Transformer, information moves upward through the residual stream — a layer receives the current representation, transforms it, adds its contribution, and passes the result onward. Imagine Layer 5 creates some representation that becomes useful again at Layer 80. Normally, that information reaches Layer 80 only after passing through every layer in between:Layer 5 → Layer 6 → Layer 7 → ... → Layer 80The information does not necessarily disappear, but after dozens of transformations, something that was once explicit can become mixed, diluted or harder for a later layer to recover. The K3 report compares this to the old bottleneck of recurrent networks, except the recurrence is not happening across time — it is happening across depth. And Moonshot reaches for the same general idea that transformed sequence modelling: attention.Attention Residuals: attention across layersOrdinary attention lets a token selectively retrieve information from earlier token positions. Attention Residuals apply that same idea across network depth. Instead of forcing a deep layer to depend entirely on whatever the previous layer hands it, the architecture gives it a mechanism to retrieve useful information from earlier depth representations.A conventional residual stream carries information through every intermediate layer. Attention Residuals let later layers selectively retrieve useful representations from earlier depth.Each layer produces a small learned pseudo-query describing what kind of information it currently needs. That query is compared with available earlier representations, a softmax determines how much each one should contribute, and the retrieved history is then combined with the normal residual path before computation continues. So instead of relying entirely on a relay -Layer 4 → Layer 5 → Layer 6 → ... → Layer 60- a later layer can selectively retrieve useful information from much earlier in the network. That is the key conceptual jump: standard attention searches across sequence positions, while Attention Residuals search across depth.Making Depth Attention AffordableDirect access creates its own scaling problemThe naive version of Attention Residuals sounds great: keep every earlier layer output alive so later layers can retrieve whichever one they want. At 93 layers, however, the difficult part is not the additional softmax arithmetic — it is memory and communication. All those intermediate representations need to remain available, and in a model distributed across pipeline stages and accelerators, keeping and moving all of that state becomes expensive. Once again, K3 solves one bottleneck and immediately runs into another one created by the solution. So Moonshot compresses the depth history too.Block Attention ResidualsK3 groups the network into blocks instead of maintaining unrestricted fine-grained access to every previous layer across the entire stack. Within a local region, the mechanism can preserve richer depth information; for longer-range access, earlier portions of the network can be represented more compactly at the block level. Conceptually, instead of globally carryingLayer 1, Layer 2, Layer 3 ... Layer 60the model can work with something closer toBlock 1 summary, Block 2 summary, Block 3 summary ...plus finer information from the current region. The trade-off should feel familiar by now: K3 keeps the useful property that later layers can recover information from earlier depth, while reducing the amount of live state required to make that possible.The Pattern Behind K3There is a surprisingly consistent idea running through this architecture. Standard attention is expressive, but using it everywhere becomes too expensive at million-token context, so KDA handles most long-range memory cheaply. KDA is compressed and therefore lossy, so Gated MLA periodically restores global token interaction. Deep residual networks can make earlier representations harder to recover, so Attention Residuals introduce retrieval across depth. Keeping every historical depth representation independently available is expensive, so Block Attention Residuals compress that history again.K3 does not eliminate trade-offs. It architects around them: when an existing mechanism stops scaling, keep the part it does well, move the common case onto something cheaper, and pay for the expensive mechanism only where its precision is actually useful.Part 1 showed that principle across model capacity and expert communication. Part 2 shows the same idea across sequence memory and network depth. In Part 3, we’ll leave the architecture itself and look at how Moonshot trained a model built this way: native vision from the start, progressive context expansion from thousands to one million tokens, and the post-training pipeline that turns the base model into a reasoning and agentic system.Credits: This write-up was developed in collaboration with Shivam Misra https://medium.com/@shivammishrrr, whose insights and contributions helped shape the analysis and discussion.From KV Cache to Depth Attention: The Bottlenecks Kimi K3 Had to Break was originally published in Towards AI on Medium, where people are continuing the conversation by highlighting and responding to this story.