Tokens per second (t/s or tok/s) is the rate at which a language model processes text: how many tokens of your prompt it reads per second, or how many tokens of its reply it generates per second. The second number, generation speed, is the one you feel while watching a reply stream in, and on local hardware it is limited mainly by memory bandwidth.
A token is a chunk of text, often a word or part of a word. How many tokens a given text becomes depends on the tokenizer; see how many tokens is a word for real counts.
The three speed numbers
| Metric | What it measures | What limits it |
|---|---|---|
| Prompt processing (prefill), t/s | How fast the model reads your input | Compute (GPU throughput) |
| Generation (decode), t/s | How fast it writes output tokens | Memory bandwidth |
| Time to first token (TTFT), seconds | Delay before the reply starts appearing | Prompt length, prompt speed, model loading, queueing |
Anthropic's latency guide defines TTFT as the time "for the model to generate the first token of the response, from when the prompt was sent", and notes it matters most when you stream responses. A long prompt can give a slow first token followed by a fast stream, or the other way round, so one number never describes the whole experience.
Why generation is slower than prompt processing
NVIDIA's inference guide explains the split. The prompt is handled in one pass as "a matrix-matrix operation that's highly parallelized", which "effectively saturates GPU utilization". Output is generated one token at a time, "a matrix-vector operation that underutilizes the GPU compute ability", and in that phase the time to move data "dominates the latency, not how fast the computation actually happens". NVIDIA calls decode "a memory-bound operation".
The gap is large. The llama.cpp benchmark README shows an example run of a 7B model at Q4_0 (3.56 GiB) on a CUDA GPU: about 2,369 t/s for prompt processing (pp512) and about 131 t/s for generation (tg128). Prompt processing was roughly 18 times faster.
Putting those numbers to work: a 512-token prompt takes about 0.22 seconds to read (512 / 2,369), and a 1,000-token reply takes about 7.6 seconds to write (1,000 / 131). For chat, generation speed dominates the wait.
The bandwidth rule of thumb for local models
To generate each token, the model has to read essentially all of its weights from memory. That gives a simple upper bound:
max generation t/s ≈ memory bandwidth (GB/s) ÷ model size in memory (GB)
It is a ceiling, not a prediction: real runs land below it because of compute overhead, the growing context and software efficiency. But it explains most of the differences between machines. Using Apple's published bandwidth figures and a 7B model at Q4_0 (3.56 GiB, which is 3.82 GB):
| Chip | Memory bandwidth | Ceiling, 7B Q4_0 (3.82 GB) | Ceiling, 70B at ~4.5 bits (≈39.4 GB) |
|---|---|---|---|
| M4 | 120 GB/s | ≈31 t/s | Doesn't fit (32 GB max) |
| M4 Pro | 273 GB/s | ≈71 t/s | ≈6.9 t/s (needs the 64 GB model) |
| M4 Max | 546 GB/s | ≈143 t/s | ≈13.9 t/s |
The 70B size is arithmetic: 70 billion weights × 4.5 bits ÷ 8 = 39.4 GB, before the KV cache. Two practical conclusions follow. A model ten times larger generates roughly ten times slower on the same hardware. And quantizing a model (for example from 8-bit to 4-bit) roughly halves the bytes read per token, so it speeds up generation as well as saving memory. LLM quantization explained covers the formats; unified memory explained covers why Macs can load such large models at all.
The rule breaks down when the model doesn't fit in GPU memory. Layers that spill to system RAM are read over a much slower path, and generation speed falls sharply. How much VRAM you need shows how to size that.
How to measure tokens per second in Ollama
Ollama's API returns timing fields with every response, all durations in nanoseconds:
| Field | Meaning |
|---|---|
prompt_eval_count | Tokens in the prompt |
prompt_eval_duration | Time spent on uncached prompt tokens |
eval_count | Tokens in the response |
eval_duration | Time spent generating the response |
load_duration | Time spent loading the model |
total_duration | Whole request |
The docs give the formula directly: generation speed is eval_count / eval_duration * 10^9. Use the same pattern with the prompt_eval_* fields for prompt speed. Worked example with illustrative numbers: eval_count = 412 and eval_duration = 9,800,000,000 ns gives 412 / 9.8 s = 42 t/s.
curl -s http://localhost:11434/api/generate -d '{
"model": "llama3.2",
"prompt": "Explain DNS in three sentences.",
"stream": false
}'
Ignore total_duration for speed comparisons: it includes load_duration, which can be several seconds on the first request after a model is loaded from disk.
How to benchmark with llama.cpp
llama-bench runs a standard prompt-processing test and a generation test and reports average tokens per second with a standard deviation:
llama-bench -m model.gguf
By default it runs pp512 (process a 512-token prompt) and tg128 (generate 128 tokens), set by -p and -n. The output table has the columns model, size, params, backend, ngl, test and t/s. Because the test sizes are fixed, results are comparable between machines, which is why people post llama-bench tables when comparing hardware. If you haven't installed it yet, getting started with llama.cpp covers that.
Comparing tokens per second fairly
- Same model, same quantization. A Q4 and a Q8 file of the same model differ in speed by design.
- Same prompt length. Speeds measured on a short prompt drop with long contexts.
- Prompt and generation separately. A single "t/s" figure without saying which is not comparable.
- Same tokenizer. Different model families split the same text into different numbers of tokens, so 50 t/s on one model is not the same amount of text as 50 t/s on another.
- Warm runs. Discard the first run, which includes loading the model.
For hosted APIs, providers report usage in tokens but you measure speed yourself: time from the first streamed token to the last, divided by the output token count in the response's usage field, gives generation speed; the time until the first token is TTFT. Both vary with load, so measure several requests rather than one.
Frequently asked questions
- What is a good tokens per second for a local LLM?
- It depends on the use. For reading a reply as it streams, generation in the low tens of tokens per second already outpaces most readers. For coding agents or batch jobs that produce long outputs, faster is directly time saved. Compare numbers only when the model, quantization, prompt length and hardware match.
- Why is prompt processing so much faster than generation?
- Prompt tokens are processed together in large parallel batches, which keeps the GPU's compute busy. Output tokens are produced one at a time, and each one requires reading the model's weights from memory again, so generation is limited by memory bandwidth rather than compute.
- Does a longer prompt slow down generation?
- Yes, somewhat. A longer prompt takes longer to process before the first token appears, and every new token also has to attend to the whole context, which adds work as the context grows. Benchmarks with short prompts therefore overstate speed for long-document use.
- Do more CPU cores or a faster GPU always mean more tokens per second?
- Not for generation. Once the model is in fast memory, generation speed is set mostly by how quickly the weights can be read, which is memory bandwidth. More compute helps prompt processing; more bandwidth helps generation.