LLM Architecture Evolution: Cross-Layer KV Reuse and Sparse Experts

    Long-context inference, on-device deployment, and high-quality post-training are reshaping large language model architecture design. This article examines three distinct architectural routes seen in recent open-weight models: cross-layer KV cache reuse for compact local models, sparse Mixture-of-Experts (MoE) structures for efficient inference, and dense architectures for quality and post-training convenience. It explains how the KV cache becomes a bottleneck, how grouped KV sharing trades structure for memory savings, and where each architecture fits, concluding with practical selection criteria and an engineering checklist.

    Long-context inference, on-device deployment, and high-quality post-training are simultaneously reshaping the architecture design of large language models. A recent batch of open-weight models reveals three notable architectural routes: small models targeting local devices have begun adopting cache mechanisms that reuse Key-Value (KV) states across layers; models built for efficient local inference use Mixture-of-Experts (MoE) structures, trading sparse activation for larger parameter capacity; and models prioritizing quality and post-training convenience retain dense architectures. These routes are not mutually exclusive—each answers a different engineering question: can memory footprint be reduced, can compute be used more efficiently per unit of work, and is the model easier to tune? Starting from the KV cache bottleneck, this article breaks down the mechanics and costs of cross-layer KV reuse, then discusses the boundaries of sparse experts and dense architectures, and closes with actionable selection and implementation guidance.

    1. Background: Why the KV Cache Is the Key Bottleneck for Long Contexts

    In autoregressive inference, the model caches the Key and Value states of historical tokens for every layer to avoid recomputation during decoding. As sequence length, batch size, and layer count grow, KV cache memory consumption increases roughly linearly with sequence length and continuously pressures memory bandwidth during decoding. For long-document QA, codebase comprehension, and multi-turn conversations, the KV cache is often more limiting on concurrency and context length than the model weights themselves.

    Traditional mitigations include reducing the number of KV heads, sharing Query heads (e.g., grouped-query attention), cache quantization, and paged cache management. These approaches focus on either the per-token cache representation or how the cache is managed. Cross-layer KV cache reuse optimizes along a different dimension: since Key-Value states across adjacent or grouped layers have reuse potential, there is no need to store a full, independent cache for every layer—subsequent layers can read states already computed by earlier layers. The core idea is to trade structural design for memory and bandwidth savings.

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

    2.1 Basic Mechanism

    In a standard Transformer decoder, layer l typically has its own Key and Value projections and maintains its own KV cache. Cross-layer reuse instead lets several layers share one set of Key-Value states: after a preceding layer computes and writes the cache, subsequent layers read that cache directly for attention computation instead of allocating and storing a separate KV tensor. This compresses the “layer dimension” of the KV cache from one copy per layer to one copy per group.

    Importantly, cross-layer reuse does not mean subsequent layers stop participating in attention. They can still retain independent Query projections, output projections, feed-forward networks, and normalization structures—only the Key-Value representations are shared within a group. What it reduces is cache storage and read cost, not the attention layers themselves. During training, shared layers must learn Key-Value representations compatible with all layers in the group; at inference, the cache allocator only needs to maintain one state per group.

    2.2 Sharing Granularity and Implementation

    Sharing granularity is the key design variable. Common approaches include sharing between adjacent layers, sharing within fixed-size groups, sharing across interleaved groups, and variants that share only Values while keeping independent Keys. Larger groups yield more cache compression but further compress representational differences between layers within the group, potentially affecting fine-grained retrieval, long-document alignment, and complex reasoning. Smaller groups preserve accuracy better but deliver limited savings.

    Implementation requires attention to three points. First, the cache layout should be indexed by group rather than by layer, avoiding repeated lookups during decoding. Second, the prefill and decoding phases must use a consistent group mapping to prevent position offsets or cache misalignment. Third, in batched serving, requests have different sequence lengths, so paged cache management is still needed—only now the page table records group-level cache blocks. For small on-device models, group-level caching also reduces memory footprint and memory bandwidth, improving the long-context experience on small devices.

    2.3 Benefits and Costs

    On the benefit side, cross-layer reuse can substantially shrink KV cache storage; in principle, the cache’s layer term drops from “one copy per layer” to “one copy per group,” with actual savings depending on group size, head count, hidden dimension, sequence length, and batch size. For memory-constrained on-device devices and high-concurrency long-context services, the reduced cache footprint often translates into higher concurrency or longer context windows.

    On the cost side, sharing weakens the independence of Key-Value representations across layers. If sharing is too aggressive, the model may lose the ability of different layers to model different levels of abstraction—manifesting as degraded recall of long-document details, weaker instruction following, or unstable complex reasoning. Cross-layer reuse therefore usually requires joint optimization during training rather than naive stitching at inference time. When adapting a pretrained model, distillation, continued pretraining, or a small amount of alignment data can help shared layers adapt to the new cache structure. Generic compression techniques such as quantization and low-rank adaptation can be stacked on top of cross-layer reuse, but accuracy must be re-evaluated.

    2.4 Illustrative Pseudocode

    The following pseudocode illustrates only the “write per group, read per group” cache logic and does not represent any specific implementation or interface:

    1. class GroupedKVCache:
    2. def __init__(self, num_layers, group_size):
    3. self.group_size = group_size
    4. self.cache = [None] * num_layers
    5. def group_base(self, layer_idx):
    6. return layer_idx - (layer_idx % self.group_size)
    7. def store(self, layer_idx, key, value):
    8. base = self.group_base(layer_idx)
    9. if self.cache[base] is None:
    10. self.cache[base] = (key, value)
    11. def load(self, layer_idx):
    12. base = self.group_base(layer_idx)
    13. return self.cache[base]

    Real-world engineering must also handle positional encoding, cache eviction, heterogeneous sequences within a batch, quantization/dequantization, and attention mask alignment. If shared layers use different normalization or positional scaling strategies, these should be explicitly constrained during training to keep inference-time caches consistent with training-time representations.

    3. Sparse Expert Architectures: Balancing Capacity and Compute Efficiency

    Mixture-of-Experts architectures use a router to select a small subset of experts for each token, activating only part of the feed-forward parameters. This keeps per-token compute bounded even when total parameter capacity is large, making MoE well suited to efficient local inference or high-throughput server-side serving. Its advantage is not “free scaling”—it is a trade-off between capacity and compute achieved through sparse activation.

    The main engineering challenges fall into three categories. First, routing stability: routers tend to produce uneven expert load early in training, requiring generic remedies such as load-balancing auxiliary losses, capacity factors, and routing temperature. Second, communication cost: expert parallelism dispatches tokens across devices, and cross-device communication can offset the gains of sparse computation—this needs careful evaluation, especially for low-latency local inference. Third, post-training difficulty: full fine-tuning, distillation, quantization, and alignment are all more complex for sparse models than for dense ones; changes in routing behavior can affect existing capabilities, and expert load shifts as data distributions drift.

    Sparse experts are therefore better suited to scenarios with “high capacity demands, throughput-first priorities, and strong training and tuning resources.” For small on-device models, routing and communication overhead may not pay off. When combining MoE with cross-layer KV reuse, cache savings and routing overhead must be evaluated together—compressing the cache should not come at the price of extra scheduling complexity.

    4. Dense Architectures: A Return to Quality and Post-Training Convenience

    Dense architectures activate all parameters for every token. Compute cost is high, but training dynamics are more stable and the post-training toolchain is mature. Full fine-tuning, distillation, quantization, alignment, and evaluation pipelines are relatively straightforward, with lower risk of routing drift or abnormal expert load. For teams pursuing model quality, convenient post-training, and fast iteration, dense architectures retain clear value.

    Dense models can also combine with cross-layer KV reuse—particularly for small on-device models, where cache reuse relieves long-context memory pressure. For large dense models, however, the impact of sharing on cross-layer representation warrants more caution. Overall, the dense architecture is not an “outdated route”; it is a more controllable trade-off among quality, stability, and tuning cost.

    5. Combining and Choosing: On-Device, Local Inference, and Quality-First

    Route Primary Goal Strengths Main Risks Best Fit
    Small models with cross-layer KV reuse Reduce long-context memory and bandwidth Low cache footprint, device-friendly Intra-group representational differences compressed; requires training compensation Small local devices, long-context on-device applications
    Sparse expert (MoE) models Increase capacity and per-unit compute efficiency Large total capacity, low activated compute Unstable routing, communication and post-training complexity Efficient local inference, throughput-first serving
    Dense models Quality and post-training convenience Stable training, mature toolchain High compute cost, heavy memory pressure Quality-first workloads, rapid tuning and alignment

    When choosing, start from your constraints: if memory and bandwidth are the primary bottleneck, evaluate cross-layer KV reuse and group size first; if throughput and capacity are core, evaluate MoE routing and parallelism costs; if post-training iteration speed and quality stability come first, dense architectures are the safer bet. All three can be combined, but the more combinations, the higher the evaluation and regression-testing cost.

    6. Engineering Practice Checklist

    1. Build a long-context evaluation suite covering retrieval, summarization, multi-turn dialogue, and code comprehension—do not rely on perplexity alone.
    2. Run ablations on cross-layer reuse: group size, the scope of shared Keys/Values, and whether joint training is used, recording accuracy and memory gains item by item.
    3. Implement group-indexed caching, unify prefill and decoding mappings, and retain paged management to handle heterogeneous batching.
    4. For sparse experts, closely monitor expert load, routing entropy, capacity factor, and cross-device communication overhead; fix the routing policy to establish a baseline before post-training.
    5. For dense models, prefer mature full fine-tuning, distillation, and quantization pipelines as the quality baseline.
    6. For any architectural change, report memory, throughput, latency, quality, and post-training cost together—avoid single-metric-driven decisions.

    7. Conclusion

    The core of recent LLM architecture evolution is not simply stacking more parameters, but finding a finer-grained balance among long-context capability, on-device deployment, and post-training efficiency. Cross-layer KV cache reuse shrinks cache size through group-level sharing, offering a structural optimization path for small local devices and long-context scenarios; sparse experts improve capacity efficiency through routed activation, at the cost of load balancing, communication, and post-training complexity; dense architectures safeguard the quality baseline with stability and tunability. When selecting an architecture, start from real constraints and validate gains with ablation experiments and comprehensive evaluation—avoid treating any single architecture as a universal answer.