LLM Architecture Evolution: Cross-Layer KV Cache Sharing and Sparsification in Practice

    Over the past year, large model architecture work has shifted from piling on parameters to improving efficiency. This article explains why the KV cache is the primary bottleneck in long-context inference, how cross-layer KV cache sharing compresses it (and where it sits relative to MHA and GQA), how Mixture-of-Experts (MoE) and Dense designs trade capability against engineering cost, and how tiered model lineups apply these choices across cloud, edge, and on-device scenarios. It ends with practical guidance on diagnosing memory pressure, selecting an architecture based on post-training capability, and avoiding over-sharing or over-sparsification.

    Introduction: Why Architecture Evolution Centers on Efficiency

    Over roughly the past year, the main line of large model architecture iteration has moved from simply “stacking parameters” to “improving efficiency.” The drivers are clear. On one hand, context windows have expanded from a few thousand tokens to hundreds of thousands or even over a million, and KV cache memory usage grows linearly with them. On the other hand, on-device and embedded hardware is extremely sensitive to memory bandwidth and cannot absorb redundant computation. As a result, reducing memory and compute cost without a significant loss in model quality has become the central question in architecture design.

    Two complementary lines of evolution have emerged around this question. One works from inside the attention mechanism, compressing the KV cache by reusing key/value states across layers. The other adjusts the model structure, seeking a balance between quality and engineering cost across Mixture-of-Experts (MoE) and Dense designs. Both are covered below.

    1. The KV Cache: The Top Bottleneck in Long-Context Inference

    In autoregressive generation, producing each new token requires the Key and Value tensors of all previously generated tokens. To avoid recomputing them, mainstream implementations cache the historical K and V, which is what the KV cache is.

    The problem is its size. Per-layer KV cache size is roughly proportional to:

    1. KV_size ∝ 2 (K and V) × num_layers × num_heads × head_dim × seq_len × batch_size × dtype_bytes

    Sequence length, layer count, and batch size all scale memory usage linearly. In long-context, large-batch serving scenarios, the KV cache often consumes more memory than the model weights themselves, and it directly determines how many requests a single GPU can serve concurrently.

    Two main families of optimization already exist in the community:

    • Quantization: compressing the KV cache from FP16 down to INT8/INT4, trading precision for space;
    • Attention structure changes: reducing the total volume by cutting the number of KV heads or sharing them across layers.

    The rest of this article focuses on the second family, specifically the techniques tied to recent architecture evolution.

    2. Cross-Layer KV Cache Reuse: Trading Sharing for Memory

    2.1 Core Idea

    Standard multi-head self-attention (MHA) computes and caches a full set of K and V independently at every layer. The core observation behind cross-layer KV sharing is that the Key/Value representations of adjacent layers, or layers within the same group, are highly similar. If they are that similar, there is no need to store a separate copy per layer: later layers can simply reuse the K and V tensors already computed by earlier layers.

    This is not a new idea. It was proposed and validated in earlier academic work (such as research around cross-layer attention) and is now increasingly adopted in smaller variants of real models, where it is particularly well suited to memory-constrained on-device scenarios.

    2.2 Where It Sits in the Attention Variant Spectrum

    Cross-layer reuse is not an isolated technique. It sits on a continuum from “fully independent” to “highly shared”:

    • MHA (multi-head attention): independent K/V per head, best quality but largest cache;
    • GQA (grouped-query attention): multiple query heads share one group of K/V heads, a compromise between quality and efficiency, and now the mainstream choice;
    • Cross-layer KV sharing: sharing along the layer dimension as well, compressing the cache more aggressively than GQA.

    The basic logic of grouped cross-layer sharing can be expressed in pseudocode:

    1. # Split L layers into groups; each group keeps only one shared K/V
    2. grouped_layers = [[0, 1, 2], [3, 4, 5], [6, 7, 8]]
    3. kv_cache = {}
    4. for layer_idx in range(num_layers):
    5. group_id = find_group(layer_idx, grouped_layers)
    6. if group_id not in kv_cache:
    7. # Only the first layer of each group actually computes and writes the cache
    8. kv_cache[group_id] = compute_kv(hidden_states)
    9. k, v = kv_cache[group_id] # Later layers reuse it directly
    10. attn_out = attention(query[layer_idx], k, v)

    2.3 Benefits and Costs

    Benefits:

    • Memory usage drops substantially with the sharing ratio, directly improving long-context and concurrency capability;
    • Reduced KV write bandwidth, which is especially valuable on bandwidth-limited on-device hardware.

    Costs:

    • Some loss in representational capacity, because layers forced to share cannot hold fully independent representations;
    • Grouping strategy and the number of shared layers need careful tuning, since excessive sharing degrades quality.

    In practice, therefore, it is typically enabled only for small models or scenarios that are extremely memory-sensitive, while large models chasing peak quality tend to keep more fully independent KV.

    3. The Architecture Trade-off: Mixture-of-Experts vs. Dense

    The other main line of evolution is sparsification at the whole-model level.

    3.1 MoE: The Cost-Effectiveness Logic of Sparse Activation

    Mixture-of-Experts architectures replace the feed-forward layer with multiple “expert” subnetworks, and a gating network (the Router) selects a few experts to participate in computation for each token. Its key characteristics are:

    • Large total parameter count, small activated parameter count: the model’s “capacity” is large, but only a small fraction is activated per forward pass, so inference compute cost stays controllable;
    • Strong cost-effectiveness: at comparable inference cost, MoE often delivers stronger representational power, which makes it a major direction for scaling up today’s large models.

    3.2 Dense: Deterministic Advantages in Post-Training and Deployment

    In a Dense architecture, every parameter participates in computation and the structure is regular. Its advantages are on the engineering side:

    • Simpler post-training and fine-tuning: there are no load-imbalance or router-drift problems introduced by expert routing, so SFT, RLHF, and similar pipelines are more stable and reproducible;
    • Deterministic deployment behavior: compute and memory overhead can be estimated precisely, and optimizations such as quantization, distillation, and operator fusion are more mature.

    This is also why some recent model families ship both MoE and Dense variants: the MoE variant targets inference efficiency and capability ceiling, while the Dense variant targets scenarios with higher demands on post-training convenience and deployment determinism.

    4. Tiered Model Lineups: Targeting Different Compute Scenarios

    Modern model families often adopt a clear tiered strategy to cover the full range from cloud to device:

    1. On-device/embedded (IoT) small models: very small parameter counts, emphasizing low memory and low power, commonly incorporating cross-layer KV reuse and aggressive quantization, able to run locally on phones, edge boxes, and similar hardware;
    2. Efficient local inference models (mostly MoE): aimed at single-machine or workstation scenarios, using sparse activation to provide strong capability under limited compute;
    3. High-quality large models (mostly Dense): pursuing capability ceilings and post-training friendliness, suited to cloud serving and complex tasks.

    The point of this tiering is that the binding constraint differs by deployment environment, and a single architecture cannot economically or realistically cover all of them.

    5. Practical Recommendations

    • Look at the KV cache first when assessing memory bottlenecks: in long-context serving, quantify KV usage first, then decide whether cross-layer sharing or KV quantization is needed;
    • Prefer cross-layer reuse plus quantization on-device: stacking the two can significantly extend usable context under limited memory;
    • Select by post-training capability: when a team’s post-training and fine-tuning capability is limited, the Dense variant is usually easier to work with; when the team can handle routing tuning and is chasing cost-effectiveness, MoE is the better choice;
    • Beware over-sharing and over-sparsification: the number of shared layers and the number of activated experts both need empirical calibration on the quality curve rather than being pushed to extremes.

    Conclusion

    Recent evolution in large model architectures is essentially a rebalancing of efficiency, quality, and engineering cost. Cross-layer KV cache reuse compresses overhead from inside the attention mechanism, MoE and Dense weigh capacity against controllability at the model-structure level, and tiered model lineups carry this methodology down to cloud, edge, and device scenarios. Understanding these underlying mechanisms is what makes it possible to make engineering decisions in selection and deployment that are grounded in evidence without over-engineering.