Slides · Inference engineering

Distributed serving, engines and hardware

Distributed serving, engines and hardware

What to do when one GPU is not enough: four ways to split a model, the arithmetic that checks a layout, why mixture-of-experts and many adapters change the memory picture, and how to pick an engine and a chip from criteria.

By the end you can choose a split and name the messages it adds, compute weights per GPU, the cache budget and the step floor, explain experts and adapters in memory terms, and choose an engine and a hardware attribute for a workload.

Concept

Splitting costs communication, so split as little as possible

Every split adds messages between GPUs, and those messages travel slower than local memory. So the question is when a split is worth that cost.

  • The vLLM parallelism page (dated 15 October 2026) says a model that fits on one GPU probably does not need distributed inference.
  • If it is too large for one GPU but fits on one node, it suggests tensor parallelism across that node’s GPUs. If it is too large for a node, it suggests tensor parallelism combined with pipeline parallelism.
  • The page ties the split to fit. The course adds a second reason: one GPU may fit the model yet miss the latency target, because splitting adds aggregate memory bandwidth. Treat that as the course’s reasoning and measure it.
  • The working rule: the smallest degree of splitting that fits and meets the target, then replicas for volume.

Source1 Parallelism and Scaling (vLLM documentation)

Diagram

Two ways to cut one model

Diagram: Tensor parallelism cuts every layer across GPUs, so they swap partial results inside each layer for every token.

Pipeline parallel

GPU 1: layers 1 to 40

GPU 2: layers 41 to 80

Tensor parallel

GPU 1: half of every layer

GPU 2: other half

Diagram summary: Tensor parallelism cuts every layer across GPUs, so they swap partial results inside each layer for every token. Pipeline parallelism gives each GPU a block of consecutive layers and passes activations from one block to the next.

Source2 Megatron-LM: Training Multi-Billion Parameter Language Models Using Model Parallelism

Compare

The four strategies side by side

StrategyWhat is splitWhat crosses the wireReach for it when
Data parallel (replicas)Nothing; each copy is wholeNothing per request; a router sends workRequests per second must grow
Tensor parallelEvery layer’s matricesPartial sums, inside each layer, each tokenThe model does not fit, or latency needs more aggregate bandwidth
Pipeline parallelBlocks of consecutive layersActivations between stagesThe model spans nodes, or links are slow
Expert parallelThe experts of a mixture-of-experts modelTokens sent to the GPU holding their expertA large mixture-of-experts model

The vLLM page names InfiniBand as the kind of link that makes tensor parallelism across nodes workable, and says nodes without NVLink (its example is the L40S) can prefer pipeline parallelism for throughput.

Source1 Parallelism and Scaling (vLLM documentation)

Diagram

Choosing a layout

Diagram: If the model and a useful cache fit on one GPU, add replicas; if they fit in one fast-linked node, use tensor parallelism there.

yes

no

yes

no

Weights plus cache fit on one GPU?

Replicas for volume

Fit in one node with fast links?

Tensor parallel in the node, replicas for volume

Tensor parallel per node, pipeline across nodes

Diagram summary: If the model and a useful cache fit on one GPU, add replicas; if they fit in one fast-linked node, use tensor parallelism there. Otherwise combine tensor parallelism inside each node with pipeline parallelism across nodes.

Source1 Parallelism and Scaling (vLLM documentation)

Worked example

Worked: what tensor parallelism sends

Megatron-LM splits each transformer layer so that the attention block and the feed-forward block each need one all-reduce in the forward pass; the paper counts four communication operations per layer once the backward pass is included. Serving only runs forward.

For a 126-layer model (Llama 3 405B, from its paper’s hyperparameter table):

QuantityArithmeticResult
All-reduces per token126×2126 \times 2252
Assumed time each (illustrative)10 microseconds
Added per step252×10 μs252 \times 10\ \mu\text{s}about 2.5 ms
Weights-only floor, 8 H100, 8-bit405 GB/26.8 TB/s405\ \text{GB} / 26.8\ \text{TB/s}about 15.1 ms

This count covers only the per-layer all-reduces; the embedding and output-logit steps add collectives of their own, so treat 252 as a floor. The course’s reasoning is that these messages are small, so their latency matters more than link bandwidth; that is not a sourced claim. Over a slower network each message costs more, and 252 of them per token multiplies the damage. The 10 microsecond figure is invented to make the arithmetic concrete; measure your own links.

Source2 Megatron-LM: Training Multi-Billion Parameter Language Models Using Model Parallelism

Concept

What pipeline parallelism does and does not buy

  • Activations cross only at stage boundaries, so slower links are tolerable.
  • A single token still passes every stage in order. Pipelining raises capacity and throughput; it does not shorten one token’s path.
  • Stages can sit idle while others work (pipeline bubbles).
  • The vLLM tuning page, read 24 October 2026, adds a “However” to each: a larger tensor-parallel size may cause excessive synchronization overhead, and a larger pipeline-parallel size may cause latency penalties. Both degrees are tuned, not maximised.

Sources3 Optimization and Tuning1 Parallelism and Scaling (vLLM documentation)

Check yourself

Check: two nodes, one big model

Provenance: Generated practice.

A model has 700 GB of 8-bit weights. Each node has 8 GPUs of 80 GB joined by NVLink, and the two nodes are joined by InfiniBand. Assume 90 percent usable memory and 4 GB of overhead per GPU. Does it fit in one node? Propose a layout, and name one way to avoid crossing nodes.

Answer

One node: 0.9×640=5760.9 \times 640 = 576 GB, minus 32 GB overhead, leaves 544 GB, below 700 GB, so it does not fit. Two nodes: 0.9×1,280=1,1520.9 \times 1{,}280 = 1{,}152 GB, minus 64 GB overhead and 700 GB of weights, leaves 388 GB for cache. Layout: tensor parallel 8 inside each node, pipeline parallel 2 across the nodes, which matches the vLLM guidance for models larger than one node; add replicas of the 16-GPU group for volume. To stay inside one node, quantize the weights to 4 bits: 350 GB of weights leaves 576−32−350=194576 - 32 - 350 = 194 GB for cache, at the price of validating quality (lesson 3).

Source1 Parallelism and Scaling (vLLM documentation)

Check yourself

Check: price the messages

Provenance: Generated practice.

An 80-layer model uses tensor parallelism with the standard two forward all-reduces per layer. Assume each takes 15 microseconds (illustrative). How many per token, how much time per step, and what share of a 7.3 ms weights-only floor is that?

Answer

80×2=16080 \times 2 = 160 all-reduces per token; 160×15 μs=2.4 ms160 \times 15\ \mu\text{s} = 2.4\ \text{ms}; 2.4/7.32.4 / 7.3 is about 33 percent of the floor, so even small messages take a visible share of every step.

Source2 Megatron-LM: Training Multi-Billion Parameter Language Models Using Model Parallelism

Math

The layout arithmetic

kv_bytes_per_token=2×layers×kv_heads×head_dim×bytes_per_value\text{kv\_bytes\_per\_token} = 2 \times \text{layers} \times \text{kv\_heads} \times \text{head\_dim} \times \text{bytes\_per\_value}kv_budget=usable×ngpus×gpu_memory−weights−overhead×ngpus\text{kv\_budget} = \text{usable} \times n_{\text{gpus}} \times \text{gpu\_memory} - \text{weights} - \text{overhead} \times n_{\text{gpus}}sequences=kv_budgetkv_bytes_per_token×tokens_per_sequence\text{sequences} = \frac{\text{kv\_budget}}{\text{kv\_bytes\_per\_token} \times \text{tokens\_per\_sequence}}step_floor=weightsngpus×bandwidth_per_gpu\text{step\_floor} = \frac{\text{weights}}{n_{\text{gpus}} \times \text{bandwidth\_per\_gpu}}
SymbolMeaning
usable\text{usable}Share of GPU memory the engine may use (0.9 here, a typical setting)
overhead\text{overhead}Memory per GPU for activations and engine state (4 GB here, illustrative)
weights\text{weights}Bytes of weights, which depend on precision
step_floor\text{step\_floor}Time to read all weights once, assuming ideal splitting; excludes cache reads and messages

If kv_budget\text{kv\_budget} is zero or negative, the layout does not serve at all.

Worked example

Worked: a 405-billion-parameter dense model on eight GPUs

Llama 3 405B: 126 layers, 8 KV heads, hidden size 16,384 over 128 heads (head dimension 128). Cache per token in 16-bit values: 2×126×8×128×2=516,0962 \times 126 \times 8 \times 128 \times 2 = 516{,}096 bytes. NVIDIA’s pages (read 24 October 2026): H100 80 GB at 3.35 TB/s, H200 141 GB at 4.8 TB/s.

LayoutWeightsKV budget8,192-token sequencesStep floor
8 H100, BF16810 GBnegative0not applicable
8 H100, 8-bit weights405 GB139 GB3215.1 ms
8 H200, BF16810 GB173 GB4021.1 ms

The BF16 model cannot even hold its weights on eight H100s (810 GB against 640 GB). The two working layouts trade quantization risk against a larger-memory GPU. Throughput then scales by adding replicas of the chosen group.

Sources4 The Llama 3 Herd of Models5 NVIDIA H100 Tensor Core GPU6 NVIDIA H200 Tensor Core GPU (product page)

Code

The same arithmetic as a short script

Python

import math

def kv_bytes(layers, kv_heads, head_dim, bytes_per_value):
    return 2 * layers * kv_heads * head_dim * bytes_per_value

def layout(n_gpus, gpu_gb, bw_tbs, weights_gb, kv_per_token, seq_tokens,
           usable=0.9, overhead_gb=4.0):
    sizes = (n_gpus, gpu_gb, bw_tbs, weights_gb, kv_per_token, seq_tokens)
    if not all(math.isfinite(x) and x > 0 for x in sizes):
        raise ValueError("all sizes must be positive and finite")
    if not math.isfinite(overhead_gb) or overhead_gb < 0:
        raise ValueError("overhead_gb must be zero or more")
    if not 0 < usable <= 1:
        raise ValueError("usable must be in (0, 1]")
    budget = usable * n_gpus * gpu_gb - weights_gb - overhead_gb * n_gpus
    seqs = int(budget * 1e9 // (kv_per_token * seq_tokens)) if budget > 0 else 0
    floor_ms = weights_gb / (n_gpus * bw_tbs * 1000) * 1000
    return round(budget, 1), seqs, round(floor_ms, 2)

print(layout(8, 80, 3.35, 405, kv_bytes(126, 8, 128, 2), 8192))   # (139.0, 32, 15.11)
Case runResult
8 H100, 8-bit weights139 GB budget, 32 sequences, 15.11 ms
8 H100, BF16 weightsbudget below zero, 0 sequences, so the layout does not serve
8 H200, BF16 weights173.2 GB, 40 sequences, 21.09 ms
Zero GPUs, a non-positive or NaN size, a negative overhead_gb, or usable above 1Raises ValueError

The script checks fit and prices a step floor; it does not model messages, cache reads or activation memory beyond the flat overhead.

Check yourself

Check: will a 70B model meet an 8 ms target?

Provenance: Generated practice.

A 70B-class model has 80 layers, 8 KV heads, head dimension 128, a 16-bit cache and 8-bit weights (70 GB). It runs on two H200s (141 GB, 4.8 TB/s each) with 90 percent usable memory and 4 GB of overhead per GPU. Compute the cache per token, how many 6,000-token sequences fit, and the weights-only floor. If the tensor-parallel messages add 2.4 ms (assumed), does it meet an 8 ms inter-token target? What would four GPUs change?

Answer

Cache per token: 2×80×8×128×2=327,6802 \times 80 \times 8 \times 128 \times 2 = 327{,}680 bytes. Budget: 0.9×282=253.80.9 \times 282 = 253.8 GB, minus 70 and 8, leaves 175.8 GB. A sequence takes 6,000×327,680=1.976{,}000 \times 327{,}680 = 1.97 GB, so 89 fit. Floor: 70/9.6 TB/s=7.29 ms70 / 9.6\ \text{TB/s} = 7.29\ \text{ms}. Adding 2.4 ms gives about 9.7 ms, over target, before counting cache reads. On four H200s the floor is 70/19.2=3.65 ms70 / 19.2 = 3.65\ \text{ms}; with the same 2.4 ms assumed for messages (they would likely grow with more GPUs) the total is about 6.1 ms, which leaves room for cache reads. The cost is two more GPUs per replica.

Concept

Mixture of experts: compute follows active, memory follows total

A router sends each token to a few experts per layer. Mixtral 8x7B has eight feed-forward experts per layer, and the router picks two. Its paper reports 47B parameters available and 13B used per token. DeepSeek-V3’s report gives 671B total and 37B activated.

  • Compute per token follows the active parameters.
  • A later token may need any expert, so all of them stay in GPU memory.
  • As the batch grows, a step touches more of the experts, so bytes read per step climb toward the total.

Sources7 Mixtral of Experts8 DeepSeek-V3 Technical Report

Diagram

One token through one expert layer

Diagram: The router sends a token to two of eight experts, so only those two do arithmetic for that token.

Token

Router picks 2 of 8

Expert 3 runs

Expert 6 runs

Other 6 experts idle but resident

Diagram summary: The router sends a token to two of eight experts, so only those two do arithmetic for that token. The other six sit idle yet stay in GPU memory, because a different token may need them on the same step.

Source7 Mixtral of Experts

Worked example

Worked: how much of a layer a batch touches

Assume each token independently picks 2 of 8 experts with equal chance (an idealisation: real routers are skewed). An expert is skipped by one token with probability 3/4, so it is touched by a batch of BB tokens with probability 1−(3/4)B1 - (3/4)^{B}.

BatchArithmeticShare of experts read
11−0.751 - 0.7525 percent
41−0.7541 - 0.75^{4}68 percent
81−0.7581 - 0.75^{8}90 percent
161−0.75161 - 0.75^{16}99 percent

With 13B active and 47B total at 2 bytes per weight, a step at batch 1 reads about 26 GB and a step near batch 16 reads about 94 GB. That is 3.6 times the bytes for 16 times the tokens, so the batch still pays, but the saving over a dense model of the same total size depends on batch size.

Source7 Mixtral of Experts

Concept

Serving experts across GPUs

Expert parallelism places different experts on different GPUs and sends each token to the GPU that holds its expert, an all-to-all exchange every layer. Two operational consequences follow.

  • Imbalance. A popular expert makes its GPU the slowest one in the step, and the whole step waits. The symptom is a slow tail (p99) with a normal median. This is the course’s reasoning, not a claim on the vLLM page.
  • Layout. vLLM documents data-parallel attention combined with expert- or tensor-parallel mixture-of-experts layers for large deployments.

Options a team weighs when one expert runs hot: spread copies of it, balance the routing, or batch with the routing in mind. Each costs memory or quality, so the choice follows measurement.

Source1 Parallelism and Scaling (vLLM documentation)

Check yourself

Check: a wider layer

Provenance: Generated practice.

Routing sends every token to 2 of 32 experts in a layer, with equal odds for each expert. The model holds 4 GB of always-read shared weights and 80 GB of expert weights (8-bit, illustrative). What share of experts does a batch of 20 read, how many bytes does a step read at batch 1 and at batch 20, and what is the bytes per token in each case?

Answer

Per token an expert is skipped with probability 30/3230/32. Batch 1 reads 2/32=6.252/32 = 6.25 percent of experts: 4+0.0625×80=94 + 0.0625 \times 80 = 9 GB, so 9 GB per token. Batch 20 reads 1−(30/32)20=72.51 - (30/32)^{20} = 72.5 percent: 4+0.725×80=624 + 0.725 \times 80 = 62 GB per step, so 3.1 GB per token. Larger batches read far more per step but spread the cost over more tokens; the shared weights and any skew in real routing move the numbers.

Source7 Mixtral of Experts

Concept

One resident base, many small adapters

A LoRA adapter replaces a change to a big weight matrix with two thin factors, so it is small next to the base model. That makes it possible to keep one base model in GPU memory and switch adapters per request.

S-LoRA (MLSys 2024) keeps all adapters in host memory, fetches the ones used by currently running queries into GPU memory, and manages adapter weights and KV tensors in one paged pool. Its abstract reports up to 4 times the throughput of HuggingFace PEFT and of vLLM with naive LoRA support, in its own experiments.

Sources9 LoRA: Low-Rank Adaptation of Large Language Models10 SLoRA: Scalable Serving of Thousands of LoRA Adapters

Diagram

Where adapters live

Diagram: All adapters wait in host memory.

Host memory: all adapters

GPU pool: adapters in use plus KV

Base model resident on GPU

Running requests

Diagram summary: All adapters wait in host memory. The adapters needed by running requests move into a shared GPU pool next to the cache, and every request runs on the same resident base model with its own adapter.

Source10 SLoRA: Scalable Serving of Thousands of LoRA Adapters

Worked example

Worked: sizing an adapter on 8B dimensions

Rank 16 on the query, key, value and output projections of an 8B model: hidden size 4,096, key and value width 1,024, 32 layers. An adapter on a din×doutd_{\text{in}} \times d_{\text{out}} matrix has r×(din+dout)r \times (d_{\text{in}} + d_{\text{out}}) parameters.

MatrixArithmeticParameters
Query, output (each)16×(4,096+4,096)16 \times (4{,}096 + 4{,}096)131,072
Key, value (each)16×(4,096+1,024)16 \times (4{,}096 + 1{,}024)81,920
One layer2×131,072+2×81,9202 \times 131{,}072 + 2 \times 81{,}920425,984
32 layers425,984×32425{,}984 \times 3213,631,488

At 2 bytes each that is 27.3 MB, about 0.17 percent of a 16 GB base. Hundreds of such adapters fit in the memory one extra copy of the base would use.

Source9 LoRA: Low-Rank Adaptation of Large Language Models

Concept

What vLLM documents, and what it costs

From the vLLM LoRA page (read 24 October 2026):

  • Serving starts with --enable-lora, and adapters are registered by name; a client selects one by putting its name in the model field.
  • Adapter requests run in parallel with base-model requests and with other adapters, subject to limits such as max_loras.
  • max_lora_rank should equal the largest rank in use; much higher wastes memory.
  • Loading adapters at runtime is flagged as a security risk, not for production outside an isolated, fully trusted environment.

The prefix-caching page lists LoRA ids among the extra values in a block’s hash, so two adapters do not share cached prefixes. Plan for load time, cache pressure and a smaller hit rate.

Sources11 LoRA Adapters (vLLM documentation)12 Automatic Prefix Caching

Check yourself

Check: adapters on a 70B model

Provenance: Generated practice.

A 70B model has hidden size 8,192, key and value width 1,024 and 80 layers, with 16-bit weights (140 GB). A rank-8 adapter covers the query, key, value and output projections. How many parameters per adapter, how many MB, what share of the base, and how much memory for 100 adapters?

Answer

Query and output: 8×(8,192+8,192)=131,0728 \times (8{,}192 + 8{,}192) = 131{,}072 each. Key and value: 8×(8,192+1,024)=73,7288 \times (8{,}192 + 1{,}024) = 73{,}728 each. One layer: 2×131,072+2×73,728=409,6002 \times 131{,}072 + 2 \times 73{,}728 = 409{,}600. Eighty layers: 32,768,000 parameters, 65.5 MB at 2 bytes. That is 0.047 percent of 140 GB. A hundred adapters take about 6.6 GB, small enough to keep many in host memory and a working set on the GPU. The base stays the dominant cost.

Source9 LoRA: Low-Rank Adaptation of Large Language Models

Process

Choose an engine from criteria

  1. Fit: does it run your model, quantization format, adapters and structured output?
  2. Performance on your traffic: your prompt and output length mix, shared prefixes, and latency target, not a leaderboard.
  3. Operations: metrics, health checks, upgrade path, and how fast the project ships fixes.
  4. Lock-in: which hardware the engine runs on.
  5. Status: is the project maintained? Check the repository before building on it.

Compare

Engines, as the pages read on 24 October 2026

EngineWhat its own pages sayWatch for (course judgment)
vLLMPagedAttention for KV memory (Kwon et al.); its site documents prefix caching and LoRA servingMoves quickly; flags need tuning per workload
SGLangREADME: a serving framework for language, vision-language and diffusion models that lists NVIDIA, AMD, TPU and other hardware; RadixAttention reuses KV cache (Zheng et al., preprint)Smaller ecosystem
TensorRT-LLMDocumentation for accelerating LLM inference on NVIDIA GPUs; lists in-flight batching, paged KV cache, FP8 on H100 and later, FP4 on B200, and EAGLE, MTP and n-gram speculative decodingTied to NVIDIA hardware
Text Generation InferenceThe repository says maintenance mode, archived read-only on 21 March 2026, and recommends vLLM and SGLang going forwardDo not start new work on it
llama.cpp, MLXNamed by the TGI notice as local enginesBuilt for local use, not datacenter concurrency

Engine facts expire; treat this table as dated.

Sources13 Efficient Memory Management for Large Language Model Serving with PagedAttention12 Automatic Prefix Caching11 LoRA Adapters (vLLM documentation)14 SGLang: Efficient Execution of Structured Language Model Programs15 sgl-project/sglang (GitHub repository)16 TensorRT LLM overview (documentation)17 huggingface/text-generation-inference (GitHub repository, archived)

Check yourself

Check: shortlist an engine

Provenance: Generated practice.

A team needs to serve one model on a mixed fleet of NVIDIA and AMD GPUs, with LoRA adapters, and is deciding between TensorRT-LLM, Text Generation Inference, vLLM and SGLang. Using only the pages above, which are eliminated and why, and what is the next step for the rest?

Answer

TensorRT-LLM: its overview page describes NVIDIA GPUs and says nothing about AMD, so on these pages it does not cover the AMD half. Text Generation Inference: archived and read-only, and its notice points elsewhere. vLLM and SGLang remain; SGLang’s README lists AMD hardware, and vLLM publishes a LoRA page. The next step is not a pick from reading but a trial: replay a trace of your own traffic through both, with adapters loaded, at your latency target, and compare goodput (lesson 6). Also check each project’s support for your exact GPU model and version.

Sources16 TensorRT LLM overview (documentation)17 huggingface/text-generation-inference (GitHub repository, archived)

Compare

Four numbers to compare across accelerators

NumberWhat it decidesFigures read 24 October 2026
Memory capacityWhether weights plus cache fitH100 SXM 80 GB; H200 141 GB
Memory bandwidthDecode speedH100 SXM 3.35 TB/s; H200 4.8 TB/s
Low-precision computePrefill and large-batch speedFP8, both shown as sparse: H100 SXM 3,958 teraFLOPS; DGX B200 system 72 PFLOPS for 8 GPUs, about 9 PFLOPS each (72/872 / 8)
InterconnectHow well tensor and expert parallelism scaleH100 and H200 NVLink 900 GB/s

Both compute figures carry the pages’ sparsity footnotes, and the pages say dense is half. The DGX B200 page lists 8 GPUs, 1,440 GB total memory and 64 TB/s aggregate bandwidth for the whole system, so divide by 8 before comparing with a single GPU. The H200 page labels its figures preliminary. Compare numbers on the same basis (dense with dense, one GPU with one GPU), and check price and availability.

Sources5 NVIDIA H100 Tensor Core GPU6 NVIDIA H200 Tensor Core GPU (product page)18 NVIDIA DGX B200 (product page)

Check yourself

Check: which number moved?

Provenance: Generated practice.

A 34B model with 8-bit weights (34 GB) is served on one GPU, once on an H100 (80 GB, 3.35 TB/s) and once on an H200 (141 GB, 4.8 TB/s). With 90 percent usable memory and 4 GB overhead, compute the weights-only floor and the cache budget on each, and say which attribute explains each difference.

Answer

Floor: 34 GB/3.35 TB/s=10.1 ms34\ \text{GB} / 3.35\ \text{TB/s} = 10.1\ \text{ms} on the H100 and 34/4.8=7.1 ms34 / 4.8 = 7.1\ \text{ms} on the H200, a ratio of 1.43, which equals the bandwidth ratio 4.8/3.354.8 / 3.35. Cache budget: H100 0.9×80−34−4=340.9 \times 80 - 34 - 4 = 34 GB; H200 0.9×141−34−4=88.90.9 \times 141 - 34 - 4 = 88.9 GB, set by capacity. Bandwidth explains the faster step; capacity explains the larger cache and therefore more concurrent sequences.

Sources5 NVIDIA H100 Tensor Core GPU6 NVIDIA H200 Tensor Core GPU (product page)

Worked example

Worked: self-hosting cost at real utilization

A GPU rents at 2.50 dollars an hour and produces 2,500 output tokens per second at full load (both invented).

CaseArithmeticDollars per million tokens
Full load2.50/(2,500×3,600)×1,000,0002.50 / (2{,}500 \times 3{,}600) \times 1{,}000{,}0000.28
30 percent utilization2.50/(750×3,600)×1,000,0002.50 / (750 \times 3{,}600) \times 1{,}000{,}0000.93

The hourly bill does not shrink when traffic does, so cost per token scales with 1/utilization1 / \text{utilization}. Add engineering and on-call time, compare quality as well as price, and price the whole layout, not one GPU. A hybrid sends the steady high-volume share to the fleet and spikes to an API.

Check yourself

Check: where is the break-even?

Provenance: Generated practice.

A GPU costs 2.00 dollars an hour and yields 1,800 output tokens per second at full load. A hosted API charges 0.60 dollars per million output tokens (invented for this exercise). At what utilization does self-hosting match the API on token cost alone, and what is missing from that comparison?

Answer

Full-load cost: 2.00/(1,800×3,600)×1,000,000=0.3092.00 / (1{,}800 \times 3{,}600) \times 1{,}000{,}000 = 0.309 dollars per million. Setting 0.309/u=0.600.309 / u = 0.60 gives u=0.514u = 0.514, so below about 51 percent utilization the API is cheaper on tokens. Missing: engineering and on-call time, spare capacity, quality differences, data-residency limits that may rule the API out, and burst handling.

Summary

Recap

  • Use the smallest split that fits and meets the target; scale requests with replicas. Tensor parallelism needs fast links, pipeline parallelism tolerates slower ones but does not shorten a token’s path, expert parallelism is an all-to-all with imbalance risk.
  • Layout arithmetic: cache per token, cache budget, sequences, and the weights-only step floor, then add messages and cache reads.
  • Mixture of experts costs compute by active parameters and memory by total parameters; coverage of experts rises with batch size.
  • One resident base plus small adapters serves many fine-tunes; an adapter is tens of MB, but loading, cache keys and rank settings cost something.
  • Choose engines from criteria and your own traffic, and date every engine and hardware fact.
  • Capacity, bandwidth, compute and interconnect map to fit, decode, prefill and scaling; cost per token depends on utilization.

References

References & Sources (1 of 4)

  1. Parallelism and Scaling (vLLM documentation) (opens in a new tab)

    vLLM project2026Documentation

    Used for Distributed inference probably unnecessary when the model fits on one GPU; tensor parallelism inside a node and combined with pipeline parallelism when the model exceeds a node; InfiniBand for cross-node tensor parallelism; pipeline parallelism for GPUs without NVLink; data-parallel attention with expert or tensor-parallel mixture-of-experts layers. Page dated 15 October 2026.

  2. Megatron-LM: Training Multi-Billion Parameter Language Models Using Model Parallelism (opens in a new tab)

    Mohammad Shoeybi, Mostofa Patwary, Raul Puri, Patrick LeGresley, et al.2019Preprint

    Used for The intra-layer split with one all-reduce each in the attention and feed-forward blocks of the forward pass, four communication operations per layer including the backward pass.

  3. Optimization and Tuning (opens in a new tab)

    vLLM project2026Documentation

    Used for Trade-off notes (each introduced with However) that larger tensor-parallel sizes may cause excessive synchronization overhead and larger pipeline-parallel sizes may cause latency penalties.

  4. The Llama 3 Herd of Models (opens in a new tab)

    Aaron Grattafiori, Abhimanyu Dubey, Abhinav Jauhri, et al.2024Preprint

    Used for Llama 3 405B hyperparameters: 126 layers, model dimension 16,384, 128 attention heads and 8 key/value heads.

  5. NVIDIA H100 Tensor Core GPU (opens in a new tab)

    NVIDIA2026Documentation

    Used for H100 SXM 80 GB memory, 3.35 TB/s bandwidth, 900 GB/s NVLink and FP8 Tensor Core 3,958 teraFLOPS (footnoted as with sparsity), read 24 October 2026.

References

References & Sources (2 of 4)

  1. NVIDIA H200 Tensor Core GPU (product page) (opens in a new tab)

    NVIDIA2026Documentation

    Used for H200 141 GB memory, 4.8 TB/s bandwidth and 900 GB/s NVLink, labelled preliminary, read 24 October 2026.

  2. Mixtral of Experts (opens in a new tab)

    Albert Q. Jiang, Alexandre Sablayrolles, Antoine Roux, Arthur Mensch, et al.2024Preprint

    Used for Eight experts per layer, two chosen per token by a router, 47B parameters available and 13B active.

  3. DeepSeek-V3 Technical Report (opens in a new tab)

    DeepSeek-AI2024Preprint

    Used for 671B total and 37B activated parameters per token.

  4. LoRA: Low-Rank Adaptation of Large Language Models (opens in a new tab)

    Edward J. Hu, Yelong Shen, Phillip Wallis, Zeyuan Allen-Zhu, et al.2022ICLR 2022Paper

    Used for LoRA as low-rank factors added to weight matrices, the basis of the adapter parameter count.

  5. SLoRA: Scalable Serving of Thousands of LoRA Adapters (opens in a new tab)

    Ying Sheng, Shiyi Cao, Dacheng Li, Coleman Hooper, et al.2024MLSys 2024 (Proceedings of Machine Learning and Systems 6)Paper

    Used for Adapters in host memory, running-query adapters fetched to the GPU, a unified paged pool for adapters and KV tensors, up to 4 times the throughput of the compared systems in its experiments.

References

References & Sources (3 of 4)

  1. LoRA Adapters (vLLM documentation) (opens in a new tab)

    vLLM project2026Documentation

    Used for Enabling LoRA, selecting an adapter by name, parallel adapter and base requests, max_loras and max_lora_rank advice, the runtime-loading security warning.

  2. Automatic Prefix Caching (opens in a new tab)

    vLLM project2026Documentation

    Used for LoRA ids as part of the extra values in a prefix-cache block hash.

  3. Efficient Memory Management for Large Language Model Serving with PagedAttention (opens in a new tab)

    Woosuk Kwon, Zhuohan Li, Siyuan Zhuang, Ying Sheng, et al.2023Preprint

    Used for PagedAttention as the KV-memory technique behind vLLM.

  4. SGLang: Efficient Execution of Structured Language Model Programs (opens in a new tab)

    Lianmin Zheng, Liangsheng Yin, Zhiqiang Xie, Chuyue Sun, et al.2023Preprint

    Used for RadixAttention as a KV cache reuse method in SGLang's runtime (preprint abstract).

  5. sgl-project/sglang (GitHub repository) (opens in a new tab)

    SGLang project2026Repository

    Used for README description of SGLang as an inference framework for language, vision-language and diffusion models, and the hardware platforms it lists.

References

References & Sources (4 of 4)

  1. TensorRT LLM overview (documentation) (opens in a new tab)

    NVIDIA2026Documentation

    Used for TensorRT-LLM described for NVIDIA GPUs: in-flight batching, paged KV cache, FP8 and FP4 support, speculative decoding algorithms. Page updated 19 October 2026.

  2. huggingface/text-generation-inference (GitHub repository, archived) (opens in a new tab)

    Hugging Face2026Repository

    Used for Maintenance mode, archived read-only on 21 March 2026, and the recommendation of vLLM and SGLang.

  3. NVIDIA DGX B200 (product page) (opens in a new tab)

    NVIDIA2026Documentation

    Used for DGX B200 system figures (8 GPUs, 1,440 GB, 64 TB/s) and the system FP8 figure of 72 PFLOPS shown as sparse, with dense at half.