LLM Architecture Evolution: KV Cache Reuse and MoE vs. Dense Deployment

    As models grow in parameter count and context length, the balance of cost shifts from one-time training to ongoing inference. This article explains how modern LLM architectures tackle inference cost through two main strategies: compressing KV Cache to cut memory usage and long-context overhead, and choosing between Mixture-of-Experts (MoE) and dense designs. It walks through how KV Cache memory is calculated, why cross-head (MQA/GQA) and cross-layer reuse reduce redundancy, the tradeoffs between MoE and dense models, how these choices map to edge and cloud deployment, and practical guidance on where developers should optimize first.

    1. Why Inference Architecture Is the Next Battleground for LLMs

    As model parameter counts and context lengths keep climbing, the one-time cost of training gradually gives way to the ongoing cost of inference. Once a model goes live, it serves thousands of requests, and every step of autoregressive decoding has to revisit all the historical information again.

    Whoever can turn “recompute the history at every step” into “incremental computation at every step” will produce higher throughput per unit of compute.

    This is the core problem driving recent LLM architecture evolution: reducing KV Cache memory usage, lowering the compute cost of long contexts, and making sensible tradeoffs between the mixture-of-experts and dense routes — all without sacrificing model quality. This article focuses on these three questions.

    2. KV Cache: The Real Source of Memory Overhead

    In standard autoregressive Transformer decoding, every time a new token is generated, the model must attend to all historical tokens. To avoid recomputing the projections for the history sequence, engineering practice caches the already-computed Key and Value vectors for every attention head in every layer. This is KV Cache.

    Its cost can be described by an intuitive formula:

    1. KV_Cache memory ≈ 2 × num_layers × num_kv_heads × head_dim × seq_len × batch × bytes_per_element

    Here the factor of 2 corresponds to the two tensors, K and V. The formula reveals a key fact: KV Cache usage is proportional to sequence length and batch size, and grows linearly with the number of layers and heads. In long-context scenarios, KV Cache often exceeds the model weights themselves and becomes the number-one memory bottleneck. It also hurts on two fronts at once: if the cache does not fit in memory, you can only shrink the batch, and a small batch caps throughput; meanwhile, attention must traverse the entire history, so the longer the sequence, the slower each decoding step becomes.

    So any architecture-level optimization is essentially answering one question: how do we reduce one factor in this formula without significantly hurting quality?

    3. Cross-Head and Cross-Layer Reuse: Cutting Redundancy at the Source

    The industry has developed a whole family of optimizations around “KV redundancy,” which can be grouped into two categories.

    3.1 Cross-Head Sharing: Multiple Heads Sharing One KV

    In traditional multi-head attention, every head independently maintains its own K and V, so KV Cache grows linearly with the number of heads. In practice, it turns out that Query heads have a lot of redundancy in what they need from K and V. This led to two progressively more aggressive approaches:

    • Multi-Query Attention (MQA): all Query heads share a single set of K and V, compressing the “KV head count” factor to 1, at the cost of a slight quality drop.
    • Grouped-Query Attention (GQA): Query heads are split into several groups, and heads within a group share one set of K and V — a balance between MQA’s extreme compression and multi-head attention’s high quality. Most mainstream models today use GQA.

    3.2 Cross-Layer Reuse: Later Layers Referencing Earlier Layers’ KV

    A further step is cross-layer sharing. The core observation is that the attention patterns of several adjacent layers are highly similar, so recomputing KV from scratch at every layer involves obvious redundant computation. This motivates a cross-layer reuse mechanism: certain later layers no longer compute Key-Value independently, but instead directly reference the KV tensors already computed by earlier layers.

    This “cross-layer KV tensor reuse” delivers a twofold benefit:

    • Memory side: it directly reduces the effective number-of-layers factor in the formula, significantly lowering memory usage under long contexts.
    • Compute side: it eliminates the KV projection computation for the reused layers, making each decoding step faster.

    It is worth emphasizing that cross-layer reuse is not lossless. After all, different layers carry different representational responsibilities, and excessive reuse weakens the model’s expressive capacity. So in practice, only some layers usually participate in sharing, and the structure is introduced during the training stage so the model learns to work under the sharing constraint — which is exactly why architectural innovation and model training must be co-designed.

    4. MoE vs. Dense: Weighing Two Architecture Paths

    Beyond KV optimization, the other main thread is the question of “how many parameters actually participate in computation.”

    Dense architecture: every token passes through all the parameters, so compute is strictly tied to parameter count. Its strengths are stable training, a mature post-training workflow (fine-tuning, alignment), abundant accumulated engineering experience, and the fact that problems are relatively easy to locate and tune.

    Mixture-of-Experts (MoE) architecture: the feed-forward layers are split into multiple “experts,” and a routing (gating) network selects a few experts to participate in computation for each token. Its core advantage is that the total parameter count is very large, but the parameters activated per token are few, so it can hold more knowledge under the same activated compute, or reduce inference cost under the same quality.

    But MoE comes at a cost:

    • Routing instability: load balancing across the gating network is difficult, and experts tend to be unevenly utilized, which requires an additional load-balancing loss to constrain.
    • Harder post-training: sparse activation makes gradient signals sparser, so the stability of fine-tuning and alignment is worse than with Dense, and the tuning bar is higher.
    • Deployment complexity: when experts are distributed across different devices, additional communication overhead is introduced, which places higher demands on distributed inference frameworks.

    So a practical rule of thumb is: for scenarios that pursue extreme local inference efficiency and can tolerate post-training complexity, lean toward MoE; for scenarios that pursue a quality ceiling and value the convenience and stability of post-training, lean toward Dense. Neither is superior to the other — they are simply the optimal solutions under different constraints.

    5. Differentiated Deployment for Edge and Cloud

    Architecture choices ultimately have to land on a deployment form. The industry typically tiers models by target scenario:

    • Edge / embedded small models: aimed at local devices like phones and IoT, emphasizing a minimal memory footprint and low power consumption. These models usually rely on structural compression such as cross-layer KV reuse and GQA, combined with quantization, to bring resident memory within what the device can handle.
    • Mid-size models for efficient local inference: often use MoE, trading “sparse activation” for a higher quality density — a good fit for local environments that have some compute but want to control cost.
    • Large models pursuing a quality ceiling: tend toward dense structures, paired with a mature post-training pipeline, putting resources into quality rather than extreme sparsification.

    At the cloud deployment level, these architectural properties directly affect resource orchestration. Developers can use a general-purpose container platform for elastic scaling, use object storage to host model weights, and use monitoring and alerting to track memory and throughput metrics, adjusting batching strategies dynamically based on real load. When making a choice, there is no need to blindly chase the newest approach; instead, weigh it against the business’s long-context ratio, concurrency scale, and latency requirements.

    6. Practical Recommendations for Developers

    1. Quantify the bottleneck before optimizing: first use the KV Cache formula above to estimate memory usage, confirm whether the bottleneck is weights or KV, then decide the optimization direction.
    2. Prioritize zero-cost techniques: GQA, KV quantization (such as lowering cache precision), and paged memory management can usually deliver significant gains at a small quality cost and should be evaluated first.
    3. Structural optimizations need training coordination: changes like cross-layer reuse must be introduced during training rather than forced on at inference time, otherwise the quality loss is uncontrollable.
    4. Align architecture choices with the business: scenarios heavy on long context and high concurrency benefit more from KV optimization and sparse activation; scenarios heavy on post-training and stability are better suited to Dense.

    7. Conclusion

    The evolution of LLM architecture is essentially an ongoing negotiation around “inference cost”: from cross-head to cross-layer KV reuse to compress memory and compute, and from the MoE-to-Dense tradeoff to balance quality density against engineering complexity. Understanding the tradeoff logic behind these mechanisms matters more than memorizing the parameters of any specific model — because real engineering capability is the ability to make the right tradeoff under given constraints.