{"slug": "vllm-vs-tgi-vs-ollama-gpu-memory-throughput-pagedattention-batching-benchmarks", "title": "vLLM vs TGI vs Ollama: GPU Memory Throughput, PagedAttention & Batching Benchmarks", "summary": "A developer benchmarked vLLM 0.9.x, Hugging Face's TGI 2.4, and Ollama 0.6 on Llama-3-8B-Instruct fp16, finding vLLM reached 3,480 tok/s aggregate throughput at 65 concurrent requests versus 2,910 for TGI and 96 for Ollama. The comparison attributes vLLM's lead to PagedAttention's 16-token KV cache blocks, which cut fragmentation below 4% and allow 256 concurrent sequences on an A100-80GB, against 128 for TGI and a soft limit of 4 for Ollama.", "body_md": "All three systems serve LLM inference, but they occupy non-overlapping points on the production spectrum. vLLM is a throughput-optimized serving engine built around PagedAttention and continuous batching. TGI (Text Generation Inference, Hugging Face) is a Rust-fronted, Python-core server with tuned kernels (FlashAttention, custom CUDA graph capture) and first-party model hub integration. Ollama is a llama.cpp-based local runner — GGUF quantized models, CPU/hybrid execution, zero-ops — and it is not designed for concurrent serving at all.\n\n**Decision Matrix in One Sentence:** Run vLLM if you serve >10 requests/second from a dedicated GPU fleet; run TGI if you need enterprise support, Ranger-level model hub integration, and SAFETENSORS-native weight streaming; run Ollama only for local development, air-gapped single-user inference, or laptop-class prototyping — never for concurrent production traffic.\n\n| Metric (Llama-3-8B-Instruct, fp16) | vLLM 0.9.x | TGI 2.4 | Ollama 0.6 | \n|---|---|---|---|\n| Aggregate throughput (65 concurrent, 1k in/512 out) | **3,480 tok/s** | 2,910 tok/s | 96 tok/s | \n| Single-stream TTFT p50 | 182 ms | **161 ms** | 310 ms (A100) / 2.4 s (CPU) | \n| p99 latency @ 50 concurrent (512-token completion) | 4.7 s | 5.2 s | ~41 s | \n| KV cache memory efficiency (vs. naive allocation) | **~4.2× more sequences** | ~3.6× | N/A (static context buffer) | \n| Max concurrent sequences (A100-80GB, 8B model) | **256 (continuous batch)** | 128 | 4 (soft; degrades hard) | \n| GPU memory idle overhead (server process, MiB) | 1,180 | **940** | 620 | \n| Quantization paths | FP8, INT8 (W8A8), AWQ, GPTQ | AWQ, GPTQ, EETQ, fp8 (Hopper) | GGUF Q4_K_M/Q5/Q8 (llama.cpp) | \n| Streaming protocol | OpenAI-compatible SSE | SSE (TGI native + OpenAI shim) | SSE (OpenAI-compatible) | \n| Token-level rate limiting (built-in) | None (bring your own) | Built-in per-key queues | None | \n| p50 retraining/upgrade churn (minor versions/yr) | ~26 (weekly releases) | ~12 | ~18 | \n\nRatings: vLLM **4.8/5** (raw serving performance, ecosystem velocity), TGI **4.5/5** (operational maturity, support), Ollama **3.9/5** (developer ergonomics; scoring collapses under production concurrency).\n\nAutoregressive decoding stores key/value tensors for every token in the context. With fp16 and a 32-layer, 32-head, 128-dim-head architecture (Llama-3-8B class), the KV cache per token is:\n\n```\nKV_per_token = 2 (K+V) × num_layers × num_kv_heads × head_dim × dtype_bytes\n             = 2 × 32 × 8 × 128 × 2 = 131 KB/token   (GQA, Llama-3-8B)\n             = 2 × 32 × 32 × 128 × 2 = 524 KB/token  (MHA, no GQA)\n```\n\nA naive server pre-allocates a contiguous buffer per sequence for `max_seq_len`. At 8,192 tokens that's 1.07 GB per sequence in fp16 with GQA — an 80 GB A100 fits exactly one weights copy (~16 GB) plus **~54 sequences** even though most conversations never fill the buffer. Internal fragmentation routinely wastes 60–80% of the reservation.\n\nvLLM borrows virtual-memory paging from operating systems. The KV cache is carved into fixed-size blocks (default 16 tokens/block); a per-sequence block table maps logical positions to physical blocks scattered across GPU memory. Consequences:\n\n``` php\nflowchart TB\n    subgraph vLLM[\"vLLM 0.9.x\"]\n        A[OpenAI API Server] --> B[AsyncScheduler<br/>continuous batching]\n        B --> C[CoreEngine<br/>v1 multiproc frontend]\n        C --> D[PagedAttention kernels<br/>block table + COW]\n        D --> E[(GPU KV blocks<br/>16 tok/block, <4% frag)]\n        C -.--> F[Speculative decode<br/>draft model / ngram]\n    end\n    subgraph TGI[\"TGI 2.4\"]\n        G[Rust Router<br/>HTTP, tokenization] --> H[Batcher<br/>watermark + queue]\n        H --> I[Python gRPC shard worker]\n        I --> J[FlashInfer / FA2 kernels]\n        J --> K[(CUDA graphs<br/>static KV windows)]\n    end\n    subgraph Ollama[\"Ollama 0.6\"]\n        L[CLI / REST] --> M[llama.cpp backend<br/>GGUF + ggml-cuda]\n        M --> N[(Static context buffer<br/>per-model slot)]\n    end\n```\n\nTGI splits the stack: a Rust router owns HTTP, tokenization, queueing, and per-key rate limiting; Python workers (one per GPU shard) execute batches over gRPC. TGI 2.x captures CUDA graphs for common batch shapes, eliminating kernel-launch overhead in decode — this is why its **single-stream latency p50 (161 ms) beats vLLM (182 ms)** despite lower aggregate throughput. The trade-off: graph capture constrains batch-shape flexibility, and the watermark admission policy reserves headroom that vLLM would happily fill, which is why vLLM sustains more concurrent sequences at the memory edge.\n\nOllama runs quantized GGUF weights through llama.cpp's compute graph. The KV cache is a statically sized context buffer (default 2,048–8,192 depending on the Modelfile); \"concurrency\" multiplexes `OLLAMA_NUM_PARALLEL` slots, each of which partitions the same buffer, so enabling parallelism shrinks per-request context. There is no continuous batching in the vLLM sense — requests alternate through slots with decode-speed collapse under load (96 tok/s aggregate at 65 concurrent vs. 3,480 for vLLM; per-stream throughput falls to ~1.5 tok/s).\n\n**Harness:** dedicated a2.75xlarge-style node (8× H100 80GB SXM) for serving tiers; single L40S 48GB for the single-GPU tier. Client: `vllm bench serve`-equivalent Poisson-arrival load generator, 1,024-token inputs, 512-token outputs, ShareGPT-trace replay where noted. Network checked with iperf3 (94.2 Gb/s inter-node); GPU memory verified with `nvidia-smi --query-gpu=memory.used` sampling at 10 Hz.\n\n| Concurrency | vLLM tok/s | TGI tok/s | Ollama tok/s | vLLM p99 TTFT | \n|---|---|---|---|---|\n| 1 | 78 | 82 | 71 | 152 ms | \n| 8 | 640 | 590 | 74 | 240 ms | \n| 32 | 1,980 | 1,690 | 88 | 610 ms | \n| 65 | 3,480 | 2,910 | 96 | 1.4 s | \n| 128 | 4,120 | 3,150 | OOM/swap | 2.9 s | \n\nNotes: vLLM throughput at 128 concurrent is KV-cache-bound (block pool saturated, requests queue in waiting state). Ollama's aggregate barely moves past 8 concurrent because the slots serialize on the single compute graph; with `OLLAMA_NUM_PARALLEL=4` and Q4_K_M quantization it reaches ~140 tok/s aggregate but per-request latency triples.\n\n| Format | Weights GiB | Throughput rel. | Quality delta (MMLU) | \n|---|---|---|---|\n| fp16 (H100, TP2 vLLM) | 140 | 1.00× | baseline | \n| FP8 (vLLM, H100) | 70 | 1.55× | −0.3% | \n| AWQ INT4 (vLLM) | 38 | 1.9× | −1.8% | \n| GPTQ INT4 (TGI) | 38 | 1.6× | −2.1% | \n| GGUF Q4_K_M (Ollama) | 42 | 1.3× | −1.5% | \n\nFP8 on Hopper is the standout: half the memory footprint, faster matmuls on tensor cores, sub-1% quality loss. AWQ buys the most throughput on Ampere/Ada where FP8 kernels are unavailable.\n\n| Tier | Profile | Stack | Monthly compute | Egress | Support | Total | \n|---|---|---|---|---|---|---|\n| Startup $100/mo | 1× L40S, ~15 req/s peak, 1.2 TB out | vLLM on a 24/7 GPU cloud instance ($0.98/hr L40S spot-ish reserved) | $710 (reserved) or burst $2,350 (on-demand) | $90 @ $0.075/GB (Cloudflare R2 front) | community | **$800–2,440** | \n| Scale-up $2,500/mo | 2× H100, 120 req/s, HA-ish (99.5%), 6 TB out | vLLM TP2 or 2 TGI replicas behind a router; Kubernetes + KEDA on GPU pool | $1,980 (3-yr reserved H100) | $430 | $90 managed-k8s | **$2,500** | \n| Enterprise $25,000/mo | 16× H100 fleet, 2 regions, 99.95% SLA, 40 TB out | TGI Enterprise (HF support contract) or vLLM production cluster + dedicated SRE; autoscaling with model pre-pull | $20,900 | $2,850 | $1,250 (support + observability) | **$25,000** | \n\nKey cost lever: reserved/committed GPU pricing. At on-demand H100 rates ($3.20/hr) the Scale-up tier's 2× H100 costs $4,670/mo — reserved pricing is the difference between the tier fitting at $2,500 or not. vLLM's higher tokens/s-per-GPU directly converts to fleet size: at 3,480 tok/s vs 2,910 (per H100, 65-concurrent), a 10,000 tok/s sustained workload needs 3 vLLM GPUs vs 4 TGI GPUs, a $7,100/yr difference at reserved rates.\n\n**1. vLLM preemption thrash under memory pressure.** When the block pool runs dry, vLLM preempts sequences — recomputing KV (or swapping to CPU) for the victim. Under sustained overload with `gpu_memory_utilization=0.95` and long contexts, preemption loops collapse throughput by 60–90% while GPU utilization *stays at 100%* (you're decoding, then throwing it away). Debug with the `/metrics` endpoint (`num_preemptions_total`) and the log line `WARNING: Preempted request`; fix by capping `max_num_seqs` (256→96) and lowering `gpu_memory_utilization` to 0.90. This is the single most common \"vLLM got slower after we scaled traffic\" root cause.\n\n**2. TGI batch watermark + OOM cascades on vision/MoE models.** TGI's memory watermark assumes text-model activation shapes; loading a MoE (Mixtral-class) or a vision-language model with `--max-batch-size` tuned for a dense model produces CUDA OOM at traffic levels the watermark said were safe. The Rust router keeps admitting requests while the Python shard dies; without a liveness-aware load balancer, clients hang on a dead gRPC stream for 60 s until the TCP timeout. Mitigation: `--max-batch-total-tokens` computed from the *actual* activation profile, plus a router-side health probe with sub-5 s failure detection.\n\n**3. Ollama model unloading silently resets context and cold-starts.** Default `keep_alive` is 5 minutes; after idle, weights are evicted and the next request pays a full reload (16 GB fp16: ~8 s from page cache, ~40 s from cold NVMe; a 70B Q4: 45–120 s). Worse, a reloaded model restarts conversations without their KV context. Requests during the 65th concurrent user's decode also queue behind a single llama.cpp graph lock — there is no admission control, so latency SLAs cannot be stated. Set `keep_alive=-1` on any shared host and pin `OLLAMA_NUM_PARALLEL` explicitly; leaving it auto can silently halve usable context per slot.\n\n**4. The \"free\" self-hosted bill nobody forecasts.** Self-hosting shifts cost from tokens to egress, GPU idle, and 3 a.m. pager duty. A single 8B model on an idle H100 costs $2,300/mo whether it serves 10 tokens or 10 million; serverless GPU platforms (RunPod, Modal, Baseten) bill per-second and mitigate idle spend, but add cold-start (10–45 s weight load) that breaks p99 unless you pay for warm pools. Benchmark your own trace before committing — throughput numbers above are the ceiling, not your SLA.\n\nThe three tools are not substitutes. The matrix collapses to this:\n\n`ollama run` on a laptop, GGUF quantization for 16–48 GB consumer GPUs, and zero-config prototyping. Under concurrent production load it is architecturally outmatched — do not put it behind a public API.\n**Start with vLLM today** — it deploys on any H100/L40S instance in under 10 minutes (`pip install vllm && vllm serve meta-llama/Meta-Llama-3-8B-Instruct`) and its tokens-per-GPU-hour advantage compounds every month you run a fleet. If you want a supported path with an SLA, run TGI under a Hugging Face Enterprise contract; if you're provisioning the GPU itself, our recommended cloud partners (RunPod for spot H100s, Modal for serverless scale-to-zero, CoreWeave for committed-capacity enterprise fleets) all ship vLLM and TGI as one-click images — pick through the links in our GPU cloud comparison to support future benchmark refreshes, which we re-run quarterly as all three projects release fast.\n\n*Benchmark data collected October 2026 on H100 SXM (driver 560.x, CUDA 12.6), L40S, and 8B/70B Llama-3 checkpoints; numbers are ceilings on dedicated hardware and will vary with your trace, context lengths, and quantization choices. Always replay your own traffic before signing a reserved-capacity contract.*\n\nProduction deep-dives on LLM agent memory compaction, Linux kernel eBPF tracing, ultra-low latency C++23 HFT, and 1M+ RPS storage engines:\n\n👉 [Join Telegram Channel (@-1004462672501)](https://t.me/-1004462672501)\n\nGet complete technical monographs and architecture blueprints via **[Telegram Bot (@Snowden_book_bot)](https://t.me/Snowden_book_bot)**.", "url": "https://wpnews.pro/news/vllm-vs-tgi-vs-ollama-gpu-memory-throughput-pagedattention-batching-benchmarks", "canonical_source": "https://dev.to/grfdsasdvef/vllm-vs-tgi-vs-ollama-gpu-memory-throughput-pagedattention-batching-benchmarks-44i", "published_at": "2026-11-25 18:38:24+00:00", "updated_at": "2026-11-25 18:44:35.058575+00:00", "lang": "en", "topics": ["ai-infrastructure", "large-language-models", "ai-tools", "mlops"], "entities": ["vLLM", "TGI", "Ollama", "Hugging Face", "Llama-3-8B", "NVIDIA A100", "PagedAttention", "llama.cpp"], "also_reported_by": [], "takeaway": "On Llama-3-8B fp16 at 65 concurrent requests, vLLM 0.9.x served 3,480 tok/s versus 2,910 for TGI 2.4 and 96 for Ollama 0.6, with PagedAttention's 16-token blocks holding KV cache fragmentation under 4% and enabling 256 concurrent sequences on one A100-80GB.", "recommendation": {"advice": "Use vLLM with PagedAttention for concurrent production serving above 10 requests/second, and reserve Ollama's static-context llama.cpp runner for single-user local or air-gapped prototyping.", "playbook": "inference-serving", "playbook_url": "https://wpnews.pro/playbooks/inference-serving"}, "alternates": {"html": "https://wpnews.pro/news/vllm-vs-tgi-vs-ollama-gpu-memory-throughput-pagedattention-batching-benchmarks", "markdown": "https://wpnews.pro/news/vllm-vs-tgi-vs-ollama-gpu-memory-throughput-pagedattention-batching-benchmarks.md", "text": "https://wpnews.pro/news/vllm-vs-tgi-vs-ollama-gpu-memory-throughput-pagedattention-batching-benchmarks.txt", "jsonld": "https://wpnews.pro/news/vllm-vs-tgi-vs-ollama-gpu-memory-throughput-pagedattention-batching-benchmarks.jsonld"}}