Skip to content

LLM Field Guide 10 — Serving at Scale: Multi-GPU Parallelism and Inference Engines

Every multi-GPU strategy is a trade: you split the model to make it fit or go faster, and you pay in communication. Pick the split your interconnect can afford and 8 GPUs behave like one big GPU; pick wrong and they behave like 8 small ones waiting on each other. Then the inference engine decides whether that hardware produces 50 tokens/s or 5,000, by how it batches, pages memory, and picks kernels.

In this post:

LLM Field Guide — all 12 posts
  1. How an LLM reads text
  2. Inside the transformer
  3. Training and generation
  4. KV cache and long context
  5. Prompting, context, and RAG
  6. Reasoning models and agents
  7. Choosing a base model
  8. Adapting a model
  9. Making it smaller and faster
  10. Serving at scale ← you are here
  11. Safety and evaluation
  12. Putting it all together

Hands-on deep dives live elsewhere

This post teaches concepts, trade-offs, and how to choose. For exact vLLM multi-node flags read Scaling LLM Inference: DP, PP, and TP with vLLM; for running vLLM in production read vLLM: Production LLM Serving from Zero to Scale.

Two reasons one GPU isn't enough

Name the problem before choosing a strategy. There are only two, and they need different fixes.

Problem 1: the model doesn't fit. Llama-3.1-70B has 80 layers, hidden size 8192, and 8 KV heads.1 At ~70.6B parameters in BF16, the weights alone are about 141 GB; an H100 SXM has 80 GB.2 You quantize (post 09) or you split.

Problem 2: the model fits, but one GPU can't keep up. Llama-3.1-8B (16 GB in BF16) fits easily on one H100. If your traffic needs 10× what one card produces, you need 10× the hardware, not a split model.

Problem Symptom Fix
Doesn't fit OOM at load, or no room left for KV cache Split the model: tensor, pipeline, or expert parallelism
Fits but too slow for the load Queueing, rising TTFT at peak, GPU at 100% Copy the model: data parallelism (replicas)
One request too slow (huge prompt) Prefill of a 128K-token prompt takes seconds Split the sequence: context parallelism

The golden rule: splitting makes a model fit; copying makes it go faster. Most expensive multi-GPU mistakes come from confusing the two.

Memory math: weights plus KV cache

"Fits" means weights plus a KV cache big enough for your concurrency. Plugging Llama-3.1-70B into the KV sizing formula from post 04 gives 2 × 80 layers × 8 KV heads × 128 dims × 2 bytes = 320 KiB per token, so one 32K-token conversation needs about 10 GiB.

Worked example: Llama-3.1-70B on 4× H100

Split four ways with tensor parallelism (next sections), each GPU holds a quarter of the weights and a quarter of the KV heads:

Weights per GPU        = 141 GB / 4             ≈ 35 GB
Usable per GPU (90%)   = 80 GB × 0.90           = 72 GB
Left for KV per GPU    = 72 − 35 − ~3 (activations, CUDA graphs) ≈ 34 GB
KV per token per GPU   = 320 KiB / 4 (2 of 8 kv heads each) = 80 KiB
Tokens of KV cache     = 34 GB / 80 KiB         ≈ 415,000 tokens
                       ≈ 12 concurrent 32K conversations, or ~100 at 4K

On 2× H100 the weights take 70 GB per GPU, leaving almost nothing for KV. It technically loads; it can't serve. That's why "how many GPUs" is a KV question as much as a weights question. The VRAM sizing field guide has the full calculator.

The five ways to split a model

Data parallel (DP)        Tensor parallel (TP)        Pipeline parallel (PP)
┌──────┐ ┌──────┐         one layer split across      layers split into stages
│ full │ │ full │         GPUs; sync every layer      ┌────────┐   ┌────────┐
│model │ │model │         ┌──┬──┬──┬──┐               │L1..L40 │──▶│L41..L80│
└──────┘ └──────┘         │¼ │¼ │¼ │¼ │ ◀─ all-reduce  └────────┘   └────────┘
 GPU0     GPU1            └──┴──┴──┴──┘                 GPU0         GPU1
 (no talk)                 GPU0..GPU3

Expert parallel (EP)                    Context parallel (CP)
MoE experts spread over GPUs;           one long sequence split over GPUs;
tokens routed with all-to-all           KV exchanged between GPUs
Strategy What's split Communication How often Needs fast links? Fixes
DP Nothing (full copies) None for dense models Never No Throughput
TP Every weight matrix All-reduce of activations 2× per layer, every token Yes (NVLink) Fit + per-token latency
PP Layers into stages Point-to-point activations Once per stage boundary Moderate Fit across nodes
EP MoE experts All-to-all token routing 2× per MoE layer Yes Fit + throughput for MoE
CP The sequence KV exchange (gather or ring) Per attention layer Yes Long-prompt latency, KV duplication

In practice you combine them: total GPUs = DP × TP × PP.

Data parallelism: copies that never talk

Run N independent copies and put a load balancer in front. For dense models, replicas never communicate during inference, so throughput scales almost linearly.

DP is the right answer far more often than people expect. If Llama-3.1-8B fits on one GPU and you have 8, 8 replicas beat one 8-way-TP copy for throughput, because TP spends a share of every step on communication and DP spends none. The catch: each replica needs the full model plus its own KV cache, so DP only applies once one replica fits.

(Training is different: data-parallel training all-reduces gradients every step, and ZeRO/FSDP shard optimizer state, gradients, and parameters to remove redundancy; ZeRO trained 100B+ parameter models on 400 GPUs.9 Training memory is covered in post 03.)

Tensor parallelism: split every matrix, sync every layer

TP comes from Megatron-LM.6 It splits each layer's weight matrices across GPUs so they all work on the same token at the same time. Take the feed-forward block (up-projection → activation → down-projection):

Input x (replicated on all 4 GPUs)
        │
        ▼
Up-projection W1 split by COLUMNS     GPU0: x·W1[:, 0:¼]    GPU1: x·W1[:, ¼:½] ...
        │                              (each GPU gets a slice of the hidden units;
        ▼                               the nonlinearity works slice-by-slice, no talk)
Down-projection W2 split by ROWS      GPU0: h0·W2[0:¼, :]   GPU1: h1·W2[¼:½, :] ...
        │                              (each GPU produces a PARTIAL sum of the output)
        ▼
ALL-REDUCE: sum the 4 partial outputs → every GPU holds the full result

Attention splits the same way, by heads. Megatron needs only two all-reduces per transformer layer in the forward pass (one after attention, one after the MLP).6

That's TP's superpower and its curse. Every GPU works on every token, so per-token latency drops. But every layer ends with a synchronization, so the GPU-to-GPU link sits on the critical path of every single token.

Worked example: how much TP actually communicates

Llama-3.1-70B, TP=4. Each all-reduce moves one hidden-state vector per token: 8192 values × 2 bytes = 16 KB per token.

Decode (batch of 32, one token each): 2 per layer × 80 layers = 160 all-reduces of 512 KB per step. Bandwidth isn't the problem; latency is, because each all-reduce has a fixed sync cost and 160 run in sequence. That's why TP decode loves NVLink's low latency and engines that fuse communication into kernels.

Prefill (one 4,096-token prompt): a ring all-reduce makes each GPU send 2(N−1)/N × message size, or 1.5× for N=4.7

Message size           = 4,096 tokens × 16 KB   ≈ 67 MB
Sent per GPU per AR    = 1.5 × 67 MB            ≈ 100 MB
Per GPU per prefill    = 160 × 100 MB           ≈ 16 GB

Back-of-envelope transfer time at the vendor-listed link speed:
  NVLink (H100 SXM, 900 GB/s)     16 GB / 900 GB/s ≈ 18 ms
  PCIe Gen5 x16 (128 GB/s)        16 GB / 128 GB/s ≈ 125 ms
  PCIe Gen4 x16 (L40S, 64 GB/s)   16 GB / 64 GB/s  ≈ 250 ms

Rough on purpose (transfers overlap compute, and vendor figures are bidirectional), but the ratio is the point: ~14× more communication time on PCIe Gen4 than NVLink. Hence the most important rule in this post: keep tensor parallelism inside an NVLink domain. vLLM's docs say that on GPUs without NVLink, such as the L40S, you should prefer pipeline parallelism "for higher throughput and lower communication overhead."10

TP limits you'll hit

  • TP size must divide the attention head count. Llama-3.1-70B has 64 heads, so TP ∈ {1, 2, 4, 8}.
  • KV duplication beyond the KV-head count. With 8 KV heads, TP=16 makes two GPUs share each KV head, duplicating the cache. MLA models with effectively 1 KV head hit this at TP=2; decode context parallelism (below) fixes it.
  • Diminishing returns. Per-GPU work shrinks as TP grows, but per-layer communication doesn't. Megatron hit 76% scaling efficiency on 512 GPUs.6

Pipeline parallelism: split by layers, pass the baton

PP cuts the model into consecutive stages: GPU 0 runs layers 1–40, GPU 1 runs layers 41–80. The only communication is handing activations across each stage boundary: for Llama-3.1-70B, PP=2 sends one 16 KB message per token where TP=2 runs 160 collectives. That's why PP tolerates slow links, and vLLM notes it supports uneven splits when your GPU count doesn't divide the model evenly.10

The cost is the pipeline bubble: with one request, each GPU waits while the others compute.

One request, 4 stages:                Four requests (micro-batches) in flight:
GPU0  [A]                             GPU0  [A][B][C][D]
GPU1      [A]                         GPU1      [A][B][C][D]
GPU2          [A]                     GPU2          [A][B][C][D]
GPU3              [A]  ← 75% idle     GPU3              [A][B][C][D] ← bubble at edges only

GPipe sized the bubble at O((K−1)/(M+K−1)) for K stages and M micro-batches, negligible once M ≥ 4×K.8 Engines fill the pipeline with concurrent requests, so PP works well under load and does nothing for single-request latency.

Tensor parallel Pipeline parallel
Single-request latency Lower (all GPUs work on each token) Same or slightly higher than 1 GPU
Throughput under load Good Good (bubble filled by concurrent requests)
Communication 2 all-reduces per layer, every token 1 send per stage boundary
Interconnect needed NVLink PCIe or network is fine
Uneven GPU counts No (must divide heads) Yes
Typical use Inside a node Across nodes

The standard recipe for big dense models: TP = GPUs per node, PP = number of nodes.10 Two nodes × 8 GPUs → --tensor-parallel-size 8 --pipeline-parallel-size 2.

Expert and context parallelism: splitting MoE and long sequences

Expert parallelism

MoE models have many experts but activate only a few per token (post 09). Expert parallelism places different whole experts on different GPUs and routes each token to whichever GPU holds its chosen experts. Communication becomes all-to-all: every GPU sends some tokens to every other GPU (dispatch), then gets results back (combine), twice per MoE layer.

EP wins twice: memory scales out cleanly (a 600B+ MoE spreads its experts over 8, 16, or 64 GPUs), and no GPU holds redundant expert weights. In vLLM, EP is a flag on top of TP or DP (--enable-expert-parallel). The high-concurrency pattern is DP attention + EP experts: attention runs data-parallel so each GPU holds only its own requests' KV cache, while experts are shared. The DP/PP/TP post covers when TP+EP beats DP+EP.

EP needs fast links even more than TP, because all-to-all traffic is bursty and every GPU talks to every other. That's what NVIDIA's GB200 NVL72 is built for: 72 GPUs in one NVLink domain at 1.8 TB/s per GPU,4 so a whole MoE's experts live in one fabric.

Context parallelism

TP, PP, and EP split the model; context parallelism splits the sequence. It solves two long-context problems:

  • Prefill CP cuts a long prompt (say 128K tokens) into N chunks, one per GPU, to cut TTFT. Each GPU gathers the full K/V from the others, or for very long prompts passes K/V around a ring ("ring attention"). vLLM marks both as under active development.11
  • Decode CP (DCP) fixes TP's KV duplication by sharding the KV cache along the token dimension, without adding GPUs. vLLM's examples: DeepSeek-R1 (1 KV head) with -tp 8 -dcp 8, and Qwen3-235B-A22B (4 KV heads) with -tp 8 -dcp 2.11 Raise TP until decode speed is acceptable, then add DCP to win back the duplicated memory.

Disaggregation: separate GPUs for prefill and decode

One more split, by phase. Prefill is compute-bound and decode is memory-bound (post 04), so running both on the same GPUs makes them interfere: a big prefill stalls everyone's next token.

Prefill/decode disaggregation runs them on separate GPU pools and ships the KV cache from prefill to decode workers over a fast link. DistServe, the paper that popularized it, reported 7.4× more requests or 12.6× tighter latency SLOs than co-located serving.12 Each pool gets its own parallelism: TP-heavy for prefill, DP-heavy for decode.

It's production-grade in 2026 (vLLM, SGLang, TensorRT-LLM, NVIDIA Dynamo, llm-d), but it adds a KV-transfer network and two pools to size. It pays off mostly for long prompts at high volume; read the llm-d post before taking it on.

The interconnect decides which split is safe

Link Bandwidth (vendor-listed) Scope Safe strategies
NVLink 5 (GB200 NVL72) 1.8 TB/s per GPU4 72 GPUs, one rack TP, EP, CP, all of it
NVLink 4 (H100 SXM) 900 GB/s2 8 GPUs, one node (HGX) TP, EP, CP
PCIe Gen5 x16 128 GB/s2 Within a node PP, DP; TP=2 at most, test it
PCIe Gen4 x16 (L40S) 64 GB/s3 Within a node, no NVLink PP, DP
InfiniBand NDR (ConnectX-7) 400 Gb/s = 50 GB/s per adapter5 Across nodes PP, DP, KV transfer for disaggregation

Notice the cliff: 900 GB/s of NVLink versus 50 GB/s per network adapter. Vendors count directions differently, so don't take the exact ratio literally, but the drop is more than an order of magnitude. That's why TP almost never crosses node boundaries on standard 8-GPU servers, and why rack-scale NVLink changed how MoE gets served.

Check what you actually have before setting any flag:

# Which GPU pairs talk over NVLink (NV#) vs PCIe (PIX/PXB/PHB/SYS)?
nvidia-smi topo -m
# NVLink status per GPU
nvidia-smi nvlink --status

In the topo -m matrix, NV18 (or any NV#) means NVLink; SYS means traffic crosses the CPU socket interconnect, the slowest path in the box. Never put a TP group across SYS links.

Three worked deployments

1. Llama-3.1-8B, 8× L40S, chat traffic. Fits on one 48 GB L40S3 with KV room; no NVLink. → DP=8: eight replicas, zero inter-GPU traffic, near-linear throughput.

2. Llama-3.1-70B, one HGX H100 node (8 GPUs, NVLink). Needs ≥4 GPUs to fit with useful KV. → TP=4, DP=2. TP=8 would shave per-token latency, but two replicas double throughput.

# vLLM v0.33: 2 replicas × TP 4 on one 8-GPU node
vllm serve meta-llama/Llama-3.1-70B-Instruct \
  --tensor-parallel-size 4 \
  --data-parallel-size 2

3. Llama-3.1-70B, two nodes of 4× L40S (no NVLink). 141 GB fits in 8 × 48 GB = 384 GB, but TP over PCIe Gen4 is painful (the 250 ms prefill estimate). → PP=8 across all cards, or quantize to FP8 and run PP=4 per node with DP=2. Test both; the second often wins because each token crosses half the stages.

Inside an inference engine

An inference engine is a scheduler and a memory manager that happens to run a neural network. Write the obvious server (transformers, model.generate(), one request at a time) and three problems kill it:

  1. One request at a time. Decode is memory-bound (post 04), so batching 64 requests reads the weights once per step and produces 64 tokens instead of 1.
  2. Static batches. Every request in a batch waits for the longest; a 20-token answer sits behind a 2,000-token one.
  3. KV fragmentation. Reserving a contiguous max_length buffer per request wastes memory on tokens never generated, so fewer requests fit.

Every serious engine exists to fix those three. Here's one request's path through one:

 HTTP request (OpenAI-compatible /v1/chat/completions)
        │
        ▼
 ┌──────────────┐   chat template + tokenizer
 │  API server  │──────────────────────────────────────────────┐
 └──────────────┘                                              │
        │ token IDs                                            │
        ▼                                                      │
 ┌──────────────┐  decides WHO runs THIS step:                 │
 │  Scheduler   │  continuous batching, chunked prefill,       │
 │              │  preemption, priority                        │
 └──────────────┘                                              │
        │                                                      │
        ▼                                                      │
 ┌──────────────┐  allocates KV blocks, finds cached prefixes  │
 │ KV cache mgr │  (PagedAttention, prefix / radix cache)      │
 └──────────────┘                                              │
        │                                                      │
        ▼                                                      │
 ┌──────────────┐  runs the forward pass: attention kernels,   │
 │ Model runner │  quantized GEMMs, CUDA graphs,               │
 │              │  TP/PP/EP comms, drafter                     │
 └──────────────┘                                              │
        │ logits                                               │
        ▼                                                      │
 ┌──────────────┐  temperature, top-p, grammar masks for       │
 │   Sampler    │  structured output                           │
 └──────────────┘                                              │
        │ next token                                           │
        ▼                                                      │
 detokenize ──▶ stream chunk to client (SSE) ◀─────────────────┘
        │
        └── loop back to the scheduler until EOS or max_tokens

Each box is a place where engines compete.

The scheduler: continuous batching and chunked prefill

Continuous batching

Orca (OSDI 2022) introduced iteration-level scheduling: the scheduler rebuilds the batch at every decode step.13 A finished request leaves immediately; a new one joins on the next step.

Static batching (each row = one request slot over time)
slot 0  AAAAAAAAAAAAAAAAAAAA
slot 1  BBBBB...............   ← idle until A finishes
slot 2  CCCCCCCC............   ← idle

Continuous batching
slot 0  AAAAAAAAAAAAAAAAAAAA
slot 1  BBBBBDDDDDDDFFFFFFFF   ← D joins the moment B leaves
slot 2  CCCCCCCCEEEEEEEEEEEE

Every engine in this post does it (TensorRT-LLM calls it in-flight batching). It's the single biggest throughput win over a naive server.

Chunked prefill

A new request's prefill processes its whole prompt at once. A 30K-token RAG prompt can freeze every other user's next token for that step; you see it as ITL spikes. Chunked prefill splits long prefills into chunks and mixes them with ongoing decodes within a per-step token budget. In vLLM V1 it's on by default, and the budget is --max-num-batched-tokens:14

max-num-batched-tokens Effect Good for
Smaller (e.g. 2048) Fewer prefill tokens slow each decode step → better ITL Chat UIs, smooth streaming
Larger (e.g. 8192+) More prompt processed per step → better TTFT Batch jobs, throughput

Preemption

When the KV cache fills, the scheduler evicts someone. vLLM V1 defaults to recompute: drop the victim's KV and rebuild it later.14 Preemption shows up as latency spikes; if it's in the logs, lower --max-num-seqs or give the KV cache more memory.

KV manager and model runner

KV manager: how engines differ on prefix reuse

PagedAttention and prefix caching, both explained in post 04, are table stakes in every GPU engine. What differs is how they find and keep shared prefixes:

  • vLLM automatic prefix caching hashes each full KV block with its prefix and reuses matching blocks. It's on by default (enable_prefix_caching: bool = True).15
  • SGLang RadixAttention keeps all cached prefixes in a radix tree, so any request reuses the longest match, with LRU eviction. The SGLang paper reported up to 6.4× higher throughput on multi-call workloads,16 which is why SGLang is the usual pick for agents and multi-turn chat.

vLLM prints your real KV capacity at startup (GPU KV cache size in tokens and maximum concurrency for your max-model-len). Read it every time you change a flag; post 04 shows how to predict it.

Model runner: where every earlier technique plugs in

Technique Explained in What the runner does
Attention kernels (FlashAttention, FlashInfer, MLA) 02, 04 Fused attention over paged KV blocks
Quantized GEMMs (FP8, NVFP4, MXFP4, AWQ, GGUF) 09 Low-precision matmuls on tensor cores
MoE routing and grouped GEMMs 09 Dispatch tokens to experts, batch per-expert matmuls
Speculative decoding 09 Run drafter, verify chain or tree, rejection-sample
TP / PP / EP / CP This post NCCL collectives between kernels
Structured output 03, 06 Mask invalid tokens before sampling

CUDA graphs matter at small batch, where launching hundreds of small kernels per step costs more CPU time than the GPU work. Engines record the step once and replay it. vLLM's default captures full and piecewise CUDA graphs; --enforce-eager skips capture for faster startup at the cost of decode speed.14

Measuring an engine: four numbers and a benchmark

Metric Definition Who cares
TTFT (time to first token) Request sent → first streamed token Chat UX, agents waiting on tool calls
ITL (inter-token latency) Gap between consecutive streamed tokens Streaming smoothness
TPOT (time per output token) Per request, excluding the first token, averaged Long generations
Throughput Output tokens/s across all requests Cost per token

Definitions follow vLLM's benchmark docs.17 Add goodput: requests per second that meet both your TTFT and TPOT SLOs. Raw throughput at terrible latency is not a win.

# Terminal 1: serve (vLLM v0.33.0)
vllm serve meta-llama/Llama-3.1-8B-Instruct --max-model-len 8192

# Terminal 2: 200 requests, 1K in / 256 out, at most 32 in flight
vllm bench serve \
  --backend openai-chat \
  --endpoint /v1/chat/completions \
  --model meta-llama/Llama-3.1-8B-Instruct \
  --dataset-name random \
  --random-input-len 1024 \
  --random-output-len 256 \
  --num-prompts 200 \
  --max-concurrency 32

It prints mean, median, and P99 for TTFT, TPOT, and ITL.17 Sweep --max-concurrency (1, 8, 32, 128) to draw the latency-vs-throughput curve; its knee is your capacity per replica. The same client works against SGLang and any OpenAI-compatible server, which makes it a fair cross-engine yardstick.

Benchmark gotcha

The random dataset is reproducible for a fixed --seed (default 0), so repeated runs can hit the prefix cache and inflate throughput.17 Vary the seed or restart the server between runs.

The 2026 engine landscape

Latest stable releases on GitHub as of 2026-11-05:

Engine Latest version Strength Hardware Model format Default port
vLLM v0.33.0 (2026-11-02)18 Broadest model coverage, general-purpose default NVIDIA (CUDA 13), AMD ROCm, others HF safetensors; FP8/FP4/AWQ/GPTQ 8000
SGLang v0.5.23 (2026-11-02)19 Prefix-heavy agent/multi-turn workloads, fast new-model support NVIDIA, AMD HF safetensors; FP8/FP4/AWQ 3000020
TensorRT-LLM v1.2.1 stable; v1.4.0rc2 pre-release21 Peak performance on NVIDIA, deep Blackwell kernels NVIDIA only HF checkpoints via PyTorch backend 8000 in docs examples
llama.cpp v0.9.0 (2026-11-04)24 CPU, Apple Silicon, consumer GPUs, edge CPU, CUDA, Metal, Vulkan, SYCL, ROCm, more GGUF 993126
Ollama v0.40.14 (2026-11-03)27 One-command local models, developer laptops CPU, NVIDIA, AMD, Apple Silicon GGUF (Ollama registry) 1143428

Two orchestration layers sit above engines for multi-node serving: llm-d (v1.0.0, 2026-10-20) adds KV-aware routing and P/D disaggregation on Kubernetes with vLLM underneath,29 and NVIDIA Dynamo (v1.6.1, 2026-10-27) does the same across vLLM, SGLang, and TensorRT-LLM.30

What changed recently

  • Hugging Face TGI is archived. The repo went read-only on 2026-03-21 after a maintenance-mode notice recommending vLLM and SGLang.31 Migrate.
  • TensorRT-LLM no longer needs an engine build. The TensorRT engine backend was removed and PyTorch is the sole backend;22 you point trtllm-serve at a Hugging Face checkpoint, no trtllm-build step.23
  • vLLM v0.33 dropped Medusa, the legacy Ray compiled-graph executor, and CUDA 12.9 wheels (CUDA 13.0 only).18 Check your driver before upgrading.
  • llama.cpp's server default port moved to 9931 in v0.7.0.25 Scripts hard-coding :8080 break.
  • Ollama still serves one request at a time per model by default (OLLAMA_NUM_PARALLEL = 1).28 Fine for a laptop, wrong for a shared server unless you raise it.

Hands-on: the same model on four engines

All four expose an OpenAI-compatible API, so one curl tests them all:

# vLLM (BF16 weights from Hugging Face)
pip install "vllm==0.33.0"
vllm serve meta-llama/Llama-3.1-8B-Instruct --port 8000

# SGLang
python3 -m sglang.launch_server --model-path meta-llama/Llama-3.1-8B-Instruct --port 30000

# llama.cpp (4-bit GGUF, runs on CPU or Apple Silicon)
llama-server -hf bartowski/Meta-Llama-3.1-8B-Instruct-GGUF:Q4_K_M --port 9931

# Ollama
ollama pull llama3.1:8b && ollama serve      # listens on 127.0.0.1:11434

# Same request against any of them (change port and model name)
curl -s http://localhost:8000/v1/chat/completions \
  -H "Content-Type: application/json" \
  -d '{"model": "meta-llama/Llama-3.1-8B-Instruct",
       "messages": [{"role": "user", "content": "Complete: The cat sat"}],
       "max_tokens": 20, "temperature": 0}' \
  | python3 -c 'import json,sys; print(json.load(sys.stdin)["choices"][0]["message"]["content"])'

Don't expect identical text across engines, even at temperature 0. Different kernels, batch composition, and quantization (BF16 vs Q4_K_M) change the floating-point math and flip near-ties. If quality matters, evaluate each engine-plus-quantization combo (post 11).

The knobs that matter, and how to choose

vLLM names; other engines have equivalents:

Flag What it controls Tune when
--gpu-memory-utilization (unset → 0.92, or 1.0 with the extensible KV cache15) Fraction of VRAM for weights + KV OOM at startup or sharing a GPU → lower
--max-model-len Longest context accepted; caps KV reservation Model supports 128K but you need 8K → set 8K, gain concurrency
--max-num-seqs Max concurrent sequences per step Preemption in logs → lower
--max-num-batched-tokens Per-step token budget (chunked prefill) ITL spikes → lower; slow TTFT → raise
--kv-cache-dtype fp8 KV precision Need ~2× more KV capacity
--quantization / pre-quantized checkpoint Weight format (post 09) Fit a bigger model or free KV memory
--speculative-config Drafter (post 09) Latency-bound, low/medium concurrency
--tensor-parallel-size, --data-parallel-size, --enable-expert-parallel Parallelism (this post) Model doesn't fit / need throughput / MoE

SGLang's equivalents include --mem-fraction-static (weights + KV pool) and --chunked-prefill-size.20

Where does it run?
├─ Laptop / CPU / Apple Silicon / edge box
│     ├─ want zero config, single user ──────────────── Ollama
│     └─ want control, server mode, GGUF tuning ──────── llama.cpp (llama-server)
│
└─ Datacenter GPUs
      ├─ default for almost everyone ─────────────────── vLLM
      ├─ agents / multi-turn / big shared prefixes,
      │  or you need a just-released model fast ────────── SGLang (benchmark vs vLLM)
      ├─ NVIDIA-only, steady volume, every % matters ──── TensorRT-LLM (benchmark vs both)
      └─ multi-node, P/D disaggregation, KV-aware routing
                                     ─── llm-d or NVIDIA Dynamo on top of the above

Three rules keep you out of trouble:

  • Start with vLLM unless you have a reason not to. Widest model support, most documentation. The Kubernetes playbook has the full decision matrix.
  • Switch engines only with a benchmark in hand. Run vllm bench serve against both at your real input/output lengths and concurrency; vendor charts show their best case.
  • Pin versions. These projects ship every 2–3 weeks with breaking changes (vLLM went from v0.31.0 to v0.33.0 between 2026-10-05 and 2026-11-0218). Pin the image tag, upgrade deliberately, re-benchmark.

Summary

Parallelism, in decision order:

  • Size it first: weights + KV for your target concurrency; consider quantizing before buying GPUs
  • Fits on one GPU? → DP only; add replicas for throughput
  • Doesn't fit on one GPU, fits in one NVLink node? → TP inside the node, then DP
  • Doesn't fit in one node? → TP = GPUs per node, PP = nodes
  • No NVLink? → prefer PP over TP
  • MoE? → add EP; DP-attention + EP at high concurrency
  • Huge prompts or few KV heads? → prefill CP for TTFT, decode CP for KV duplication
  • Long prompts at high volume stalling decode? → evaluate P/D disaggregation (llm-d, Dynamo)
  • Verify topology with nvidia-smi topo -m before setting any parallelism flag

Engine, in setup order:

  • Pick the engine with the decision tree; pin its version
  • Set --max-model-len to what you need, not the model's maximum
  • Read the startup log's KV capacity and compute max concurrency for your context length
  • Put stable prompt content first to hit the prefix cache
  • Benchmark TTFT, ITL, and throughput at 3+ concurrency levels; find the knee
  • Watch for preemption and ITL spikes; tune max-num-seqs and max-num-batched-tokens
  • Re-run quality evals whenever you change quantization or engine
Strategy / component One-line rule
DP Copies for throughput; free if the model fits
TP Lowest latency, but only over NVLink
PP Crosses slow links; fills its bubble only under load
EP MoE's native split; needs all-to-all bandwidth
CP Splits sequences, not weights; for long context
Continuous batching The biggest single throughput win; every engine has it
Chunked prefill Smaller budget for smooth streaming, larger for TTFT
Prefix reuse vLLM APC by default; SGLang RadixAttention for agents and multi-turn

Next: Post 11 — Safety and Evaluation: your engine will now happily answer anything, including what it shouldn't, and you need proof that every change made it better.

Go deeper:


  1. Meta Llama 3.1 70B Instruct, config.json (ungated mirror of the Meta checkpoint) — hidden_size 8192, 80 layers, 64 attention heads, 8 KV heads. ↩

  2. NVIDIA, H100 Tensor Core GPU — H100 SXM: 80 GB, 3.35 TB/s; NVLink 900 GB/s; PCIe Gen5 128 GB/s. ↩↩↩

  3. NVIDIA, L40S GPU — 48 GB GDDR6, PCIe Gen4 x16 64 GB/s bidirectional, NVLink not supported. ↩↩

  4. NVIDIA, GB200 NVL72 — 72-GPU NVLink domain, 1.8 TB/s GPU-to-GPU per GPU, 130 TB/s total. ↩↩

  5. NVIDIA, InfiniBand Adapters — ConnectX-7 400 Gb/s; ConnectX-8 SuperNIC up to 800 Gb/s. ↩

  6. Shoeybi et al., Megatron-LM: Training Multi-Billion Parameter Language Models Using Model Parallelism, 2019 — two all-reduces in the forward path per layer; 8.3B model on 512 GPUs at 76% scaling efficiency. ↩↩↩

  7. NVIDIA, nccl-tests PERFORMANCE.md — ring AllReduce time t = (S/B) × 2(n−1)/n. ↩

  8. Huang et al., GPipe: Efficient Training of Giant Neural Networks using Pipeline Parallelism, 2019 — bubble time O((K−1)/(M+K−1)); negligible when M ≥ 4×K. ↩

  9. Rajbhandari et al., ZeRO: Memory Optimizations Toward Training Trillion Parameter Models, 2019 — 100B+ parameter models on 400 GPUs. ↩

  10. vLLM docs, Parallelism and Scaling — TP within a node, TP+PP across nodes; PP supports uneven splits; on GPUs without NVLink such as L40S, prefer PP over TP. ↩↩↩

  11. vLLM docs, Context Parallel Deployment — prefill CP under active development; decode CP via -dcp shards KV along tokens; DeepSeek-R1 -tp 8 -dcp 8, Qwen3-235B-A22B -tp 8 -dcp 2. ↩↩

  12. Zhong et al., DistServe: Disaggregating Prefill and Decoding for Goodput-optimized Large Language Model Serving, OSDI 2024 — 7.4× more requests or 12.6× tighter SLO. ↩

  13. Yu et al., Orca: A Distributed Serving System for Transformer-Based Generative Models, OSDI 2022 — iteration-level scheduling (continuous batching). ↩

  14. vLLM docs, Optimization and Tuning — chunked prefill on by default in V1; max_num_batched_tokens trade-off; RECOMPUTE preemption; FULL_AND_PIECEWISE CUDA graphs; --enforce-eager. ↩↩↩

  15. vLLM source, vllm/config/cache.py — enable_prefix_caching: bool = True; gpu_memory_utilization unset resolves to 1.0 with the extensible KV cache, 0.92 otherwise. ↩↩

  16. Zheng et al., SGLang: Efficient Execution of Structured Language Model Programs, 2024 — RadixAttention; up to 6.4× higher throughput. ↩

  17. vLLM docs, Benchmark CLI — vllm bench serve; TTFT, TPOT, ITL statistics; random dataset seed behavior. ↩↩↩

  18. vLLM, releases — v0.33.0 published 2026-11-02 (CUDA 13.0 only; Medusa, MLP speculator and legacy Ray compiled-graph executor removed); v0.31.0 published 2026-10-05. ↩↩↩

  19. SGLang, releases — v0.5.23 published 2026-11-02. ↩

  20. SGLang docs, Server Arguments — default --port 30000; --mem-fraction-static; --chunked-prefill-size. ↩↩

  21. NVIDIA, TensorRT-LLM releases — v1.2.1 latest stable (2026-04-20); v1.4.0rc2 pre-release (2026-10-28). ↩

  22. NVIDIA TensorRT-LLM docs, Migration Guide: TensorRT Backend Removed — PyTorch is the sole execution backend. ↩

  23. NVIDIA TensorRT-LLM docs, Quick Start Guide — trtllm-serve on a Hugging Face checkpoint, port 8000. ↩

  24. ggml-org, llama.cpp releases — v0.9.0 (2026-11-04); nightly build b12121 (2026-11-05). ↩

  25. ggml-org, llama.cpp v0.7.0 release notes — server gets "a new default port (9931)". ↩

  26. ggml-org, llama-server README — --port default 9931; -hf <user>/<model>[:quant]. ↩

  27. Ollama, releases — v0.40.14 published 2026-11-03. ↩

  28. Ollama docs, FAQ — binds 127.0.0.1:11434 by default; OLLAMA_NUM_PARALLEL default 1. ↩↩

  29. llm-d, releases — v1.0.0 published 2026-10-20. ↩

  30. NVIDIA, Dynamo releases — v1.6.1 published 2026-10-27. ↩

  31. Hugging Face, text-generation-inference — "now in maintenance mode", recommends vLLM and SGLang; archived (last push 2026-03-21). ↩

Discussion

Have thoughts on this post? Share them below — questions, corrections, or your own experience are all welcome.