Cross-Layer KV Cache Reuse: Architecture Evolution and Inference Efficiency for LLMs
This article explains why LLM architecture optimization must account for inference-time state as well as parameter count. It introduces a simple KV cache cost model, describes how cross-layer cache reuse can reduce independently maintained historical key/value states, and analyzes why smaller caches do not automatically translate into proportional speedups. It also compares this approach with grouped-query attention, low-precision KV caches, sliding-window attention, and sparse expert architectures, then outlines deployment validation methods covering workloads, baselines, quality, and cache lifecycle.
1. The Core of Architecture Evolution: Inference State Matters, Not Just Parameter Count
When discussing large model architectures, parameter scale tends to attract the most attention. In actual deployment, however, what determines whether a system can support long documents, multi-turn interaction, and high-concurrency requests is not only the model weights, but also the intermediate state that accumulates during inference.
For models that use autoregressive generation, each new token requires the existing context. To avoid recomputing attention information for historical tokens, inference systems typically store the keys and values for each layer. This state is called the key-value cache, commonly written as KV Cache.
The cache turns repeated computation into storage overhead, making token-by-token generation practically efficient. However, the longer the context and the more requests processed concurrently, the larger the cache becomes. Even after model weights have been reduced through low-precision representations and similar methods, the KV cache can still become the main factor limiting service concurrency and context length.
Architecture optimization is therefore proceeding along several different paths: reducing the information that must be stored per layer, reducing the number of layers that independently maintain caches, lowering the computation associated with each token, and improving runtime memory management. Cross-layer cache reuse is one of the more direct routes. Its core question is: must adjacent layers each store an independent copy of historical key-value state?
2. Understanding Cache Cost: Start with a Computable Resource Model
In a conventional decoding structure, the attention computation for a given layer can be simplified as:
Q_l = H_l × W_Q,l
K_l = H_l × W_K,l
V_l = H_l × W_V,l
Here, H_l represents the hidden state used for projection in that layer, while Q_l, K_l, and V_l represent query, key, and value, respectively. Real models usually also include normalization, positional encoding, and other processing. Only the core relationships relevant to caching are retained here.
When a new token is generated, the layer produces a new query and reads historical keys and values. Historical queries generally do not need to be retained long term, while historical keys and values must be kept for subsequent generation.
Under the simplified conditions of identical layer configurations and identical key/value dimensions, cache memory can be approximated as:
Cache bytes ≈ 2 × B × T × L × H_kv × D × S
The terms are as follows:
- B: number of sequences processed concurrently;
- T: cached length per sequence;
- L: number of layers that independently maintain caches;
- H_kv: number of key-value heads;
- D: dimension of each key-value head;
- S: bytes occupied by each cache element;
- factor 2: corresponds to keys and values, respectively.
This formula does not include memory alignment, paging management, metadata, or temporary workspace. It is therefore suitable for capacity estimation, not as a direct replacement for runtime measurement.
It also reveals an important fact: compressing model weights does not mean compressing inference state proportionally. Weight occupancy is relatively fixed, while cache grows with request count and context length. Deployment evaluation must consider both parts.
3. Cross-Layer Cache Reuse: Reducing Independently Stored Historical State
3.1 Basic Idea
Conventional structures usually let each attention layer maintain its own cache. Cross-layer reuse allows certain layers to act as cache provider layers. Subsequent layers then read the key-value state already produced by those layers instead of each storing a complete, independent historical cache.
This can be abstracted as:
Q_l = query generated by the current layer
K_shared, V_shared = keys and values maintained by designated provider layers
Attention_l = Attention(Q_l, K_shared, V_shared)
What is shared here is the historical state read by attention; it does not mean that different layers perform exactly the same computation. Consumer layers can still retain independent query projections, output projections, feed-forward networks, and residual updates. Different depths can therefore still carry different information-processing roles.
If a model originally has L layers with independent caches, and after modification only G cache provider layers remain, then under otherwise equal conditions the main cache occupancy can be approximated as changing by a ratio of G/L. This is a structural estimate; it does not mean that end-to-end memory usage and inference time will decrease by the same ratio.
3.2 Why It May Work
Different layers have different functions, but they may also contain reusable information. For some layers, rather than reconstructing a complete historical representation, it may be more efficient to use the current layer’s query to extract different information from an existing historical representation.
This is equivalent to letting multiple layers share a set of “retrievable context memory” while retaining different retrieval methods. Its value lies in reducing redundant state, not simply reducing network depth.
However, this sharing also limits each layer’s freedom to independently construct key-value representations. There is therefore a real trade-off between cache savings and model expressiveness, and final effectiveness cannot be judged from a structural diagram alone.
3.3 It Is Not a Direct Runtime Replacement
For a model that has already been trained and in which each layer independently generates key-value state, directly letting later layers read earlier-layer caches usually changes the original computation relationships.
Even if tensor shapes are identical, that does not mean their numerical distributions and semantic roles are consistent. Cross-layer sharing generally needs to be explicitly introduced during architecture design and training, or be fully adapted and validated.
In addition, the dimensions between queries and shared keys, the positional encoding method, the attention mask, and cache update timing must all have consistent semantics. Being able to “multiply” at the implementation level does not mean the model can “use it correctly” at the model level.
4. Why a Smaller Cache Does Not Necessarily Mean Proportional Acceleration
Cross-layer reuse first changes the state storage structure. Its performance benefits need to be discussed separately.
4.1 Capacity Benefits Are Usually More Direct
When the number of independent caches decreases, the same device memory may support longer contexts or more concurrent sequences. For memory-constrained edge devices, this may directly determine whether a model can run at all.
However, total memory also includes model weights, activations, temporary buffers, and runtime overhead. Therefore, halving the cache does not mean overall memory usage is halved.
4.2 Key-Value Projection Computation May Decrease
If consumer layers no longer independently generate keys and values, the corresponding projection computation may also be eliminated. The benefit depends on the specific architecture; some schemes may still retain adaptation or transformation operations.
4.3 Attention Reads May Not Decrease in Step
Multiple layers sharing the same cache does not mean they only need to read the cache once. Each layer may still use different queries to access the same historical state, and attention computation still exists.
As a result, a reduction in logical storage does not necessarily bring an equal reduction in device memory reads. Actual results depend on compute kernels, on-chip cache utilization, tensor layout, and scheduling.
4.4 Benefits Differ by Inference Phase
The input-processing phase usually handles many tokens at once and has higher computational parallelism. The token-by-token generation phase repeatedly reads historical state and is more likely to be constrained by memory-access efficiency.
Cross-layer reuse may affect these two phases differently. Evaluation should record first-token latency, subsequent token-by-token latency, and steady-state throughput separately, rather than summarizing all benefits with a single speed metric.
5. Relationship with Other Architecture Optimizations
5.1 Grouped-Query Attention: Different Dimension of Compression
Grouped-query attention lets multiple query heads share fewer key-value heads, mainly reducing H_kv per layer.
Cross-layer cache reuse mainly reduces the number of independent cache layers, affecting L.
The two act on different dimensions in the resource model and can therefore be considered together. However, quality and performance after combination still need validation: the higher the degree of sharing, the stronger the capacity constraint on key-value representations may become.
5.2 Low-Precision Cache Representation: Structural Compression vs. Numerical Compression
Low-precision cache representation reduces S in the formula by reducing the number of bytes per element; cross-layer reuse reduces the number of copies of state that must be stored.
The two are complementary, but low-precision representation may also introduce quantization error, conversion computation, and additional scaling parameters. Actual benefits cannot be judged only from theoretical byte counts.
5.3 Sliding-Window Attention: How Much History to Keep vs. How to Share History
Sliding-window attention limits the historical range accessible to some layers, mainly controlling effective cache length; cross-layer reuse focuses on whether different layers can use the same historical representation.
The former changes context coverage, while the latter changes how state is organized. For tasks that require access to distant information, the window should not be reduced solely for cache savings.
5.4 Sparse Expert Architectures: Different Optimization Targets
Sparse expert architectures usually configure multiple experts in the feed-forward portion, and each token selects only a subset to participate in computation. This balances a larger total parameter capacity with lower per-token activation computation.
However, this does not inherently reduce attention cache, and it introduces expert routing, load balancing, and possible cross-device communication costs. Total parameter count, activated parameter count, weight storage, and cache occupancy must be accounted for separately.
Dense structures usually have a more unified computation path, and deployment and tuning pipelines are often more direct. Sparse expert structures require additional attention to routing behavior and training stability. However, post-training difficulty is not determined only by whether an expert structure is used; data, training objectives, and runtime frameworks are equally important.
6. Validation Methods for Practical Deployment
6.1 Define Real Workloads First
Before evaluation, input length, output length, concurrent request count, and task type should be clearly defined. Short question answering, long-document analysis, and sustained multi-turn interaction have different cache growth patterns and cannot share a single test result.
Edge deployment should also consider peak memory, sustained power consumption, and operating temperature; enterprise services need to focus on peak concurrency, request queuing, and tail latency.
6.2 Establish a Fair Baseline
During comparison, keep the device, weight precision, cache precision, input/output length, and scheduling policy as consistent as possible. If multiple factors change at the same time, it becomes difficult to determine whether benefits come from architecture or runtime optimization.
It is advisable to report two types of results: one comparing resources and latency under the same workload, and another comparing supported concurrency and throughput under the same memory budget.
6.3 Give Quality Evaluation Equal Importance
Cross-layer sharing changes how the model processes information, so capabilities such as long-distance retrieval, multi-step reasoning, structured output, and multi-turn instruction following must be checked.
In particular, avoid testing only whether the model “can process long input” without testing whether it “can correctly use long input.” Context length is an interface capability; effective use of distant information is the task capability.
6.4 Check the Cache Lifecycle
Shared caches must not be implemented by copying tensors, otherwise the savings may be offset. The runtime also needs to correctly manage reference relationships, release after request completion, batch reordering, and historical prefix reuse.
Cross-layer sharing usually occurs within the same request; it does not mean that different user requests can share state arbitrarily. Any cross-request reuse must be built on consistent prefixes, permission isolation, and data security constraints.
7. Conclusion: Measure Architecture Value by Effective Output per Unit Resource
The focus of large model architecture optimization is shifting from simply increasing parameters to organizing computation, memory, and memory access more precisely. The value of cross-layer key-value cache reuse is that it reduces the cost of repeatedly maintaining historical state in some layers, creating new room for long-context and high-concurrency deployment.
However, architectural advantages must undergo complete validation before they can become engineering benefits. A reasonable decision order is: first confirm whether task quality meets requirements, then measure memory, latency, and throughput under real workloads, and finally make a choice based on maintenance cost and deployment complexity.
For developers, what matters is not whether a structural change is novel, but whether it can stably increase the effective work completed per unit resource within acceptable quality boundaries.
