LLM Inference: Understanding Prefill-Decode Asymmetric Activation

    This article explains why LLM inference acceleration should start from execution stages rather than the model architecture alone. It breaks down the natural redundancy in the prefill phase, shows how cross-layer KV cache sharing turns a minor saving into a substantial reduction in prefill compute, and outlines the engineering trade-offs of asymmetric activation between input and output sides. Readers will also find practical deployment advice and common misconceptions to avoid when evaluating these optimizations.

    1. Starting Point: Why Inference Acceleration Should Focus on Stages, Not the Model

    When discussing LLM inference performance, the industry often focuses on parameter count, quantization precision, or operator fusion. But a more fundamental and easily overlooked fact is that a single autoregressive generation is not a uniform computation. It is a concatenation of two phases with very different computational characteristics: prefill and decode. Most discussions of “asymmetric activation” begin with the asymmetry between these two phases.

    It is worth emphasizing that this asymmetry is not exclusive to any new architecture. Even the most conventional decoder-only structure already has natural computational redundancy during prefill. Understanding this is the prerequisite for understanding all subsequent optimizations.

    2. The Dual Objective and Natural Redundancy of Prefill

    The prefill phase processes the complete prompt sequence from the user input. It actually accomplishes two things at once:

    1. It computes and writes the key-value cache (KV Cache) layer by layer, for repeated reads during the subsequent decode phase.
    2. It predicts the next token in the sequence, which is the first token of the generated result.

    The key point is that the first task must go through all Transformer layers, because the key-value projection of each layer depends on the output of the previous layer. The second task, however, only relates to the output of the final layer. The feed-forward network (MLP) and the language model head (LM Head) do not participate in constructing the cache; they only serve the goal of “predicting the next token.”

    From this, we can derive an often-overlooked conclusion: during prefill, except for the last position in the sequence, no other position needs to compute the final layer’s MLP and LM Head. The only downstream consumer of the intermediate representations at these positions is the key-value projection of the next layer, and skipping them does not change the cache content.

    The masking logic can be expressed with illustrative pseudocode:

    1. # Prefill: only the last position needs to pass through output-side modules
    2. hidden = embed(input_ids) # [B, S, D]
    3. for layer in layers[:-1]:
    4. hidden = layer(hidden) # full sequence participates, writing KV Cache layer by layer
    5. kv_cache = layers[-1].compute_kv(hidden) # the last layer only computes K/V
    6. last_hidden = layers[-1].norm(hidden[:, -1:, :])
    7. logits = lm_head(last_hidden) # only 1 position passes through MLP + LM Head

    It must be objectively noted that under conventional structures, this saving accounts for a very small proportion of the overall overhead. What is skipped is only “the last-layer MLP computation at S-1 positions” plus “the output head projection at S-1 positions.” When the sequence length is limited and the hidden dimension is not large, the benefit is almost negligible. This also explains why this property has long remained theoretical and has not become a default optimization in mainstream inference frameworks.

    3. How Cache-Sharing Architectures Amplify This Benefit

    The real turning point appears when design ideas like “cross-layer cache sharing” are introduced. If some layers of the model no longer maintain independent key-value caches but instead reuse cache representations from other layers, the prefill computation chain is structurally shortened: once the cache from the shared source is ready, the main task of subsequent layers during prefill degrades to “no longer needing to repeatedly construct the cache.”

    At this point, the previously mentioned “skipping output-side modules” changes from a small discount into a substantial reduction of the main prefill computation. It can be understood as: originally you saved a side branch, now you save a large section of the main trunk.

    From an engineering perspective, the benefits and costs of such designs must be evaluated in pairs:

    • Benefit side: reduced prefill compute, improved time to first token (TTFT), and reduced cache write bandwidth pressure in long-context scenarios.
    • Cost side: cache capacity and representation ability are compressed, and the model must learn during training to maintain quality under limited cache. Meanwhile, the inference framework’s cache management, batch scheduling, and memory layout all require corresponding modifications.

    Therefore, evaluating whether such an architecture is reasonable cannot rely solely on “smaller activated parameters.” It must look at end-to-end service metrics: throughput, latency distribution, long-text quality retention, and the comprehensive cost per request.

    4. Engineering Implications of Asymmetric Activation

    Abstracting the above discussion one level up yields a general principle: the “activation scale” during inference does not need to be symmetric between the input side and the output side. Traditional mixture-of-experts (MoE) models usually adopt the same routing and activation scale for both input and output. The design that separates “input-side activation” from “output-side activation” essentially models the resource profiles of the two phases explicitly.

    This brings three practical values:

    1. Decoupling capacity from cost. Total parameter count determines the upper limit of model capability, while activated parameters determine the actual cost of a single forward pass. Separating the two allows expanding capacity without significantly raising inference costs.
    2. Finer scheduling. The different overheads on the input and output sides allow batch strategies, cache eviction strategies, and parallel partitioning methods to be tuned separately.
    3. Easier integration with general cloud capabilities. Inference services typically also rely on container platforms for elastic scaling, object storage for hosting models and data, and logging services with monitoring and alerting systems for observability. The asymmetric structure allows capacity planning to be estimated separately by phase.

    5. Deployment Advice and Common Misconceptions

    • Misconception 1: Treating “skipping the output head” as a universal acceleration method. It only holds during prefill, and its benefit highly depends on prerequisites such as whether the architecture supports cache sharing.
    • Misconception 2: Looking only at activated parameters. Evaluation should return to measured percentile latency and unit cost, rather than a single structural metric.
    • Misconception 3: Ignoring numerical consistency. Any change involving cross-layer cache reuse or skipped computation needs regression validation on long contexts, multi-turn conversations, and low-probability branches, to avoid quality regression being masked by throughput gains.

    Overall, the asymmetry between prefill and decode is an inherent property of inference systems. Conventional structures simply “give up by default” this dividend. Only when new ideas like cache sharing compress the main prefill computation does this dividend truly gain engineering value. For developers, the correct approach is to first build a phase-by-phase cost model, then determine whether a given optimization is worth the investment under your model structure and business workload.