TAI BUI
Back to curriculum
LearnPython

Self-Hosted Serving Selection — llama.cpp, Ollama, TGI, vLLM, SGLang

Four engines dominate self-hosted inference in 2026, and the pick comes down to hardware, scale, and ecosystem. **llama.cpp** is the fastest on CPU, with the widest model support and full control over quantization and threading. **Ollama** is the one-command install for a dev laptop. It runs roughly 15-30% slower than llama.cpp (Go, CGo, and HTTP serialization), and the gap grows to about 3x throughput under prod-like load. **TGI entered maintenance mode on December 11, 2025**, so it gets bug fixes only. It runs about 10% slower than vLLM on raw throughput, though it has historically had top observability and tight HF-ecosystem integration. That status makes it a risky long-term bet, and SGLang or vLLM are safer defaults for new projects. **vLLM** is the general-purpose production default: v0.15.1 (February 2026) adds PyTorch 2.10, RTX Blackwell SM120, and H200 optimization. **SGLang** is the specialist for agentic multi-turn and prefix-heavy work, with 400,000+ GPUs in production (xAI, LinkedIn, Cursor, Oracle, GCP, Azure, AWS). Hardware narrows the field fast. On CPU you are on llama.cpp. On AMD or other non-NVIDIA GPUs you are on vLLM (or SGLang), because TRT-LLM is NVIDIA-locked. The pipeline pattern for 2026: dev on Ollama, staging on llama.cpp, prod on vLLM or SGLang, with the same GGUF/HF weights throughout.

TIME: ~45 minutesPREREQUISITES: All Phase 17 lessons covering engines (04, 06, 07, 09, 18)

Learning Objectives

  • Pick an engine given hardware (CPU / AMD / NVIDIA Hopper / Blackwell), scale (1 user / 100 / 10,000), and workload (general chat / agent / long-context).
  • Name the 2026 TGI maintenance-mode status (December 11, 2025) and why it biases new projects toward vLLM or SGLang.
  • Describe the dev/staging/prod pipeline using the same GGUF or HF weights throughout.
  • Explain why "CPU only" forces llama.cpp and "AMD" excludes TRT-LLM.

The Problem

Your team starts a new self-hosted LLM project. One engineer says Ollama, another says vLLM, and a third asks whether TGI just works out of the box. Each of them is right in some context and wrong in others.

In 2026 the choice tree runs hardware first, scale second, workload third. One 2025 event also changes the default for new projects: TGI entered maintenance mode on December 11.

Warm-up0/3
1. What does quantizing a model's weights do?Warm-up
One model weight shown as a full 32-bit number next to a box with the same value at an unlabeled, smaller bit width, above a memory bar for the whole set of weights. A line asks what exactly changes and why someone would do it.
Setup: one weight, stored two ways, with the second width left blank. What changes and why is left open.
2. A software project is announced as being in "maintenance mode". What does that usually mean?Warm-up
A generic open-source project's release timeline, v1.0 through v2.0, ending in a highlighted announcement that the project is now in maintenance mode. A line asks what happens to the project from here.
Setup: an unnamed project's own timeline, ending at the announcement itself. What maintenance mode means for it next is left open.
3. How does a model server's throughput differ from its latency?Warm-up
A server with two unlabeled metrics defined only by their descriptions: metric A, total work finished per second, and metric B, how long one request waits. A line asks which one is throughput and which is latency.
Setup: both metrics described by what they count, with the throughput/latency label left off each. Which name goes with which is left open.

The Concept

The five engines

EngineBest forNotes
llama.cppCPU / edge / minimal deps / widest model supportFastest on CPU, full control
OllamaDev laptops, single user, one-command install15-30% slower than llama.cpp; 3x prod throughput gap
TGIHF ecosystem, regulated industriesMaintenance mode Dec 11, 2025
vLLMGeneral-purpose production, 100+ usersBroad production default; v0.15.1 Feb 2026
SGLangAgentic multi-turn, prefix-heavy workloads400,000+ GPUs in production

Hardware-first decision

CPU only → llama.cpp. Ollama works too but is slower. I would not reach for anything else on CPU.

AMD GPU → vLLM (AMD ROCm support). SGLang also works. TRT-LLM is NVIDIA-locked, so it's off the table.

NVIDIA Hopper (H100 / H200) → vLLM, SGLang, or TRT-LLM. All three are top-tier here.

NVIDIA Blackwell (B200 / GB200) → TRT-LLM is the throughput leader (Phase 17 · 07). vLLM and SGLang follow close behind.

Apple Silicon (M-series) → llama.cpp (Metal). Ollama wraps this.

Scale-second decision

1 user / local dev → Ollama. One command, first-token in seconds.

10-100 users / small team → vLLM single-GPU.

100-10k users / production → vLLM production-stack (Phase 17 · 18) or SGLang.

10k+ users / enterprise → vLLM production-stack + disaggregated (Phase 17 · 17) + LMCache (Phase 17 · 18).

Workload-third decision

General chat / Q&A → vLLM wins on broad default.

Agentic multi-turn (tools, planning, memory) → SGLang's RadixAttention (Phase 17 · 06) does best.

RAG with heavy prefix reuse → SGLang.

Code generation → vLLM fine; SGLang slightly better on cache.

Long context (128K+) → vLLM + chunked prefill; SGLang + tiered KV.

The TGI maintenance trap

Hugging Face TGI entered maintenance mode on December 11, 2025, which means only bug fixes going forward. Historically it had top-tier observability and best-in-class HF-ecosystem integration (model cards, safety tools), and it ran slightly behind vLLM on raw throughput.

For new projects in 2026, default away from TGI. Existing TGI deployments can keep running, but plan a migration. SGLang and vLLM are the safer defaults.

The pipeline pattern

Dev (Ollama) → staging (llama.cpp) → prod (vLLM). Same GGUF or HF weights throughout. Engineers iterate quickly on laptops; staging mirrors production quantization; prod is the serving target.

Ollama caveat

Ollama is great for dev. It is a poor fit for shared production because Go HTTP serialization adds overhead, concurrency management is simpler than vLLM's, and OpenTelemetry support lags. Use Ollama where it shines (one user, one command) and switch to vLLM once the service is shared.

Self-hosted vs managed is a separate decision

Phase 17 · 01 (managed hyperscalers) and · 02 (inference platforms) cover managed. Here I assume you've already decided to self-host. Reasons to self-host: data residency, custom fine-tune, total cost ownership at scale, domain model not available on hosted.

Numbers you should remember

  • TGI maintenance mode: December 11, 2025.
  • vLLM v0.15.1: February 2026; PyTorch 2.10; Blackwell SM120 support.
  • SGLang production footprint: 400,000+ GPUs.
  • Ollama throughput gap vs llama.cpp: 15-30% slower; 3x under prod load.
Check: The Concept0/27
1. Which of these engines runs only on NVIDIA GPUs?Define
Four hardware categories, CPU, AMD GPU, NVIDIA GPU and Apple Silicon, with one unlabeled engine box connected by a line to only the NVIDIA GPU box. A line asks which engine that is.
Setup: one engine, linked to only one hardware box, left unnamed. Which engine it is is left open.
2. What does SGLang's RadixAttention let it reuse across requests?Define
A card naming RadixAttention as a technique inside SGLang, named among the lesson's serving optimizations. A line asks what it lets SGLang reuse across requests.
Setup: the term and where it lives. What it reuses is left open.
3. What 2025 event moves the default away from TGI for new projects?Define
TGI's own release timeline from 2023 to 2025, with an unlabeled event marker placed sometime in 2025. A line asks what that event is and what it means for new projects.
Setup: TGI's timeline with an unresolved marker somewhere in 2025. The event itself and its meaning are left open.
4. What is llama.cpp?Define
A card naming llama.cpp as one of five serving engines the lesson compares, alongside Ollama, TGI, vLLM and SGLang. A line asks what it is.
Setup: the name, in the company of the other four engines. What it is is left open.
5. What is Ollama?Define
A card naming Ollama as one of five serving engines the lesson compares, alongside llama.cpp, TGI, vLLM and SGLang. A line asks what it is.
Setup: the name, in the company of the other four engines. What it is is left open.
6. What role does vLLM play in the 2026 engine landscape?Define
A card naming vLLM as one of five serving engines the lesson compares, alongside llama.cpp, Ollama, TGI and SGLang. A line asks what role it plays in the 2026 engine landscape.
Setup: the name, in the company of the other four engines. What role it plays is left open.
7. What is GGUF?Define
A card naming GGUF and listing it among the Key Terms table's Production-stack and Pipeline pattern entries. A line asks what it is.
Setup: the name, in the company of two other Key Terms entries. What it is is left open.
8. What is vLLM production-stack?Define
A card naming production-stack and listing it among the Key Terms table's GGUF and Pipeline pattern entries. A line asks what it is.
Setup: the name, in the company of two other Key Terms entries. What it is is left open.
9. Which dev-to-prod pipeline does the lesson recommend on the same weights?Define
Three pipeline stages, dev, staging and prod, in a row with an arrow between each and the same weights carried through, every engine slot left as a question mark.
Setup: the three stages in order, with no engine attached to any of them. Which engine fills each one is left open.
10. Which mapping matches the scale-second decision?Define
The lesson's own four scale bands, 1 user, 10 to 100, 100 to 10,000, and 10,000+, each paired with a blank engine slot beneath it. A line asks which named engine or combination fills each band.
Setup: the four given scale bands, with every engine slot left blank. Which engine fills each one is left open.
11. Which details does the lesson attach to vLLM v0.15.1 (February 2026)?Define
A card naming vLLM v0.15.1, dated February 2026 and named in the lesson's own Numbers section. A line asks what's new in this release.
Setup: the version and its date. What is new in it is left open.
12. Why does the decision tree check hardware before scale and workload?Explain
The decision tree's own checking order, hardware then scale then workload, hardware marked first in the sequence. A line asks why that order specifically.
Setup: the given order of the three checks. The reason for that order is left open.
13. Why does a CPU-only deployment point to llama.cpp?Explain
CPU-only hardware with an arrow to the already-chosen engine, llama.cpp. A line asks why llama.cpp specifically, given that choice is already made.
Setup: the given hardware and the given choice. The reason for that choice is left open.
14. Why does an AMD GPU deployment rule out TRT-LLM?Explain
AMD GPU hardware with TRT-LLM struck through and marked as already ruled out. A line asks why, specifically, given that exclusion is already given.
Setup: the given hardware and the given exclusion. The reason for the exclusion is left open.
15. Why does TGI's maintenance-mode status push new 2026 projects toward vLLM or SGLang?Explain
TGI, labeled with its given maintenance-mode status, next to a new 2026 project choosing an engine. A line asks why that status pushes the choice away from TGI.
Setup: the given status and the given decision point. The reason the status matters to that decision is left open.
16. Why is Ollama a poor fit for shared production?Explain
Ollama with an arrow toward a shared production service serving many users at once. A line asks why that fit is poor, specifically, given it is already known to be poor.
Setup: the given engine and the given target. The reason the fit is poor is left open.
17. Why does the pipeline pattern keep the same GGUF or HF weights from dev to prod?Explain
One set of weights flowing down into three pipeline stages, dev, staging and prod, each stage otherwise unlabeled. A line asks why the same weights flow through unmodified at every stage.
Setup: the given weights and the given stages, with no engine attached to any stage. Why the weights stay the same is left open.
18. Why does a RAG product with heavy prefix reuse favor SGLang?Explain
A RAG product with heavy prefix reuse across requests, with an arrow to the already-given pick, SGLang. A line asks why SGLang specifically, given that pick is already made.
Setup: the given workload and the given pick. The reason for the pick is left open.
19. Which of these is a reason the lesson gives for self-hosting rather than using a managed service?Explain
A managed hosted API struck through as the alternative, with an arrow to the already-chosen option, self-hosting. A line asks what a legitimate reason for that choice is.
Setup: the given decision, self-hosting over managed. A legitimate reason for it is left open.
20. You run 12 H100 nodes for a support agent. Sessions are multi-turn with tool calls, and every session reuses the same 6K-token system prompt and tool schema. Which engine do you pick first?Apply
A support-agent service running on 12 H100 nodes, with multi-turn sessions that include tool calls, and every session reusing the same 6,000-token system prompt and tool schema. A line asks which engine to pick first.
Setup: the given hardware, session shape and shared prefix. Which engine fits is left open.
21. A team of about 40 people needs a shared chat assistant on one NVIDIA GPU. Which engine fits the scale?Apply
A shared chat assistant for about 40 people on one NVIDIA GPU. A line asks which engine fits this scale.
Setup: the given team size and hardware. Which engine fits is left open.
22. A shared service for 100 users runs on Ollama. Throughput is far below expectations, and traces are hard to collect. What is the likely wrong assumption?Analyze
A shared service running on Ollama for about 100 users, with throughput far below expectations and traces hard to collect. A line asks what the likely wrong assumption is.
Setup: the given symptoms. The wrong assumption behind them is left open.
23. A team plans TRT-LLM for a new AMD MI300X cluster because it leads throughput on Blackwell. What is wrong with the plan?Analyze
A new AMD MI300X cluster with a plan to run TRT-LLM on it, justified by a given reason that TRT-LLM leads throughput on Blackwell. A line asks what's wrong with the plan.
Setup: the given hardware, plan and stated reason. What's wrong with it is left open.
24. A model behaves well on a dev laptop but gives noticeably different answers in prod. Staging used a different quantization from prod. Which pipeline rule was broken?Analyze
The dev, staging and prod stages in a row, dev behaving well, staging noted as using a different quantization from prod, and prod's answers noted as differing noticeably. A line asks which pipeline rule was broken.
Setup: the given mismatch across the three stages. Which rule it breaks is left open.
25. Your infrastructure is 12 H100 GPUs plus 8 AMD MI300X, and you want a single engine across both. Which fits best?Design
A fleet of 12 NVIDIA H100 and 8 AMD MI300X GPUs, with a single blank engine box meant to cover both. A line asks which engine fits best.
Setup: the given mixed fleet. Which single engine covers both is left open.
26. A multi-tenant RAG product on NVIDIA Hopper has an 8K P99 prefix with high reuse across tenants and serves thousands of users. Which design fits?Design
A multi-tenant RAG product on NVIDIA Hopper GPUs, serving thousands of users with an 8K-token P99 prefix reused heavily across tenants. A line asks which design fits.
Setup: the given hardware, scale and prefix-reuse pattern. Which design fits is left open.
27. An existing internal service runs on TGI and works well. What is the best plan given its maintenance-mode status?Design
An existing internal service running on TGI, working well, with TGI's own maintenance-mode status given. A line asks what the best plan is, given that status.
Setup: the given service, its good behavior, and its given status. The best plan from here is left open.

Use It

code/main.py is a decision-tree walker. Give it hardware, scale, and workload, and it picks an engine and explains why.

Check: Use It0/6
1. What engine does `pick_engine("CPU", "single_user", "chat")` return?Apply
A function-call card showing pick_engine called with CPU, single_user and chat, its return value left blank. A line asks what engine this call returns.
Setup: the real call, exactly as given. Its return value is left open.
2. What does the walker return for NVIDIA Hopper, small_team, and "long-context 128K"?Apply
A function-call card showing pick_engine called with NVIDIA Hopper, small_team and long-context 128K, its return value left blank. A line asks what this call returns.
Setup: the real call, exactly as given. Its return value is left open.
3. What engine does the walker pick for AMD, production, and "RAG with heavy prefix reuse", and why?Apply
A function-call card showing pick_engine called with AMD, production and RAG with heavy prefix reuse, its return value left blank. A line asks what this call returns, and why.
Setup: the real call, exactly as given. Its return value and the reason are left open.
4. For NVIDIA Blackwell at enterprise scale, which output does the walker produce?Apply
A function-call card showing pick_engine called with NVIDIA Blackwell, enterprise and MoE frontier serving, its return value left blank. A line asks what this call returns.
Setup: the real call, exactly as given. Its return value is left open.
5. Which line appears in the printed reasons for all seven scenarios?Apply
Seven unlabeled scenario calls feeding into three output rows, an engine that varies, reasons that mostly vary, and one more line marked as always the same across every call. A line asks what is on that always-the-same line.
Setup: the shared structure of all seven outputs, with the one constant line left blank. Its content is left open.
6. A reader runs the walker on NVIDIA Hopper with a 128K long-context workload and expects a long-context-specific result, but gets plain vLLM. What explains it?Analyze
A reader's run of the walker on NVIDIA Hopper with a 128K long-context workload, showing what they expected, something long-context-specific, next to what they actually got, plain vLLM. A line asks why there's a mismatch.
Setup: the given input and the gap between what was expected and what came back. The reason for the gap is left open.

Ship It

This lesson produces outputs/skill-engine-picker.md. Given constraints, it picks an engine and writes the migration plan.

Author's Note

I'd run main.py first and read the seven scenarios as a test of your own instincts. It is stdlib Python, and each scenario prints an engine plus a list of reasons, so you can see which branch fired and why.

The hardware branch comes first in the code, the same order the decision tree uses above. Scale and workload are then checked inside each branch, and scale also appends the enterprise stack note at the end. The workload check is a substring match on "agentic" or "prefix", so the long-context scenario on Hopper has no branch of its own and falls through to vLLM. If you care about long context, that is the first spot I'd extend, with the chunked-prefill and tiered-KV split from the workload section.

Two results might surprise you. A single user on CPU gets Ollama rather than bare llama.cpp, because the code treats Ollama as the one-command wrapper over it. Blackwell returns TRT-LLM, and the vLLM "close second" note only appears for small-team and production scale, so the enterprise Blackwell scenario never mentions it. The TGI maintenance-mode line gets appended to every result, which is the code's way of making that default hard to miss.

The code and the prose differ in two small places. The enterprise note in the code names a cache-aware router (Phase 17 · 11), where the scale section above names LMCache (Phase 17 · 18). And Apple Silicon with a single user returns Ollama, while the hardware section above lists llama.cpp as the engine underneath. Treat the code as a simplified walker and the prose as the fuller picture.

Exercises

  1. Run code/main.py with your hardware / scale / workload. Does the output match your intuition?
  2. Your infra is 12 H100s and 8 MI300X AMD. What engine? Why is TRT-LLM off the table?
  3. A team wants to use TGI in 2026 because "it's what we know." Argue the migration case.
  4. Ollama dev to vLLM prod: what changes in quantization, configuration, and observability?
  5. RAG product with P99 prefix length 8K and high reuse across tenants. Pick an engine and stack it with Phase 17 · 11 + 18.

Key Terms

TermWhat people sayWhat it actually means
llama.cpp"the CPU one"Widest model support, fastest on CPU
Ollama"the laptop one"One-command install, dev-grade throughput
TGI"HF's serving"Maintenance mode since Dec 2025
vLLM"the default"Broad production baseline 2026
SGLang"the agentic one"Prefix-heavy, RadixAttention
TRT-LLM"NVIDIA-locked"Blackwell throughput leader, NVIDIA only
GGUF"llama.cpp format"Bundled K-quant variants
Production-stack"vLLM K8s"Phase 17 · 18 reference deployment
Pipeline pattern"dev→stage→prod"Ollama → llama.cpp → vLLM on same weights

Further Reading

Code

Ships With