KV Cache Optimization and Mixture-of-Experts: New Trends in LLM Architecture

    This article examines why KV Cache has become a critical bottleneck in long-context LLM inference and how recent architecture trends address it. It analyzes cross-layer KV sharing, the tradeoffs between small edge models, Mixture-of-Experts models, and dense models, and provides practical engineering guidance for deployment, quantization, cache management, and long-context evaluation.

    1. Background: In the Long-Context Era, Architecture Design Priorities Have Shifted

    Over the past year or so, LLM architecture iteration has shown a very clear common theme: reduce memory overhead and improve throughput during inference, especially by lowering KV Cache usage. This is not accidental. As reasoning models that require long chains of thought and agent applications that need very long sessions and multi-turn tool calls become mainstream, the context length a model must handle during inference has risen rapidly from a few thousand tokens to hundreds of thousands or even millions. The key-value state cache (KV Cache) introduced by traditional attention mechanisms has become one of the most expensive resources in the entire inference pipeline.

    Several recently released open-weight models from different teams respond to this theme from different angles: some reduce cache size by reusing KV states across layers, some use Mixture-of-Experts (MoE) structures to expand total model capacity at the same activated parameter count, and others stay on the dense path to obtain more stable training and post-training behavior. This article breaks down these evolution directions one by one from a neutral technical perspective.

    2. Why KV Cache Matters So Much

    To understand the motivation behind recent architecture changes, we first need to clarify the KV Cache cost model.

    2.1 Where KV Cache Comes From

    Transformer autoregressive decoding generates tokens one by one. When generating the t-th token, the attention layer needs the Key and Value vectors of all previous tokens. To avoid recomputing the projections of historical tokens at every step, inference frameworks cache them. This is the KV Cache.

    Its memory usage can be estimated with a general formula:

    1. KV Cache memory ≈ 2 × number of layers L × sequence length S × attention head dimension H × precision bytes B × batch size Batch

    For a typical medium-to-large dense model, if the model has many layers, a large head dimension, and a 128K context, the KV Cache for even a single request may exceed the memory required by the model weights themselves. Under multi-request concurrency, the bottleneck becomes even more pronounced.

    2.2 Three Cost Dimensions of KV Cache

    1. Memory cost: KV Cache grows linearly with sequence length, directly limiting the context length and concurrency a single GPU can serve.
    2. Bandwidth cost: During decoding, every generated token requires reading all historical KV states. The memory access volume is much larger than the compute volume, making decoding a classic memory-bandwidth-bound task.
    3. Scheduling cost: KV Cache size is uncertain and grows dynamically with requests, complicating memory allocation, request preemption, and batch scheduling.

    Therefore, the fundamental goal of “shrinking KV Cache” is to reduce inference memory usage and thereby support longer context windows and higher concurrent throughput. This is especially critical in the era of reasoning models and agents: if an agent that repeatedly reviews long historical records carries the full KV state every round, the cost becomes unacceptable.

    3. Cross-Layer KV Reuse: A Technical Analysis of Shared Cache Mechanisms

    3.1 Basic Idea

    A recently released family of open-weight small models designed to be edge-friendly introduced a notable mechanism: subsequent layers no longer independently compute and cache their own Key-Value states; instead, they reuse KV tensors already computed by earlier layers. This is often called cross-layer attention or a shared KV Cache mechanism.

    The principle relies on an empirical observation: in deep networks, the attention patterns of several adjacent layers are highly similar, and maintaining a full set of KV states for every layer is redundant. If a group of layers shares the same KV states, the KV Cache size can theoretically be compressed several-fold with almost no quality loss.

    Similar ideas have existed in the academic community for some time; for example, some papers published at top conferences have explored the effect of cross-layer attention on reducing cache size. The significance of this recent evolution is that such methods have been deployed at scale in mainstream open-weight models for the first time, showing that their engineering feasibility has been validated through large-scale training and evaluation, moving from “an option in papers” to “a production approach that can be directly borrowed.”

    3.2 Key Implementation Design Points

    Implementing cross-layer KV sharing in engineering requires handling several details:

    • Sharing granularity: Should one KV set be shared every N layers, or should only a small number of KV groups be maintained globally? Finer granularity yields a smaller cache, but representational capacity may be limited, requiring a tradeoff between quality and memory.
    • Query independence: Usually each layer still keeps its own Query projection, and only Key/Value are shared. In this way, attention weights remain layer-specific and the loss remains controllable.
    • Combination with grouped-query attention (GQA): GQA reduces cache size by reducing the number of KV heads, while cross-layer sharing further compresses along the layer dimension. The two are orthogonal and can be combined.

    An illustrative pseudocode expression is as follows:

    1. # Regular layer: independent cache per layer
    2. cache[l] = (K_l, V_l) # one copy per layer
    3. # Cross-layer sharing: one copy every N layers
    4. if l % N == 0:
    5. cache[l // N] = (K_l, V_l)
    6. shared_kv = cache[l // N]
    7. else:
    8. shared_kv = cache[(l // N) * N] # reuse previous KV
    9. attn_out = Attention(Q_l, shared_kv.K, shared_kv.V)

    For small models targeting mobile and embedded devices—often collectively referred to as “on-device small models”—memory and power budgets are extremely tight. Such mechanisms can directly determine whether long-context capability is usable, so it is not surprising that they were adopted first.

    4. Three Model Forms: Differentiated Tradeoffs Under the Same Theme

    The recent open-weight model ecosystem has roughly split into three forms, each responding to different deployment requirements:

    4.1 On-Device and Embedded Small Models

    For small-parameter models targeting resource-constrained scenarios such as phones and IoT, the core requirement is to run a usable long context within extremely small memory. In addition to the cross-layer KV sharing described above, this type of model often combines quantization-friendly designs, small head dimensions, and fewer layers. Their technical significance lies more in “validating the effectiveness of new mechanisms at small scale,” paving the way for later larger-scale adoption.

    4.2 Mixture-of-Experts (MoE) Models

    The MoE architecture takes a different approach from KV compression: through a routing mechanism, each token activates only a small number of expert sub-networks, allowing the model to operate in a form with very large total parameter count and very small per-token activation. The benefits appear in two areas:

    • Inference compute is related to activated parameters; a small activated parameter count means faster decoding.
    • A large total weight capacity means greater knowledge capacity and a higher model quality ceiling.

    But MoE also has costs: weight memory usage increases rather than decreases, and training stability, expert load balancing, and post-training (such as preference alignment and instruction tuning) are significantly more difficult than with dense models. In practice, specialized load-balancing losses, routing regularization, and more careful hyperparameter search are usually required. In addition, MoE imposes new requirements on inference-system memory management and expert scheduling, which is also a direction many inference frameworks have recently focused on optimizing.

    4.3 Dense Models

    Another type of model stays on the Dense path, pursuing a higher model quality ceiling and a smoother post-training process. The reason is that MoE models are usually harder to post-train and tune, while dense models behave more predictably and are friendlier to reinforcement-learning-style alignment methods. For applications that require many post-training iterations and stable quality, dense models remain a safe choice.

    The three forms are not a question of which is better or worse; they correspond to different deployment positions: on-device, high-throughput server-side, and customized scenarios requiring heavy post-training.

    5. Engineering Implications for Developers

    Based on the evolution trends above, here are several actionable practical recommendations:

    1. Calculate the KV budget before deployment. Use the formula above to estimate KV usage at the target context length, then decide whether to enable compression mechanisms. In many cases, the bottleneck is the cache rather than the weights.
    2. Prioritize evaluating models with native cache compression support. If a model natively includes mechanisms such as cross-layer sharing or GQA, ensure the inference framework correctly recognizes its configuration rather than falling back to a generic path.
    3. Combine quantization with paged cache management. KV quantization (such as low-bit storage for the cache) and paged cache management are orthogonal methods that can be stacked with architecture-level compression to further amplify the benefits.
    4. Choose the model form by scenario. For edge deployment, prioritize small models plus cache compression; for high-concurrency online services, consider the throughput advantages of MoE; for teams that need extensive in-house post-training, the stability of dense models deserves consideration in decision-making.
    5. Pay attention to long-context evaluation. Compression mechanisms may affect long-range dependency capability. Before launch, run regression evaluations on long-context tasks such as recall, summarization, and multi-turn dialogue.

    6. Summary and Outlook

    The recent evolution of LLM architecture can be condensed into one sentence: keep scaling capacity on the training side, and aggressively reduce costs on the inference side. The formal adoption of cross-layer KV sharing by mainstream open-weight models marks that cache compression has moved from academic exploration into the engineering standard toolkit; the parallel development of MoE and Dense reflects the ongoing tradeoff among capacity, quality, and tunability.

    It is foreseeable that the next stage of architecture innovation will further revolve around “inference economics”: more aggressive sparse attention, deeper integration of cache and retrieval systems, and dedicated cache eviction and reuse strategies for the multi-turn long-session characteristics of agents. For developers, understanding the origins and implications of the KV Cache bottleneck is the key to reading these evolution trends and making the right technical choices.