Skip to content
HUIAHUB

TutorialModels & inference

LLM inference benchmark tokens per second: local and server tests

Run an LLM inference benchmark tokens per second comparison with llama-bench and vLLM. Measure latency, throughput, and record settings.

Edited by Published 10 min read7 sources
A laptop and server stack exchange data through an AI chip, with a stopwatch, speed gauge and bar chart showing inference performance.

Illustration generated with ChatGPT

To run an LLM inference benchmark, tokens per second is the starting point, but you need separate measurements for generation speed and server throughput. Use llama-bench to measure prompt processing and token generation on one machine. Use vLLM bench serve to measure response latency and throughput when multiple requests share a server.

A useful benchmark also records the model, hardware, prompt length, output length and inference settings. Without those details, two speed figures may describe different workloads.

LLM inference benchmark tokens per second: what to measure

LLM inference has two main stages. During prefill, the model processes the input tokens and builds its key-value (KV) cache. During decoding, it generates output tokens using that context.

The NVIDIA NIM benchmarking metrics documentation (opens in a new tab) defines the latency and throughput measurements used below.

MetricWhat it measuresUnit
Time to first token (TTFT)Time from sending a request until the first output token arrivesMilliseconds
Inter-token latency (ITL)Time between consecutive output tokens, excluding the first tokenMilliseconds
Generation speedOutput tokens produced per second for a generation workloadTokens/second
System output throughputTotal output tokens generated across concurrent requests per secondTokens/second
Request throughputSuccessfully completed requests per secondRequests/second

Time to first token

TTFT measures how long someone waits before receiving the first generated token.

For a remote server, this can include network latency, request queuing, tokenization and prompt processing. Longer input sequences generally require more prefill work.

A server can generate output quickly once decoding begins while still taking a long time to return the first token.

TTFT is especially useful for streaming applications because it captures the delay before visible output begins.

Inter-token latency and generation speed

ITL measures the gaps between successive generated tokens.

For a request with multiple output tokens, a common calculation is:

ITL = (end-to-end latency - TTFT) / (output tokens - 1)

This excludes the initial wait.

Generation tokens per second describes how quickly output tokens are produced. For long outputs, it is closely related to the inverse of ITL.

Be careful with tool definitions. Some benchmarking tools use time per output token (TPOT) for an average decoding interval, but their aggregation methods can differ. vLLM reports TPOT and ITL separately.

System throughput and requests per second

System output throughput is the total generated tokens divided by the measurement interval.

Requests per second is the number of completed requests divided by that interval.

These metrics answer different questions. A server handling short replies may complete more requests than one generating longer replies, even when its output token throughput is lower.

The NVIDIA explanation of LLM benchmarking (opens in a new tab) also distinguishes throughput for an individual user from aggregate throughput across the system.

Why does single-request speed differ from throughput under load?

A single-request test measures performance when one generation workload uses the available inference resources.

A concurrent test measures what happens when several requests compete for those resources.

Inference servers can batch work from multiple requests. That can increase total system throughput without increasing generation speed for every individual request.

As concurrency rises, more requests may wait for processing capacity. TTFT and inter-token latency can increase even while aggregate tokens per second improves.

Eventually, the server reaches a point where additional demand produces little or no throughput improvement. Latency can continue rising.

For a local assistant used by one person, generation speed and response latency may be the primary measurements.

For a shared API server, record aggregate throughput alongside latency at each concurrency level. A high output throughput figure is less useful when requests wait too long.

These tests also measure different parts of the system:

  • A local model benchmark isolates prompt processing and decoding work.
  • A server benchmark includes the effects of serving requests, scheduling, queuing and communication with the benchmark client.
  • A complete application measurement can include additional work outside inference, such as retrieval and prompt construction.

Keep those boundaries clear when comparing results.

How to benchmark local inference with llama-bench

llama-bench is the performance measurement tool included with llama.cpp. It measures model processing speed using a supported model file.

The official llama-bench documentation (opens in a new tab) describes separate tests for prompt processing, text generation and combined processing.

If you are still choosing a local runtime, the llama.cpp, Ollama and LM Studio comparison covers the runner options.

Step 1: Prepare the model and machine

Use a built llama.cpp installation with the llama-bench executable available.

Choose the GGUF model file you want to measure. Record its exact filename and quantization.

For comparisons, keep these settings unchanged:

  • Model weights and quantization
  • CPU and GPU hardware
  • Number of CPU threads
  • GPU layer offloading
  • Batch and microbatch sizes
  • KV cache configuration
  • Context depth
  • llama.cpp build revision

Record the selected device and whether some model layers run on the CPU.

GPU offloading changes how much work runs on each processor. The benchmark supports -ngl for controlling the number of layers assigned to GPU execution.

Step 2: Run the benchmark

From the directory containing the executable, run:

./llama-bench \
-m /path/to/model.gguf \
-p 512 \
-n 128 \
-r 5 \
-o csv > local-bench.csv

Replace /path/to/model.gguf with your actual model file.

The example uses the following settings:

ArgumentMeaning
-mModel file to measure
-p 512Process 512 prompt tokens
-n 128Generate 128 tokens
-r 5Repeat each test five times
-o csvWrite results in CSV format

These lengths are an illustrative workload, not recommended values for every application.

With -p and -n, llama-bench reports separate prompt-processing (pp) and text-generation (tg) tests. It does not treat them as one end-to-end request.

The tool also supports -pg for a combined prompt-processing and generation test.

Step 3: Read the output correctly

Look for the test type and its reported tokens per second.

Prompt processing (pp) tells you how quickly the model processes input tokens.

Text generation (tg) tells you how quickly the model generates new tokens during the benchmark.

The documentation says llama-bench repeats each test, calculates its average and reports the standard deviation. CSV output also includes information about the build, hardware and test configuration.

Keep the original CSV instead of copying only the generation speed.

There is an important limit to these measurements. llama-bench excludes tokenization and sampling time. Its token generation result is therefore different from the full response speed an application experiences.

It also does not directly report network TTFT, request queuing or multi-user server throughput.

For generation at an existing context depth, llama-bench supports -d to prefill the KV cache before measuring. Record that setting because generation speed can depend on context length.

How to benchmark an inference server with vLLM

vllm bench serve sends requests to a running model endpoint and measures serving performance.

It supports OpenAI-compatible endpoints, including the completions API. The vLLM benchmark CLI reference (opens in a new tab) documents its request rate, concurrency, dataset, length and result-export options.

For initial server configuration, see the HuiaHub guide to serving an open model with vLLM.

Step 1: Start the server

The following model identifier comes from the official vLLM quickstart (opens in a new tab):

vllm serve Qwen/Qwen2.5-1.5B-Instruct \
--generation-config vllm

This example assumes vLLM is installed and the model can run on your hardware.

The server exposes an OpenAI-compatible API at http://localhost:8000 by default.

The --generation-config vllm option prevents the server from applying generation defaults supplied by the model repository. That helps keep server-side sampling settings explicit.

You can use another supported model. Make sure the model identifier in the benchmark matches the model being served.

Step 2: Run a single-concurrency baseline

Open another terminal while the server is running.

vllm bench serve \
--backend openai \
--base-url http://127.0.0.1:8000 \
--endpoint /v1/completions \
--model Qwen/Qwen2.5-1.5B-Instruct \
--dataset-name random \
--random-input-len 512 \
--random-output-len 128 \
--num-prompts 100 \
--seed 42 \
--request-rate inf \
--max-concurrency 1 \
--ignore-eos \
--save-result \
--result-filename bench-c1.json

This example uses synthetic prompts with fixed input and output lengths. The prompt count and lengths are illustrative test settings.

The important arguments are:

  • --dataset-name random selects the synthetic random workload.
  • --random-input-len and --random-output-len control token lengths.
  • --seed controls random sampling for repeatable input generation.
  • --request-rate inf requests a maximum-throughput test rather than a fixed arrival rate.
  • --max-concurrency 1 limits outstanding requests to one.
  • --ignore-eos asks the server to continue generation despite end-of-sequence tokens.
  • --save-result and --result-filename preserve the benchmark output.

The --ignore-eos setting helps generated output reach the intended length. Check the actual generated token count rather than assuming every request completed with the target length.

Step 3: Increase concurrency

Run the same benchmark with:

--max-concurrency 8

Change the result filename to bench-c8.json and leave the other settings unchanged.

Run this as a separate benchmark command, replacing the concurrency value in the previous example.

For a clean comparison, restart the server before each measurement. Keep the same model and configuration.

This matters because vLLM's benchmarking guide (opens in a new tab) warns that repeated requests can benefit from prompts already stored in the server's prefix cache. Reusing cached prompts can increase measured throughput.

Record whether prefix caching was enabled and how the server was prepared before the test.

The examples use an infinite requested arrival rate with a concurrency limit. That is a saturation-style test, not a simulation of evenly spaced production requests.

For a production-like workload, use a finite --request-rate and record the selected rate and arrival pattern. vLLM also supports --burstiness to control variation in request arrival times.

Step 4: Compare the server measurements

The benchmark reports measurements including:

  • Successful requests
  • Total generated tokens
  • Request throughput
  • Output token throughput
  • Total token throughput, including input and output tokens
  • Mean, median and P99 TTFT
  • Mean, median and P99 TPOT and ITL

Look for changes in output token throughput alongside TTFT and ITL.

For instance, higher concurrency may raise system throughput while reducing the speed experienced by each request. The result depends on the model, serving configuration and available hardware.

P99 values help identify long waits that an average can conceal.

Keep unsuccessful requests visible in the report. Throughput measured during a run with failures should not be interpreted without its success count.

There is another measurement boundary to watch. When --max-concurrency holds requests in the benchmark client, that client-side waiting is separate from the server-side timing. The benchmark supports client queue metrics for investigating this delay.

How to keep inference benchmarks comparable

Changing a model, its precision or the workload can change the meaning of the reported speed.

Before comparing hardware or runners, establish one workload definition.

Keep model and generation settings fixed

Use the same model weights and tokenizer when comparing serving configurations.

Record the quantization or numerical precision used by each implementation. A GGUF model and a model served through another runtime may use different representations.

Matching the model name alone does not establish that the implementations perform equivalent calculations.

Hold input length and output length constant. Record decoding settings such as temperature, sampling configuration and end-of-sequence handling.

For a real application workload, use representative input and output lengths instead of relying entirely on synthetic prompts.

Control the test environment

Record available CPU and GPU resources, software revisions and inference settings.

Try to avoid other workloads competing for the same hardware while collecting measurements.

Use the same warmup procedure for each run. Distinguish an initial run after server startup from a run on an already active server.

The request source also matters. A benchmark client running beside the server has different network conditions from a client accessing it remotely.

Do not combine those measurements into one comparison without identifying where the client ran.

A reusable LLM benchmark record

Use the following table as a blank template. Fill in the fields that apply to each measurement.

FieldValue to record
Test date
HardwareCPU, GPU, memory
Model and revision
Model format and quantization
Tokenizer
Inference engine and build
CPU threads and GPU offload
Batch size and KV cache settings
Input tokens
Target and actual output tokens
Context depth
Dataset and random seed
Sampling and EOS settings
Prefix cache and warmup procedure
Concurrency and request rate
Repetitions
Prompt processing tokens/second
Generation tokens/second
Mean and P99 TTFT
Mean and P99 ITL
Output throughput tokens/second
Successful requests and requests/second
Failed requests
Raw results filename

Not every field applies to both tools. llama-bench provides local processing measurements, while vLLM bench serve provides server latency and throughput measurements.

Keep their results separate until you have established equivalent workloads.

The template also makes software changes easier to investigate. If a later run is slower, the model, runner configuration and hardware record provide places to check before attributing the difference to the model itself.

What does a speed benchmark say about answer quality?

A speed benchmark does not measure whether generated answers are correct, useful or suitable for the application.

The synthetic workloads used for throughput tests measure processing behavior. They are not evaluations of reasoning, factual accuracy or instruction following.

Quantization and model selection should therefore be evaluated on two separate dimensions: inference performance and output quality.

Keep a representative set of prompts and expected behavior checks for the application. Run those checks separately from the performance benchmark.

The HuiaHub guide to evaluating LLM outputs with promptfoo covers a separate workflow for testing model responses.

For a deployment decision, retain both sets of results. A model that completes requests quickly may still fail the tasks the application requires.

Frequently asked questions

Can I compare tokens per second across models with different tokenizers?

Direct comparisons need care because tokenizers can split the same text into different numbers of tokens. Record the tokenizer, input workload and output lengths for each model. Token throughput alone does not establish how quickly two models produce equivalent text.

Does llama-bench measure time to first token?

llama-bench measures prompt processing and generation performance, but its standard results are not end-to-end TTFT measurements. Its documentation also excludes tokenization and sampling time. Use an appropriate request-level measurement when TTFT is required.

Can vLLM bench serve test a chat completions endpoint?

Yes. The current CLI supports `--backend openai-chat` with `--endpoint /v1/chat/completions`. Keep the chat template, messages and server configuration consistent when comparing results.

How many repetitions are needed for an LLM inference benchmark?

There is no universal repetition count that makes every benchmark reliable. llama-bench uses five repetitions by default and reports variation between runs. For server tests, repeat the same controlled workload and inspect how much the reported measurements change.

Sources

  1. 1.LLM Inference Benchmarking: Fundamental Concepts | NVIDIA Technical BlogOfficial docsPrimarydeveloper.nvidia.com
  2. 2.Metrics | NVIDIA NIM Benchmarking DocumentationOfficial docsPrimarydocs.nvidia.com
  3. 3.llama.cpp/tools/llama-bench at master · ggml-org/llama.cpp · GitHubRepositoryPrimarygithub.com
  4. 4.serve - vLLMOfficial docsPrimarydocs.vllm.ai
  5. 5.Benchmark CLI - vLLMOfficial docsPrimarydocs.vllm.ai
  6. 6.github.com/ggml-org/llama.cpp/blob/master/tools/llama-bench/README.mdRepositoryPrimary
  7. 7.Quickstart - vLLMOfficial docsPrimarydocs.vllm.ai

Spotted an error? See our corrections policy.

Enjoyed this? Get the weekly brief.

New guides, Project & Tool of the Week and the AI developments that matter. One email, no spam.

Read next

More on these topics