All glossary terms

Serving

Time to first token

How long a caller waits before the reply's first word: queue wait plus the prefill pass over the prompt. The latency users judge a service by.

Time to first token (TTFT) is the wait from the request arriving to the first token of the reply existing. It has two parts: queue wait while the server finds room, and prefill - one big pass over the whole prompt that writes the KV cache entries decode will read from. Everything the user perceives as "it is thinking" is these two parts.

Prefill dominates on long prompts because it is compute-bound: the whole prompt rides through the model in one pass, and its cost grows with prompt length. The single biggest lever is a prefix cache, which reuses the KV states of text that repeats across requests - a fixed system prompt, a large document - so only the new tail prefills. After that: shorter prompts, chunked prefill scheduling that hides prefill inside decode traffic, and faster cards.

TTFT is also the metric users judge first, because a reply that starts fast and streams steadily at a modest per-token rate feels better than one that waits three seconds and types at triple the speed. Watch it at p95: the worst wait, not the average, is where caching misses, queueing, and cold starts appear.

A worked example

A 3,000-token prompt on an H100 (about 989 TFLOPs/s dense 16-bit), a 70B model at 140 GFLOPs per token, with 0.08 s of measured queue wait.

  1. Full prefill: 3,000 x 140 GFLOPs = 4.2e14 FLOPs; at 989 TFLOPs/s that is about 0.42 s.
  2. Time to first token: 0.42 s + 0.08 s queue = about 0.5 s.
  3. A prefix cache hits on 2,700 of the 3,000 tokens: only 300 new tokens prefill, 300 x 140 GFLOPs = 4.2e13 FLOPs, about 0.04 s.
  4. The first token now arrives after about 0.12 s - the cache, not a faster GPU, removed the wait.

Prefill is most of the wait on long prompts, and a cache on the repeated part removes almost all of it - for a fraction of the cost of new hardware.

Where this shows up

Test yourself

Related terms