LLM Architecture Evolution: Cross-Layer KV Reuse and Mixture-of-Experts in Practice
This article examines how large language model architectures are evolving to deliver higher effective capacity under limited compute. It explains the KV Cache memory problem, how cross-layer KV reuse reduces cache costs, and how Mixture-of-Experts (MoE) models trade parameter capacity against routing and communication complexity. It also compares dense and MoE designs for on-device, local, and fine-tuning scenarios, and outlines how weights, cache, scheduling, and monitoring fit into a complete deployment plan.
In recent years, the competition among large language models has shifted from simply scaling up parameter counts to achieving higher effective capacity under limited compute. Models must meet several requirements at once: longer context windows, lower latency, smaller memory footprints, easier fine-tuning, and deployment across a wider range of environments. To meet these goals, the industry has settled on three main architectural directions: lightweight designs for on-device use, Mixture-of-Experts (MoE) structures for efficient inference, and cache reuse mechanisms that reduce KV Cache costs by modifying the attention module.
This article does not focus on any specific model or brand. It takes a general technical view and analyzes the problems behind these structural changes, their implementation approaches, and their engineering impact.
1. The Core Tension in Architecture Evolution
When an autoregressive language model generates text, it predicts the next token one step at a time. It does not need to recompute all historical information at every step. However, it still has to keep the Key and Value states from the attention mechanism. These stored states are the KV Cache.
Suppose a model has (L) Transformer layers, several attention heads per layer, a history length of (S), and a Key or Value vector dimension of (d). The memory used by the KV Cache is then roughly proportional to:
[
Memory \propto L \times S \times N_{kv} \times d \times 2
]
Here, (N_{kv}) is the number of KV heads stored in the cache, and the factor of 2 accounts for the Key and Value tensors.
This means the cache grows roughly linearly with context length, and it grows further as the number of layers increases. In long-document question answering, code analysis, AI agents, and multi-turn dialogue, the KV Cache can quickly become the main source of memory consumption instead of a minor auxiliary cost.
Architecture optimization therefore has to address three related problems:
- How to reduce the number of cache entries kept for each layer;
- How to lower the memory bandwidth needed to read and write the cache;
- How to keep model quality as high as possible after compressing the cache.
Cross-layer KV reuse is an important approach that emerged in this context.
2. Cross-Layer KV Reuse: Lowering the Cost of Long-Context Caching
2.1 Basic Idea
A traditional Transformer computes the Query, Key, and Value independently in each layer. Even when different layers process the same input, each layer produces its own set of KV states and writes them to the cache separately.
The core idea of cross-layer reuse is that not every layer must generate fully independent Key and Value tensors. Some later layers can reuse KV states computed by earlier layers directly, or apply lightweight transformations to them. This reduces the number of tensors that must be stored and transferred.
Consecutive layers can be grouped into a reuse group, as shown below:
Input│├─ Layer 1: compute and generate KV├─ Layer 2: reuse KV from the previous layer to complete attention├─ Layer 3: continue reusing the existing KV└─ Layer 4: recompute KV and start the next group
With this design, the KV Cache no longer grows by one copy per layer. It grows by one copy per reuse group. Larger groups reduce cache usage in theory, but they also place higher demands on model expressiveness and training stability.
2.2 Why KV Reuse Can Work
Different layers in a Transformer perform different representation transformations, but adjacent layers usually share some structural continuity. For attention access patterns, some layers may not need entirely separate Key and Value spaces.
In lightweight models, storing a full KV state for every layer can make the cache larger than the model weights. Cross-layer reuse relieves this pressure along the layer dimension, which makes models better suited to mobile devices, edge nodes, and local inference.
KV reuse is not the same as copying tensors. A sound implementation usually combines several mechanisms:
- Structural constraints on attention projections across layers;
- Training methods that adapt to fully or partially shared KV representations;
- Careful design of reuse cycles, so that layers do not lose all diversity;
- Joint optimization across quality, cache size, and compute cost.
2.3 Impact on Inference Systems
Cross-layer KV reuse helps inference in three main ways.
First, memory usage drops. During long-context generation, the cache no longer grows fully with every layer, so a single accelerator can hold more concurrent requests.
Second, memory bandwidth pressure decreases. Attention needs compute, and it also reads the KV Cache frequently during inference. A smaller cache means less data movement, which particularly helps devices limited by memory bandwidth.
Third, on-device deployment becomes easier. Mobile and embedded devices usually have limited memory or unified memory. Quantization can compress model weights, but the KV Cache still grows with context length. Structural cache optimization is therefore often more important than weight compression alone.
A smaller cache does not always lower end-to-end latency in proportion. If the reuse mechanism adds extra projections, reordering, or synchronization steps, compute overhead can offset some of the gains. Real deployments still need testing against the hardware, batching strategy, and context lengths in use.
3. Mixture-of-Experts: Expanding Model Capacity Through Sparse Activation
Beyond cache optimization, another important route is the Mixture-of-Experts (MoE) architecture.
A dense model passes every token through all of its parameter layers. In general, more parameters mean more compute per token. An MoE model prepares several expert networks. A routing module then selects a small number of experts for each token based on that token’s features.
The basic flow is shown below:
Input token│▼Routing network computes expert weights│├─ Expert A├─ Expert B└─ Other experts remain inactive│▼Weighted aggregation of outputs
The defining feature of this design is that the total parameter count is large, but each token activates only part of those parameters. As a result, the model can keep high capacity while controlling the compute cost per token.
3.1 Advantages of MoE
First, model capacity and per-token compute can be decoupled to a degree. Adding experts expands the model’s knowledge and representation space without requiring every token to access all parameters.
Second, experts can gradually develop functional specialization. For example, some experts may handle code patterns better, while others handle natural language, mathematical reasoning, or specific syntactic structures. This specialization usually emerges during training. It cannot be fully specified by hand.
Third, in high-concurrency serving, sparse activation can improve compute efficiency per request. This depends on routing balance, expert parallelism strategy, and hardware communication capacity. Adding more experts does not automatically make inference faster.
3.2 Engineering Challenges of MoE
The most obvious challenge of MoE is routing and communication.
When tokens are dispatched to different experts, the system must reorder tokens, transfer them across devices, and aggregate the results. If experts sit on different compute devices, communication overhead can cancel out the gains from sparse computation.
Load imbalance is another problem. If many tokens select the same few experts, those experts become overloaded while others sit idle. Common engineering responses include routing constraints, capacity limits, load-balancing losses, and fallback paths for overflow tokens.
Post-training an MoE model is also more complex. Dense models have relatively stable parameter update paths. MoE routing is dynamic, and different samples may
