Understanding PD Asymmetry in Large Language Model Inference

    This article explains the asymmetric design between the Prefill and Decode stages of large language model inference. It covers what each stage does, why decoder-only architectures are inherently asymmetric, and how arithmetic intensity determines whether a stage is compute-bound or bandwidth-bound. It also details serving strategies such as stage separation, chunked prefill, cache reuse, and continuous batching, along with capacity planning, cost accounting, common misconceptions, and benchmarking practices.

    1. Clarifying the Concepts: What Prefill and Decode Actually Do

    In a large language model inference pipeline, a single request is typically split into two stages: Prefill and Decode. Prefill reads in all input tokens at once, builds the key-value cache (KV Cache) required for attention, and produces the first output token. Decode then generates output autoregressively, one token at a time, where each step processes only a single new token but must read the entire history cache.

    Many discussions treat “asymmetry” as if it were a patent of some new architecture. This is a misunderstanding. A standard decoder-only structure is inherently asymmetric, and the root cause is that the two stages have different objectives:

    1. Prefill has two goals: compress historical information into the cache, and predict the first token of the answer.
    2. The feed-forward network (MLP) and the output vocabulary projection (LM Head) are unrelated to cache construction; they only act on the position that is about to produce a token.
    3. Therefore, apart from the last position, the remaining positions in Prefill do not need to go through the MLP and LM Head, and this portion of computation is naturally skipped.

    2. A Quantitative View of the Asymmetry: Arithmetic Intensity Differences

    The common industry metric for deciding whether a stage is compute-bound or bandwidth-bound is arithmetic intensity (the number of floating-point operations per byte of memory access).

    • Prefill: processes L tokens at once, and the arithmetic intensity of matrix multiplications rises linearly with L. It usually falls in the compute-bound range, with compute capacity as the bottleneck.
    • Decode: only 1 token per step, and both the weights and the KV Cache must be read in full. Arithmetic intensity is extremely low, placing it in the bandwidth-bound range, with memory bandwidth and capacity as the bottleneck.

    Illustrative comparison (pseudocode, expressing only the structural difference):

    1. # Prefill: process the entire input in parallel at once
    2. logits = model(input_ids[:, :L], use_cache=True)
    3. kv_cache = model.saved_cache
    4. # Decode: single-step serial, repeatedly reading weights and cache
    5. for _ in range(max_new_tokens):
    6. logits = model(next_token, kv_cache=kv_cache)
    7. next_token = argmax(logits[:, -1])

    This leads to several practical conclusions: improving Prefill throughput mainly relies on parallelism and compute utilization; improving Decode throughput mainly relies on higher bandwidth efficiency, larger batch sizes, and a smaller cache footprint. The optimization techniques for the two barely overlap, which is precisely the motivation for disaggregated deployment.

    3. Serving in Practice: Disaggregated Scheduling and Resource Allocation

    When the two stages run on the same instance, they interfere with each other: a long-input Prefill blocks an ongoing Decode and causes tail-latency jitter, while a large number of concurrent Decodes crowd out the compute quota for Prefill. Common mitigation approaches include:

    • Stage separation: split prefill and decode into different resource pools, scale each independently, and set the allocation ratio separately based on the input-length distribution and the output-length distribution.
    • Chunked prefill: cut long inputs into fixed-size chunks and interleave them with decode batches in scheduling, avoiding a long request monopolizing the device.
    • Cache reuse: apply prefix cache hits for identical prefixes (system prompts, templates, few-shot examples), skipping repeated computation directly.
    • Continuous batching: batch at the token level rather than the request level, so new requests can be inserted at any time, improving device utilization.

    For capacity planning, it is recommended to measure two metrics separately: on the Prefill side, look at input tokens processed per second and first-token latency; on the Decode side, look at output tokens per second, per-request token rate, and peak cache usage.

    4. The Cost Perspective: Putting the Bill in the Right Place

    Because the two stages have different bottlenecks, costs should be accounted separately for “input token processing” and “output token generation,” rather than priced generically per call. Practical cost-reduction measures include: raising the cache hit rate, compressing cache precision and capacity, setting reasonable limits for short-output requests, and tuning the batching window to match business latency targets.

    When implementing on the cloud, you can combine general capability categories: a container platform to host elastic inference instances, object storage to hold models and datasets, a message queue for request buffering and peak shaving, and logging and monitoring/alerting services responsible respectively for auditing and for observability of latency, throughput, and cache hit rate.

    5. Common Misconceptions and Verification Methods

    • Misconception 1: assuming asymmetry is unique to a new architecture. In fact, it stems from the inherent structure of autoregressive generation and the caching mechanism.
    • Misconception 2: evaluating a service with a single average latency. You should look at first-token latency and per-token rate separately.
    • Misconception 3: blindly increasing batch size. Too large a batch raises queuing latency and needs to be tuned against the business SLA.

    Verification recommendation: fix the input and output length distributions for benchmarking, record device utilization, memory usage, and latency percentiles for each stage separately, and then adjust the separation ratio and batching parameters accordingly to form a reusable capacity model.