LLM Inference Optimization: Asymmetric Activation and Shared KV Cache
This article examines how to evaluate large-model inference architectures beyond parameter counts or benchmark scores, focusing on the real workload: what prefill and decode each do, which computations produce cache, and how cache is organized. It explains why prefill and decode are fundamentally different workloads, how their asymmetry already exists in standard decoder models, and how global cache sharing amplifies that asymmetry into structural gains. It also covers the intuition and limits of causal encoder-decoder style layering, a practical evaluation matrix (quality, time-to-first-token, decode speed, throughput, cache efficiency, cost, stability), and key engineering concerns such as staged scheduling, cache lifecycle management, continuous batching, kernel adaptation, and version governance. Readers will learn to reduce architectural claims to verifiable end-to-end metrics under matched conditions.
LLM Inference Optimization: Asymmetric Activation and Shared KV Cache
Judging whether a class of LLM inference architectures represents progress cannot rely on parameter scale, leaderboard scores, or a single throughput number. A more reliable approach is to return to the inference workload itself: what the input phase does, what the output phase does; which computations produce cache and which only serve the next token; how the cache is organized and how memory access changes; and under what business loads these changes translate into real gains. Recent discussion of “prefill/decode asymmetry,” “asymmetric activation,” and “global cache sharing” all point to the same issue: the compute path of LLM inference should not be simplified into a black box with a fixed parameter count, but should be optimized separately by phase, by token role, and by cache lifecycle.
1. Prefill and Decode Are Not the Same Workload
Autoregressive LLM inference is usually divided into two phases.
The prefill phase processes the entire prompt. All input tokens can be computed in parallel; the main goals are to build the key-value cache needed for subsequent generation and to compute the probability distribution of the first output token. This phase typically has good parallelism, large matrix sizes, and high compute intensity, and with long prompts the attention portion significantly amplifies the cost. The metric users notice most is time-to-first-token (TTFT): the time from request arrival to producing the first output token.
The decode phase generates one token at a time. Each step reads the historical cache, computes the representation of the current token, obtains the probability distribution of the next token, then samples and moves to the next step. Because only a few new tokens participate in each step, matrix parallelism is limited, and performance is often constrained by memory bandwidth, cache reads, and scheduling overhead. What users notice most is the time per output token, the overall generation speed, and tail latency under high concurrency.
The two phases have different goals, different resource bottlenecks, and different optimization methods. Placing prefill and decode in the same resource pool easily leads to problems such as long prompts blocking decode requests, short requests crowding out cache, and fluctuating batching efficiency. Therefore, modern inference systems often deploy the two phases in separate pools with time-based scheduling, or at least adopt strategies such as continuous batching, chunked prefill, and length-aware scheduling to reduce mutual interference.
2. The Prefill/Decode Asymmetry Has Always Existed
Much discussion tends to treat “prefill/decode asymmetry” as some newly invented structure. In fact, this asymmetry already exists in conventional decoder models; only the magnitude of the gain differs.
Consider a standard layer-by-layer compute model. The prefill phase must build the cache for all input tokens and ultimately predict the first output token. For the last input position, its final hidden state must pass through the last layer’s feed-forward network and output projection to produce the distribution over the next token; but for the other input tokens, their role is mainly to populate the cache for later decode steps to read. In other words, apart from the last position, the other prompt tokens do not need to immediately produce a vocabulary distribution after the last layer, and can therefore skip computations that only serve prediction, such as the last layer’s feed-forward network and output head.
This idea can be expressed with simplified pseudocode:
def simplified_prefill(prompt_tokens):hidden = embed(prompt_tokens)cache = []# Earlier layers must build the cache for all input tokensfor layer in layers[:-1]:hidden, kv = layer.attention_and_ffn(hidden)cache.append(kv)# The last layer still needs to compute the attention cache for all tokenshidden_after_attn, kv = layers[-1].attention(hidden)cache.append(kv)# But only the last position needs to continue with the last layer's FFN and output projectionlast_hidden = hidden_after_attn[:, -1]last_hidden = layers[-1].ffn(last_hidden)logits = lm_head(last_hidden)return cache, logits
This pseudocode omits engineering details such as residuals, normalization, and parallel partitioning, but it expresses a key fact: cache construction and next-token prediction are not fully overlapping sets of computation. In a conventional architecture, this optimization only affects part of the last layer’s computation, and relative to the model’s overall depth and width, the speedup may be limited; but if the cache organization changes—for example, letting multiple layers share the same global cache—this local optimization is amplified into a structural gain.
3. How Cache Sharing Amplifies the Asymmetric Gain
A notable problem with conventional multi-layer caching is that cache size grows linearly with the number of layers. Every decode step must read a large amount of historical key-value pairs, affecting memory footprint, bandwidth pressure, and concurrency capacity. To reduce this cost, one approach is to reduce the number of layers that must be kept long-term: part of the network reads the full context and forms a reusable global representation, and later layers reuse this representation via cross-attention or other means, rather than each layer keeping a full historical cache.
Under this design, the prefill phase can be split into two segments:
- Cache-building segment: processes the full input and compresses or encodes the context into a reusable global cache. This segment must cover all input tokens, because any position may affect subsequent generation.
- Output-generation segment: once the global cache is available, only the last input position continues through the subsequent decode layers to obtain the distribution of the first output token. Other input positions do not need to continue through the full subsequent network for “predicting the next token.”
Prefill is thus no longer a fully symmetric process of “all tokens passing through all layers.” For the set of input tokens, the main computation stops at the point where the cache is formed; only for the first output token is it necessary to continue through the later decode path and the output head. This creates the difference between an “input activation path” and an “output activation path,” which is one of the core intuitions of so-called asymmetric activation.
This asymmetry is not entirely the same as the “total parameters vs. activated parameters” in sparse mixture-of-experts (MoE) models. MoE models focus on which experts a single token is routed to, while cache sharing focuses on which layers and which cache paths different phases and different token roles must pass through. The two can coexist: a model may both use sparse experts to reduce per-token compute and use shared cache to reduce long-context cache overhead. When evaluating, one must not conflate “total parameters,” “activated parameters,” “number of cache layers,” “input-side compute,” and “output-side compute.”
4. The Intuition and Boundaries of Causal Encoder-Decoder Style Layering
From an architectural-intuition standpoint, cache sharing resembles splitting the model into a “causal encoder” and a “decode generator”:
- The causal encoder reads the full context and forms a global memory under causal constraints;
- The decode generator reads existing memory when generating each token and processes only the current few tokens;
- The decoder does not need to repeatedly store the full historical cache at every layer, reducing cache capacity and read pressure;
- Because the context is encoded only once, workloads such as long prompts, multi-turn dialogue, and repeated prefixes may see more pronounced gains.
This structure suits workloads with “long input, short output” or “the same context reused multiple times,” such as document QA, retrieval-augmented generation (RAG), structured information extraction, long-document classification, and stable system prompts in multi-turn conversations. For “short input, long output” generation tasks, prefill is already a small share, and the gains depend more on decode-phase cache read/write efficiency, batching strategy, and sampling overhead. Therefore, architectural prefill optimization does not automatically translate into end-to-end speedup.
In addition, shared cache usually requires extra projection, cross-attention, or cache-management logic. It reduces the number of cache layers but may add new compute and synchronization costs. The actual effect depends on cache granularity, attention kernel implementation, batch size, parallel strategy, long-sequence distribution, and hardware memory-access characteristics. Without end-to-end measurement, one cannot claim from a structure diagram alone that a certain class of architecture is necessarily and comprehensively superior.
5. Which Metrics to Look At When Evaluating
For developers and enterprise users, it is advisable to build an evaluation matrix across at least the following dimensions.
| Dimension | Key Question | Typical Metrics |
|---|---|---|
| Quality | Does the architectural change affect output correctness, stability, and long-context consistency? | Task accuracy, human evaluation, long-context consistency, repetition rate |
| Time-to-first-token | Do long prompts start output faster? | Mean and P95 TTFT |
| Decode speed | Is continuous generation smoother? | Time per output token, tokens per second |
| Throughput and concurrency | How many requests can be served per unit of hardware? | Request throughput, token throughput, concurrency ceiling |
| Cache efficiency | Does long context use less memory and bandwidth? | Per-request cache footprint, cache hit rate, concurrency capacity |
| Cost | Does per-request cost drop while meeting quality? | Cost per thousand tokens, cost per request, resource utilization |
| Stability | Does tail latency spiral out of control under high load? | P95/P99 latency, error rate, timeout rate, number of degradations |
Test workloads should cover the length distribution of real business traffic, not just a single short prompt or a single long document. At least four categories are recommended:
- Long input, short output: document QA, information extraction, classification, RAG;
- Short input, long output: code generation, creative writing, dialogue continuation;
- Balanced input and output: general QA, multi-turn dialogue;
- High-concurrency mixed load: interleaved long and short requests, observing scheduling and tail latency.
Comparisons should be made under the same hardware, the same quantization strategy, the same batching strategy, and the same sampling parameters. If conditions allow, run ablation experiments: disable cache sharing, enable only partial cache reuse, adjust the number of cache layers, and change the chunked-prefill size, to observe where the gains come from. Otherwise, it is easy to mistake scheduling optimization, improved cache hit rate, hardware differences, or test-set bias for an architectural dividend.
6. Key Engineering Implementation Issues
First, staged resource scheduling. Prefill is compute-intensive while decode is memory-access-intensive. Pooling, tiering, or length-aware scheduling of the two can reduce mutual interference between long and short requests. For long-prompt tasks, prioritize routing into resource pools suited to large-matrix computation; for long-output tasks, focus on cache bandwidth and continuous-batching efficiency.
Second, cache lifecycle management. A global cache needs clear invalidation conditions: whether the prefix has changed, how multi-turn context is appended, how tenants are isolated from one another, and how permissions and consistency are verified when reusing cache. Cache reuse can improve efficiency, but must be premised on guaranteeing correctness and data security.
Third, continuous batching and chunked prefill. A long prompt entering all at once blocks decode requests; chunked prefill can reduce jitter but adds complexity in cache stitching and scheduling. Batch size is not “bigger is better” either; mixing large-cache requests with short requests in one batch can raise tail latency.
Fourth, kernel and parallel-strategy adaptation. Shared cache, cross-attention, and asymmetric paths change the load balance of tensor parallelism, pipeline parallelism, and cache sharding. Some paths compute only at the last position, which can easily cause small operators, idle spinning, or a higher communication ratio. Fused operators, paged cache, and parallel partitioning need to be optimized for the actual shapes.
Fifth, version and compatibility governance. A large architectural change does not necessarily imply strong interface incompatibility. A version number should express interface compatibility, service contracts, quality baselines, and performance changes together, rather than simply equating to “how large the internal refactor is.” For users, what matters more is obtaining clear migration notes, comparable evaluation reports, and a stable rollback mechanism.
7. Conclusion: Reducing Architectural Innovation to Verifiable Engineering Gains
Asymmetric activation and global cache sharing represent a direction worth attention: no longer assuming that prefill and decode, or input tokens and output tokens, must go through exactly the same compute path, but instead designing in layers around where the cache is formed, how context is reused, and what generation requires. It may reduce long-context cache pressure, shorten time-to-first-token, improve concurrency capacity, and provide a more natural integration point for disaggregated prefill/decode serving.
But this does not mean that larger parameters, newer structures, or higher version numbers are necessarily better. Real gains depend on quality preservation, hardware fit, kernel implementation, scheduling strategy, and business workload. For developers, the most reliable way to judge is to clarify your input/output length distribution, build an evaluation set covering quality, time-to-first-token, time per token, throughput, cache footprint, and tail latency, and run ablation and reproduction experiments under the same conditions. Reducing concepts like “asymmetric” and “shared cache” to end-to-end metrics is the correct way to evaluate an architectural evolution.
