vLLM vs SGLang vs llama.cpp: which engine should you choose?
vLLM for GPU throughput, SGLang for requests sharing the same context, llama.cpp for CPU and edge hardware.
vLLM, SGLang, and llama.cpp are three open-source engines that run language models and serve their output to applications. The model determines what the system has learned; the engine controls how the model runs on the available resources and how requests are handled. vLLM was built to serve many requests while using accelerator memory efficiently. SGLang includes mechanisms for reusing shared parts of requests. llama.cpp runs on CPUs and GPUs, local machines included. These capabilities overlap: vLLM also reuses common prefixes, and llama.cpp can serve multiple users. So no single ranking fits every organization. The choice depends on the available model and file format, the hardware, the number of concurrent requests, and the required response time. Before buying compute capacity or committing to a service level, test the actual combination of version, model, and workload instead of going by the engine's name.
See also: InferenceAI inference applies a trained model to new data to produce predictions or responses; latency and cost depend on the workload and the infrastructure behind it.
Memory and prefix reuse
The vLLM paper describes PagedAttention, a technique that manages the KV cache (temporary storage for model computations) in blocks. In the authors' tests, vLLM achieved two to four times the throughput of FasterTransformer and Orca at the same latency. That result holds only for those comparisons; it does not prove vLLM always beats SGLang or llama.cpp.
The SGLang paper introduces RadixAttention, which reuses computation across requests with a common prefix. The vLLM documentation also describes prefix reuse, which speeds up initial prompt processing but not, directly, answer generation. The benefit depends on how much context is actually shared and still held in memory.
llama.cpp and the GGUF format
llama.cpp is a candidate for a local model on a CPU or GPU and for GGUF files, a model distribution format. Its server documentation covers parallel requests and continuous batching, the dynamic handling of concurrent requests, so a multi-user service is no reason to drop llama.cpp from a comparison. The vLLM documentation calls its GGUF support, which requires a separate plugin, highly experimental and under-optimized.
An enterprise example
A company wants to query an internal manual at headquarters and at branches without dedicated GPUs. For the central service, it compares vLLM, SGLang, and llama.cpp with requests that include the manual and others that share no text. At each branch, it tests llama.cpp on the existing machine. This is an illustrative scenario, not a measured result: choosing an engine requires testing the approved model under real operating conditions.
How to compare them
Using the same hardware, model version, weight precision, and request lengths, measure time to first token, generation speed, and memory use. Repeat under representative concurrent load, separating new requests from cached prefixes. Record versions and settings: without them a result cannot be reproduced.
Why it matters for decision makers
Cost includes hardware, operations, and the capacity required to meet promised response times. A compatible API can make switching engines easier but does not guarantee the same features or results. Before buying, check model compatibility, answer quality, access controls, and the model's license terms separately from the engine's license.
Frequently asked questions
Related terms
- InferenceAI inference applies a trained model to new data to produce predictions or responses; latency and cost depend on the workload and the infrastructure behind it.
- KV cacheThe KV cache stores a language model's intermediate attention values so the model does not recompute them as it generates an answer, one token at a time.
- Continuous batchingContinuous batching changes which LLM requests are processed together at each iteration, freeing capacity when a response ends so others can be served at once.
- Local LLMA local LLM is a language model whose open weights run on hardware you control through a runtime like Ollama, so prompts and responses never leave your network.