Skip to content
inhausi

llama.cpp, vLLM or SGLang? The right inference engine for your company

llama.cpp, Ollama, vLLM and SGLang compared. We explain which software runs a language model fastest, what several graphics cards bring and when each one is the right choice.

Revised on 11 min readby inhausi

In short

Ollama suits single users and trying things out, llama.cpp suits models that only just fail to fit into graphics memory. For operation with many simultaneous users vLLM is the standard. SGLang has the advantage when many requests share the same context, as with an assistant with a fixed system prompt or with search in documents.

Anyone who buys a GPU server and runs a language model on it usually thinks about the hardware first: how much VRAM, how many GPUs and which card. That matters, but it is only half the story. The software that actually runs the model, the so-called inference engine, decides how much of the available computing power really reaches the user. Chosen badly, it gives away half the performance. Chosen well, the same system scales to many times the number of users.

This article explains the three engines that matter in practice, which are llama.cpp, vLLM and SGLang. It covers what they do differently inside, where each one is strong and which is the right choice for which use in a company.

What an inference engine actually does

A language model consists of billions of weights, numbers that were learned during training. To generate an answer, the model has to read these weights through memory once in full for every generated token. That is not a computing task in the classic sense, it is above all a matter of memory bandwidth. How fast the GPU can read data from VRAM determines how fast tokens are generated.

The inference engine is the software that orchestrates this process. It loads the model into memory, accepts requests, distributes the work across the available GPUs and returns the results. That sounds simple, but it is not. Depending on how the engine bundles requests, manages memory and handles parallel requests, the difference in throughput can be many times over.

llama.cpp: portability above all

llama.cpp was written in C++ by Georgi Gerganov in 2023 and has built up a huge community since then. The aim from the start was to make models run everywhere with as few dependencies as possible, and that has worked. llama.cpp runs on NVIDIA GPUs, AMD GPUs, Apple Silicon and on the CPU alone, and in hybrid configurations where parts of the model sit on the GPU and parts in RAM.

The format llama.cpp uses is called GGUF. All common open-source models are available in this format, typically at various quantisation levels from Q2 to Q8.

The limit of llama.cpp lies in many simultaneous requests. The built-in server can handle several requests in parallel, but it divides the available context among its slots in fixed shares and makes less good use of the GPU than engines that were built from the start for operation with many users. When ten employees work at the same time, the total throughput therefore grows considerably more slowly than with vLLM or SGLang.

In return llama.cpp has an ability that no other engine offers in this form, which is CPU offloading. If the model does not fit entirely into VRAM, individual layers can be moved to the CPU. That costs speed, but it makes models run that would otherwise not start at all.

Ollama is essentially a wrapper around llama.cpp with a developer-friendly interface. It offers model management similar to Docker, simple installation and automatic switching between models. In return it is somewhat slower than llama.cpp itself. For single users and development environments Ollama is the most convenient option.

CPU offloading: when it helps and when it does not

If a model only just fails to fit into VRAM, llama.cpp can move individual layers to the CPU with the -ngl flag (number of GPU layers). Technically it works like this: the weights for these layers lie in RAM, for every calculation they are transported to the GPU over PCIe and processed there, and the result is written back.

The loss of speed is considerable. On a CPU alone without GPU support, a 7B model typically generates 1 to 2 tokens per second, which is hardly usable for interactive work. In hybrid operation, with the attention layers on the GPU and the expert feed-forward layers on the CPU, it is considerably better, but still noticeably slower than running entirely on the GPU.

For MoE models there is an interesting special case. Since only a fraction of the experts is active per token in these architectures, the PCIe overhead of moving the expert layers out stays within limits. There are even specialised guides on how to split MoE models across CPU and GPU systems and still achieve acceptable speeds. But it always remains a stopgap. Anyone who wants to run a model productively for ten or more users needs it entirely in VRAM.

Here is a typical scenario in which CPU offloading really makes sense: a 140 GB model in Q4 on a system with 96 GB of VRAM. If you move the last 10 to 15 per cent of the layers to the CPU, the model runs, at a cost of perhaps 25 to 35 per cent in speed. For a single user who occasionally analyses complex documents that can be enough. For twenty simultaneous users in an office it is not.

vLLM: built for production

vLLM came out of the Sky Computing Lab at UC Berkeley in 2023 and has since become the de facto standard for productive LLM deployments. Its core concept is called PagedAttention.

To understand why that matters, you need to know briefly what the KV cache is. When a model generates an answer, it stores an entry in the so-called key-value cache for every token already processed. That saves recomputing all previous tokens at every new step. Without the KV cache the model would have to work through all the previous tokens again for every new one. The KV cache grows with the context length, and it occupies VRAM.

Traditional engines reserve a contiguous block of VRAM for every request, even if the answer turns out shorter than expected. According to the measurements of the authors of vLLM, 60 to 80 per cent of the reserved KV cache memory stays unused in the process. vLLM solves this the way an operating system manages virtual memory. The KV cache is divided into small pages that are allocated dynamically and reused immediately once a request is finished. The authors put the resulting waste at under 4 per cent.

That makes continuous batching possible. Rather than waiting for a whole group of requests before the GPU starts work, vLLM inserts new requests into the running batch as soon as another one is finished. The scheduler works at the level of tokens, not of requests, so the GPU is busy almost all the time.

The result shows as soon as many people ask at once. vLLM combines the requests of ten users into shared computing steps and thereby achieves many times the total throughput that llama.cpp manages on the same hardware. In published comparisons on H100 GPUs, vLLM reaches around 12,500 tokens per second across all requests with a small model.

vLLM supports true tensor parallelism across several GPUs. That does not mean that every GPU gets different layers (that would be pipeline parallelism, as llama.cpp does it), but that every matrix multiplication is divided among all GPUs at the same time. All GPUs compute every layer in parallel. That scales considerably better than splitting by layers.

One restriction of vLLM is that there is no CPU offloading. The model has to fit entirely into VRAM, either on a single card or distributed over several cards by tensor parallelism.

SGLang: when context is shared

SGLang comes from the same academic environment as vLLM and starts from a different question: what if many requests share the same context?

With an internal company assistant almost every request has the same system prompt. In a RAG system many requests share the same document context. In agent workflows prefixes repeat. SGLang recognises these shared prefixes automatically and stores their KV cache in a radix tree structure that is reused through RadixAttention. If ten users send the same system prompt, it only has to be processed once.

In the same published comparison on H100 hardware, SGLang reaches around 16,200 tokens per second, about 29 per cent more than vLLM. With workloads that share a lot of context the difference is larger, and the authors of SGLang report up to six times the throughput for RAG pipelines and multi-turn conversations. DeepSeek names SGLang as the recommended engine in the documentation of its models.

The trade-off is complexity. SGLang has a smaller community, less documentation and, with unusual model architectures or hardware set-ups, more potential points of friction than vLLM. Anyone who depends on stability and broad model compatibility is better off with vLLM as the standard.

A note for everyone who knows TGI (Text Generation Inference from Hugging Face): TGI has been in maintenance mode since December 2025. Hugging Face officially recommends vLLM or SGLang for new deployments.

Several GPUs: pipeline versus tensor parallelism

Anyone running a model that is larger than a single card needs several GPUs. But how they work together is decisive.

llama.cpp uses pipeline parallelism. GPU 1 gets the first layers, GPU 2 the next ones, and so on. That lets the model start, but it is sequential, because GPU 2 waits until GPU 1 has finished. The gain in speed over a single GPU is minimal, and what you mainly gain is memory.

vLLM and SGLang use tensor parallelism. Every matrix operation is divided among all GPUs at the same time, all GPUs compute in parallel and the result is merged. With four GPUs each one processes a quarter of every layer at the same time. That scales well, even though the coordination between the cards costs part of the gain.

For MoE models such as MiniMax-M2.5, Kimi K2.5 or DeepSeek V3.2 this is particularly relevant, because these models activate only a fraction of their parameters per token anyway. The communication overhead between the GPUs over PCIe is considerably lower with MoE than with dense models, because only the active experts have to communicate.

Which engine for which use

The question is not which engine is technically the best, but which one fits the concrete use case.

Ollama makes sense for developers, tests and single users who want to try out a model. It installs in minutes, needs no configuration and switches models on the fly. As soon as more than three to five users are active at the same time, you reach its limits.

llama.cpp directly comes into play where CPU offloading is needed, that is for a model that only just fails to fit into VRAM, or for a system that also has to work without a GPU. For deployments with a single user and full use of the GPU, llama.cpp is competitive with vLLM.

vLLM is the production standard for deployments with many users. It has the broadest model and hardware compatibility, a mature community and good documentation. Anyone serving a company with 20 or more simultaneous users gets the best results here without much configuration effort.

SGLang is the choice when the workload has a lot of shared context, such as internal chatbots with a constant system prompt, RAG systems in which many requests share the same document context, or agent pipelines with repetitive prefixes. Its lead over vLLM is largest with such workloads. Anyone running DeepSeek models should evaluate SGLang first.

ScenarioRecommendation
Single user, testing, developmentOllama
Model only just fails to fit into VRAMllama.cpp with offloading
5 to 50 simultaneous users, stable systemvLLM
Multi-turn chat, RAG, agents with shared contextSGLang
DeepSeek models in productionSGLang

What this means for planning the hardware

The choice of engine directly affects how much VRAM you really need. With llama.cpp you can make a model that is too large run in a makeshift way with CPU offloading. With vLLM and SGLang there is no such way out. The model has to fit entirely into VRAM, or the server does not start.

In return vLLM and SGLang manage the available VRAM considerably more efficiently. Thanks to PagedAttention and dynamic allocation of the KV cache, substantially more simultaneous users can be served on the same VRAM than with a naive implementation. In practice that means that anyone planning with vLLM or SGLang can get by with less VRAM for a given number of simultaneous users than the raw model sizes suggest.

How much VRAM is actually needed for which configuration depends on model size, quantisation, context length and the number of simultaneous users. We look at that in detail in the article on working out VRAM.

If you are unsure which combination of hardware, model and engine is right for your use case, we are happy to advise you free of charge. Write to us at office@inhausi.at or use our configurator as a starting point.

Published on 5 April 2026, last revised on 19 November 2026. Models, prices and the legal situation change all the time. The current figures are in the model overview and in the configurator. All figures without guarantee.

Would you like to work this out for your company?

In a first call of half an hour we work out whether an AI machine of your own makes sense for you, how large it would have to be and what it costs. The call is free.

Or write to us at office@inhausi.at and call us on +43 650 37 50 530