Skip to content
Athrael.net logoAthrael.net

Introduction to GPU InferenceChapter 1: Foundations

Measuring inference

Lesson 3 of 4 · about 7 min

What this lesson covers

Previously we came across terms like time to first token, tokens per second and throughput. This lesson defines them and adds a few more.

Time to first token

Time to first token, or TTFT, is the time between sending a prompt and receiving the first token of the reply.

Part of it is queue time, while the request waits for a free slot on the GPU. The rest is the model processing the whole prompt before it can generate anything, which grows with the length of the prompt.

Time to first token
Prompt
1Waiting for a slot
Queue time
2Processing the prompt
Processing time
3First token
In total
The times are illustrative, with a slot freeing up every 150 ms and the model processing 10,000 prompt tokens a second.

Time per output token

Once the reply starts, tokens arrive one after another, and time per output token, or TPOT, is the average gap between them.

Tokens per second counts how many of those gaps fit in one second, so a TPOT of 20 milliseconds equals 50 tokens per second.

Time per output token
Each tick and each word is one token, the playhead moves in real time, and reading pace is set at about five and a half tokens a second.

Most people read about four words a second, which is five or six tokens, so a reply generated faster than that is ready before you reach it, and a slower one makes you wait for each word.

End-to-end latency

End-to-end latency is the time from sending the prompt to the last token of the reply, which comes to the time to first token plus one TPOT for every token after the first.

With a TTFT of 300 milliseconds and a TPOT of 20, a 10-token reply is done in about half a second, most of it waiting for the first token. A 500-token reply takes about 10 seconds, nearly all of it spent generating.

End-to-end latency
Reply
Tokens after the first
End-to-end latency
First token Tokens after it
The bar under the sum shows how the total splits between the time to first token and the tokens after it.

Throughput and goodput

The measures so far describe a single request, and throughput describes the whole server. A server at full load keeps its throughput high, but its TTFT and TPOT can then be too slow to be useful, so goodput counts only the requests that met a target, such as a first token within half a second.

Throughput and goodput as load rises
Throughput Goodput Finished late Time to first token
The numbers are illustrative. Every reply here is the same length, so throughput is counted in replies, and the target is a first token within half a second.

As more requests arrive, throughput rises and then levels off, while goodput follows it at first and then falls as more requests miss the target.

Percentiles

A server handles thousands of requests and each has its own TTFT, so the results are usually summarized in a single number. The average is the common choice, but it can look acceptable even when some requests took several times longer.

A percentile states the share of requests that were faster than a given time. The median, or 50th percentile, splits the requests in half, and the 95th percentile, written p95, is the time that 95 of every 100 requests are faster than, which makes it a measure of the slowest requests, and a service is usually judged on its p95 or p99.

Time to first token for twenty requests
Average Median 95th percentile
Each dot is one request placed at its time to first token, and the times are invented for this example.

A service is usually judged on its p95 or p99.

Recap

The speed of one reply is described by time to first token, which covers queue time and prompt processing, and time per output token, the gap between the tokens that follow. Together they give end-to-end latency. Throughput describes the whole server, goodput counts only the requests that met a target, and percentiles such as p95 report the slowest requests.

You will find these numbers on provider pages and in benchmark tables, and teams use them to decide whether a setup is good enough. A claim that a model is fast refers to one of these numbers at a particular load.

Servers are also measured on things like how often requests fail, how long a model takes to load and how much energy it uses, and the next lesson covers memory and cost.