LLM Architecture Evolution: KV Cache Reuse and Sparsification Routes
This article examines two recent directions in large language model architecture: cross-layer KV cache reuse to reduce long-context memory and memory-access costs, and scenario-specific trade-offs between Mixture-of-Experts (MoE) and dense architectures. It explains the mechanisms, benefits, costs, engineering-stack implications, and practical deployment considerations, with a checklist for evaluating quality, latency, and cost.
Large language model architecture is shifting from simply scaling parameters toward improving effective context and inference efficiency per unit of compute and memory. Looking at recent iterations of open-weight models as observation samples, two clear themes stand out: first, reducing the memory footprint and memory-access cost of long-context inference by reusing key-value states (KV Cache) across layers; second, making scenario-specific trade-offs between Mixture-of-Experts (MoE) and dense architectures to balance inference efficiency, model quality, and post-training convenience. This article is not tied to any specific product; instead, it abstracts the relevant technologies into general architecture questions and discusses their mechanisms, benefits, costs, and engineering implementation points.
1. Background: Long-Context Costs and Architecture Divergence
In autoregressive inference, the KV Cache stores the Key and Value states produced by historical tokens during attention computation, avoiding repeated computation in the decoding phase. Its capacity is approximately:
KV cache size ≈ 2 × number of effective cache layers × batch size × sequence length × number of KV heads × head dimension × bytes per element
Here, “2” corresponds to Key and Value. It is clear that the number of layers, batch size, and sequence length all linearly amplify cache overhead. In long-context scenarios, the KV Cache not only occupies memory but also creates sustained memory bandwidth pressure, becoming a key bottleneck for throughput and latency.
At the same time, model product forms are diverging. Small models for mobile, embedded, and IoT devices focus more on memory footprint and energy consumption. Models targeting efficient local inference tend to adopt sparsely activated MoE architectures to gain larger total capacity with fewer activated parameters. Models targeting higher quality and a more convenient post-training workflow may stay with dense architectures, because the training and tuning pipeline for dense models is usually more direct and easier to stabilize. Although MoE models have advantages in inference efficiency, routing, load balancing, and post-training tuning are usually more complex.
2. Cross-Layer KV Reuse: From Independent Caches to Shared Caches
The core idea of cross-layer KV reuse is that subsequent layers no longer store a separate set of Key/Value states for every layer. Instead, they reuse KV tensors already computed by earlier layers according to layer groups. This reduces the “number of effective cache layers” from the total number of layers to the number of sharing groups, thereby reducing memory footprint and cache memory access in long-context scenarios. A simplified pseudocode example is as follows:
# Pseudocode: inference with KV cache shared by layer groupsdef forward(layers, x, cache, share_group_of_layer):for layer_idx, layer in enumerate(layers):group = share_group_of_layer[layer_idx]if group is None:# This layer starts a sharing group; compute and write KVk, v = layer.compute_kv(x)cache[layer_idx] = (k, v)else:# Subsequent layers reuse KV cached at the group startk, v = cache[group]x = layer.attend(x, k, v)x = layer.ffn(x)return x
The main benefits of this mechanism include lowering the peak memory of the KV cache, reducing the bandwidth required to read the cache during decoding, and improving throughput in long-sequence and multi-batch scenarios. However, shared KV is not cost-free. If different layers completely share the same set of Key/Value states, model expressiveness may be limited. Therefore, during training, shared layers need to adapt to this constraint, or quality regression needs to be mitigated through inter-layer normalization, position encoding adaptation, and sharing-group granularity design. Engineering teams also need to consider sharing granularity, cache layout, consistency between prefill and decode phases, quantization compatibility, and fallback strategies. Coarser sharing granularity brings more obvious benefits but higher quality risk; finer sharing granularity is more stable in quality but provides limited cache savings. Practical deployment should use the quality regression acceptable to the business as the boundary and determine the strategy through offline evaluation and small-traffic canary rollout.
3. MoE and Dense Architectures: A Trade-Off Between Efficiency and Trainability
A Mixture-of-Experts architecture uses a routing network to select a small number of experts for each token, enabling sparse computation with “large total parameter count and few activated parameters per token.” Its advantages lie in local inference and per-unit compute efficiency, but engineering complexity is higher: it needs to handle routing load balancing, expert capacity factors, expert-parallel communication, expert collapse, and cold-start issues. If routing is uneven, some experts becoming overloaded will slow overall throughput. If parallel partitioning is too fine-grained, communication overhead may offset the benefits of sparse activation.
A dense architecture activates all parameters for each token. Its computation path is stable, post-training and tuning pipelines are simpler, and deployment avoids an additional layer of routing and expert scheduling complexity. The cost is higher per-token computation, especially in long-context and large-batch scenarios. A general comparison between the two architecture types is as follows:
| Dimension | Mixture-of-Experts Architecture | Dense Architecture |
|---|---|---|
| Per-token computation | Sparse activation, usually lower | Full-parameter activation, usually higher |
| Total capacity | Can be expanded through experts | Constrained by single-model scale |
| Post-training complexity | Routing and expert balance are more complex | Pipeline is direct, tuning is more stable |
| Deployment complexity | Expert parallelism, communication, and scheduling are complex | Relatively simple |
| Suitable scenarios | Efficient local inference, multi-expert capacity expansion | Quality-first, frequent post-training, deployment simplicity |
Architecture selection should not rely only on theoretical compute efficiency. If the business requires frequent post-training, domain adaptation, and rapid iteration, the engineering determinism of dense architectures is more valuable. If inference cost is sensitive, the scenario is relatively stable, and the team has the operational capability for expert parallelism, MoE architectures are more suitable. For small mobile and embedded scenarios, memory bandwidth, cache footprint, and energy consumption should be evaluated first, rather than looking only at parameter count.
4. Impact of Architecture Evolution on the Engineering Stack
Cross-layer KV reuse and sparse architectures will change cache management, batch scheduling, and observability in inference engines. Cache management needs to support layer-group sharing, paged KV management, and continuous batching while avoiding conflicts between shared caches and dynamic batching. Observability metrics should cover time to first token, time per output token, throughput, peak memory, KV cache reuse rate, batch size distribution, and MoE routing load variance. In a general-purpose cloud environment, container platforms can host inference services; logging and monitoring services can observe latency, memory, and throughput; and object storage can manage model artifacts. These are generic categories, and specific specifications should be determined through business load testing.
5. Practical Checklist
First, long-context workloads should prioritize evaluating cross-layer KV sharing, but a quality regression baseline must be established. Second, small-device scenarios should focus on cache footprint and memory bandwidth, avoiding blind pursuit of total parameter count. Third, when adopting MoE architectures, include routing balance, expert-parallel communication, and capacity factors in load testing. Fourth, dense architectures are suitable for businesses with frequent post-training and a priority on deployment determinism. Fifth, any architecture optimization should validate quality, latency, and cost through A/B testing, and retain a switch to disable shared KV or fall back to a dense path. The value of architecture evolution is ultimately reflected in an engineering loop that is observable, rollback-capable, and operable.
