Guide
Choosing an on-premises inference engine
vLLM, SGLang, llama.cpp and Ollama all run open-weight models on hardware you control, but each is built for a different job. This guide compares them as their own documentation describes them on 27 October 2026.
In short
Use vLLM or SGLang to serve many users from data-centre GPUs: both are built for high-throughput serving, reuse cached prompt prefixes and offer OpenAI-compatible APIs. Use llama.cpp for CPUs, edge devices and mixed hardware. Use Ollama for developer laptops and evaluation; by default it processes one request per model at a time.
DefinitionAn LLM inference engine is the software that loads a model's weights onto GPUs or CPUs, schedules incoming requests and generates tokens, usually behind an HTTP API that applications call.
Key takeaways
- vLLM and SGLang are open-source engines built for multi-user serving on GPU servers; both are released under Apache 2.0 and offer OpenAI-compatible APIs.
- SGLang's RadixAttention reuses cached computation across requests that share a prefix, which suits retrieval, long system prompts and multi-turn agents; vLLM also caches prefixes automatically.
- llama.cpp runs quantised GGUF models on CPUs, Apple silicon and most GPU types, which makes it a good fit for CPU-only servers, edge devices and mixed hardware.
- Ollama, which uses llama.cpp as its backend, makes it easy to run models on a laptop, but by default it processes one request per model at a time and its local API has no authentication.
- All four can constrain output to a JSON schema. Capabilities change with every release, so benchmark candidates on your own models, prompts and hardware.
What is the difference between vLLM, SGLang, llama.cpp and Ollama?
All four are open-source engines that run open-weight language models on hardware you control, but each is built for a different job. vLLM and SGLang serve many concurrent users from GPU servers, llama.cpp runs models on a wide range of hardware with minimal setup, and Ollama turns local models into a simple tool for laptops and workstations.
- vLLM is a library for LLM inference and serving. It manages the key-value (KV) cache, which holds attention results for tokens already processed, with a technique called PagedAttention, and it batches incoming requests continuously, so the GPU keeps working as individual requests start and finish.
- SGLang is a serving framework for language and multimodal models, designed for low-latency, high-throughput inference from a single GPU to large clusters. Its RadixAttention technique reuses the KV cache across requests.
- llama.cpp is a C/C++ engine without external dependencies, aimed at inference with minimal setup on a wide range of hardware. It runs models stored in GGUF, a file format designed for engines built on the GGML library, and includes an HTTP server.
- Ollama packages model downloads, a model library and a REST API into one installer for macOS, Windows and Linux, with an official Docker image. Its README lists llama.cpp as its supported backend.
The rest of this guide compares the four on the points that decide an on-premises deployment. Our explainer on LLM inference serving covers batching, latency and throughput in more depth.
How do the four engines compare?
In short, vLLM and SGLang focus on multi-GPU serving, llama.cpp on running with minimal setup on many kinds of hardware, and Ollama on ease of local use. The table summarises each project’s own documentation and repository as checked on 27 October 2026. The projects release often, so confirm each point for the version you deploy.
| vLLM | SGLang | llama.cpp | Ollama | |
|---|---|---|---|---|
| Licence | Apache 2.0 | Apache 2.0 | MIT | MIT |
| Hardware | NVIDIA, AMD and Intel GPUs; x86, ARM, PowerPC and IBM Z CPUs; TPU, Gaudi, Ascend and others through separately maintained plugins | NVIDIA and AMD GPUs, Intel Xeon CPUs, Google TPUs, Ascend NPUs, Moore Threads GPUs and Apple silicon | x86 and RISC-V CPUs; Apple silicon; NVIDIA, AMD, Intel and Vulkan GPUs; Ascend NPUs; Snapdragon | NVIDIA GPUs (compute capability 5.0 or later), AMD GPUs with ROCm 7, Apple Metal and Vulkan; CPU fallback |
| APIs | OpenAI-compatible server, Anthropic Messages API and gRPC | OpenAI- and Hugging Face-compatible, Anthropic Messages endpoint and a native API | OpenAI-compatible chat, responses and embeddings; Anthropic Messages; reranking | Own REST API, plus subsets of the OpenAI and Anthropic APIs |
| Batching and caching | PagedAttention, continuous batching, chunked prefill, prefix caching, speculative decoding, disaggregated prefill and decode | RadixAttention cache reuse, prefix caching, multi-GPU parallelism, prefill-decode disaggregation | Parallel slots for several users; continuous batching and prompt caching on by default; speculative decoding | One request per model at a time by default, a queue of 512, up to three models per GPU loaded at once |
| Operational fit | Multi-user production serving on data-centre GPUs | Multi-user serving where requests share long prefixes, up to large clusters | CPU servers, edge devices, Apple silicon and mixed hardware | Developer laptops, evaluation and small pilots |
Which engine should serve many users on GPU servers?
Start with vLLM or SGLang. Both are built for high-throughput serving on data-centre GPUs, offer OpenAI-compatible APIs and can spread one model across several GPUs.
vLLM documents a long feature list: continuous batching, chunked prefill, automatic prefix caching, speculative decoding, disaggregated prefill and decode, serving many LoRA adapters on one base model, and tensor, pipeline, data, expert and context parallelism. It runs quantised weights in formats such as FP8, INT8, INT4, GPTQ, AWQ and GGUF. Beyond NVIDIA and AMD GPUs, it reaches accelerators such as Google TPUs, Intel Gaudi and Huawei Ascend through hardware plugins maintained outside the main repository, so check each plugin’s own status before you rely on it.
SGLang is built around cache reuse. RadixAttention keeps the KV cache of earlier requests and reuses it when a new request begins with the same tokens. That helps when many requests share a long system prompt, the same retrieved documents or a growing conversation history. SGLang can also run the prefill phase, which processes the prompt, and the decode phase, which generates tokens, on separate servers, moving the cache between them with the Mooncake or NIXL transfer engines.
Because vLLM caches prefixes too, the difference shows only under your own load. Benchmark both with your model, prompt mix, context lengths and concurrency. Before you buy hardware, estimate memory with our LLM GPU sizing calculator: the KV cache grows with context length and the number of concurrent requests, and it often limits how many requests one GPU can serve at once.
When is Ollama the right choice?
Ollama suits developer laptops, workstations, demonstrations and small pilots, where a one-step install and a ready model library matter more than throughput. Running it as a shared production service takes extra work.
Its documented defaults explain why:
- Each loaded model processes one request at a time unless you raise
OLLAMA_NUM_PARALLEL. Further requests wait in a queue of up to 512 before Ollama rejects them. - The default context window depends on the machine’s GPU memory (VRAM): 4,096 tokens below 24 GiB, 32,768 from 24 GiB and 262,144 from 48 GiB. Ollama recommends at least 64,000 tokens for agents, coding tools and web search, set with
OLLAMA_CONTEXT_LENGTH. Longer contexts need more memory;ollama psshows the context each loaded model received, so check it against the prompt lengths your application sends. - The server listens on 127.0.0.1, port 11434, and the local API needs no authentication.
OLLAMA_HOSTexposes it on the network, so put an authenticating gateway in front before you do. - Ollama can also run cloud-hosted models. Ollama’s service processes the prompts sent to them, without storing or logging that content according to its FAQ. On managed devices, switch to local-only mode with
OLLAMA_NO_CLOUD=1or the equivalent server setting.
Ollama imports models in GGUF and Safetensors formats. Because it offers subsets of the OpenAI and Anthropic APIs, applications written against those APIs can later point at a production engine instead; test the parameters they use when you switch.
When should you run llama.cpp directly?
Choose llama.cpp for CPU-only servers, edge devices, Apple silicon and mixed hardware, or when you want a small engine with no dependencies inside an isolated network.
Its hardware reach is wide. It has optimised CPU paths for x86 (from AVX to AMX) and RISC-V; ARM NEON, Accelerate and Metal on Apple silicon; CUDA, HIP, SYCL, MUSA and Vulkan back ends for NVIDIA, AMD, Intel, Moore Threads and other GPUs; and back ends for Ascend NPUs and Snapdragon devices. Integer quantisation from 1.5 to 8 bits shrinks models to fit, and hybrid inference can run a model partly on the CPU when it is larger than the GPU’s memory.
The built-in HTTP server offers OpenAI- and Anthropic-compatible endpoints, reranking, parallel decoding for several users, continuous batching and prompt caching (both on by default), speculative decoding and API keys. Its Prometheus metrics endpoint stays off until you enable it. It runs models in GGUF format, downloaded as GGUF or converted from other formats, so record the exact file and quantisation you approve. For large multi-GPU clusters, vLLM and SGLang document more parallelism options.
Which engines support structured outputs?
All four can force a model’s output to follow a JSON schema, and vLLM, SGLang and llama.cpp also support regular expressions or grammars. This matters for extraction, classification and agent tool calls, where an application parses the output.
- vLLM supports JSON schemas, regular expressions, a fixed list of choices, context-free grammars and structural tags, through the xgrammar or guidance back ends. Requests use the OpenAI-compatible
response_formatfield or vLLM’s own parameters. - SGLang supports JSON schemas, regular expressions and EBNF grammars, with XGrammar as the default back end and Outlines or llguidance as alternatives, and one constraint per request. The SGLang research paper describes compressed finite state machines that speed up structured decoding.
- llama.cpp uses GBNF grammars and converts a subset of JSON Schema into a grammar, passed in a
json_schemafield or inresponse_format. - Ollama takes a JSON schema in its
formatfield, or JSON mode without a schema, and also acceptsresponse_formatthrough its OpenAI-compatible API. Its cloud models do not support structured outputs.
Constrained decoding guarantees the shape of the output, not that its content is right. The llama.cpp, SGLang and Ollama documentation all advise describing the expected structure in the prompt as well, and your application should still validate every response against the schema and your business rules.
What should you check before running an engine in production?
Treat the engine as one layer of a governed platform: put a gateway in front of it, control its outbound traffic and monitor it from day one.
- Gateway first. Applications should call an AI gateway with an OpenAI-compatible API, never the engine itself, so you can authenticate users, apply quotas and swap engines without breaking applications. Our on-premises AI reference architecture shows where each layer sits.
- Outbound connections. vLLM collects anonymous usage statistics by default; switch this off with
VLLM_NO_USAGE_STATS=1orDO_NOT_TRACK=1. Disable Ollama’s cloud features. Then block egress at the network as well, as described for air-gapped AI. - Metrics. vLLM exposes a Prometheus-compatible
/metricsendpoint, while llama.cpp’s has to be switched on. Collect latency, queue time, token throughput and errors. - Defaults. Check context length, parallelism and memory settings against your workload instead of accepting the defaults.
- Versions. Pin engine and model versions, and rerun your evaluation and load tests before each upgrade.
- Licences. The engines use permissive licences, but every model has its own. Our guide to open-weight model licences explains what to check.
How do you choose the right engine for each workload?
Choose by workload, and keep the API contract stable so that the choice can change later. You may well run more than one engine: a serving engine in the data centre and a local tool for developers.
- Many concurrent users on data-centre GPUs: shortlist vLLM and SGLang and benchmark both. Lean towards SGLang when most requests share long prefixes, such as retrieval over the same documents or agents with long system prompts, and confirm it in the benchmark.
- Accelerators other than NVIDIA and AMD GPUs: check vLLM’s hardware plugins and SGLang’s platform list for your device, then test the exact model and version.
- Developer laptops, demonstrations and evaluation: Ollama with cloud features switched off on managed devices, or llama.cpp directly.
- CPU-only servers, edge sites and mixed fleets: llama.cpp with quantised GGUF models.
- Strict output formats: any of the four for JSON schemas; vLLM, SGLang or llama.cpp when you need regular expressions or grammars.
The engine is one decision within a private LLM platform, alongside model selection, the gateway, identity and monitoring. SysArt benchmarks candidate engines on your own workload and designs the serving layer around the one that fits.
Frequently asked questions
Is vLLM better than Ollama?
They are built for different jobs. vLLM serves many concurrent users from GPU servers, with continuous batching, prefix caching and an OpenAI-compatible server. Ollama runs models on a laptop or workstation: by default it processes one request per model at a time, and its local API needs no authentication. You can prototype with Ollama and move production traffic to vLLM or SGLang, because they offer OpenAI-compatible APIs and Ollama supports a subset of the same API.
Is SGLang faster than vLLM?
It depends on the workload, and we do not quote benchmark figures because they depend on the model, prompts, hardware and versions tested. SGLang's RadixAttention reuses cached computation across requests that share a prefix, which helps retrieval, long system prompts and multi-turn agents. vLLM also caches prefixes automatically. Benchmark both with your own model, prompt mix, context lengths and concurrency before you choose.
Can llama.cpp serve multiple users?
Yes. Its HTTP server decodes requests in parallel for several users through slots, and continuous batching and prompt caching are on by default. It also offers OpenAI- and Anthropic-compatible endpoints, API keys and an optional Prometheus metrics endpoint. It suits a single server, CPU-only hardware or an edge site. For large GPU clusters, vLLM and SGLang document more ways to split a model across GPUs.
Can you run an LLM inference engine without a GPU?
Yes, and CPU inference suits smaller or quantised models. llama.cpp is plain C/C++, uses CPU vector instructions on x86 and RISC-V and ARM NEON on Apple silicon, and supports integer quantisation from 1.5 to 8 bits. vLLM supports x86, ARM, Apple silicon and IBM Z CPUs, SGLang lists Intel Xeon CPUs among its platforms, and Ollama falls back to the CPU when it finds no supported GPU.
Which inference engines support JSON schema output?
All four. vLLM supports JSON schemas, regular expressions, fixed choices and grammars through its xgrammar or guidance back ends. SGLang supports JSON schemas, regular expressions and EBNF grammars, with XGrammar as the default. llama.cpp converts a subset of JSON Schema into its GBNF grammars. Ollama accepts a JSON schema in its format field. Constraints guarantee the format of the output, not the correctness of its content.
Are these engines compatible with the OpenAI API?
Largely. vLLM, SGLang and the llama.cpp server provide OpenAI-compatible endpoints, and Ollama supports a subset of the OpenAI API. All four also document an endpoint compatible with Anthropic's Messages API. Support differs in detail, such as which request parameters work, so test the calls your applications make. An AI gateway in front of the engines keeps one stable API when you change engines.
Is Ollama safe to use with confidential data?
Run locally, Ollama keeps prompts on the machine; its FAQ says Ollama does not see your prompts or data when you run locally. Cloud-hosted models are different, because Ollama's service processes those prompts. On managed devices, enable local-only mode with OLLAMA_NO_CLOUD=1. The local API needs no authentication and listens on 127.0.0.1 by default, so never expose it on a network without a gateway.
What licences do vLLM, SGLang, llama.cpp and Ollama use?
vLLM and SGLang are released under the Apache License 2.0, and llama.cpp and Ollama under the MIT licence. Both are permissive licences that allow commercial use. The engine's licence does not cover the models you run with it: each open-weight model has its own licence, which can restrict uses, users or revenue, so review the model licence separately before production.
Sources
- vLLM documentation (features and supported hardware) · checked 27 October 2026
- vLLM repository on GitHub (Apache-2.0 licence) · checked 27 October 2026
- vLLM documentation: installation and hardware plugins · checked 27 October 2026
- vLLM documentation: structured outputs · checked 27 October 2026
- vLLM documentation: online serving, API endpoints and metrics · checked 27 October 2026
- vLLM documentation: usage stats collection · checked 27 October 2026
- SGLang documentation (features and supported hardware) · checked 27 October 2026
- SGLang repository on GitHub (Apache 2.0 licence) · checked 27 October 2026
- SGLang documentation: structured outputs · checked 27 October 2026
- SGLang documentation: OpenAI-compatible and Anthropic-compatible APIs · checked 27 October 2026
- SGLang documentation: prefill-decode disaggregation · checked 27 October 2026
- Zheng et al.: SGLang, Efficient Execution of Structured Language Model Programs (arXiv 2312.07104) · checked 27 October 2026
- llama.cpp repository on GitHub (features, backends, MIT licence) · checked 27 October 2026
- llama.cpp HTTP server documentation · checked 27 October 2026
- llama.cpp: GBNF grammars and JSON Schema conversion · checked 27 October 2026
- GGML: GGUF file format specification · checked 27 October 2026
- Ollama repository on GitHub (MIT licence) · checked 27 October 2026
- Ollama documentation: FAQ (concurrency, network binding, local-only mode) · checked 30 October 2026
- Ollama documentation: context length (defaults by GPU memory, settings for agents and coding tools) · checked 30 October 2026
- Ollama source code: default context length by GPU memory (server/routes.go) · checked 30 October 2026
- Ollama documentation: hardware support · checked 27 October 2026
- Ollama documentation: OpenAI compatibility · checked 27 October 2026
- Ollama documentation: Anthropic compatibility · checked 27 October 2026
- Ollama documentation: structured outputs · checked 27 October 2026
- Ollama documentation: authentication · checked 27 October 2026
- Ollama documentation: importing models · checked 27 October 2026