## The Inference Bottleneck Norris: Welcome to Mechanical Dreams, the podcast where we tinker with the gears of machine learning and natural language processing. I am Professor Norris, and as always, I am joined by my brilliant student, Linda. Linda, what mechanical dream are we exploring today? Linda: Hi Professor! Thanks for the wonderful intro. Today, I am super excited because we are looking at a systems-level architecture paper. It is called Decode-Branch Transformers: Decoupling the Primary Prefill Path from Additional Decode Computation, by Liu and colleagues from Georgia Tech and Peking University. Norris: Systems-level, you say? That usually means we are trying to squeeze more juice out of our hardware without buying a warehouse full of new GPUs. I am intrigued. But before we get into the Decode-Branch part, we need to set the stage for our listeners. What exactly is the problem they are trying to solve? Linda: The core problem is something anyone deploying large language models knows all too well: the inference bottleneck. When you ask an LLM a question, the inference process happens in two very distinct phases that demand completely different things from our hardware. Norris: Ah, yes. The classic prefill versus decode asymmetry. It is the bane of my existence when looking at server cluster costs. Walk us through it. Linda: Absolutely! Phase one is the prompt prefill. This is when the model reads your entire input prompt. Because all the prompt tokens are available at once, the model can process them in parallel. It loads the weights once and performs massive matrix multiplications. So, prefill is generally compute-bound. The GPUs are happily crunching numbers at maximum arithmetic throughput. Norris: Right, it is highly efficient. But it also constructs the persistent Key-Value cache, or KV cache, storing the attention keys and values for all those prompt tokens. And then we hit phase two, the autoregressive decode phase, where things slow down to a crawl. Linda: Exactly. In the decode phase, the model has to generate one token at a time. To generate a single new token, it has to read the entire model weight matrix and the entire growing KV cache again. It is incredibly sequential. Because we are moving so much data just to do a tiny bit of math for one token, decoding is memory-bandwidth-bound, not compute-bound. Norris: It is like renting a massive freight train to deliver a single envelope, and then renting it all over again for the next envelope. So, under conventional scaling, if we make the model wider or deeper to get better reasoning, we punish both phases. We are increasing the amount of weights we have to read at every single decode step, which drives up our latency and cost immensely. Linda: Spot on. The authors of this paper ask a brilliant question: since decoding is bottlenecked by memory traffic and leaves our arithmetic compute units underutilized, what if we could just allocate extra learned computation specifically to the continuation prediction? What if we could use that idle compute to make the model smarter? Norris: Let me guess: they want to use that idle compute during the decode phase without expanding the weights we have to fetch, and without making the prefill phase any heavier. It sounds like a free lunch, Linda. And you know how I feel about free lunches. Linda: I know you are naturally skeptical, Professor! But they actually pull it off by physically decoupling the architecture into a primary path and a separate decode branch, which we will dive right into. ## Enter the Decode-Branch Norris: Alright Linda, you promised me a free lunch. Or at least, a highly discounted one. How exactly does this 'Decode-Branch Transformer' use our idle compute during decoding without ruining our prefill phase? Linda: It all comes down to a phase-decoupled architectural objective. The authors designed a single model with two separate paths. First, there is a complete primary causal path. During the prefill phase, this primary path works exactly like a standard Transformer. It processes the prompt all by itself and writes to the KV cache. Norris: Okay, so during prefill, it is business as usual. No extra FLOPs, no weird overhead to slow down that compute-bound phase we just established. Linda: Exactly! The magic happens with the second path: the decode branch. Because the primary path is completely self-contained, the decode branch is just turned off, or omitted entirely, during the earlier prompt positions. It only wakes up at the continuation boundary—which is the final prompt token—and stays awake for every generated token after that. Norris: I see. So we are explicitly targeting that memory-bound decode phase. But here is where my skepticism kicks back in. I have seen methods before that try to add parallel streams or latent computation inside the model. They usually require you to maintain stream-specific histories. Doesn't this branch need its own KV cache to remember what it was thinking? Linda: That is the trap they avoid. The decode branch reads the primary KV cache, but it never writes a persistent state of its own. And crucially, it never feeds back into the primary path. The primary path has absolutely zero dependence on the branch. Norris: Wait, so the primary path is completely oblivious to the fact that this decode branch even exists? It just goes about its business appending one set of keys and values at each step? Linda: Yes! The primary path just appends its keys and values to the cache, just like a standard autoregressive model. The decode branch simply forms its own queries and reads that shared, single KV cache. Norris: That is actually quite brilliant. By not having a persistent branch state, the total KV cache size remains exactly the same as a conventional model. Anyone who has tried to deploy these models knows that the KV cache is a massive memory hog, especially for long-context windows. Keeping it single and shared is a huge systems win. Linda: It really is. Think about how this contrasts with other test-time compute methods. Things like Chain-of-Thought or pause tokens spend their budget externally by generating more tokens, which forces you to run the whole sequential autoregressive loop more times. Norris: Right, and other internal parallel-stream methods, like Hidden Decoding, usually end up participating in the prompt processing, which slows down your prefill, or they bloat the memory with separate caches. Linda: Exactly. Decode-Branch enforces strict phase-decoupling. You get a complete primary causal path, no persistent branch state, and extra computation that is applied exclusively at continuation-prediction steps. Norris: I am almost entirely convinced, but there is one glaring issue we haven't touched. If the branch is doing a whole parallel track of computation to generate its own queries and states, doesn't it need its own parameters? Because if we are loading a second set of weights from off-chip memory during the memory-bound decode phase, we have defeated the whole purpose. We would just be bottlenecked by memory all over again. Linda: You are right on the money, Professor. If they just slapped a second set of layers in there, it would be a disaster for latency. But they do something incredibly clever with weight sharing and grouped execution to make sure the added arithmetic does not proportionally increase the memory traffic. Norris: Oh? You have my attention again. Grouped execution sounds like a systems engineer's dream. How exactly are they sharing these weights without the two paths just collapsing into the exact same representations? Because if the weights are the same and the inputs are the same, the outputs will be the same. Linda: That is the perfect segue. They keep the representations distinct right from the beginning, and use something called asymmetric shared-KV attention to let them interact. We should unpack the exact math of how they share those heavy matrices. ## Asymmetric Attention & Shared Weights Norris: So, Linda, picking up where we left off. If the primary path and the decode branch are sharing the same heavy weight matrices, how do they not just collapse into identical representations? Linda: They prevent that right at the starting line. The model uses completely independent token embedding tables for the two paths. The primary path gets its starting vector, and the decode branch gets a different one. Norris: Ah, I see. They start at different coordinates in the vector space. But once they hit the first transformer block, they share the dense projections. How does that work in practice? Linda: They share the query, key, and value projection matrices. The primary path computes its queries, keys, and values exactly like a standard causal transformer. But the decode branch is only allowed to produce a new query. Norris: That makes perfect sense. It doesn't need to produce keys and values because it doesn't have its own KV cache. It is just going to attend to the primary path's cache. Linda: Exactly. And because the projection matrices are shared, the hardware can stack the residual states of both paths and run a single grouped matrix multiplication. Norris: That is the systems win right there! You fetch the massive weight tile from off-chip memory once, and compute the projections for both paths simultaneously. Since we are in the memory-bound decode phase, that extra arithmetic throughput is essentially free. Linda: Bingo. But they don't want the paths to remain completely isolated. They use learned coupling vectors to let information flow from the primary path into the branch. Norris: How do they do that without breaking the asymmetric rule? We established earlier that the primary path absolutely cannot depend on the branch. Linda: It is strictly a one-way street. Before the branch computes its attention, it takes its query and adds a piece of the primary path's query, scaled by a learned vector. They do this same element-wise coupling inside the shared MLP as well. Norris: So the branch is constantly getting enriched by the primary path's intermediate states. The primary path is entirely oblivious to this, which perfectly preserves the asymmetry. Linda: Yes, and because these coupling vectors are just simple element-wise operations broadcast across tokens, they add virtually zero overhead. They account for less than zero point one percent of the non-embedding parameters. Norris: Okay, so we have these two intertwined paths cruising through the network. The primary path is driving the KV cache, and the branch is doing extra parallel thinking. How do they actually predict the next token? Do they just average their final logits? Linda: It is a bit more sophisticated than that. Both paths hit a shared output matrix, yielding two probability distributions. The final prediction is a dynamic mixture of both. Norris: Dynamic? So the mixture weight changes based on the token being generated? Linda: Exactly. They use a confidence score based on the primary distribution's concentration. Mathematically, it is the collision probability, which is the chance that two independent samples from the primary path would produce the exact same token. If the primary path is highly concentrated and confident, it dominates the mixture. Norris: And if the primary path is uncertain, the collision probability is low, so the model leans more heavily on the decode branch's distribution. That is a very elegant way to handle it. I imagine they let gradients flow through that weighting during training? Linda: They do! It gives the decode branch a direct training signal, so the model learns exactly when that extra computation is actually useful. They also clip the weight so the primary path always contributes at least fifty percent, keeping the prediction anchored. Norris: Incredible. It seems they have completely solved the dense model. But earlier, you teased something about sparse Mixture-of-Experts. MoE models are notoriously tricky. If the two paths route to completely different experts, our grouped execution trick falls apart, because we would have to load twice as many expert weights from memory! Linda: That is a massive challenge, and it is where a concept called 'router replay' comes in. It is easily my favorite part of the paper, and we should definitely dive into how they fix the MoE routing next. ## Mixture of Experts and Router Replay Norris: Alright, Linda, you left us hanging on quite the cliffhanger. We established that for dense models, grouping the matrix multiplications saves us from the memory bandwidth bottleneck during decoding. But modern LLMs are increasingly moving toward sparse Mixture-of-Experts, or MoE, architectures. Linda: Exactly. And MoE introduces a huge complication here. In a standard MoE layer, you replace the dense MLP with a bank of expert networks. For each token, a router selects a small handful of those experts, say the top two or top four, to actually process the data. Norris: Which is great for scaling capacity without scaling per-token FLOPs. But in our Decode-Branch setup, the primary path and the decode branch are independent. If the branch's router decides it wants completely different experts than the primary path, we suddenly have to fetch twice as many expert weights from off-chip memory! Linda: And that would completely destroy the grouped execution benefit we praised in the last chapter. We would be right back to being bottlenecked by memory traffic. To solve this, the authors introduce a mechanism they call router replay. Norris: Router replay? Does the primary path just dictate the routing probabilities to the branch? Linda: Not quite the probabilities, just the selection! The primary path acts as the boss. It computes its router logits and selects its top-k experts. The decode branch still computes its own router logits, but it is not allowed to pick its own top-k. Instead, it is forced to gather its routing weights only at the indices that the primary path selected. Norris: Oh, that is incredibly clever! Both paths execute the exact same set of experts, meaning the hardware only has to load those specific expert weights from memory once. But because the branch evaluated its own logits, it can still assign its own unique combination weights to those experts. Linda: Exactly. The referenced expert weights are identical, loaded once, and applied to both hidden states simultaneously. It preserves the memory footprint perfectly while still giving the branch flexibility. Norris: I have to admit, that is an elegant fix. It keeps the latency down. But knowing this field, researchers never just stop at a single configuration. If we have decoupled these paths, does that mean we can start playing with how much compute we assign to each? Linda: You read their minds, Professor. This is where they introduce phase-specific expert allocation. For these experiments, they actually drop the router replay and use independent routing, specifically so they can assign a different number of experts to the primary path versus the decode branch. Norris: Ah! So instead of both paths using, say, four experts, the primary path could use four, and the decode branch could use eight? Linda: Exactly! They call that the fixed prefill budget regime. You lock in the primary expert count, so your prompt processing cost and KV cache size stay exactly the same. But you increase the branch's expert count to give the model extra continuation compute. Norris: That would be highly attractive for workloads where prefill is the binding constraint. Say, single-machine deployments or fragmented requests where you have spare arithmetic headroom during decoding. Did this actually improve the model's predictive quality? Linda: It did! They found that as the branch expert budget grows, the validation loss decreases monotonically. So fixing prompt computation and adding decode-side expert compute translates directly into better reasoning and quality. Norris: Fascinating. But what about the inverse? What if I am running a highly batched, throughput-oriented server where decode capacity is my actual bottleneck, and I want to squeeze more efficiency out of the prefill? Linda: They tested that too, in their fixed decode budget experiments. Here, you lock the total number of decode experts. Say the total budget is eight experts per decode token. You can allocate all eight to the primary path, or you can split it: say, two for the primary path, and six for the decode branch. Norris: Let me think about that. If I shift experts away from the primary path, I am drastically reducing the prompt-wide arithmetic. My prefill becomes much cheaper. But because the decode branch picks up the slack with those six experts, my decode cost stays the same. Linda: Spot on. And they found that a half-prefill allocation, where the expert budget is split evenly between the two paths, improved over a standard MoE baseline while using fifty percent fewer routed-expert applications during the prompt processing! Norris: Half the prompt compute for better quality? That exposes a fantastic three-way trade-off surface between prefill cost, decode cost, and predictive quality. A serving engineer could dynamically select a point on that surface depending on their live workload. Linda: Exactly, Professor. It gives deployment-specific flexibility without having to change the shared parameter pool or train multiple different models. ## Training Costs and Takeaways Norris: This all paints an incredibly rosy picture for inference, Linda. But as a seasoned academic, my 'too good to be true' alarm is ringing. What is the catch when we actually have to train this Decode-Branch Transformer? During training, every single token is essentially a continuation boundary for the next one. Linda: You caught the catch perfectly, Professor. The prompt-side compute savings we just praised are strictly an inference-time property. During training, both the primary path and the decode branch have to be evaluated at every single token position across the full sequence length. Norris: I knew it! Since the shared attention and MLP backbone is applied once to each path, that means a single training step for a Decode-Branch model requires approximately twice the dominant training FLOPs of a standard Transformer. Not to mention the extra activation memory to store both residual trajectories. Linda: That is exactly right. It is roughly double the training compute per step. But the authors anticipated that critique. They ran an approximate training-compute matched experiment using their NanoGPT setup to see if that extra compute was actually worth it. Norris: Oh? So they compared a standard model trained for twice as many steps against the Decode-Branch model? What were the results? Because usually, just shoving more data through a standard model is very hard to beat. Linda: They did exactly that. They compared a standard Transformer trained on twenty times the base data budget against a Decode-Branch model trained on only ten times the budget. Even under that strict compute-matched accounting, the Decode-Branch model reached a lower final validation loss. Norris: Well, I stand corrected. If it beats a compute-matched baseline, that proves that allocating training compute across two interacting paths is fundamentally more effective than just spending it on additional tokens for a single flow. Linda: Exactly! And they saw consistent gains not just at the NanoGPT scale, but also in dense LLaMA-style model-size scaling up to one billion parameters, and of course in the sparse MoE configurations we just discussed. Norris: It is a remarkably thorough paper. It gives us a structural opportunity to phase-decouple our models, optimizing prefill and decode independently without blowing up that dreaded KV cache. I think this will give systems engineers and researchers a lot to chew on for the next generation of LLMs. Linda: I completely agree. It is a brilliant example of co-designing the model architecture with the hardware bottlenecks in mind. Norris: Well, that brings us to the end of today's episode. Thank you, Linda, for walking us through this fantastic paper, and thank you to our listeners for joining us. Keep dreaming in mechanics, and we will see you next week on Mechanical Dreams.