Explainer
What is LLM inference serving?
Inference serving turns a model file and a set of GPUs into a service that many users and applications can rely on. This explainer covers how generation works, what to measure, how to size memory and how to choose an engine.
In short
LLM inference serving runs a trained language model as a service: it receives prompts, schedules them on GPUs, generates tokens and streams them back. Engines such as vLLM batch many requests together and manage key-value cache memory, so that one server can answer many users. Serving is judged on latency, throughput and reliability.
DefinitionLLM inference serving is the software and infrastructure that load a trained language model, accept requests from users and applications, schedule them on GPUs or other accelerators and return the generated tokens, with the batching, memory management, scaling and monitoring that production use requires.
Key takeaways
- Generation has two phases: prefill processes the whole prompt at once, then decode produces one token per step, and each phase stresses the hardware differently.
- GPU memory must hold the model weights plus the key-value cache of every request in flight, which grows with context length and concurrency.
- Continuous batching and paged KV-cache memory let one GPU serve many users; the vLLM authors reported 2 to 4 times the throughput of earlier systems at the same latency.
- Measure time to first token, time per output token, throughput, queue time and cache use, against targets set for each workload.
- Treat models, engine versions and serving settings as released artefacts, with evaluation, gradual rollout and rollback.
What is LLM inference serving?
LLM inference serving is running a trained language model as a service that many users and applications can call at once. Training produces the model’s weights; serving loads those weights onto GPUs, accepts requests, generates the answers and keeps the service fast, reliable and observable.
A serving stack has a few parts:
- An inference engine, such as vLLM or SGLang, that loads models, schedules requests and manages GPU memory.
- An API, usually OpenAI-compatible, so that applications can call different models in the same way.
- An AI gateway in front of the engines, for identity, quotas, routing and audit logging.
- Monitoring of latency, throughput, errors and memory.
- A model registry and release process, so that only approved model versions reach production.
The on-premises AI reference architecture shows where serving sits among the other layers of a platform.
How does an LLM generate a response?
In two phases. Prefill processes the whole prompt in parallel and produces the first token; decode then generates the rest of the answer one token at a time, each step depending on the previous ones.
The two phases stress the hardware differently. The Sarathi-Serve paper describes prefill iterations as slow but saturating the GPU’s compute, and decode iterations as fast but using little of it. Long prompts, such as the retrieved passages in retrieval-augmented generation, make prefill heavier; long answers make decode heavier.
To avoid recomputing the prompt for every new token, the model keeps a key-value (KV) cache: the attention keys and values of every token processed so far. The cache grows with context length and with the number of requests in flight. The PagedAttention paper gives an example: one token of a 13-billion-parameter model needed about 800 KB, so a single 2,048-token request could need up to 1.6 GB. Managing this memory well is what lets one GPU serve many users.
Why does batching matter so much?
Because decode uses little of a GPU’s compute per request, a server is economical only when it processes many requests together. How it batches them decides both cost and latency.
- Request-level batching waits for a group of requests and runs them together. The Orca paper showed the problem: requests that finish early cannot return until the whole batch is done, and new requests wait for the next batch.
- Continuous batching, introduced in Orca as iteration-level scheduling, lets requests join and leave the batch after every generation step. Orca reported up to 36.9 times the throughput of NVIDIA FasterTransformer at the same latency on a GPT-3 175B model.
- Paged KV-cache memory, introduced with vLLM, stores the cache in small blocks instead of one large reservation per request. Its authors found that earlier systems used only 20.4% to 38.2% of KV-cache memory for actual token states, and reported 2 to 4 times the throughput of FasterTransformer and Orca at the same latency.
Batching still involves a trade-off: larger batches raise total throughput, but each user’s tokens can arrive more slowly. Chunked prefill splits long prompts into pieces so that new requests can join the batch without pausing answers that are already being generated. vLLM supports it.
Which metrics show whether serving works?
Two groups: latency metrics that users feel, and capacity metrics that operators need. Set targets for each workload and track percentiles, not only averages.
- Time to first token (TTFT): the wait before the answer starts, covering queueing and prefill.
- Time per output token (TPOT), or inter-token latency: how fast the answer streams, driven by decode.
- End-to-end latency: the total time for a request, which matters most for agents and batch jobs.
- Throughput: tokens or requests per second across all users.
- Queue time, running and waiting requests, and KV-cache usage: early warnings that the server is near capacity.
The DistServe paper treats TTFT and TPOT as the two latency targets of LLM serving, and vLLM exposes both, along with queue time, KV-cache usage and prefix-cache hits, as Prometheus metrics. Different workloads put different metrics first:
| Workload | What users notice | Metric to watch | Serving levers |
|---|---|---|---|
| Chat assistant | The wait before the first word, then the reading speed | TTFT and time per output token | Moderate batch sizes, prefix caching for shared system prompts, speculative decoding |
| Question answering over documents | The wait before the answer starts | TTFT, which grows with prompt length | Prefix caching for documents asked about repeatedly, chunked prefill, fewer but better passages |
| Batch document processing | The time to finish the whole job | Throughput | Large batches, scheduled outside peak hours |
| Agents | The total time across many sequential calls | End-to-end latency per step and per task | Prefix caching for long shared context, small models for simple steps |
| Embedding and reranking | Search latency | Requests per second | A separate deployment sized for its own load |
Which techniques reduce latency and memory?
Four are standard in current engines: prefix caching, speculative decoding, quantisation and parallelism across GPUs. Each has a cost, so enable them per workload and measure the effect.
- Prefix caching reuses the KV cache of a shared prompt prefix, such as a long system prompt, a document asked about repeatedly or the earlier turns of a conversation. vLLM’s documentation notes that it shortens prefill only, not the generation of new tokens.
- Speculative decoding lets a small draft model propose several tokens that the large model then verifies in one step. Leviathan and colleagues showed that this leaves the output distribution unchanged, and reported 2 to 3 times faster generation on T5-XXL. The gain depends on how often the draft is right.
- Quantisation stores weights, and in some engines the KV cache, at 8 or 4 bits instead of 16, halving or quartering their memory. Quality can drop, so evaluate the quantised model on your own tasks.
- Parallelism splits a model that does not fit on one GPU across several, through tensor, pipeline or expert parallelism. vLLM supports these and also disaggregated serving, which runs prefill and decode on separate GPUs; the DistServe paper showed that this can serve more requests within the same latency targets.
How much GPU memory does inference serving need?
Enough for the model weights, the KV cache of every concurrent request and some runtime overhead.
- Weights = parameters × bytes per parameter: about 2 bytes at 16-bit precision, 1 byte at 8-bit and half a byte at 4-bit. An 8-billion-parameter model at 16-bit needs about 16 GB.
- KV cache per token = 2 (keys and values) × layers × key-value heads × head dimension × bytes per value. Multiply it by the context length and by the number of concurrent requests.
- Overhead for activations, the runtime and memory fragmentation, usually estimated as a percentage.
The LLM GPU sizing calculator applies these formulas to your model, precision, context length and number of users. Memory is the first check, not the last: benchmark latency and throughput with your own prompts and expected concurrency before you buy hardware.
Which inference engine should you use?
For a shared production service, use an engine built for concurrent serving, and benchmark two or three candidates on your own models and prompts.
The main open-source options for servers are:
- vLLM, a library for LLM inference and serving built around PagedAttention, with an OpenAI-compatible API server and support for NVIDIA and AMD GPUs and several CPU architectures.
- SGLang, a serving framework for language and multimodal models, with RadixAttention prefix caching and OpenAI-style APIs.
- NVIDIA TensorRT-LLM, an open-source library for accelerating inference on NVIDIA GPUs, with in-flight batching, a paged KV cache and speculative decoding.
Hugging Face has put its Text Generation Inference server into maintenance mode and recommends vLLM or SGLang instead, with llama.cpp or MLX for local use. When you compare engines, check hardware and model support, metrics, licences and support for serving several adapters of fine-tuned models on one base model. Our comparison of vLLM, Ollama, llama.cpp and SGLang goes through the trade-offs.
How do you run inference serving in production?
As a platform service with an owner: behind a gateway, monitored, and changed only through releases.
- Put a gateway in front. Applications call the gateway, never an engine directly, so engines can be added, replaced or moved without changing applications.
- Give each model class its own deployment. General-purpose models, small task models, embedding models and rerankers face different demand and scale separately.
- Release changes like software. A new model version, engine version, quantisation level or batch setting passes the evaluation set, runs on part of the traffic first and can be rolled back in one step.
- Plan capacity from metrics. Rising queue time and KV-cache usage show when to add capacity, before users notice.
- Log with care. Record request metadata and latency for every call, and prompts and outputs only where policy allows, with restricted access and a set retention period.
Organisations that do not want to run this themselves can have the platform operated as a private LLM service on their own infrastructure, or in a dedicated environment through private AI hosting.
Frequently asked questions
What is LLM inference serving?
It is the layer that runs a trained language model as a service. An inference engine loads the model onto GPUs, accepts requests through an API, schedules them in batches, manages key-value cache memory and streams the generated tokens back, while latency, throughput and errors are monitored. It is separate from training, which produces the model weights.
What is the difference between inference and training?
Training adjusts a model's weights on large datasets and runs as a long batch job. Inference uses the finished weights to generate outputs for incoming requests, continuously and often interactively. Serving costs therefore depend on usage: the number of requests, the length of prompts and answers, and the latency that users expect.
What is time to first token?
Time to first token is the delay between sending a request and receiving the first generated token. It covers queueing and the prefill phase, in which the model processes the whole prompt, so it grows with prompt length. For chat assistants it is the delay users notice most. vLLM, for example, exposes it as a Prometheus metric.
What is continuous batching?
Continuous batching, introduced as iteration-level scheduling in the Orca paper, lets requests join and leave a batch after every generation step instead of waiting for the whole batch to finish. Short answers return as soon as they are complete and new requests start sooner, so the GPU stays busy and throughput rises.
What is the KV cache?
The key-value cache stores the attention keys and values of every token a model has already processed, so they are not recomputed for each new token. It grows with context length and the number of concurrent requests. In the PagedAttention paper, one token of a 13-billion-parameter model needed about 800 KB, and one 2,048-token request up to 1.6 GB.
Can inference serving run on CPUs?
Yes, for small models and light workloads. vLLM, for example, supports x86, ARM and PowerPC CPUs as well as NVIDIA and AMD GPUs. For larger models serving many concurrent users, GPUs or other accelerators are usually needed, because they hold the weights and cache in fast memory and process many requests in parallel.
Does quantisation reduce answer quality?
It can. Storing weights at 8 or 4 bits instead of 16 halves or quarters their memory and lets a model fit on fewer GPUs, but the effect on quality varies by model, method and task. Evaluate the quantised model on your own test set before release, and record the precision as part of the model version.
Which inference engine should we choose?
For a shared service, choose an engine built for concurrent serving, such as vLLM or SGLang, which both offer OpenAI-compatible APIs and prefix caching. Check hardware and model support, metrics and adapter support, then benchmark on your own prompts. Hugging Face has put its Text Generation Inference server into maintenance mode and recommends vLLM or SGLang instead.
Sources
- vLLM documentation · checked 27 October 2026
- vLLM documentation: metrics · checked 27 October 2026
- vLLM documentation: automatic prefix caching · checked 27 October 2026
- vLLM documentation: quantized KV cache · checked 27 October 2026
- Kwon et al.: Efficient Memory Management for Large Language Model Serving with PagedAttention (SOSP 2023) · checked 27 October 2026
- Yu et al.: Orca, a Distributed Serving System for Transformer-Based Generative Models (OSDI 2022) · checked 27 October 2026
- Agrawal et al.: Taming Throughput-Latency Tradeoff in LLM Inference with Sarathi-Serve · checked 27 October 2026
- Zhong et al.: DistServe, Disaggregating Prefill and Decoding for Goodput-optimized Large Language Model Serving (OSDI 2024) · checked 27 October 2026
- Leviathan et al.: Fast Inference from Transformers via Speculative Decoding (ICML 2023) · checked 27 October 2026
- SGLang documentation · checked 27 October 2026
- NVIDIA: TensorRT-LLM overview · checked 27 October 2026
- Hugging Face: Text Generation Inference documentation (maintenance mode notice) · checked 27 October 2026