## The PreNorm Dilution Problem
Norris: Welcome back to Mechanical Dreams, the podcast where we untangle the complex webs of machine learning and natural language processing. I am Professor Norris, and as always, I am joined by my brilliant student, Linda. Linda: Hi everyone! I am so excited for today's paper. We are looking at a highly technical and frankly fascinating technical report from the Kimi Team titled Attention Residuals. Norris: Residual connections. The absolute bread and butter of deep learning since ResNets hit the scene back in 2015. You take the input, apply your layer transformation, and just add the original input back to the output. It creates an identity highway for gradients, allowing us to train incredibly deep networks without vanishing gradients. What is possibly left to improve there, Linda? Linda: That is exactly what I thought when I first read the title! But the authors point out a massive blind spot we have all been living with. That fixed unit weight addition is actually a huge bottleneck. Think about what happens when you unroll that recurrence equation over a hundred layers. Norris: Ah. If layer fifty is just layer forty-nine plus its output, and forty-nine is forty-eight plus its output... you end up with every single layer receiving the exact same uniformly-weighted sum of all prior layer outputs. Linda: Exactly! Unlike sequence mixing or expert routing in MoE models, which use learnable, input-dependent weights, this depth-wise aggregation is totally fixed. A layer has no mechanism to selectively emphasize or suppress individual past layer contributions. And this gets really nasty when you combine it with PreNorm. Norris: Right, PreNorm has become the dominant paradigm for modern LLMs because it keeps the identity path completely clean. But the trade-off is that because you apply layer norm before the transformation, the residual stream itself is never normalized. It just accumulates. Linda: Which brings us to the core issue the paper tackles: the PreNorm dilution problem. Because of that unweighted, unnormalized accumulation, the magnitude of the hidden states grows linearly with the depth of the network. It grows as O of L. Norris: I see where this is going. If the residual stream gets mathematically louder and louder as you go deeper, the relative contribution of any new layer gets completely drowned out. The denominator gets huge. Linda: Precisely. The early-layer information gets entirely buried. And if a deeper layer actually wants to influence the network's final output, it is compelled to learn increasingly massive outputs just to overcome that accumulated residual stream. It can severely destabilize training. Norris: That explains a lot, actually. It is a known headache for very deep networks. It also explains why recent empirical studies show you can just prune a significant fraction of layers in deep LLMs with minimal loss in performance. The layers just stop mattering because they are shouting into a hurricane. Linda: That is such a good way to put it! The network suffers from irreversible information loss because that single compressed state conflates all earlier outputs. You cannot selectively retrieve a specific feature computed thirty layers ago. Norris: Alright, you have thoroughly convinced me that the residual connection is secretly plotting against us. So, how does the Kimi Team propose we fix this? Because I imagine dropping residuals altogether is not on the menu.
## Attention Residuals and the Time-Depth Duality
Linda: To fix it, the Kimi Team looked at the problem and realized it looks exactly like the bottleneck we used to have with recurrent neural networks, but flipped on its side. Norris: Ah, the time-depth duality! That is a very elegant framing. RNNs tried to compress all prior sequence history into a single hidden state as you moved forward in time. Just like standard residuals compress all prior network history into a single vector as you move deeper into the layers. Linda: Exactly! And how did the deep learning community fix that bottleneck for sequences? With the Transformer architecture and the attention mechanism. So, the authors propose doing the exact same thing for the depth dimension. They call it Attention Residuals, or AttnRes. Norris: I love a good conceptual symmetry. So, instead of just blindly adding the previous layer's output to the current state, layer fifty is going to compute an attention score over the outputs of layers one through forty-nine? Linda: You got it. They replace the fixed additive recurrence with depth-wise softmax attention. Each layer selectively aggregates earlier representations. And because it uses a softmax function, it forces the layers to compete for probability mass. The network has to actually decide which past layers are most relevant for the current computation. Norris: Okay, let us get into the weeds of how they implement this. Standard attention needs queries, keys, and values. What are those in this depth-wise setup? Linda: The keys and values are simply the outputs of all the preceding layers, plus the original token embedding. The really clever part is the query. Instead of projecting a query dynamically from the current hidden state, which would be computationally heavy, they just use a single learned 'pseudo-query' vector per layer. Norris: Just one d-dimensional vector per layer? That is incredibly lightweight. It adds virtually no parameters to the total model count. Linda: Right! And to make it stable, they apply an RMSNorm to the keys before computing the attention scores. That is crucial because, as we discussed, some layers might have naturally large-magnitude outputs. The RMSNorm prevents those loud layers from unfairly dominating the softmax distribution. Norris: Mathematically, it sounds beautiful. But Linda, I have to put my systems hat on here. This sets off a few alarm bells. If every layer is attending to every single previous layer, you are doing O of L squared attention operations, where L is the depth. And worse, you have to keep all those past layer activations alive in memory! Linda: It sounds scary, but let's break it down. For the compute side, remember that network depth, L, is usually just a few dozen or maybe a hundred layers. Meanwhile, sequence lengths are in the tens or hundreds of thousands. So the O of L squared arithmetic cost is actually a drop in the bucket compared to normal sequence attention. Norris: Fair point. A 100-by-100 attention matrix is basically a rounding error for a modern GPU. But what about the memory? Linda: In a standard, small-scale training loop, it introduces zero memory overhead! Think about it: you already have to keep those layer outputs alive in memory anyway to compute gradients during backpropagation. Norris: Ah, but there is the catch! 'Small-scale' training. Nobody training a frontier LLM does vanilla training anymore. We use activation checkpointing to save memory, discarding activations and recomputing them later. And more importantly, we use pipeline parallelism to split the model across multiple GPUs. Linda: Bingo. And that is exactly where this Full AttnRes formulation hits a wall. Norris: I knew it! Under pipeline parallelism, if layer 50 is on GPU 4, and it needs to attend to the output of layer 1 from GPU 1, you have to explicitly transmit all those intermediate layer outputs across the server boundaries. That means communication overhead grows at O of L times d per token. That will completely choke the interconnect bandwidth. Linda: You hit the nail on the head, Professor. The memory and communication overhead makes Full AttnRes totally impractical for large-scale distributed training right now. But don't throw the paper out just yet, because the Kimi Team anticipated this exact bottleneck and came up with a highly practical compromise.
## Block Attention Residuals
Linda: So, right when the communication bottleneck of Full AttnRes threatens to break the whole idea, the Kimi team introduces their scalable variant: Block Attention Residuals, or Block AttnRes. Norris: Block AttnRes. Let me guess, they chunk the network into manageable pieces to save on memory and communication. Linda: Exactly! They partition the total L layers of the network into N contiguous blocks. Inside each block, it is business as usual. The layers just do your standard, additive residual accumulation. Norris: So layers inside a block just sum up their outputs normally. But what happens at the boundary of the block? Linda: At the boundary, they take that final summed state, treat it as a single block-level representation, and make it available to the attention mechanism. Then, for any layer moving forward, the inter-block attention is only computed over those N block representations, plus the original token embedding. Norris: Ah! That is a very pragmatic compromise. So instead of tracking and transmitting, say, sixty-four individual layer outputs across your GPU cluster, you only track the N block summaries. If N is small, your O of L times d overhead just plummeted to O of N times d. Linda: Precisely. And they still use the RMSNorm inside the attention kernel for this variant. Since block-level representations are accumulating over several layers, their magnitudes can get quite large. The RMSNorm ensures that these beefy block vectors do not completely hijack the softmax distribution. Norris: Smart. But wait, what about the layers inside the current active block? Do they only get to look at the completed past blocks? Linda: Great catch! For any layer inside the current block, the attention keys include all the previous completed block representations, the token embedding, and the evolving partial sum of the current block up to that point. So it always has access to its immediate local context as well as the macro-history. Norris: Okay, that is a very elegant setup. But I have to ask about the trade-off here. By compressing, say, eight layers into one block, you are essentially blurring the network's vision. You lose the ability to selectively retrieve a specific feature from just one of those layers. Does the performance tank? Linda: You would absolutely think so, right? But their ablation studies show something fascinating. They tested different block sizes, sweeping all the way from Full AttnRes down to very coarse blocks. It turns out, using just about eight blocks recovers almost all the performance gains of Full AttnRes across different model scales! Norris: Only eight blocks? That implies the network does not actually need microscopic, layer-by-layer retrieval most of the time. It just needs macro-level access to the distant past. Linda: Exactly! To prove this, they actually compared Block AttnRes to a sliding-window approach that only remembers the most recent eight individual layers. Block AttnRes blew it out of the water. It proves that selectively accessing distant layers is much more valuable than having high-resolution access to just your immediate neighbors. Norris: That is a profound insight into how these models route information. Grouping layers acts almost like an implicit regularization. It smooths out the local noise while preserving the major architectural highways. Linda: Yes! And keeping N around eight means we only need to store eight hidden states per token. Suddenly, the memory and communication overhead is entirely manageable for large-scale training. Norris: Manageable, yes. But manageable still means we have to actually implement it in the real world. If I am running pipeline parallelism, I still have to pass those eight block vectors across my pipeline stages. And do not even get me started on inference! A KV cache for depth sounds like an absolute nightmare for latency. Linda: I am so glad you brought up inference and systems, Professor. Because the engineering gymnastics they perform to make this run efficiently at scale might just be my favorite part of the whole paper.
## Infrastructure and System Optimizations
Linda: You ended the last segment exactly where the authors' minds were, Professor. Because if you naively transmit all those accumulated block representations across your pipeline stages at every single transition, you are going to incur a massive amount of redundant communication. Norris: Right! If my network is split across four GPUs, and GPU 3 needs the history, I do not want GPU 2 sending Block 1, then sending Block 1 and 2, then sending Block 1, 2, and 3. That is a completely unnecessary traffic jam on the interconnect. Linda: And the Kimi Team completely agrees with you. To solve this, they implemented what they call cross-stage caching. Since each physical GPU processes multiple virtual stages in succession, they just cache the blocks locally. When a stage boundary is crossed, the sending GPU only transmits the incremental new blocks that were just completed. Norris: Ah, of course. You just send the delta. If GPU 3 already cached the first four blocks during an earlier micro-batch, GPU 2 only needs to send block five. That is a classic systems optimization. Linda: Exactly! That caching trick reduces the peak per-transition communication cost by a factor of V, the number of virtual stages. It allows the communication to fully overlap with computation during the steady state. The end-to-end training overhead under pipeline parallelism ends up being less than four percent. Norris: Less than four percent overhead for a fundamentally different routing architecture? That is incredibly impressive. But Linda, I am still waiting for the other shoe to drop. Inference. Autoregressive decoding is notoriously memory-bandwidth bound. If every single layer has to read those block summaries from memory, your generation speed is going to crawl. Linda: You are thinking of a naive implementation, where you evaluate the attention residual sequentially at every layer. But remember what we talked about in chapter two? How is the query vector generated? Norris: You said it was a single learned pseudo-query vector per layer. Wait... a learned vector is just a static parameter. It does not depend on the hidden state of the current token! Linda: Bingo! Because the queries are decoupled from the forward computation, you do not have to wait for layer 10 to finish before computing the attention weights for layer 11. They built a Two-Phase computation strategy to exploit this. In Phase 1, they batch the inter-block queries for all layers within the current block into a single matrix multiplication. Norris: Oh, that is beautiful. Instead of reading the block history from High Bandwidth Memory S times for S layers in a block, you read it exactly once, compute all the attention scores for the whole block simultaneously, and just hold them in fast memory. Linda: Exactly. That amortizes the memory access cost entirely. Then, in Phase 2, they compute the sequential intra-block attention for the immediate local layers, which is tiny. Finally, they merge the parallel Phase 1 results with the sequential Phase 2 results. Norris: Let me guess how they merge them. You cannot just add softmax outputs together... they must be using online softmax, keeping track of the running max and log-sum-exp. Linda: You read my mind! They use online softmax, which happens elementwise and naturally admits kernel fusion. It keeps the I/O footprint almost identical to standard residual connections. The inference latency overhead is measured at less than two percent. Norris: Two percent. I have to tip my hat to the engineers on this team. But what about long-context prefilling? If I feed this a 128K-token document, storing those N block representations for every single token is going to eat my GPU memory alive. Linda: They solved that too! A 128K sequence with 8 blocks would normally take about 15 gigabytes of memory just for this depth cache. But they shard these representations along the sequence dimension across the Tensor Parallel devices. Norris: Sequence sharding! So if you have 8 GPUs, each one only holds an eighth of the sequence's depth cache. Then you just use the standard all-reduce communication path to stitch it together during the online softmax merge. Linda: Right! That reduces the per-device footprint from 15 gigabytes to about 1.9 gigabytes. And when they combine it with chunked prefilling, the overhead drops to under 0.3 gigabytes per device. It is practically free. Norris: Okay, I am officially out of skeptical systems questions. They have successfully defended the architecture, the training scale, and the inference latency. Now, you need to tell me if all this brilliant engineering actually resulted in a better language model.
## Results, Scaling Laws, and Wrap-up
Linda: It absolutely did! To prove it, the Kimi Team first validated the architecture with a rigorous scaling law experiment. They trained five different model sizes, sweeping all the way up to 528 million parameters, and plotted the validation loss against the compute budget. Norris: The ultimate test in modern deep learning. Did the Block Attention Residuals actually shift the Pareto frontier? Linda: It shifted it beautifully. Across the entire compute range, Block AttnRes consistently achieved lower validation loss than the standard PreNorm baseline. To put it in perspective, at their largest scale, the Block AttnRes model matched the performance of a baseline model that used 1.25 times more compute. Norris: A twenty-five percent compute advantage. When you are talking about pre-training frontier models, that translates to millions of dollars in saved GPU time. Did they actually take the leap and scale it up to a full production-size model? Linda: Yes, they did. They integrated Block AttnRes into the Kimi Linear architecture, creating a 48-billion parameter Mixture-of-Experts model. It uses about 3 billion active parameters per token, and they pre-trained it on a massive 1.4 trillion tokens. Norris: And the downstream benchmarks? I have to imagine that the ability to retrieve exact features from early layers is particularly useful for tasks that require long chains of logic. Linda: You hit the bullseye. The improvements were especially pronounced on multi-step reasoning and compositional tasks. On GPQA-Diamond, it jumped by 7.5 points over the baseline. Minerva Math improved by 3.6 points, and HumanEval for code generation went up by 3.1 points. Norris: That perfectly aligns with the theory we discussed back in chapter one. In a complex coding task or a multi-step math proof, you often need to recall a specific variable or premise processed much earlier in the network. Having direct, selective access to those early layers via attention is exactly what you need. Linda: Right! And to bring it all full circle, the authors visualized the training dynamics to prove they definitively solved the PreNorm dilution problem. Just like we hoped, the output magnitudes no longer grow linearly with depth. Because the block boundaries reset the selective accumulation, the hidden state magnitudes form this beautifully bounded, periodic pattern. Norris: So the deeper layers are no longer shouting into a hurricane just to be heard over the accumulated residual stream. And I assume the gradient flow looks much healthier as a result? Linda: Much healthier. Because the learnable softmax weights introduce competition among the sources for probability mass, the gradients are distributed far more uniformly across the network depth, rather than disproportionately blowing up in the earliest layers like they do in the baseline. Norris: It is incredibly satisfying when a theoretically elegant concept like the time-depth duality actually translates into clean engineering, concrete scaling improvements, and stabilized training dynamics. This was an excellent paper, Linda. Thank you for bringing it in. Linda: My pleasure, Professor! It is always thrilling when a team completely reimagines a component we all take for granted. Thank you for listening, everyone, and keep dreaming mechanically!