Skip to content
IJK

Prefill vs Decode: Which Phase Sets Which Latency Metric

By IJK ·

What a Hugging Face post says separates prefill from decode, which two metrics reflect the difference and why prefill takes longer than one decode step.

What separates the phases

In the prefill phase, the calculations for all input tokens can be executed in parallel, while in the decode phase, no parallelization is possible on the level of individual requests. [1]

Which metrics reflect it

The difference between the prefill and decode phases is also reflected in two key metrics for text generation: Time to first token and time per output token. [2]

The time to first token is given by the latency of the prefill phase, while the time per output token is the latency of a single decode step. [3]

setssetsPrefill phaseall input tokens processed in parallelDecode phaseno parallelization within one requestTime to first token and time per output tokenset by prefill latency and one decode step
Which phase determines which metric?

Sources

  1. The Hugging Face source says: In the prefill phase, the calculations for all input tokens can be executed in parallel, while in the decode phase, no parallelization is possible on the level of individual requests. Prefill and Decode for Concurrent Requests
  2. The Hugging Face source says: The difference between the prefill and decode phases is also reflected in two key metrics for text generation: Time to first token and time per output token. Prefill and Decode for Concurrent Requests
  3. The Hugging Face source says: The time to first token is given by the latency of the prefill phase, while the time per output token is the latency of a single decode step. Prefill and Decode for Concurrent Requests

Editorial (AI-assisted; automatically checked, not human-reviewed). Each statement is linked to its source; check the source before relying on a detail.

  • llm
  • inference
  • latency
  • hugging face