From Open Weights to an Inference Service: Self-Hosting LLMs and the AI Infra Beneath

阅读中文版

0. Self-hosting open models

Two or three years ago, the question of whether a company should deploy a large model itself usually circled back to one thing: are open models good enough?

Back then the answer was mostly no. Closed models led in reasoning, code, and long-context work, and open models were more of a "replacement that you can actually get running". To use the best capability, you sent your data to an API provider; to keep your data in your own hands, you accepted a weaker model. Many teams tried local deployment, got a demo working, and ended up back on the API.

Within that trade-off, the need to keep data from leaving never went away. Finance, healthcare, manufacturing, government, and any company that treats source code, design drawings, or customer records as core assets have strong reasons not to hand that content to a third party. But faced with the capability gap, that need often gave way.

0.1 The gap is narrowing

What has changed most in recent years is this capability gap.

Stanford's AI Index 2025 report found that within one year, the gap between open-weight and closed models on some benchmarks shrank from 8% to 1.7%[1]. By AI Index 2026, the report concluded that the performance gap between Chinese and American models has "largely disappeared": the two sides have traded the lead several times since early 2025, and as of March 2026 the top model's lead is only 2.7%[2]. A good share of the leading Chinese models are released with open weights, such as the DeepSeek, Qwen, GLM, and Kimi families.

There is another signal that is easy to overlook: the way open models are released is itself changing. Early open weights were almost all BF16, and the deployer had to do the quantization and bear the accuracy risk. Now more and more models ship directly in low precision. In the config file of DeepSeek-V4-Flash, for example, the MoE expert weights are stored directly as FP4, and the remaining weights use FP8 with scaling per 128×128 block[3]. The model developers considered deployment cost at design time, so the weights you download are already in a form "prepared for inference".

Of course, a gap on a leaderboard and a gap in a specific business scenario need to be looked at separately. For many vertical tasks, the bar for "good enough" was never at the top of the leaderboard. Customer support, internal knowledge Q&A, document extraction, and code completion need models that are stable, controllable, and good enough; a few more points on the hardest benchmark help little. So my judgment is that the model is no longer the main obstacle to self-hosting.

0.2 Once the model is in place, the problem moves to deployment

Once the model is good enough, what remains comes down to how to deploy it. Three things change as a result.

First, data and control go from "something to put up with" to "something you can choose". Handing data to an API used to be a compromise with no alternative. Now the alternative exists, and compliance teams have a real option they can act on. Beyond the data itself, self-hosting brings several kinds of control that an API cannot give: you freeze the model version yourself, so a provider update does not change its output behavior; you can apply LoRA or fine-tuning on your own data; and you can integrate deeply with internal systems and the intranet permission model.

Second, the nature of the cost changes. Calling an API is paid per token, so cost grows linearly with usage; self-hosting is paid per unit of time, and a GPU costs the same per hour whether it is busy or idle. So whether self-hosting pays off depends on how many useful tokens you get out of the same GPU time, that is, utilization and throughput. Neither number is a property of the model; both are properties of the deployment. Section 1 works through this arithmetic.

Third, deployment quality has a large effect on cost. With the same weights, different deployments can differ in unit cost by an order of magnitude. The vLLM paper shows that improving only how the KV cache manages GPU memory raised throughput 2–4x over the leading systems of the time at the same latency level[4]. On top of that you can stack batching strategies, prefix reuse, low-precision compute, parallelism schemes, speculative decoding, and more, each of which affects the final output multiplicatively. Conversely, one wrong parameter can leave an expensive machine idle most of the time.

These capabilities do not come down with the weights. Every combination of model architecture, precision format, and hardware generation needs purpose-written compute kernels and scheduling policies. DeepInfer, the inference framework DeepSeek open-sourced, is one example: it supports one model and two kinds of hardware and integrates a full set of in-house compute libraries, but its README also says that the KV cache system, prefill/decode disaggregation, and load balancing across data-parallel replicas needed for a complete inference service are not included in this release[5]. Even the model's own authors open-sourced only the engine, not the whole serving stack.

0.3 What this article covers

Put simply:

The self-hosting question has shifted from "do we have a good model?" to "can we run the model well?"

This article is mostly about that second question. It starts from cost and works down to hardware:

How to read it. The first five sections focus on measurement and decisions; from Section 6 on, the article goes into compute kernels and hardware. Each section tries to start from a problem a deployer will meet, and when it reaches the underlying principles it comes back to "what this means for deployment". When I explain a concept I try not to tie it to one engine; when I get to how things are actually done, I compare vLLM, SGLang, llama.cpp, and TensorRT-LLM side by side.

About the numbers. The numbers in the text are of two kinds. One kind is theoretical values computed by hand from public hardware specifications, marked as "estimates". The other kind is cited from public papers, official blogs, or benchmarks, with sources noted. Theoretical values show orders of magnitude and trends; the performance of a real deployment has to be confirmed by load testing, and Section 8 gives a method for it.

1. The cost of inference

1.1 Two shapes of cost

A large model's life involves roughly three expenses: pre-training, post-training, and inference.

The first two are project-style investments. Pre-training often means thousands of cards running for months. Post-training (SFT, RLHF, and various forms of alignment and domain adaptation) is much smaller, but it is also episodic: once a version is trained, the money is spent until the next version.

Inference is an operating-style expense. Every call costs money, more business means more spend, and it runs 24/7. A model is trained once but called many billions of times.

For most companies in vertical domains, pre-training is not something they will do themselves, and post-training is at most LoRA or small-scale fine-tuning on an open model. The bill that is long-lived, continuous, and grows with the business is inference. That bill keeps getting thicker: an agent application goes back and forth with the model for many rounds per task, each round carrying an ever longer context, so one user request can consume dozens of times the tokens of traditional Q&A.

1.2 Measuring an inference service

Before discussing cost, let us settle on metrics. From the moment a request is sent to the moment it finishes, the time a user perceives falls roughly into two parts: waiting for the first word to appear, then watching the rest appear one by one.

Metric Meaning When it matters most
TTFT (Time To First Token) Time from sending the request to receiving the first token Interactive chat; determines whether it feels responsive
TPOT (Time Per Output Token) Average time per output token after the first one Streaming output; determines "typing speed", which must be at least faster than a person reads
ITL (Inter-Token Latency) The gap between two adjacent output tokens; look at the distribution, not the mean Stutter. If average TPOT meets the target but there are occasional half-second pauses, the experience is just as bad
E2E latency Total time of the whole request, roughly TTFT + TPOT × (output length − 1) Non-streaming calls, each round of an agent
Throughput Tokens the system processes per second, usually counted separately for input and output Batch and offline jobs; determines how much work one machine can do
goodput Throughput while meeting the latency targets (SLO) The real capacity of an online service
$/Mtok Cost per million tokens Comparing with API prices, budgeting
Timeline of a streaming request
Figure 1-1: Timeline of a streaming request. Timeline of a streaming request. TTFT includes queueing and the time to process the input; the gap between each subsequent token is the ITL, and their mean is TPOT.

A few notes:

1.3 One formula

The unit cost of self-hosting can be written as:

Cost per million tokens = P ÷ (TSLO × U × 3600) × 106

The formula gives three levers, and almost every later section hangs off one of them:

Lever How to pull it Main sections
Lower P Pick the right hardware generation and model; use lower precision so the same model occupies fewer cards; consider non-NVIDIA hardware Sections 6, 7
Raise TSLO Batching and scheduling, KV cache management, quantization, faster compute kernels, parallelism strategy, speculative decoding; plus measures such as PD disaggregation that make more of the throughput "count" Sections 2–4, 6
Raise U Smoothing peaks and valleys, sharing resources across models, scaling with load, moving offline jobs into off-peak hours Sections 4, 8

Of the three levers, only P is mainly a purchasing decision; TSLO and U come down to engineering capability. For the same hardware budget, the final unit cost depends largely on the latter two.

1.4 A worked example

Let us run the formula with a set of hypothetical numbers. They only illustrate orders of magnitude and relationships, and do not represent any specific model, hardware, or quote.

Suppose an 8-card server at $2.5 per card per hour, so P = $20/hour. Suppose that after reasonable tuning, under the target SLO, this machine can stably produce TSLO = 10,000 tokens/second. At full load it produces 36 million tokens per hour.

Utilization U Effective tokens per hour Cost per million tokens
100% 36 million $0.56
60% 21.6 million $0.93
30% 10.8 million $1.85
10% 3.6 million $5.56

On the same machine, dropping utilization from 60% to 10% raises the unit cost 6x.

Unit cost vs. utilization
Figure 1-2: Unit cost vs. utilization. Unit cost as a function of utilization (illustrative numbers). The two curves correspond to throughputs of 10,000 and 20,000 tokens/second; the horizontal dashed lines are two assumed API prices, and the intersection of a curve with a dashed line is the break-even utilization.

Now the break-even. Let the API price be pAPI dollars per million tokens. Self-hosting is cheaper when:

U > P × 106 ÷ (TSLO × 3600 × pAPI) = 0.56 ÷ pAPI

If pAPI = $2, self-hosting pays off above 28% utilization; if pAPI = $1, you need more than 56%; if pAPI is only $0.5, this configuration can never catch up.

Now suppose tuning doubles TSLO to 20,000 tokens/second. The break-even utilization threshold is halved: at pAPI = $1, it drops from 56% to 28%. The most direct effect of inference optimization is this: it lowers the business volume at which self-hosting starts to pay off.

This calculation has several simplifications that need to be added back in a real estimate:

1.5 Why throughput and latency are in tension

Take the generation phase (decode) as an example. At each step, the engine generates one token for each request in the current batch, and the time for a step is approximately:

tstep(b) ≈ max(tmovement, b · tcompute/token) + tfixed overhead

Here b is the number of requests in the batch. tmovement is mainly the time to read the model weights once from GPU memory; Section 2 explains why they must be read once at every step.

This gives a typical curve: as concurrency rises, throughput first climbs steeply and then flattens, while TPOT first stays flat and then curves upward. Goodput is the highest throughput you can take from this curve under the constraint that neither TPOT nor TTFT exceeds the SLO. Section 2 works this curve out with a concrete model, and will show that the assumption "movement time is independent of b" does not hold at long context.

There is one more source of interference: when a new request arrives, its input must be processed first (prefill), which is very compute-heavy. If it is executed in the same step as the requests already generating, the latter's ITL suddenly stretches. Chunked prefill and PD disaggregation in Section 4 are meant to solve this problem.

The next question is what actually limits TSLO. To answer it, we first need to see what a request goes through inside the engine.

2. The life of a request

2.1 From sending a request to receiving a reply

A user types a sentence into a chat box and presses Enter. Inside the inference service, that sentence passes through roughly six stops.

  1. Receive: The HTTP server receives the request, parses its parameters (model, maximum output length, temperature, whether to stream, and so on), and applies the chat template.
  2. Tokenize: Split the text into token IDs. This is pure CPU work, and long text can take tens of milliseconds.
  3. Queue and schedule: The request enters a waiting queue. At every step, the scheduler decides which requests can enter the current batch, provided there is room in GPU memory for the request's KV cache.
  4. Prefill: Feed the whole input into the model in one pass, compute the Key and Value of every layer and store them in the KV cache, and obtain the probability distribution for the first output token.
  5. Decode loop: At each step, generate one new token for every request in the batch, append its K and V to the KV cache, and use the new token as the input for the next step. This continues until an end token, the length limit, or a stop word is reached.
  6. Detokenize and stream back: Turn token IDs back into text and push it to the client piece by piece.

Several metrics from Section 1 map onto this pipeline: TTFT covers steps 1–4, and TPOT and ITL describe the rhythm of steps 5–6.

Request lifecycle and the process split of four engines
Figure 2-1: Request lifecycle and the process split of four engines. The top shows the stages a request passes through; the bottom shows which stages each of the four engines puts in the same process.

2.2 How the four engines divide the pipeline

The pipeline is the same in every engine; what differs is who does which segment.

Engine Frontend (HTTP, tokenize) Scheduling Model execution Detokenize
vLLM (V1) API server process EngineCore process, a busy loop responsible for scheduling and KV cache management; one per data-parallel replica One worker process per GPU API server process
SGLang HTTP server and TokenizerManager in the main process Scheduler subprocess, one per GPU; scheduling and forward computation in the same process Same Scheduler process Separate DetokenizerManager subprocess
llama.cpp (llama-server) HTTP threads A single main loop that assembles all active slots into one batch Same process, calling llama_decode Same process
TensorRT-LLM (trtllm-serve) OpenAI-compatible frontend and LLM API One PyExecutor worker process per rank; a background loop takes requests, schedules, allocates KV, runs forward, and samples, in that order Same PyExecutor Frontend

(The vLLM and TensorRT-LLM structures are taken from their official architecture documents[7][8].)

All three Python engines split their CPU-heavy work into separate processes, for a practical reason. Python has a global interpreter lock (GIL), so within one process only one thread can execute Python code at a time. If tokenizing a long text, assembling HTTP responses, and making scheduling decisions all crowd into the same process, the GPU idles while waiting for the CPU to issue the next batch of work. Splitting them apart lets the model-execution process concentrate on feeding the GPU. llama.cpp is written in C++ and has no such burden, so threads are enough.

This idea of "don't make the GPU wait for the CPU" will come back repeatedly: overlap scheduling and CUDA Graph in Section 4, and DeepEP letting the GPU initiate communication itself in Section 6, all start from the same idea.

2.3 Prefill and decode: one model, two workloads

The steps that actually spend GPU time in the pipeline are 4 and 5. They run the same model with the same weights, but the workload is quite different.

Prefill processes the whole input at once. For a 4,000-token prompt, all 4,000 tokens pass through each layer together. On the left of each matrix multiplication is a large matrix of 4,000 rows, so the weights are read from GPU memory once and reused by 4,000 tokens.

Decode generates only one token per request at a time, but for that single token, the entire model's weights must be read in full from GPU memory; and in the attention step, the K and V of all of that request's historical tokens must be read as well. The data read in is used to compute a single row and then thrown away.

The bottlenecks differ accordingly: prefill is limited by compute and decode by memory bandwidth. Section 2.5 works through the numbers.

The engines handle the two phases in different ways:

The engines share one aim: to pair the "compute-bound prefill" with the "bandwidth-bound decode" so that the hardware is never idle at either end.

2.4 Three hardware resources

A GPU offers three kinds of resources:

Resource Measure Example: H100 SXM[10] Symptom when insufficient
Compute Floating-point operations per second About 989 TFLOPS dense BF16 The compute units are always full, and adding data will not make it faster
GPU memory Capacity (how much fits) and bandwidth (how much can be moved per second) 80 GB, 3.35 TB/s If capacity is short, the model does not fit and must be split across cards; if bandwidth is short, the compute units wait for data
Interconnect Bandwidth between cards and between machines Intra-node NVLink 450 GB/s per direction; across nodes it depends on the NIC One card has finished computing and is waiting for another card to deliver data

A computing task on a GPU involves three things: computing, moving data from GPU memory, and exchanging data with other cards. Each has a theoretical minimum time:

tcompute = operations ÷ peak computetmemory = bytes moved ÷ memory bandwidthtcomm = bytes transferred ÷ interconnect bandwidth

These three can overlap: while one block is being computed, the next block of data can already be on its way. So for a well-designed computing task, the actual time is close to the longest of the three. Whichever is longest is where the bottleneck is. Here we look at a single card, so only the first two apply; interconnect is left for Sections 4 and 6.

2.5 By hand: Qwen3-32B on one H100

Let us run the formulas above on a concrete model. We pick Qwen3-32B because it is a dense model, which makes the arithmetic cleanest: 64 layers, hidden size 5120, 64 Query heads and 8 KV heads, 128 dimensions per head, and about 32.8 billion parameters in total[11]. For hardware we use one H100 SXM at BF16 precision.

The numbers below are all theoretical estimates: they assume compute and data movement overlap perfectly and run at peak. What is actually achieved is usually a fraction of peak, with the fraction depending on the quality of the compute kernel implementation (Section 6). But the relationships between orders of magnitude do not change.

Decode, a single request. To generate each token, all weights except the vocabulary embedding must be read once: about 32 billion parameters, roughly 64 GB at BF16.

Movement time is about 300 times compute time. During this step, the tensor cores spend more than 99% of the time waiting for data. A single user can get at best about 1000 ÷ 19.1 ≈ 52 tokens/second, and this ceiling has almost nothing to do with the GPU's compute and depends only on memory bandwidth.

Prefill, a 4,096-token input. The weights are still read just once, 19.1 ms; but the compute is that of the linear layers over 4,096 tokens plus attention, about 280 trillion operations in total.

This time it is reversed: compute is about 15 times movement. Even if the GPU is completely idle, the TTFT for this input cannot theoretically go below about 0.28 seconds.

Same model, same weights, same card: change the phase, and the bottleneck jumps from memory bandwidth to compute.

2.6 Roofline: a ruler for finding the bottleneck

Abstracting the reasoning above gives the roofline model.

Define arithmetic intensity: how many operations can be done per byte moved from GPU memory.

I = operations ÷ bytes moved (FLOP/byte)

The performance a computing task can reach is bounded above by:

attainable compute = min(peak compute, I × memory bandwidth)

The boundary between the two segments is called the ridge point, equal to peak compute ÷ memory bandwidth. The H100's ridge point is 989 ÷ 3.35 ≈ 295 FLOP/byte: below an arithmetic intensity of 295, performance is limited by bandwidth; above 295, by compute.

The arithmetic intensity of a linear layer is easy to derive. Suppose a batch has b tokens and the weight matrix is k × n, with 2 bytes per number in BF16:

I ≈ 2bkn ÷ 2kn = b

So at BF16, the arithmetic intensity of a linear layer is approximately the number of tokens computed together in that step. For a single decode request, b = 1 and the intensity is about 1, nearly 300 times below the ridge point; for a 4,096-token prefill, the intensity is about 4,000, far to the right of the ridge point.

The H100 roofline and several typical operating points
Figure 2-2: The H100 roofline and several typical operating points. The roofline of the H100 SXM at BF16 (log-log axes). The sloped segment is limited by memory bandwidth, and the horizontal segment by compute. The dots are several operating points of Qwen3-32B: in decode, as the batch grows from 1 to 256, the operating point climbs to the right along the slope; prefill is on the horizontal segment from the start.

Ridge points differ considerably between GPUs:

GPU Dense BF16 compute Memory bandwidth Ridge point (FLOP/byte)
A100 SXM 80GB 312 TFLOPS 2.04 TB/s 153
H100 SXM 989 TFLOPS 3.35 TB/s 295
H200 SXM 989 TFLOPS 4.8 TB/s 206
B200 2,250 TFLOPS 8.0 TB/s 281
L40S 362 TFLOPS 0.86 TB/s 419
RTX 4090 165 TFLOPS (FP32 accumulate) 1.01 TB/s 164

(Data are from each model's official spec sheet, all dense, non-sparse peaks.)

Two points from the table:

2.7 Batching: the lifeline of decode

Since the arithmetic intensity of decode is approximately the number of tokens in the batch, the way to raise it is direct: have more requests decode together. The weights are read once and serve b requests at the same time.

Back to Qwen3-32B and the H100. Looking only at weights, growing the batch from 1 to 64 still reads the same 64 GB per step, so 19.1 ms is unchanged, while throughput rises from 52 to about 3,350 tokens/second, a 64x increase. That is the "free" range described in Section 1.

But we left something out earlier: the KV cache must be read too. For every token each request generates, attention must read all of its historical K and V. Qwen3-32B's KV is 256 KB per token (worked out in detail in the next section), so a request with a 2,048-token context is 512 MB. For 64 such requests, each step must read an extra 34 GB.

Batch b Context Bytes moved per step Time per step (≈ TPOT) Throughput
1 2,048 64.5 GB 19.3 ms 52 tokens/s
64 weights only 64.0 GB 19.1 ms 3,352 tokens/s
64 2,048 98.3 GB 29.4 ms 2,180 tokens/s
64 8,192 201 GB 60.1 ms 1,065 tokens/s
256 2,048 201 GB 60.1 ms 4,258 tokens/s

(Theoretical estimates; whether the GPU memory capacity can hold this is not considered.)

Decode throughput and time per step as a function of batch size
Figure 2-3: Decode throughput and time per step as a function of batch size. Theoretical decode throughput (top) and time per step (bottom) of Qwen3-32B on one H100. The three lines correspond to different average context lengths, and the gray dashed line is the weights-only case that ignores KV. The longer the context, the smaller the throughput gain from a larger batch, and the faster each user's TPOT rises.

Three things stand out in the figure:

  1. Batching is still the most effective lever for decode. On every line, throughput rises as the batch grows.
  2. But the longer the context, the less "free" batching is. The amount of KV read grows linearly with both batch size and context length, and quickly becomes as large as the weights. At 8,192 context and 64 requests, the KV is already more than twice the weights, and TPOT is 3 times that of a single request. The approximation in Section 1 that "movement time is independent of batch size" holds only at short context.
  3. The attention step is itself bandwidth-bound. A linear layer can amortize the weight movement through batching, but attention cannot: each request's KV belongs only to that request, and there is nothing to share (unless several requests share a prefix, Section 4). So at long context, the decode bottleneck gradually shifts from "reading weights" to "reading KV".

The table also points to a more practical problem: 64 requests at 2,048 context need 34 GB for KV alone, while Qwen3-32B's BF16 weights already take 65.5 GB, so an 80 GB H100 cannot hold them. How large a batch can be opened must first pass the GPU memory capacity check.

The next section works out that accounting.

3. The memory ledger

The previous section showed that decode needs a large batch to make use of the hardware, and how large a batch can be opened depends on how many requests' KV cache still fit in GPU memory. This section works out the memory ledger.

3.1 Where the GPU memory goes

After an inference service starts, a GPU's memory is roughly divided into these parts:

Part Contents Size depends on
Model weights All parameters Parameter count × bytes per parameter; fixed after startup
KV cache pool The Keys and Values of all running requests Reserved once when the engine starts; the larger the pool, the more requests can be served at the same time
Activations and scratch space Intermediate results of the forward pass, workspaces for attention and matrix multiplication Tokens processed per step; largest when prefilling a long input
CUDA Graph buffers Fixed buffers needed by pre-recorded compute graphs (Section 4) How many batch sizes were recorded
Runtime overhead CUDA context, communication library buffers, memory fragmentation Driver, library versions, and whether multiple cards are used

Weights and the KV pool are the "static" bulk, determined at startup; activations are "dynamic" and fluctuate with each step's load. Inference engines largely work the same way: load the weights first, measure the activation peak with a trial run, and give almost all the remaining memory to the KV pool. So every 1 GB saved on weights is 1 GB more for the KV pool, and a few more requests can be served at the same time.

3.2 Weights: parameter count × bytes per parameter

The size of the weights is the easiest to calculate:

Mweights = parameter count × bytes per parameter

BF16 uses 2 bytes per parameter and FP8 uses 1 byte. 4-bit quantization uses 0.5 bytes per parameter, but usually every 32 or 128 parameters need an extra scale factor, which averages out to about 4.25–4.5 bits (covered in detail in Section 6).

Model Total parameters BF16 FP8 About 4-bit (counted as 4.25 bits)
Qwen3-32B (dense) 32.8 billion 66 GB 33 GB 17 GB
Qwen3-235B-A22B (MoE) 235 billion 470 GB 235 GB 125 GB
DeepSeek-V3 (MoE) 671 billion 1,342 GB 671 GB 356 GB

The table shows directly how many cards are needed at minimum:

An MoE model needs little compute per token, but its capacity cannot be saved. Qwen3-235B-A22B activates only 22 billion parameters per token, and DeepSeek-V3 only 37 billion, but all experts must stay resident in GPU memory, because which experts the next token will select is not known in advance. Moreover, in large-batch decode, dozens or hundreds of tokens each choose their own experts, and together they hit almost every expert, so each step still reads most of the expert weights. MoE saves bandwidth at small batches and mainly saves compute at large batches.

3.3 KV cache: each token's "memory"

As mentioned in Section 2, every time decode generates a token, attention looks back at the Keys and Values of all historical tokens. To avoid recomputing them at every step, the engine stores them, and this is the KV cache.

For standard multi-head attention, each token stores one K and one V at every layer, and the size of each is the number of KV heads × the dimension per head. The KV size per token is therefore:

KV per token = 2 × L × HKV × dhead × bytes per element

Here L is the number of layers, and 2 stands for one copy each of K and V.

Take Qwen3-32B: 2 × 64 layers × 8 KV heads × 128 dimensions × 2 bytes = 262,144 bytes, that is, 256 KB per token. A 2,048-token request is 512 MB, and a 32K-token request is 8 GB.

Several architectural techniques compress this number.

GQA (grouped-query attention). Lets several Query heads share one set of K and V. Qwen3-32B has 64 Query heads but only 8 KV heads, with every 8 Query heads sharing one set. With traditional multi-head attention without sharing, KV per token would be 2 MB, and GQA compresses it to 1/8. Today's mainstream dense models almost all use GQA.

MLA (multi-head latent attention). The approach DeepSeek uses in V2 and V3: instead of storing K and V directly, store a compressed low-dimensional "latent vector" and reconstruct them when needed. DeepSeek-V3 stores only a 512-dimension latent vector plus a 64-dimension positional-encoding part per layer[12], about 68.6 KB per token at BF16. For comparison, if it used multi-head attention without sharing (128 heads, 192 dimensions per head for K and 128 per head for V), each token would need about 4.8 MB, so MLA compresses it by about 70x. The cost is that the attention computation is more complex and needs dedicated compute kernels (Section 6).

Model Attention type KV per token (BF16)
Qwen3-32B GQA, 64 Q / 8 KV heads 256 KB
Qwen3-235B-A22B GQA, 64 Q / 4 KV heads, 94 layers 188 KB
DeepSeek-V3 MLA, 512 + 64 dimensions 68.6 KB

Compare the two: DeepSeek-V3 has 20 times the parameters of Qwen3-32B, yet its KV per token is only about 1/4 of the latter's. The size of KV is determined by the attention design and has no direct relationship with the model's total parameter count.

KV quantization. Storing KV in FP8 instead of BF16 halves it directly. This is a purely deployment-side choice that does not require changing the model, and all four engines support it (parameters in Section 3.6). The cost is some accuracy loss, whose magnitude varies by model and task, so validate it on your own evaluation set before going live.

Some architectures let certain layers avoid keeping the full history, such as sliding-window attention, or mixing linear-attention layers with standard attention layers. Their KV is computed in different ways, and when you use them you need to work it out separately from the specific structure.

3.4 How many users one card can serve at once

Now the ledger can be completed. Still Qwen3-32B and an H100 (80 GB), comparing three configurations under two assumptions:

The memory ledger under three configurations
Figure 3-1: The memory ledger under three configurations. Three ways to deploy Qwen3-32B on H100s. With BF16 on a single card, the weights take up most of the GPU memory and the KV pool is left with only about 1.5 GB; switching to FP8 weights, or using two cards with tensor parallelism, can expand the KV pool to about 34 GB (34 GB per card in the two-card case).

The total number of tokens the KV pool can hold, divided by each request's average context length, is the number of requests that can theoretically be served at the same time:

Configuration Cards KV pool Tokens held Concurrency (average context 2K) 8K 32K
A: BF16 weights, single card 1 1.5 GB about 5,600 2 0 0
B: FP8 weights, single card 1 34 GB about 130,000 63 15 3
B′: FP8 weights + FP8 KV, single card 1 34 GB about 260,000 127 31 7
C: BF16 weights, two cards with tensor parallelism 2 34 GB per card about 260,000 127 31 7

(Theoretical estimates.)

A few points from the table:

This is one concrete trade-off between P and TSLO in the cost formula of Section 1.

3.5 Long context: KV overtakes the weights

In the table above, as the average context grows from 2K to 32K, concurrency drops by 16x.

For Qwen3-32B, a 32K-token request has 8 GB of KV. 8 such requests come to 64 GB, as large as the whole model's BF16 weights. In long-context scenarios such as retrieval-augmented generation, long-document analysis, code repository Q&A, and multi-turn agents, how many users a machine can serve is often decided by KV, with the weights second.

So long-context scenarios are especially sensitive to a few kinds of optimization: attention structure (GQA, MLA), KV quantization, sharing the KV of the same prefix across requests (prefix caching), and moving KV that is not currently needed to CPU memory or SSD (tiered KV cache). The last two are covered in Section 4.

3.6 Memory parameters in the engines

The four engines control memory in different ways, and parameters with similar names do not mean exactly the same thing.

Purpose vLLM SGLang llama.cpp TensorRT-LLM
Memory budget --gpu-memory-utilization: the fraction of total GPU memory this instance may use, including weights, activations, and KV; default 0.92 --mem-fraction-static: the fraction of total GPU memory taken by weights plus the KV pool, excluding activations; computed automatically from GPU memory if not set No fraction parameter; --fit (on by default) automatically adjusts -c and -ngl if they are not set manually, so the model fits in memory kv_cache_config.free_gpu_memory_fraction: the fraction of the memory remaining after weights are loaded that goes to KV; default 0.9
Maximum context --max-model-len --context-length -c / --ctx-size max_seq_len
Maximum concurrency --max-num-seqs --max-running-requests -np / --parallel (number of slots, auto by default) max_batch_size
Tokens per step limit --max-num-batched-tokens --chunked-prefill-size -b / -ub max_num_tokens
KV precision --kv-cache-dtype fp8 --kv-cache-dtype fp8_e4m3 and others; FP4 is also supported -ctk / -ctv, such as q8_0 (quantizing V requires flash attention to be enabled) kv_cache_config.dtype: fp8
Weight placement All on GPU by default All on GPU by default -ngl sets how many layers go on the GPU, with the rest left on the CPU; -ot can place by tensor, for example putting only the MoE experts on the CPU All on GPU by default

(Parameter names follow each engine's documentation as of October 2026[14].)

A few easy traps:

3.7 Where OOM happens

Out of memory (OOM) is the most common error in deployment. When troubleshooting, first identify which stage it occurs in, because different stages correspond to different parameters.

Stage Typical cause What to adjust first
While loading weights The weights alone do not fit Switch to lower-precision weights, add cards for tensor parallelism, or switch to cards with more GPU memory
While allocating the KV pool The KV pool cannot hold even one request of maximum length (vLLM reports an error directly) Lower the maximum context, or raise the memory budget, or quantize KV
While recording CUDA Graphs Too many or too large batch sizes recorded Reduce the recorded batch sizes (such as SGLang's --cuda-graph-max-bs), or first turn off CUDA Graph (vLLM's --enforce-eager, SGLang's --disable-cuda-graph) to confirm the problem
At runtime, handling long inputs Prefill processes too many tokens at once and the activation peak is too high Lower the per-step token limit so that long inputs are split into smaller chunks
At runtime, during generation Concurrency is too high Lower the maximum concurrency, or lower the memory budget to leave more headroom for activations

The suggested order of adjustment is to change first the parameters that do not affect model quality (chunk size, CUDA Graph, maximum concurrency), then the capacity parameters (maximum context, memory budget), then precision (KV quantization, weight quantization), and to add cards last. The further down the list, the greater the impact on quality or cost.

The first three sections covered how to compute cost (Section 1), how a request moves through the engine and which resource is the bottleneck (Section 2), and how GPU memory is allocated and how much concurrency it can support (Section 3). Next we look at what an inference engine actually does to get more tokens out of the same hardware.

4. Optimization techniques in inference engines

The first three sections gave us a set of measures: P, TSLO and U in the cost formula, the three hardware resources, and the memory ledger. This section uses them to look at what inference engines actually do.

Inference engines have many optimizations with a wide variety of names, but almost every one can be asked the same two questions: which resource bottleneck does it relieve, and which lever in the cost formula does it pull? The table below lists them against those two questions:

Layer Technique Mainly relieves Mainly moves
Scheduling Continuous batching Memory bandwidth (larger decode batches) TSLO
Scheduling Chunked prefill Interference of prefill on decode TSLO (tail latency)
Scheduling Prefix caching Compute (skips repeated prefill) TSLO, TTFT
Scheduling PD disaggregation Mutual interference between prefill and decode TSLO, U
Scheduling Cache-aware routing Repeated computation across replicas TSLO, U
Scheduling CPU/GPU overlap CPU scheduling overhead TSLO
Memory Paged KV (PagedAttention) Memory capacity (fragmentation) TSLO
Memory Weight-only quantization Memory capacity and bandwidth P, TSLO
Memory KV cache quantization Memory capacity and bandwidth TSLO
Memory Hierarchical KV cache Memory capacity TSLO, TTFT
Compute Attention backend Memory bandwidth, compute TSLO
Compute CUDA Graph and kernel fusion CPU launch overhead, memory round trips TSLO
Compute Speculative decoding Idle compute during decode Single-user speed
Parallelism TP / PP / DP / EP Capacity, bandwidth, interconnect P, TSLO

The rest of this section goes through them layer by layer, covering what problem each one solves, what it costs, and how the four engines handle it. The internals of compute kernels are left to Section 6.

4.1 Scheduling: deciding what to compute at each step

Continuous batching

The simplest form of batching is static batching: collect a batch of requests, start them together, wait until the longest one in the batch finishes generating, and then end the whole batch together. The problem is that requests that finish early sit in their slots doing nothing, and newly arrived requests cannot enter until the whole batch is done. The number of useful requests in the batch keeps shrinking, and the batching curve from Section 2 falls back down for nothing.

Continuous batching refines the scheduling granularity from "a batch of requests" to "a step": after every generated token, the scheduler decides again who is in the batch for that step. When a request finishes, its slot and its KV are released immediately. When a new request arrives, it can be added at the next step. The idea was first proposed in the Orca system, under the name iteration-level scheduling[15].

Static batching and continuous batching
Figure 4-1: Static batching and continuous batching. In static batching (top), requests that finish early leave empty slots, and new requests wait for the whole batch to end. Continuous batching (bottom) reclaims empty slots and fills in new requests at every step, so the batch on the GPU stays full.

It is now standard in every mainstream engine: vLLM and SGLang call it continuous batching, TensorRT-LLM calls it in-flight batching, and the llama.cpp server enables --cont-batching by default and serves requests in parallel across the number of slots set by -np. Engines differ in how they pick who runs at each step, which is what the next few items are about.

Chunked prefill

Continuous batching creates a new problem: when a new request arrives, it must be prefilled first. For a long input of 8K tokens, prefill can take several hundred milliseconds (Section 2). If it shares a step with dozens of requests that are decoding, that step is stretched out, and every user who is generating at the time feels a noticeable stall. This is the ITL spike in Figure 1-1.

Chunked prefill splits a long input into fixed-size chunks and processes only one chunk per step, leaving the rest of the budget for decode requests. The Sarathi-Serve paper calls this approach "stall-free scheduling"[16]: decode requests advance at every step, and prefill is completed over several steps.

The cost is a tradeoff. The smaller the chunk, the smoother the decode ITL, but the longer the TTFT of a long input, and each chunk adds some overhead. A larger chunk does the opposite. This per-step token budget is one of the most important tuning parameters for online serving, and each engine exposes it differently:

Engine Parameter Notes
vLLM --max-num-batched-tokens Chunked prefill is on by default in V1; each step schedules decode first, gives the remaining budget to prefill, and splits any excess into chunks automatically
SGLang --chunked-prefill-size Maximum tokens per chunk; if a long-input prefill hits OOM, lower this first
TensorRT-LLM enable_chunked_prefill, max_num_tokens Turns on chunking and caps the total number of tokens per step
llama.cpp -ub / --ubatch-size Physical batch size, the maximum number of tokens sent into computation at once; default 512

Prefix caching

Many requests start the same way: the same system prompt, the same set of tool definitions, the same few-shot examples, and, in multi-turn conversations, the history of all earlier turns. Every new request would prefill these identical prefixes again and produce exactly the same KV.

Prefix caching keeps KV that has already been computed in memory. If a new request shares a prefix with an earlier one, it reuses that part of the KV directly and prefills only the part that differs. For agents with long system prompts, multi-turn conversations, and batch processing of the same document, it can cut TTFT and prefill compute substantially.

There are two mainstream implementations, with different data structures.

Two data structures for prefix caching
Figure 4-2: Two data structures for prefix caching. Three requests share the same system prompt. On the left, block hashing: the hash of each block depends on all the blocks before it. On the right, a radix tree: the shared prefix is a common path, and the branches are independent after the fork.

The corresponding feature in TensorRT-LLM is called KV cache block reuse (enable_block_reuse, on by default). It organizes full blocks in a radix search tree and evicts them with a priority-aware LRU. llama.cpp works more at the single-machine level: each slot reuses the prefix it shares with its previous prompt, and --cache-ram can additionally keep a slot's cache in host memory so later requests can retrieve it.

Prefix caching places a direct requirement on how prompts are written: put stable content first and changing content last. The cache only recognizes a prefix that is identical token for token from the very beginning. If the current time is inserted in the first line of the system prompt, nothing after it can be reused. Many API providers charge less for cache-hit input because that part does not need to be recomputed.

PD disaggregation

Chunked prefill eases the interference between prefill and decode but does not remove it: they still compete for resources on the same GPUs, in the same scheduling loop. Section 2 explained that their bottlenecks differ: prefill needs compute, while decode needs bandwidth and memory capacity. Put together, neither side gets an optimal configuration.

PD disaggregation (prefill/decode disaggregation) splits the two onto different groups of GPUs: prefill nodes only prefill, and after finishing they pass the KV cache to decode nodes, which only generate. DistServe[6] and Splitwise[19] are the earliest systems papers in this direction, and both Kimi's Mooncake[20] and DeepSeek's inference system[21] have used this architecture at scale in production.

PD disaggregation architecture
Figure 4-3: PD disaggregation architecture. The routing layer sends a new request to a prefill node. The KV produced by prefill travels over a high-speed network to a decode node, and all later generation happens on the decode node. The two groups of nodes can use different parallelism schemes and batch sizes, and can be scaled independently.

There are three benefits:

  1. Interference is eliminated. Decode nodes no longer stall because of long-input prefill, and ITL is smoother.
  2. Each side is tuned separately. Prefill nodes can use the parallelism scheme and batch size that suit compute-bound work, while decode nodes can reserve all their memory for KV and run the largest possible batches.
  3. Resources are allocated in proportion to load. Workloads with long inputs and short outputs (such as document summarization) get more prefill nodes; workloads with short inputs and long outputs (such as long-form generation) get more decode nodes.

The main cost is KV transfer. Take Qwen3-32B: for an input of 4,096 tokens, the KV is 1.07 GB. Over a 400 Gb/s NIC (about 50 GB/s), the transfer takes about 21 ms. Compared with the prefill time (about 283 ms in theory) this is not large, but it is not zero. For a model that uses MLA, such as DeepSeek-V3, the KV at the same length is only about 288 MB, and the transfer takes about 6 ms. The smaller a model's KV, the better it suits PD disaggregation. The transfer also needs an RDMA network (InfiniBand or RoCE) and GPUDirect RDMA (Section 6), because the latency and bandwidth of an ordinary TCP network are not enough.

It is also more complex to operate: two types of nodes, a routing layer, and a KV transfer mechanism, and a problem in any one of them affects the whole. For deployments with only one or two machines, PD disaggregation usually does not pay off; its benefits become clear at a scale of several dozen cards or more.

Engine PD disaggregation support
vLLM Connects to transfer backends such as NIXL, Mooncake and LMCache through the KV connector; the official documentation still marks it as experimental, and production deployments usually rely on frameworks such as llm-d and NVIDIA Dynamo
SGLang Native support: --disaggregation-mode prefill / decode; the transfer backend defaults to Mooncake, with NIXL and others as options; the SGLang Model Gateway routes to the two types of nodes separately
TensorRT-LLM trtllm-serve disaggregated orchestrates context and generation workers, with KV transferred through NIXL (Beta); NVIDIA Dynamo can also orchestrate it
llama.cpp Not supported; it is designed for a single machine

Cache-aware routing

When a service has multiple replicas, which replica a request goes to also affects efficiency. With random dispatch, a user's multi-turn conversation or an agent's consecutive calls land on different replicas, each replica has to recompute the prefix, and the prefix cache hit rate drops sharply.

Cache-aware routing has the routing layer remember which prefixes are cached on each replica and send a new request first to the replica with the longest prefix hit, while still balancing load so that not all requests pile onto one replica. SGLang's routing layer (Model Gateway), llm-d and NVIDIA Dynamo all provide strategies of this kind. A single engine instance cannot handle this, so it needs components outside the engine (Section 5), which makes it the first dividing line between the "inference engine" and "inference serving".

CPU and GPU overlap scheduling

Section 2 mentioned that scheduling decisions, input preparation and output processing are all CPU work. If the CPU waits for the GPU to finish every step before it starts preparing the next one, the GPU sits idle during that time. The smaller the model and the faster the GPU, the larger the share of this idle time.

Overlap scheduling lets the CPU prepare the batch for step n+1 while the GPU computes step n, so the GPU can continue as soon as it finishes. SGLang's overlap scheduler is on by default, vLLM V1 offers asynchronous scheduling, and TensorRT-LLM's PyExecutor also has an overlap scheduler.

4.2 Memory: managing KV well

Paged KV: PagedAttention

Early inference systems reserved a contiguous region of memory for each request's KV, sized for the maximum length. But how many tokens a request will end up generating is not known in advance: reserve too much and memory is wasted, too little and it runs out. On top of that, requests have very uneven lengths, so memory is full of gaps that cannot be used. The vLLM paper measured that in the systems of the time only 20%–40% of KV memory actually held token state[22].

PagedAttention borrows from operating system virtual memory: KV is cut into fixed-size blocks (for example, 16 tokens per block), and each request has a "block table" recording which physical blocks its logical blocks map to. Physical blocks do not need to be contiguous and are allocated when needed. Waste occurs only in the last block of each request.

It also has two useful side effects:

All mainstream engines today use paged or similar fine-grained KV management: vLLM manages by block, SGLang defaults to single-token granularity, and TensorRT-LLM uses a paged KV cache. Paging itself is no longer what sets engines apart. What differs is the block size, the eviction policy, and how it is combined with prefix caching and hierarchical caching.

Weight-only quantization

Section 3 already showed that switching weights from BF16 to FP8 raises Qwen3-32B's concurrency on a single card from 2 to 63. There are several ways to quantize, each with its own conditions:

Approach Typical formats What it saves Conditions
Weight-only INT4 (GPTQ, AWQ), GGUF k-quants Memory capacity, bandwidth for reading weights Benefits small-batch decode the most; weights must be dequantized to 16-bit before computing, and at large batch sizes the dequantization overhead shows
Weights and activations both quantized FP8 (W8A8) Capacity and bandwidth, and computing with FP8 tensor cores doubles compute Requires native hardware FP8 support (Section 7); quality loss is usually small, and many models ship an official FP8 version
4-bit floating point NVFP4, MXFP4 Capacity and bandwidth halved again; compute doubles again on supported hardware Native compute requires the Blackwell generation; on Hopper it can only be stored, not computed on directly

The order for choosing a quantization format is: first look at what the hardware can compute natively, then at what the model provider officially releases, and only then quantize it yourself. Officially released quantized versions are usually calibrated and evaluated specifically, while quantizing yourself means taking on the cost of verifying quality. How formats match hardware is covered in Sections 6 and 7.

The GGUF format of llama.cpp deserves a separate note. Its k-quants (such as Q4_K_M, Q5_K_M, Q8_0) use different bit widths for different tensors and keep higher precision for the more sensitive parts, and it is the most commonly used format for local deployment. It is designed to run efficiently on CPUs, Apple silicon and consumer GPUs, a different route from the native FP8/FP4 compute that data-center engines pursue.

KV cache quantization

KV cache quantization already appeared in Section 3: switching BF16 to FP8 doubles capacity. Here we add another finding from Section 2: at long context, the decode bottleneck gradually shifts from reading weights to reading KV. KV cache quantization lets memory hold more requests and also reduces the number of bytes moved at each step, so TPOT at long context drops accordingly.

The KV cache quantization parameters of each engine are in the comparison table in Section 3. The effect of KV cache quantization on quality varies by model, and long-context tasks are usually more sensitive, so it needs dedicated evaluation before going live.

Hierarchical KV cache

Prefix caching has a natural limit: memory is only so large, and the more prefixes are cached, the less room is left for running requests, so eventually something has to be evicted. But an evicted prefix may be needed again shortly, for example when a user comes back a few minutes later to continue a conversation.

A hierarchical KV cache moves evicted KV into larger, cheaper storage: if GPU memory cannot hold it, it goes to CPU memory; if CPU memory cannot hold it, it goes to a local SSD or remote distributed storage. On the next hit, the KV is fetched back instead of recomputed.

Whether this pays off comes down to comparing the time to fetch back with the time to prefill again. Take Qwen3-32B and a 4,096-token prefix again, with a KV of 1.07 GB. Fetching it back from CPU memory over PCIe 5.0, estimated at about 50 GB/s in practice, takes about 21 ms; re-prefilling takes about 283 ms in theory. Fetching is faster by an order of magnitude. As long as the hit rate is not too low, the trade is worthwhile.

Engine Hierarchical caching
vLLM Connects to external caches such as LMCache through the KV connector, and also has connectors that offload KV to CPU memory
SGLang HiCache: three tiers of GPU, CPU memory and external storage (such as Mooncake)
TensorRT-LLM host_cache_size sets the size of the secondary cache in host memory; off by default
llama.cpp --cache-ram keeps a slot's prompt cache in host memory

Kimi's Mooncake takes this idea further: the whole inference system is designed around the KV cache, using idle CPU memory and SSDs in the cluster to form one large distributed KV store[20].

4.3 Compute: making each step faster

Attention backend

Attention is the most unusual computation in inference: besides the current token, its inputs include the KV of all the historical tokens of that request, with different lengths, stored in paged blocks. General matrix multiplication libraries cannot handle this shape, so every engine has dedicated attention implementations and usually offers several selectable backends: the FlashAttention family, FlashInfer, Triton implementations, FlashMLA for MLA, and TensorRT-LLM's own attention kernels.

They produce the same results. The differences lie in which GPU, which attention structure and which phase they are optimized for. Engines usually choose automatically based on the GPU model, and most of the time there is no need to specify one manually. The reason the same attention needs so many implementations is differences between hardware generations, which Section 6 explains through the evolution of FlashAttention.

CUDA Graph and kernel fusion

At each decode step, the GPU executes hundreds or thousands of compute kernels: normalization, matrix multiplication, attention, activation functions and residual addition for every layer, and so on. Each kernel needs the CPU to issue a "launch" call, and each call costs microseconds. In prefill each kernel runs for a long time, so this overhead does not matter. But with the small batches of decode, many kernels run for only a few microseconds themselves, and launch overhead becomes a non-negligible part.

CUDA Graph works by "recording" all the kernels of a whole decode step into a graph in advance, so that each later step can "replay" the entire graph with a single call. The cost is that tensor shapes in the graph must be fixed, so the engine records graphs separately for a set of common batch sizes (such as 1, 2, 4, 8, ...), and the actual batch is rounded up to the nearest one. The more graphs are recorded, the more memory they take (the entry in the OOM table in Section 3).

Engine CUDA Graph
vLLM On by default, combined with torch.compile; --enforce-eager turns it off
SGLang On by default; --cuda-graph-max-bs controls the maximum recorded batch size, and --disable-cuda-graph turns it off
TensorRT-LLM Configured with cuda_graph_config
llama.cpp Used by default in the CUDA backend

Kernel fusion is another direction: several consecutive, element-wise small operations (such as residual addition plus normalization, or an activation function multiplied by a gate) are merged into one kernel, so intermediate results do not have to be written back to memory and read out again. It reduces both the number of kernels and the memory round trips. vLLM does part of this fusion automatically through torch.compile, and TensorRT-LLM has a large number of hand-written fused kernels.

Speculative decoding

Decode is bandwidth-bound: each step reads the entire set of model weights just to produce one token, and most of the compute sits idle. Speculative decoding exploits this idle compute.

The method is: first use a very cheap approach to "guess" the next k tokens, then have the large model verify all k tokens at once. Verification is like a small prefill of only k+1 tokens, and in the bandwidth-bound regime it takes about as long as generating a single token. The large model checks from the start, accepts the guesses that are right, replaces the first wrong guess with its own result, and continues from there.

With a specific acceptance rule (rejection sampling), the output distribution of speculative decoding is exactly the same as the large model generating one token at a time[23]. It changes only the speed, not the distribution of results.

How many tokens each step advances depends on the acceptance rate α of the guesses and the number of guesses k. Assuming the probability that each guessed token is accepted is independent, the expected number of tokens advanced is:

Expected tokens advanced per step = (1 − αk+1) ÷ (1 − α)
Expected gain from speculative decoding
Figure 4-4: Expected gain from speculative decoding. Expected tokens advanced per step as a function of acceptance rate α, for different guess lengths k. When the acceptance rate is low, guessing more does not help; when it is high, guessing more gains more. The actual speedup must also subtract the overhead of the guessing itself and of verification.

With an acceptance rate of 0.8 and 4 guesses per step, the expected advance is about 3.4 tokens per step; if the acceptance rate drops to 0.6, it falls to about 2.3. There are several ways to guess:

Method How it guesses Characteristics
Small draft model A small model from the same family generates first General, but takes extra memory, and the draft model itself has to run
EAGLE family A lightweight prediction head attached to the large model's hidden states High acceptance rate; a head must be trained for each model
MTP The model is trained with a multi-token prediction module built in (such as DeepSeek-V3) No extra training; the model ships with it
n-gram / prompt lookup Finds repeated fragments in the input or in the text generated so far Needs no model; very effective for tasks with a lot of "copying", such as code editing and retrieval QA

Speculative decoding has two prerequisites:

  1. There must be spare compute. It trades idle compute for speed. The higher the concurrency, the closer decode itself gets to being compute-bound (Section 2), so the verification computation is no longer "free", the gain shrinks, and it can even get slower. Speculative decoding therefore suits low-concurrency scenarios that are sensitive to single-user speed, such as interactive coding assistants; it is usually turned off for high-concurrency batch processing.
  2. The acceptance rate must be high enough. The acceptance rate depends on the task. It is high for code, structured output and highly repetitive tasks, and low for open-ended creative writing. Measure the acceptance rate on real traffic before going live, not only the numbers in papers.

All four engines support speculative decoding, and the methods they cover are converging: vLLM, SGLang and TensorRT-LLM all support EAGLE-3, MTP, draft models and n-gram; llama.cpp supports draft models, EAGLE-3, MTP and several n-gram methods through --spec-type[24].

4.4 Parallelism: when one card is not enough

When one card cannot hold the model, or one card's speed or throughput is not enough, multiple cards are needed. There are four main ways to split across cards, and they differ in what they save and what communication cost they pay.

Four kinds of parallelism
Figure 4-5: Four kinds of parallelism. Tensor parallelism splits each layer's matrices and needs one all-reduce per layer. Pipeline parallelism places different layers on different cards and passes only activations between layers. Data parallelism keeps full replicas that do not communicate with each other. Expert parallelism spreads the MoE experts across cards, and tokens are sent to the card holding their expert and then returned.

Tensor parallelism (TP)

The large matrices of each layer are split by column or by row across n cards. Each card computes only its own share, and an all-reduce adds the results together. This happens once after attention and once after the MLP in every layer.

Consider the communication volume for Qwen3-32B prefilling 4,096 tokens with 2-card TP: each all-reduce moves about 42 MB, with 128 all-reduces across 64 layers, about 5.4 GB in total.

Interconnect Bandwidth (one direction) Communication time Compared with about 142 ms of compute per card
NVLink (H100) 450 GB/s About 12 ms Can overlap with compute, minimal impact
PCIe 5.0 x16 About 64 GB/s About 84 ms Close to 60% of compute time
Cross-machine NIC 400 Gb/s About 50 GB/s About 107 ms Close to 80% of compute time

(Theoretical estimates, counting each all-reduce as moving the data once.)

The conclusion is that TP should be limited to what NVLink connects, usually within the 8 cards of one machine. Running TP on a PCIe-only machine, or across machines, lets communication eat most of the gain.

There is another easily overlooked constraint, the number of KV heads. TP splits by attention head, and each card needs at least one KV head. Qwen3-32B has 8 KV heads, so TP up to 8 works exactly. Qwen3-235B-A22B has only 4 KV heads, so with TP=8 each KV head must be stored on two cards, wasting half of the KV memory. DeepSeek-V3, which uses MLA, is even more extreme: its latent vector amounts to a single "KV head", which TP cannot split. That is why attention DP appears below.

Pipeline parallelism (PP)

The model's layers are divided into several stages, each placed on a group of cards, and data flows through them in sequence like a pipeline.

A common use of PP is combining it with TP: TP within a machine, PP across machines. For example, a model that needs 16 cards, on two machines with 8 each, uses TP=8 within a machine and PP=2 across machines.

llama.cpp's default for multiple cards is a layer-wise split (--split-mode layer): different layers go on different cards. It lets multiple cards in one machine hold a larger model, but a single request does not get faster with more cards. Newer versions add an experimental --split-mode tensor, which is tensor parallelism.

Data parallelism (DP)

The simplest approach: each group of cards holds a full copy of the model and serves different requests independently, with no communication between groups.

When the model fits on one card (or one group of TP cards), DP is the first choice for scaling throughput: there is no communication overhead, and failures are isolated from each other.

Expert parallelism (EP)

A split specific to MoE models: different experts are placed on different cards. After the router in each layer selects experts, tokens are sent to the cards holding those experts (dispatch), and after computing they are sent back to the original cards (combine). This is an all-to-all communication, in which every card exchanges data with every other card.

For MLA + MoE models such as DeepSeek-V3, the mainstream split is DP for the attention part and EP for the MoE part: each card handles the attention computation of different requests and stores the KV of those requests itself (avoiding the duplicated KV storage under TP), and at the MoE layers an all-to-all sends tokens to the various experts. SGLang's --attn-dp-size, vLLM's --data-parallel-size plus --enable-expert-parallel, and TensorRT-LLM's enable_attention_dp are all this same setup.

How to choose

Situation Recommended split
The model fits on one card Single card, scale replicas with DP
Needs several cards to fit, machine has NVLink TP within the machine, then scale replicas with DP
Needs several cards, but only PCIe First consider whether quantization can get it onto one card; otherwise use PP or DP, and be careful with TP
Does not fit in one machine TP within the machine + PP across machines
Large MoE, multiple machines Attention DP + MoE EP, with a high-speed network

The four engines have broadly similar capability lists. They differ in how far each capability is taken, how it is configured by default, and what scale of deployment it targets. The next section compares the four engines and looks at DeepInfer as a case study.

5. The engine ecosystem and DeepInfer

Nearly all four mainstream engines implement the techniques from Section 4. Their feature lists look more alike over time, and the differences mainly lie in three things: what scale of deployment they target, which hardware they cover, and where they go deepest.

5.1 Where the four engines sit

vLLM SGLang TensorRT-LLM llama.cpp
Origin and governance Originated at the UC Berkeley Sky Computing Lab; now a project hosted by the PyTorch Foundation Hosted by the nonprofit LMSYS Led by NVIDIA The ggml team; joined Hugging Face in February 2026, keeping its technical direction independent
License Apache 2.0 Apache 2.0 Apache 2.0 MIT
Main languages Python + CUDA/C++ Python, with a Rust router layer Python (PyTorch) + C++/CUDA C/C++
Self-description Easy, fast, and cheap serving for everyone For agents, large-scale serving, and reinforcement learning rollouts Accelerating inference on NVIDIA GPUs with specially optimized compute kernels LLM inference in C/C++
Hardware NVIDIA, AMD, Intel, and CPU are first-party; TPU, Gaudi, Ascend, and others via plugins NVIDIA, AMD, TPU, Ascend (including 950), Intel, Apple, and others NVIDIA only (Ampere to Blackwell) Broadest: CUDA, Metal, Vulkan, HIP, SYCL, CANN, MUSA, CPU, and others
Quantization FP8, MXFP4, NVFP4, INT8, INT4, GPTQ/AWQ, GGUF, and others Similar to vLLM, plus FP4 KV FP8, FP4 (NVFP4/MXFP4), W4A16, W4A8, and others GGUF: 1.5–8-bit integer quantization, k-quants, i-quants
Distributed TP, PP, DP, EP, context parallelism, PD disaggregation (experimental) TP, DP-attention, EP, native PD disaggregation TP, PP, attention DP, EP, Wide-EP, PD disaggregation (Beta) Mainly single-node multi-GPU (layer split, experimental tensor parallelism); RPC can span machines
Strongest direction Broad model coverage, the largest ecosystem, many downstream projects Prefix reuse, large-scale MoE and PD disaggregation First-day support for new NVIDIA hardware and precisions Runs on any hardware, local deployment

(Information comes from each project's README, official documentation, and release notes as of October 2026[25].)

A few notes on each:

Positioning of the four engines and DeepInfer
Figure 5-1: Positioning of the four engines and DeepInfer. A qualitative sketch. The horizontal axis is breadth of hardware and model coverage; the vertical axis is the deployment scale targeted. llama.cpp covers the most but is mostly single-node; vLLM and SGLang balance breadth and scale; TensorRT-LLM covers only NVIDIA but goes deep; DeepInfer is an extreme: one model, two kinds of hardware, aimed at very large-scale production.

5.2 How to choose

The table below lists the engine to consider first for each scenario.

Scenario Consider first Reason
Personal computers, Macs, edge devices, no data-center GPU llama.cpp (or tools built on it) Broadest hardware coverage, mature GGUF quantization, CPU/GPU hybrid deployment
Single node with multiple GPUs, many model types, fast time to launch vLLM or SGLang Broad model coverage, active communities, plentiful documentation and examples
Agents, multi-turn dialogue, long system prompts, heavily repeated prefixes SGLang RadixAttention and cache-aware routing
Large-scale MoE, multi-node, PD disaggregation SGLang or vLLM (wide-EP), together with llm-d / Dynamo Both have public large-scale deployment recipes
All-NVIDIA hardware, maximum single-GPU performance, latest-generation GPUs TensorRT-LLM (often with Dynamo) New hardware and precisions are optimized first
Ascend and other domestic Chinese hardware vLLM's Ascend plugin, SGLang's Ascend support, llama.cpp's CANN backend Confirm the level of support for your specific hardware model

That table is only a starting point. In practice, teams usually run both vLLM and SGLang, and which one they pick depends mostly on the model: for a given model, they use whichever engine supports it better, has fewer bugs, and runs faster; for the next model the answer may be different. Scale matters too: running one mid-size model on a single machine and running a large MoE across dozens of machines call for different things. So there is no need to commit to a single engine.

Two more points to keep in mind when choosing.

  1. Performance rankings change with versions. These projects iterate quickly, and a comparison from a few months ago may be reversed today. Benchmarks published by each project will also naturally pick scenarios that favor itself. In the end, load-test with your own model, your own traffic profile, and your own SLO (Section 8).
  2. Switching cost is lower than it looks. All four engines provide an OpenAI-compatible API, so upper-layer applications can usually switch without code changes. What has to be redone is tuning and load testing, and that work is unavoidable anyway.

5.3 A case study: what DeepInfer shows

Section 0 mentioned DeepInfer, which DeepSeek open-sourced. Here is a closer look, using what the earlier sections covered.

According to its README, DeepInfer is "a high-performance inference framework that supports DeepSeek's large-scale production serving"[5]. The scope of this release is narrow:

Three things can be read from this list.

First, narrow and deep. One model and two kinds of hardware, yet an entire set of purpose-built compute libraries. This is the combinatorial explosion described in Section 0: model structure (MLA, MoE, sliding window), precision format, and hardware generation each combine into a case that merits its own dedicated implementation. DeepSeek can push its own model and chosen hardware very far, but that work is hard to transplant directly to other models or other hardware. Section 6 explains, from the hardware side, why "the same operator has to be rewritten for each new hardware generation".

Second, what is missing belongs to the "serving" layer. The KV Cache system, PD disaggregation, and load balancing across replicas all appeared in Section 4, and they determine TSLO and U in the cost formula. In 2025, DeepSeek published some data about its online inference system[21]:

More than half of the input tokens did not need to be recomputed, and that depends on the KV Cache system that DeepInfer does not open-source. The engine determines how fast each GPU can run, while the serving layer determines how much computation can be skipped entirely and how much hardware time is not wasted.

Third, what is open source is only the engine, not a complete inference service, and that is true even for the authors of the model. For enterprises that want to self-host, choosing an engine is only the beginning, and the layer outside the engine still has to be built.

Within a week of DeepInfer's release, vLLM and SGLang had absorbed its kernels and scheduling ideas, and in their own published tests came close to it or beat it[28]. SGLang also added the KV cache system, PD disaggregation, and load balancing that DeepInfer left out. A lead that one engine holds on one model rarely lasts, so after choosing an engine it is worth rerunning load tests on your own workload from time to time.

5.4 The layer outside the engine

A complete inference service usually needs routing, KV storage, orchestration, and observability components outside the engine.

Component Problem it solves Open-source examples
Routing and gateway Load balancing across replicas, cache-aware routing, scheduling the two node types separately under PD disaggregation, rate limiting and retries SGLang Model Gateway, the router in vLLM production-stack, llm-d's inference gateway, NVIDIA Dynamo's KV-aware routing
KV storage and transfer Reusing KV across requests and nodes; moving KV between nodes under PD disaggregation Mooncake, LMCache, NIXL
Orchestration and scaling Deploying and managing multiple engine instances on Kubernetes, autoscaling by load or SLO llm-d (a CNCF sandbox project), NVIDIA Dynamo's Planner, vLLM production-stack
Observability Latency percentiles, KV utilization, cache hit rate, GPU utilization Each engine's Prometheus metrics, DCGM Exporter, Grafana (Section 8)

(The role of each component comes from its README[29].)

This layer varies a great deal in maturity. When choosing, look at which engines and hardware it supports and whether anyone has already used it at a similar scale. For a deployment of one or two machines, a single engine instance plus a simple reverse proxy is often enough; as scale grows, this layer quickly becomes more important than the differences between engines.

The first five sections covered what the engine does at the system level. A few questions have kept being pushed back: why does attention need so many backends? Why can FP4 on H100 be stored but not computed natively (can store, cannot compute)? Why does DeepInfer write an entire compute library for a single hardware generation? Answering them means going one layer below the engine, to the hardware.

6. AI Infra: below the inference engine

The preceding sections have all been about the "engine" layer: scheduling, memory, parallelism. This section goes one layer down to see who the engine hands computation to, how that code reaches the GPU, what the inside of a GPU looks like, and how GPUs connect to each other. This layer is usually called AI Infra.

Deployers do not need to write compute kernels, but many "strange" phenomena in deployment have their root in this layer: why a service fails to start after a driver version change, why the first startup takes ten-plus minutes, why an FP4 model gets no faster on H100, why among machines with the same 8 GPUs some run tensor parallelism quickly and some slowly. At the end of each subsection I come back to what it means for deployment.

6.1 The scheduling layer and the backend layer

An inference engine can be roughly divided into two layers:

Take one layer of Qwen3-235B-A22B as an example (all 94 layers share this structure; 64 query heads, 4 KV heads, and each token selects 8 of 128 experts). Simplified into pseudocode, with each line annotated with the kind of backend it is handed to:

def decoder_layer(x, kv_cache):           # x: [tokens in this step, 4096]
    h = rms_norm(x)                       # element-wise op (often fused with other ops)
    q, k, v = linear(h, W_qkv)            # matrix multiplication backend
    o = attention(q, k, v, kv_cache)      # attention backend (reads/writes paged KV)
    x = x + all_reduce(linear(o, W_o))    # matrix multiplication + communication backend (with TP)
    h = rms_norm(x)
    ids, w = router(h)                    # each token selects 8 experts
    t = dispatch(h, ids)                  # communication backend (with EP: send to the GPUs hosting the experts)
    y = grouped_gemm(t, W_experts)        # MoE backend: compute multiple experts in one call
    return x + combine(y, w)              # communication backend (with EP: send back to the original GPUs)

All four engines dispatch these computations to replaceable backends; they just expose them differently:

Computation SGLang vLLM TensorRT-LLM llama.cpp
Attention --attention-backend (fa3, flashinfer, triton, trtllm_mha, etc.) --attention-backend (FLASH_ATTN, FLASHINFER, etc.) attention_backend, default TRTLLM -fa switch; each hardware backend has its own implementation
MoE expert computation --moe-runner-backend (deep_gemm, triton, flashinfer_*, cutlass, etc.) Chosen automatically; Triton fused MoE ships with per-GPU tuned configurations moe_config.backend (CUTLASS, TRTLLM, DEEPGEMM, etc.) Built in
EP communication --moe-a2a-backend (deepep, mooncake, nixl, etc.) --all2all-backend (deepep_high_throughput, deepep_low_latency, etc.) Determined by the MoE backend and the Wide-EP configuration Not applicable
Matrix multiplication Chosen separately by precision Chosen automatically Chosen automatically On CUDA, chosen between its own quantized matrix multiplication and cuBLAS

(Parameters are taken from each engine's documentation as of October 2026.)

These options produce mathematically identical results; the difference is only who computes, and how. At startup, the engine first asks "what GPU is this": PyTorch returns a compute capability number, for example 9.0 (Hopper) for H100, 10.0 (Blackwell) for B200, and 8.9 (Ada) for RTX 4090. The engine then picks a default implementation for each kind of computation based on that number. For example, SGLang defaults to FlashAttention-3 for attention on Hopper, and switches to TensorRT-LLM's attention kernels on Blackwell.

For deployment:

6.2 How code reaches the GPU

How do the backend libraries the engine calls end up running on the GPU? This subsection follows the path from Python's import all the way down to the hardware, and along the way we run into the most common kinds of environment problems in deployment.

.so and cubin

On Linux, importing a Python extension that contains CUDA code loads a .so shared library. The .so holds CPU instructions, but it also carries a block of data: compiled GPU machine code, called a cubin, one per specific GPU architecture (for example, sm_90a corresponds to Hopper). Many libraries also ship a PTX, an intermediate representation that the driver can compile into machine code for the current GPU at runtime.

A library can run directly on exactly those GPUs whose architectures it was compiled for before release. If your GPU architecture is not in the list and no PTX is shipped, the runtime reports no kernel image is available for execution on the device. This is one of the most common errors when deploying on a new or an old GPU.

AOT vs. JIT compilation

By when the GPU code is generated, backend libraries fall into two kinds:

Why compile on the spot? Because writing matrix shapes and tile sizes as compile-time constants produces faster code, and the combinations of model, parallelism layout, batch size, and GPU generation are too many to precompile all of them. The cost is a cold start: the first startup has to compile a large number of kernels, which can take several minutes or even ten-plus minutes. The compiled results are stored in cache directories (Triton's ~/.triton, DeepGEMM's ~/.dj, vLLM's torch.compile cache, and so on) and reused on the next startup.

Runtime API and Driver API

Whether precompiled or compiled on the spot, GPU code ultimately reaches the GPU through two layers of CUDA interfaces:

Runtime API calls are ultimately translated into Driver API calls. Since these two layers come from the image and the host respectively, the most common version problem in deployment arises: the CUDA version in the image requires that the host's driver version not be too old. When the driver is too old, you get CUDA driver version is insufficient for CUDA runtime version.

In a container, libcuda.so.1 is not in the image; the NVIDIA Container Toolkit mounts it from the host when the container starts, and the same goes for device files such as /dev/nvidia*. The container and the host share one kernel, and there can be only one kernel driver, so the user-space half has to follow the host as well.

System calls, device files, and kernel modules

Below libcuda.so.1 is the operating system. An ordinary program cannot operate hardware directly; it must ask the kernel to do so on its behalf through system calls. Observing a minimal PyTorch GPU program with strace, you will see it open these files:

The ioctl calls issued on them afterward are what operations such as allocating GPU memory and launching kernels actually look like. Behind these device files are kernel modules: nvidia.ko is the core of the GPU driver and nvidia-uvm.ko manages unified memory; they operate the real hardware over the PCIe bus.

The communication side has the same layered structure, with a different set of components: NCCL or NVSHMEM in user space, below them the user-space library of the NIC driver (libmlx5 for Mellanox NICs), and below that the /dev/infiniband/uverbs* device files and the mlx5_core and mlx5_ib kernel modules. The two columns have one key connection point: the kernel module nvidia-peermem. It hands GPU memory addresses to the NIC driver so the NIC can read and write GPU memory directly, without first copying to CPU memory. This is GPUDirect RDMA (Section 6.6).

The inference software stack: where each layer is installed
Figure 6-1: The inference software stack: where each layer is installed. The left column is computation and the right column is communication. The right side marks where each layer comes from: Python packages and the middle layers ship with the image, while the user-space part of the driver and the kernel modules come with the host, separated by the wall of system calls. Version problems in deployment mostly arise at the boundary between the "image" and the "host".

To see this for yourself, run these commands on a GPU machine with an inference engine installed:

# Which shared libraries a backend library depends on, and where they are
ldd $(python -c "import flash_attn_interface as m; print(m.__file__)")
# Which architectures of GPU code are embedded in a .so
cuobjdump --list-elf <a backend's .so file>
# What requests a minimal GPU program sends to the kernel
strace -f -e trace=openat,ioctl python -c "import torch; torch.zeros(1, device='cuda')"
# Which GPU- and NIC-related modules are loaded in the kernel
lsmod | grep -E "nvidia|mlx5"
# How GPUs and NICs are connected to each other
nvidia-smi topo -m

In deployment, these problems show up most often:

Problem Cause What to do
CUDA driver version is insufficient The image's CUDA runtime is newer than the host driver Upgrade the host driver, or switch to a matching image; put the driver version under infrastructure version management
no kernel image is available The library was not compiled for the current GPU architecture Switch to a version or image that supports the architecture, or build from source
Very slow first startup JIT compilation Mount the compile cache directory on persistent storage; warm up before the service goes live; make health checks wait for warmup to finish
NCCL is slow or errors on a multi-GPU NVLink machine NVSwitch machines need the fabric manager service Confirm nvidia-fabricmanager is running and its version matches the driver
Cross-machine communication bandwidth far below NIC line rate GPUDirect RDMA is not in effect, so data detours through CPU memory Confirm nvidia-peermem is loaded (requires a manual modprobe), and that the NIC and GPU are under the same PCIe switch

6.3 Inside a GPU

SMs and the two kinds of compute units

Take the H100 SXM as an example: one GPU chip has 132 SMs (streaming multiprocessors), and each SM can be understood as an independent small processor[30]. A GPU's speed comes from having a large number of SMs work at the same time: if a computation task can be cut into only 30 pieces of work, 100 of the 132 SMs sit idle. This becomes important when we reach MoE in Section 6.5.

Each SM contains two kinds of compute units:

The throughput gap between the two is large. By H100 SXM specifications, non-tensor-core FP32 compute is about 67 TFLOPS, while BF16 tensor core dense compute is about 989 TFLOPS, a gap of about 15x. So the first priority of every matrix multiplication library is to hand the computation to tensor cores; the second is to find ways to keep the tensor cores supplied with data at all times.

The memory hierarchy

A compute unit can directly process only data that is already inside the SM. GPU memory is divided into several levels, from near to far:

Level Capacity on H100 SXM Characteristics
Registers 256 KB per SM Closest to the compute units, private to each thread
Shared memory / L1 Up to 228 KB per SM Shared by threads within the same SM, managed explicitly by the program
L2 cache 50 MB, shared by the whole chip Managed automatically by hardware
HBM 80 GB, 3.35 TB/s bandwidth Weights and KV Cache live here

Adding up the registers and shared memory of all SMs, plus the L2 cache, on-chip memory totals only about 0.1 GB, and HBM is nearly a thousand times that. Conversely, on-chip bandwidth is more than an order of magnitude higher than HBM.

The memory hierarchy of H100
Figure 6-2: The memory hierarchy of H100. The memory hierarchy of the H100 SXM. The higher up, the closer to the compute units, the smaller the capacity, and the faster the access. Compute units can only operate on data already moved into the SM, so the key technique of high-performance kernels is to move data on-chip in tiles, reuse it as many times as possible on-chip, and then discard it.

GPU programming has one basic principle: moving data from HBM into the SM is expensive, so once it is in, use it as many times as possible. Tiling in matrix multiplication, FlashAttention, and operator fusion are in essence different applications of this principle.

This layer has no parameters for deployers to tune directly, but it explains two things. One is why one computation has so many implementations: each GPU generation differs in SM count, shared memory size, and tensor core instructions, so the optimal tiling differs as well. The other is why inference performance on a newly released GPU is often far from the multiples on the spec sheet: the compute libraries need time to be rewritten and tuned for the new hardware.

6.4 Precision: from BF16 to FP4

How floating-point numbers are stored

A floating-point number has three parts: the sign bit for positive or negative, the exponent bits for range (how large and how small a number can be represented), and the mantissa bits for precision (how many digits can be resolved). Some common formats:

Format Total bits Exponent Mantissa Max value Notes
FP32 32 8 23 about 3.4×1038 Traditional single precision
BF16 16 8 7 about 3.4×1038 Same exponent bits as FP32, so the range is unchanged and only precision is sacrificed; the baseline format for large-model training and inference
FP16 16 5 10 65,504 Higher precision than BF16, much smaller range
FP8 E4M3 8 4 3 448 The FP8 format commonly used for inference
FP8 E5M2 8 5 2 57,344 Larger range, lower precision
FP4 E2M1 4 2 1 6 The positive side has only eight values: 0, 0.5, 1, 1.5, 2, 3, 4, 6

Why do hardware vendors keep moving to lower precision, generation after generation? Because the fewer the bits, the smaller the multiplier circuit, and the more multipliers fit in the same chip area. The pattern on the spec sheets is regular: H100's BF16 dense compute is about 989 TFLOPS, and FP8 doubles to about 1,979; B200's BF16 is about 2,250, FP8 about 4,500, and FP4 about 9,000. Each step down in precision doubles compute and halves the bytes to move.

Scaling: making 4-bit numbers usable

FP4 has only 16 values, and the smallest nonzero magnitude is 0.5. Model weights, however, are mostly small decimals like 0.0x. Take four arbitrary weights: 0.021, −0.047, 0.008, 0.035. Stored directly as FP4, all four are rounded to 0, and this block of weights is lost.

The fix is scaling: first enlarge the whole group of numbers, then shrink them back after use. Find the largest absolute value in the group, 0.047, and map it exactly to FP4's maximum of 6, giving a scale factor s = 0.047 ÷ 6 ≈ 0.00783. Dividing each number by s gives 2.68, −6, 1.02, 4.47, and rounding to the nearest FP4 values gives 3, −6, 1, 4. At use time, multiply by s to restore 0.0235, −0.047, 0.0078, 0.0313. There is error compared to the original values, but the magnitudes are right.

Floating-point formats and block scaling
Figure 6-3: Floating-point formats and block scaling. The top shows the bit layouts of several formats; the bottom shows all the values FP4 can represent, and a comparison of a group of small weights rounded directly (all become 0) versus rounded after scaling.

The scale factor is shared by a group of numbers. The different low-precision schemes are distinguished by how large the group is and what format the scale factor is stored in:

Scheme Group size Scale factor format Average bits per number Who uses it
FP8 block scaling Weights in 128×128 blocks FP32 (DeepSeek-V3) or UE8M0 (V4) about 8 DeepSeek-V3, V4, and others
MXFP4 Every 32 numbers E8M0: exponent only, so the scale factor can only be a power of 2 4.25 OCP open standard (jointly developed by AMD, Intel, Meta, Microsoft, NVIDIA, and others); the expert weights of DeepSeek-V4
NVFP4 Every 16 numbers FP8 E4M3, plus a tensor-level FP32 factor 4.5 NVIDIA's format, commonly used by models NVIDIA releases in quantized form

NVFP4 spends 0.25 more bits per number, in exchange for smaller groups and finer scale factors, and gives better accuracy[31]. For deployment, the other point matters more: the two FP4 formats have different data layouts, so the compute kernels must be implemented separately for each. When someone says FP4, first ask which one it is, then confirm that your engine and hardware support it.

Which GPU generation can compute which precision

Architecture Representative models Compute capability Low precisions natively supported by tensor cores
Ampere A100 8.0 FP16, BF16, TF32, INT8; no FP8
Ada L40S, RTX 4090 8.9 Adds FP8
Hopper H100, H200 9.0 FP8
Blackwell B200, B300, RTX PRO 6000 10.0 / 10.3 / 12.0 Adds FP6, FP4, and block-scaled formats such as MXFP8/MXFP6/MXFP4 and NVFP4

(From the NVIDIA spec pages for each model and the CUTLASS documentation[32].)

One more detail: who multiplies in the scale factor? On Hopper, the tensor core only computes A×B and does not also multiply in the per-block scale factors. The DeepSeek-V3 paper describes their approach[33]: along the accumulation direction of the matrix multiplication, split into segments of 128 elements; the tensor core computes the partial sum of a segment and hands it to the CUDA cores, which multiply in that segment's scale factor and add it into an FP32 running total. This also resolves another problem: the paper found that the Hopper-generation FP8 tensor core keeps only about 14 bits of precision in its internal accumulation, so the longer the accumulation, the larger the error; handing off periodically to CUDA cores for FP32 accumulation keeps the error under control. While the CUDA cores multiply in the scale factor, the tensor core is already computing the next segment, so the two can overlap.

On Blackwell, the tensor core itself supports block-scaled matrix multiplication, with one scale factor per 16 or 32 elements, handled directly in hardware[34]. The same FP8 matrix multiplication is written differently on Hopper and Blackwell. DeepGEMM's source contains separate implementations for SM90 and SM100.

Stored but not computed natively

Putting the above together, one point matters a lot for deployment: a weight's storage precision can be lower than the compute precision the hardware natively supports.

When running an FP4 model on H100, the weights are stored in GPU memory as FP4 and read from GPU memory as FP4, then converted to FP8 or BF16 after being moved into the SM and handed to the tensor core. Decode is bound by weight-read bandwidth, so it still gets faster; but prefill is bound by compute, and H100 has no FP4 tensor core, so this half cannot get faster. A calculation with Qwen3-32B (a theoretical estimate, counting only the linear-layer weights, simplified):

Weight read per decode step Compute for a 4,096-token prefill
Weight precision H100 B200 H100 B200
BF16 (64 GB) 19.1 ms 8.0 ms 283 ms 124 ms
FP8 (32 GB) 9.5 ms 4.0 ms 141 ms (FP8 compute) 62 ms
FP4 (about 18 GB, at 4.5 bits) 5.4 ms 2.3 ms 141 ms (can only compute as FP8) 31 ms (FP4 compute)

With FP4 on H100, decode is nearly twice as fast as FP8, but prefill is the same as FP8. Only on B200 is FP4 fast at both ends.

For deployment:

6.5 Three kinds of core computation

Matrix multiplication: tiling and reuse

Matrix multiplication accounts for the vast majority of inference compute. The basic approach of high-performance matrix multiplication libraries (cuBLAS, CUTLASS, and others) is: cut the output matrix into small tiles (for example, 128×128), with each SM responsible for one tile; along the accumulation direction, move the corresponding small blocks of the inputs into shared memory one segment at a time and reuse them repeatedly on-chip. The larger the tile, the more times each byte moved in is reused, and the closer to tensor core peak; but if tiles are too large, there are too few tiles to keep all SMs busy. So libraries usually prepare different tiling plans for different matrix shapes and pick among them at runtime by shape.

Matrix multiplication in decode has a special shape: the input has only a few dozen rows (the number of tokens in the batch), while the weights are thousands by thousands. The bottleneck is then reading the weights (Section 2), and the kernel design focus becomes "finish reading the weights in the least time"; a common technique is to split along the accumulation direction (split-K) so that more SMs take part in the reads.

On CUDA, llama.cpp has a path of its own: it has matrix multiplication kernels dedicated to the GGUF quantization formats (MMQ), which compute directly on quantized data blocks without first dequantizing the entire weight to 16 bits; on Metal, Vulkan, and other hardware, it likewise has its own implementation for each.

Attention: the evolution of FlashAttention

Written per the formula, attention takes three steps: first compute the score matrix S from Q and K, then apply softmax to S to get P, and finally take a weighted sum of V using P. The problem is the size of S and P: they are n×n, where n is the sequence length.

Take Qwen3-32B: for a 32K-token input, S for a single head has 32,768 × 32,768 numbers, about 2.1 GB in BF16; with 64 heads on a single GPU, one layer comes to about 137 GB, more than the entire H100's memory. Moreover, at every step S has to be written back to HBM and read out again, so much of the time goes into data movement.

The idea of FlashAttention is not to write out the full S[35]. It cuts Q into small blocks by rows, with each SM responsible for one block, and that block of Q stays on-chip throughout; then K and V are moved in one block at a time, and with each arrival, the corresponding small block of scores is computed on-chip, used immediately, and the running result for that row is updated. When all K and V blocks have been processed, the output O for this block is complete, and only O is written back to HBM.

Tiled computation in FlashAttention
Figure 6-4: Tiled computation in FlashAttention. On the left, computed per the formula, the n×n score matrix must be written out in full to HBM; on the right, FlashAttention has each SM hold one block of Q, read in small blocks of K and V in turn, finish the computation on-chip and discard them, so HBM holds only the inputs and the output.

Softmax needs to see an entire row to normalize, so is it still correct after tiling? Yes. FlashAttention uses an "online softmax" technique: after processing each block, it records the maximum so far and the sum of exponentials, and when a larger value appears later, it rescales the earlier running result proportionally. The final result is exactly identical to the formula-based computation, not an approximation.

The tiling idea was there in the first version; the later versions are reimplementations for different generations of hardware:

Version Target hardware Key improvements
FlashAttention-2 Ampere (A100) Better parallel partitioning; reaches only about 35% of peak compute on H100
FlashAttention-3 Hopper (H100) Uses Hopper's new TMA (a unit dedicated to moving data) and asynchronous tensor cores; some threads are dedicated to moving data and some to computing, overlapping the two; reaches about 75% of peak in FP16[36]
FlashAttention-4 Blackwell (B200) Blackwell's tensor cores are about twice as fast, but the exponential units used in softmax did not speed up in step, becoming the new bottleneck; FA4 computes some of the exponentials on ordinary arithmetic units using a polynomial approximation and reduces unnecessary rescaling work, reaching about 71% utilization in BF16 on B200[37]

The same idea has to be rewritten for each hardware generation, because each generation has a different bottleneck.

Attention in the decode phase is a different problem again: each request has only 1 new query, but must scan the KV of thousands or tens of thousands of historical tokens, and that KV is scattered across paged blocks. The optimization focus here is to split and parallelize along the KV length (often called flash-decoding) and to read efficiently from paged blocks. Models that use MLA (such as the DeepSeek series) also need dedicated kernels, such as DeepSeek's FlashMLA. In its September 2026 release, FlashMLA removed support for Hopper and kept only Blackwell[38]. A compute library's maintainers can decide to follow only the latest hardware generation, deployers on older hardware can only stay on older versions.

MoE: keeping every SM busy

Each expert in an MoE model is a small feed-forward network, and each token is sent to only a few of them. This creates a new difficulty for matrix multiplication.

Take Qwen3-235B-A22B: 128 experts, each token selecting 8. In decode, a batch of 64 requests yields 1 token each, for a total of 64 × 8 = 512 "token-expert" tasks; spread over 128 experts, each expert gets only about 4 tokens. Each expert's matrix multiplication becomes 4 input rows times a 4096 × 3072 weight (gate and up projections combined). Cutting in tiles of 128 rows, only 4 rows in each tile are useful.

If you write a loop that computes one expert after another, only a small part of the SMs has work each time, and a kernel has to be launched separately for each expert. Grouped GEMM works differently: first sort the tokens by expert, tell the kernel how many tokens each expert received, and then lay out the computation for all experts in a single call so that all SMs compute together. DeepGEMM provides two layouts: for prefill, a contiguous layout where the tokens of each expert follow one another end to end; for decode, a masked layout used with CUDA Graph, because the CPU does not know in advance how many tokens each expert will receive[39].

The larger the EP scale, the fewer experts each GPU holds, the more tokens each expert can collect from the global batch, and the closer the matrix multiplication gets to an efficient shape. This is what Section 4 meant by saying a larger EP is better. DeepSeek's online decode uses EP144, with each GPU holding just 2 routed experts and 1 shared expert[21], and goes down this road.

MoE kernels depend especially heavily on JIT compilation. The expert matrix shapes, the number of experts per GPU, and every possible token count combine into a very large number of cases. DeepGEMM JIT-compiles for the actual shapes at service startup, and the first run may take a long time to compile; vLLM's Triton MoE kernels ship with tuned configuration files for common GPU models and expert shapes, and combinations with no ready configuration fall back to default parameters, which can noticeably reduce performance.

For deployment, with an MoE model, watch the startup log for JIT compilation and "missing tuned configuration" messages; persist the compile cache; and before bringing a new hardware and model combination online, load-test the MoE layer on its own.

6.6 Between GPUs

The bandwidth ladder

Within one GPU, data sits in HBM, with bandwidth at the TB/s level; once data has to leave the GPU, bandwidth drops step by step:

Link One-way bandwidth (H100 generation) Relative to HBM
HBM (within the GPU) 3.35 TB/s 1
NVLink 4 (between GPUs in a node) 450 GB/s (900 GB/s bidirectional total) about 1/7
PCIe 5.0 x16 about 64 GB/s about 1/50
400 Gb/s NIC (across machines) about 50 GB/s about 1/70
The bandwidth ladder
Figure 6-5: The bandwidth ladder. From HBM to the cross-machine network, each step outward cuts bandwidth by roughly an order of magnitude (log scale). The optimization approach for multi-GPU deployment is to make data travel one level less far, or to send less data when it does go out.

This ladder explains the parallelism choices in Section 4: TP communicates at every layer and so can only sit within NVLink range; PP and EP have relatively little communication, or can overlap it with computation, so they can span machines.

Within a node: NVLink and NVSwitch

In an HGX H100 server, all 8 GPUs are connected to NVSwitch chips, and any two GPUs are linked by full-bandwidth NVLink. In the connection table printed by nvidia-smi topo -m, every pair of GPUs shows NV18, meaning 18 NVLink lanes. NVSwitch is configured by the fabric manager service, and without it NVLink cannot be used at runtime (the table in Section 6.2). Newer NVSwitch generations can even perform addition inside the switch chip (NVLink SHARP), so NCCL's all-reduce can offload part of its computation to the switch.

PCIe models are different. Cards like the L40S have no NVLink, and GPUs can only talk over PCIe; consumer GPUs also usually do not support peer-to-peer direct access between GPUs, or have it disabled by default, so data may detour through CPU memory. On such machines, tensor parallelism carries much more communication overhead (the table in Section 4). When buying a multi-GPU server, the GPU interconnect matters as much as the GPU model.

Across machines: RDMA and GPUDirect

Cross-machine communication goes through NICs. Data centers commonly use InfiniBand or Ethernet-based RoCE, and both support RDMA: the NIC reads and writes the remote machine's memory directly, without going through the remote CPU. With GPUDirect RDMA added, the NIC can read and write GPU memory on both the local and remote machines, and the data path is "GPU memory → NIC → network → NIC → GPU memory", bypassing CPU memory.

A typical configuration gives each GPU a 400 Gb/s NIC, so an 8-GPU machine has 8 NICs. nvidia-smi topo -m also shows how many PCIe switch levels lie between each GPU and its NIC; the closer, the better.

NCCL: collective communication

NCCL handles TP's all-reduce. At startup it first probes the topology (the very table nvidia-smi topo -m shows), and then picks a suitable communication method for the machine: NVLink peer-to-peer or NVLink SHARP within a node, and GPUDirect RDMA across machines. Setting the environment variable NCCL_DEBUG=INFO shows in the log which path it chose.

All-reduce in decode has one characteristic: the data volume per call is very small (only a few hundred KB for Qwen3-32B at batch 64), so the bottleneck is latency, not bandwidth. That is why vLLM, SGLang, and TensorRT-LLM have each implemented their own small-message all-reduce to replace NCCL in this scenario.

The EP problem and DeepEP

EP's dispatch and combine are much harder than all-reduce. An all-reduce has a fixed pattern each time, whereas how many tokens each GPU sends to each other GPU in dispatch depends on what the router has just computed, and changes at every layer and every step.

The conventional approach is: after the GPU finishes routing, it copies the table of "how many to send to each GPU" to the CPU, the CPU arranges the receive buffers, and then orders the send. During this the GPU can only wait. In decode each layer computes quickly to begin with, so this wait becomes the dominant cost.

DeepSeek's open-source DeepEP is the most representative solution to this problem. Taking its widely known v1 design as an example[40]:

In 2026, DeepEP's main branch was upgraded to V2, rebuilt on NCCL and no longer dependent on NVSHMEM. The implementation changed, but the idea of "let the GPU send by itself, without waiting for the CPU" did not.

For deployment:

6.7 Switching to another vendor's hardware

Nearly everything above uses NVIDIA as the example. Does this knowledge still hold on other vendors' hardware?

NVIDIA AMD Instinct Huawei Ascend AWS Trainium
Compute units SM; CUDA core + tensor core CU; Matrix Core AI Core; Cube (matrix) + Vector units NeuronCore; large matrix array + vector and scalar engines
On-chip memory Registers, shared memory, L2 Registers, LDS, L2, Infinity Cache On-chip buffers SBUF, PSUM; no hardware cache, fully software-managed
GPU interconnect NVLink, NVSwitch Infinity Fabric In-house high-speed interconnect NeuronLink
Programming stack CUDA, cuBLAS, NCCL ROCm, HIP, hipBLASLt, RCCL; AITER compute library CANN, HCCL Neuron SDK; NKI for writing custom kernels
Low precision FP4 supported from Blackwell FP4, FP6 supported from MI355X See the CANN documentation Trainium3 supports MXFP8, MXFP4

(From the vendors' official documentation and release information[41].)

AMD is closest in structure to NVIDIA, with almost every item mapping one to one, only under different names. Ideas such as tiling, low precision, and overlapping communication with computation can mostly be carried over, but the code must be rewritten: SGLang and vLLM have dedicated backends on AMD, and AMD's own AITER library provides kernels for attention, MoE, matrix multiplication, and more. MI300X has 192 GB of memory and MI355X has 288 GB, with added FP4 and FP6 support.

On Huawei Ascend, DeepInfer and SGLang both already support Ascend 950, and vLLM supports the Atlas A2/A3 series through the vllm-ascend plugin.

AWS Trainium differs the most. It does not have the hundreds of small cores a GPU has. Each chip has 8 NeuronCores, each containing one large matrix array; on-chip memory is entirely software-managed, with no hardware cache to fall back on. On a GPU, "move tiles on-chip, compute, then discard" is an optimization; on Trainium, it is something the compiler or the developer must arrange by hand.

So the ideas transfer but the code does not, and every vendor and every generation of hardware needs its own set of compute kernels. Backend options in inference engines keep multiplying, and Section 0 said "these capabilities do not download along with the weights"; the reason for both is here.

Hardware and models also influence each other. Hopper added FP8, and DeepSeek-V3 trained in FP8; Blackwell added FP4, and DeepSeek-V4 released its expert weights directly in FP4. In the other direction, MoE becoming ever sparser forced the creation of grouped GEMM and DeepEP; once Blackwell's tensor cores got faster, the exponential became the new bottleneck, giving rise to FlashAttention-4. Model structure, precision format, and hardware generation advance together, so there are always new backends to write.

For deployment, when considering non-NVIDIA hardware, what to look at is whether the model you want to deploy, at the precision you want, on the engine you want to use, has a mature backend on that hardware. However good the specs, if key operators fall back to generic implementations, performance may be only a fraction. Before choosing, check each of the four dimensions "model × precision × engine × hardware" one by one, and reserve ample time for validation.

With this background, we can move on to procurement: which GPUs to buy, at what precision, on how large a machine.

7. Hardware and precision selection

The previous six sections build toward one concrete question: which card to buy, which precision to use, and how large a machine to get. This is where P in the cost formula comes from, and it affects TSLO as well.

7.1 Look at the workload first, then the specs

For the same budget, the right hardware depends on which end of inference the workload leans toward:

Workload profile Typical use Bottleneck Specs to look at first
Long output, interactive Chat, coding assistants, long-form generation decode: memory bandwidth, KV capacity Memory bandwidth, memory capacity
Long input, short output Document summarization, retrieval QA, classification, information extraction prefill: compute Low-precision compute (FP8/FP4)
Very long context Long-document analysis, code repository QA, multi-turn agents KV capacity and KV read bandwidth Memory capacity, and the model's attention structure
High concurrency, latency-insensitive Offline batch processing, data labeling, evaluation Total throughput Compute and bandwidth per dollar

Section 2 showed that the H200 and H100 have the same compute and the H200 has 43% more bandwidth. For an online service dominated by decode, the H200 gets faster almost in proportion to bandwidth. For batch work dominated by prefill, the two are about the same. The "compute" figure on a spec sheet is only one dimension, and bandwidth, capacity, and interconnect often matter more.

7.2 GPU generation × model precision

The core conclusion of Section 6 is that the precision a model is stored in and the precision the hardware can compute natively are two different things. The table below turns that into a decision aid.

GPU BF16 FP8 FP4 (NVFP4 / MXFP4) INT4 weight quantization (AWQ, GPTQ, GGUF)
A100 (Ampere) Native Saves only memory and bandwidth; compute is still 16-bit Saves only memory and bandwidth Good for small batches; dequantization overhead shows up at large batches
L40S, RTX 4090 (Ada) Native Native Saves only memory and bandwidth Same
H100, H200 (Hopper) Native Native, the main precision Saves only memory and bandwidth: decode gets faster, prefill does not change Same
B200, B300 (Blackwell data center) Native Native Native, compute doubles again FP4 is usually preferred
RTX PRO 6000, RTX 50 series (Blackwell, compute capability 12.x) Native Native Native (exact formats depend on engine support) Same

Three suggestions for reading the table:

  1. Fix the hardware generation first, then pick the model's precision variant. On the H100, FP8 is the best value: capacity and bandwidth are halved and compute is doubled, and many models ship an official FP8 version.
  2. "Saves only memory and bandwidth" is still worth having. As Section 3 explained, when memory is tight, every 1 GB saved goes into the KV pool and directly raises concurrency. Just do not expect prefill to get faster too.
  3. Confirm engine support separately. Hardware that can compute a format does not guarantee that your engine, at your version, has an efficient kernel for this model and this format. The four-dimension check in the last part of Section 6 applies here as well.

7.3 Topology and scale

How many cards a model needs is determined mainly by memory. How those cards are connected determines which parallelism you can use. A rough rule of thumb: weights should preferably take no more than half to 60% of a single card's memory, leaving the rest for KV and activations. Otherwise concurrency suffers (configuration A in Section 3).

Model (FP8 weights) Weight size Reasonable configuration Notes
Qwen3-32B 33 GB 1 × H100 / H200; or 1 × L40S (48 GB, KV space is tight) One card is enough; scale out with DP
Qwen3-235B-A22B 235 GB 8 × H100 (640 GB); 4 × H200 (564 GB) is tight In-node TP or EP; NVLink is required
DeepSeek-V3 / R1 671 GB 8 × H200 (1,128 GB) or 8 × B200 (1,440 GB); 8 × H100 does not fit, two nodes needed Prefer a single node when it fits; for multiple nodes, use DP-attention + EP

Then look at the interconnect:

7.4 The small tier of hardware

Not every private deployment needs data center GPUs. For small departmental use, offline scenarios with extremely sensitive data, and edge devices, a workstation, a consumer graphics card, or even a Mac is often enough.

The most important metric at this tier is memory (or unified memory) capacity and bandwidth. The upper bound on single-user decode speed can be estimated directly as "bandwidth ÷ bytes read per generated token". MoE models get a big advantage here: Qwen3-30B-A3B has 30.5 billion total parameters, but only about 3 billion are active per token[43], so each step reads only one tenth of the data that a dense model of the same size would.

Single-user decode speed upper bound on small-tier hardware
Figure 7-1: Single-user decode speed upper bound on small-tier hardware. Theoretical upper bounds, computed as "bandwidth ÷ weight bytes read per token", with Q4_K_M quantization taken as about 4.85 bits on average. Actual speed usually reaches only a little over half of the bound: in llama.cpp community tests, Llama 2 7B (Q4_0) runs at about 83 tokens/s on an M4 Max and about 189 tokens/s on an RTX 4090, roughly 58% and 72% of the theoretical bound respectively[44].
Device Memory Bandwidth Qwen3-30B-A3B (Q4_K_M, about 18.5 GB) Qwen3-32B (Q4_K_M, about 19.9 GB)
RTX 4090 24 GB 1,008 GB/s About 550 tokens/s, fits About 52 tokens/s, fits but context is very tight
RTX PRO 6000 Blackwell 96 GB 1,597 GB/s About 880 About 82
Mac (M4 Max) Up to 128 GB unified memory 546 GB/s About 300 About 28
Mac (M3 Ultra) Up to 512 GB unified memory 800 GB/s or more About 440 About 41
DGX Spark 128 GB unified memory 273 GB/s About 150 About 14

(Theoretical upper bounds, single user. Device specifications are from the vendors' official pages[45].)

A few conclusions:

7.5 Non-NVIDIA hardware

Section 6 concluded that "the ideas transfer, the code does not". For selection, when considering AMD, Ascend, or other hardware, confirm the following in this order:

  1. Whether the target model has an official deployment guide on the target engine, such as the dedicated AMD or Ascend pages in the SGLang and vLLM documentation. An official guide usually means the key operators already have dedicated implementations.
  2. Whether the target precision is natively supported: the MI300X supports FP8 but not FP4, and the MI355X adds FP4 and FP6; the Ascend 950 series supports FP8 and FP4.
  3. Whether the multi-GPU and multi-node communication libraries are mature: the bandwidth RCCL and HCCL actually achieve on your topology.
  4. Whether the team can handle problems: when something goes wrong, community material and the responsiveness of vendor support often matter more than the spec sheet.

For enterprises where data compliance or supply chain security comes first, non-NVIDIA hardware may be a requirement. In that case, reserve ample validation time at the project start, and load-test on the target hardware with real traffic using the method in Section 8.

7.6 A pre-purchase checklist

The next section covers what happens once you have the machines: how to deploy, load-test, and tune.

8. Three deployment tiers

This section works through deployments at three scales. Each tier follows the same order: constraints, model and precision, memory ledger, theoretical upper bound, launch configuration, load test, which metrics to watch, and common pitfalls.

The launch commands are illustrative. Parameter names come from each engine's documentation as of October 2026; parameters may change between versions, so follow the documentation for the version you use. Theoretical upper bounds are estimated with the method of Sections 2 and 3 and do not include communication or scheduling overhead. Public benchmarks are cited with their sources, but their models, hardware, and workloads all differ, so they serve only as an order-of-magnitude reference.

8.1 Small tier: one workstation

Constraints. A team of a dozen or so people uses a coding assistant and document QA internally, and data cannot leave the office. The hardware is a workstation with an RTX 4090 (24 GB), or a Mac with 128 GB of unified memory. No more than 4 people use it at the same time.

Model and precision. Qwen3-30B-A3B with Q4_K_M quantization, a file of about 18.5 GB. The reason is the figure in Section 7: it reads only about 3 billion parameters per token, which on this class of hardware makes it nearly ten times faster than a dense model of the same size.

Memory ledger. On the RTX 4090, about 5 GB remain after the 18.5 GB of weights. Qwen3-30B-A3B has only 96 KB of KV per token (48 layers × 4 KV heads), so a 32K context takes about 3 GB at FP16; quantizing KV to q8_0 halves that to about 1.5 GB. 4 concurrent requests with 8K context each fit exactly. A Mac has ample memory, so you can open up a larger context or switch to a larger model.

Theoretical upper bound. For single-user decode, about 550 tokens/s on the RTX 4090 and about 300 tokens/s on the M4 Max (Section 7). In practice you reach half to 70% of the bound.

Launch configuration.

llama-server -m Qwen3-30B-A3B-Q4_K_M.gguf \
  --gpu-layers all \
  -c 32768 -np 4 \
  -fa on --cache-type-k q8_0 --cache-type-v q8_0 \
  --metrics --host 0.0.0.0 --port 8080

Load test. Measure the raw single-machine speed first, then behavior under concurrency:

# Single user: speed of a 512-token prefill and 128 generated tokens
llama-bench -m Qwen3-30B-A3B-Q4_K_M.gguf -p 512 -n 128 -fa on

# Concurrency: use any load-test tool compatible with the OpenAI API, e.g. NVIDIA AIPerf
aiperf profile --model qwen3-30b-a3b --url http://localhost:8080 \
  --endpoint-type chat --streaming --concurrency 4 --request-count 200

Which metrics to watch. --metrics turns on a Prometheus-compatible metrics endpoint. At this tier I care most about three things: whether single-user generation is fast enough (at least faster than reading speed), whether TTFT grows noticeably under concurrency, and whether any request is truncated because the context is too small.

Common pitfalls.

8.2 Mid tier: one 8-GPU node

Constraints. Internal knowledge QA and a coding assistant for a company, used by several hundred people, with working-hours peak concurrency of about 100–200 requests. Average input is about 4K tokens (including the system prompt and retrieval results) and average output is about 500 tokens. Latency targets: P99 TTFT under 2 seconds, P99 TPOT under 50 ms. The hardware is one 8 × H100 HGX server.

Model and precision. The official FP8 version of Qwen3-235B-A22B. The H100 computes FP8 natively (Section 7), and 235 GB of weights fit comfortably across 8 cards.

Parallelism. The node has NVLink, so use TP=8 for attention and EP=8 for MoE. There are two reasons to use EP rather than also splitting the experts with TP. First, each expert sits whole on one card, so the matrix multiplication shapes are better (Section 6). Second, this model's FP8 weights use 128 × 128 block scaling and the expert intermediate size is 1,536; splitting with TP=8 leaves 192 per card, which is not a multiple of 128, so the block boundaries would be cut. Before choosing a parallelism, check that the split dimensions match the quantization block size.

Memory ledger. Per card:

Item Per card
Attention weights (split by TP=8) About 0.8 GB
Expert weights (EP=8, 16 experts per card) About 28.4 GB
Vocabulary embedding and output layer (BF16, split by TP) About 0.3 GB
Activations and CUDA Graph reserve 5 GB
KV pool (engine uses 90% of memory) About 37.5 GB

The model has only 4 KV heads, so at TP=8 each KV head is stored on two cards (Section 4). With FP8 KV, each token takes about 24 KB of KV per card, and the KV pool holds about 1.56 million tokens: about 190 concurrent requests at an average context of 8K, or about 47 at 32K. This basically meets the peak concurrency demand.

Theoretical upper bound. In decode with 128 requests at an average context of 8K, each card reads about 29.5 GB of weights plus about 25 GB of KV per step, about 16 ms per step, and the theoretical upper bound on whole-node throughput is about 7,800 tokens/s. With the context cut to 2K and the batch raised to 256, the bound is about 20k tokens/s. As an order-of-magnitude reference, in TensorRT-LLM's official published numbers, Llama 3.3 70B (FP8, 2 × H100) reaches a total throughput of about 4,200 tokens/s at 1,000 input and 1,000 output tokens, and Llama 3.1 405B (FP8, 8 × H100) about 3,000 tokens/s[46]. These are dense models that compute far more parameters per token than Qwen3-235B-A22B, so they cannot be compared directly, but they help you judge whether the estimate is in a sensible range.

Launch configuration. How the three engines express it:

# vLLM
vllm serve Qwen/Qwen3-235B-A22B-FP8 \
  --tensor-parallel-size 8 --enable-expert-parallel \
  --max-model-len 32768 --gpu-memory-utilization 0.90 \
  --kv-cache-dtype fp8

# SGLang
python -m sglang.launch_server --model-path Qwen/Qwen3-235B-A22B-FP8 \
  --tp 8 --ep 8 \
  --context-length 32768 --mem-fraction-static 0.85 \
  --kv-cache-dtype fp8_e4m3 --enable-metrics

# TensorRT-LLM
cat > config.yml <<EOF
kv_cache_config:
  dtype: fp8
  free_gpu_memory_fraction: 0.85
  enable_block_reuse: true
EOF
trtllm-serve Qwen/Qwen3-235B-A22B-FP8 --backend pytorch \
  --tp_size 8 --ep_size 8 --max_seq_len 32768 --config config.yml

Prefix caching is on by default in all three engines. In this scenario the system prompt, tool definitions, and retrieval template are highly repetitive, so make sure the prompt puts the stable parts first (Section 4).

What if you only have PCIe machines? With 8 × L40S (48 GB per card, 864 GB/s bandwidth), TP=8 for Qwen3-235B-A22B would pay a large communication cost because there is no NVLink. A more reasonable approach is to switch to the FP8 version of Qwen3-32B, one replica per card, 8 replicas running DP. But after 33 GB of weights, each L40S has only about 5 GB left for KV, so at an average context of 8K each card can serve only about 5 concurrent requests, with TPOT of about 43 ms. The same model on one H100 can serve about 31 concurrent requests with TPOT of about 20 ms. The L40S is cheaper per card, but in this scenario each card carries much less load. Compare options by "goodput per dollar at the SLO"; the price per card tells you little.

Load test. Use a length distribution close to the real one and sweep concurrency:

# vLLM's built-in load-test tool
vllm bench serve --backend vllm --model Qwen/Qwen3-235B-A22B-FP8 \
  --dataset-name random --random-input-len 4096 --random-output-len 512 \
  --num-prompts 2000 --max-concurrency 128

# SGLang's built-in load-test tool; a shared-prefix dataset can simulate system prompt reuse
python -m sglang.bench_serving --backend sglang \
  --dataset-name random --random-input-len 4096 --random-output-len 512 \
  --num-prompts 2000 --max-concurrency 128

Sweep concurrency (for example 16, 32, 64, 128, 256), record throughput and the P50 and P99 of TTFT and TPOT at each level, and draw the throughput-latency curve from Section 1. The highest throughput that meets the SLO is this machine's goodput, which is the TSLO in the cost formula.

Which metrics to watch.

What you want to know vLLM SGLang
Time to first token vllm:time_to_first_token_seconds sglang:time_to_first_token_seconds
Generation pace vllm:inter_token_latency_seconds sglang:inter_token_latency_seconds
Queueing vllm:num_requests_waiting, vllm:request_queue_time_seconds sglang:num_queue_reqs
Requests running vllm:num_requests_running sglang:num_running_reqs
KV pool usage vllm:kv_cache_usage_perc sglang:token_usage
Prefix cache hits vllm:prefix_cache_hits ÷ vllm:prefix_cache_queries sglang:cache_hit_rate

(Metric names are from the official vLLM and SGLang documentation[47].) GPU utilization, memory, power, and NVLink traffic can be collected with NVIDIA's DCGM Exporter and put into Grafana alongside.

Common pitfalls.

8.3 Large tier: multi-node large MoE

Constraints. A platform-level service for the whole company or even external customers, with peaks of several hundred requests per second, using a DeepSeek-V3/R1-class model (671 billion parameters, 671 GB of FP8 weights). At this tier you are building a whole inference system, not deploying a single engine.

Reference architecture. A few public references are worth looking at:

The model versions, hardware, input lengths, and whether cache hits are counted differ across these numbers, so they cannot be compared directly side by side. But the architecture is similar:

Reference architecture for a multi-node large MoE
Figure 8-1: Reference architecture for a multi-node large MoE. The routing layer assigns requests to prefill units by cache hits and load; within a prefill unit, DP-attention plus EP is used, and the finished KV is sent over RDMA to a decode unit; the decode unit is larger and its EP is wider. The KV storage layer keeps reusable prefixes. Each layer needs its own monitoring and scaling policy.

Sizing. First measure the goodput of one prefill unit and one decode unit under the SLO, then set the ratio according to the business's input-to-output ratio. Workloads with long input and short output get more prefill, and the reverse gets more decode. The ratios of DeepSeek and SGLang (4 : 18 and 4 : 9) differ greatly because their workloads differ.

KV transfer. DeepSeek-V3 uses MLA, so FP8 KV is about 34 KB per token, about 144 MB for a request of 4K tokens, which takes about 3 ms over a 400 Gb/s NIC. MLA keeps the transfer cost of PD disaggregation low (Section 4).

Launch configuration (SGLang, illustrative).

# Prefill unit (2 machines, 16 cards; on the second machine change --node-rank to 1)
python -m sglang.launch_server --model-path deepseek-ai/DeepSeek-V3 \
  --disaggregation-mode prefill --disaggregation-transfer-backend mooncake \
  --tp 16 --attn-dp-size 16 --ep 16 \
  --moe-a2a-backend deepep --deepep-mode normal \
  --nnodes 2 --node-rank 0 --dist-init-addr <prefill-0>:5000

# Decode unit (4 machines, 32 cards)
python -m sglang.launch_server --model-path deepseek-ai/DeepSeek-V3 \
  --disaggregation-mode decode --disaggregation-transfer-backend mooncake \
  --tp 32 --attn-dp-size 32 --ep 32 \
  --moe-a2a-backend deepep --deepep-mode low_latency \
  --enable-eplb --ep-num-redundant-experts 32 \
  --nnodes 4 --node-rank 0 --dist-init-addr <decode-0>:5000

# Routing layer
python -m sglang_router.launch_router --pd-disaggregation \
  --prefill http://<prefill-0>:30000 --decode http://<decode-0>:30000 \
  --host 0.0.0.0 --port 8000

Prefill uses DeepEP in normal mode to favor bandwidth, and decode uses low-latency mode to favor per-step speed (Section 6). The decode unit enables EPLB and redundant experts to ease the load imbalance caused by popular experts.

Cost ledger. Applying DeepSeek's published numbers to the formula in Section 1: at $2 per GPU-hour, an 8-GPU machine costs $16 per hour; decode on one machine runs at 14.8k tokens/s, about 53 million tokens per hour. At full load, the decode part costs about $0.30 per million output tokens (prefill is counted separately). Compared with the illustrative ledger in Section 1, a large-scale inference system can bring the unit cost down a lot, provided both TSLO and U are done well enough.

Common pitfalls.

8.4 The tuning loop

The three tiers differ in scale, but the tuning method is the same.

The tuning loop
Figure 8-2: The tuning loop. Set the SLO first, then load-test with a workload close to real traffic, use the metrics to decide which resource the bottleneck falls on, adjust the corresponding parameter, and load-test again. Change only one variable per round.
  1. Set the SLO. The TTFT and TPOT targets and percentiles, and the required attainment rate.
  2. Prepare the load-test workload. Prefer anonymized real traffic; if none is available, at least make the input and output length distributions and the degree of prefix reuse close to reality.
  3. Sweep concurrency and draw the curve. Find the highest throughput that meets the SLO.
  4. Locate the bottleneck from the metrics and adjust the matching parameter:
Symptom Likely bottleneck What to adjust first
High TTFT, long queueing time Insufficient capacity, requests are queueing Raise max concurrency, enlarge the KV pool (KV quantization, higher memory budget), or add replicas
High TTFT, short queueing, long prefill time prefill compute Raise the prefix cache hit rate; consider PD disaggregation; move to higher compute or lower precision
Occasional ITL spikes prefill interrupting decode Lower the per-step token limit (chunked prefill); do PD disaggregation when scale allows
TPOT keeps growing as concurrency rises Memory bandwidth (reading weights and KV) KV quantization; lower max concurrency; add replicas
KV usage stays near 100% and requests get preempted KV capacity Lower max context, KV quantization, weight quantization, add cards
Low GPU utilization, busy CPU Scheduling and CPU overhead Confirm CUDA Graph and overlap scheduling are on; add tokenizer processes
Low prefix cache hit rate Prompt structure or routing Adjust the prompt to put stable content first; use cache-aware routing with multiple replicas
  1. Repeat. Change only one variable per round, and record the configuration and result of each one. Rerun the whole loop after an engine version upgrade.

The loop produces the TSLO in the formula of Section 1; multiply it by the business's actual utilization U and you get the real unit cost.

9. Closing

9.1 A decision checklist

The whole post can be compressed into a set of questions, answered in order. The last column gives the relevant section.

Order Question Section
1 Is the main motivation for self-hosting cost, data compliance, or control? If it is compliance, the question changes from "is it worth it" to "how do we spend the least" Sections 0 and 1
2 What is the business SLO? What are the TTFT and TPOT targets and percentiles? Section 1
3 Does the workload lean toward prefill or decode? What do the distributions of input, output, and context length look like? Sections 2 and 7
4 With the chosen model and precision, how large are the weights? At the target concurrency and context, how much KV is needed? Section 3
5 How many cards are needed? If multi-GPU splitting is needed, is there NVLink? Which parallelism? Sections 4 and 7
6 Can the hardware natively compute the model's release precision? Sections 6 and 7
7 Which engine? Is its support for "this model × this precision × this hardware" mature? Sections 5 and 6
8 Is the prompt structured to benefit from prefix caching? Is speculative decoding needed? Section 4
9 Has scale reached the point of needing PD disaggregation, cache-aware routing, or tiered KV? Sections 4, 5, and 8
10 Is the base environment (drivers, images, fabric manager, RDMA) ready? Section 6
11 Did the load test use a workload close to real traffic? What is the goodput? Section 8
12 How large is the peak-to-trough difference? How can average utilization over the whole day be raised? Section 1

9.2 Summary

This article comes down to three points.

First, do the arithmetic before you build anything. The cost formula in Section 1, the roofline in Section 2, and the memory ledger in Section 3 need only a sheet of paper and public spec sheets. An afternoon spent on them often rules out half of the options that look feasible, and tells you whether a load-test result is plausible when it comes in.

Second, the choice of engine matters less than you might expect, and the serving layer and engineering skill matter more. The four mainstream engines are converging in what they can do, they all expose OpenAI-compatible APIs, switching is cheap, and real projects often switch engines from one model to the next. What separates costs is whether prompts reuse prefixes, whether peaks and troughs are evened out, whether load tests resemble real traffic, and whether a problem can be traced quickly to the layer responsible. More than half of DeepSeek's input tokens hit the cache, so that part of the computation never has to be done.

Third, keep an eye on hardware and precision. Model architectures, precision formats, and hardware generations are moving together, and quickly. Today's best configuration may need to be redone when the next hardware generation arrives. With the layers from Section 6 in mind, you can read the release notes for new hardware, formats, and engines and work out fairly quickly what they mean for your own deployment.

Models will keep getting better and easier to obtain, and what remains is whether you can run them well.

Appendix

A. Formula summary

Purpose Formula Section
Unit cost Cost per million tokens = P ÷ (TSLO × U × 3600) × 106 1.3
Break-even utilization U > P × 106 ÷ (TSLO × 3600 × pAPI) 1.4
Theoretical time t ≈ max(operations ÷ peak compute, bytes moved ÷ memory bandwidth, bytes transferred ÷ interconnect bandwidth) 2.4
Arithmetic intensity I = operations ÷ bytes moved; for a BF16 linear layer, I ≈ number of tokens in this step 2.6
Ridge point Peak compute ÷ memory bandwidth 2.6
decode time per step ≈ (weight bytes + batch × context × KV per token) ÷ memory bandwidth (when bandwidth-bound) 2.7
Single-user decode upper bound ≈ memory bandwidth ÷ weight bytes read per token 7.4
Weight memory Parameter count × bytes per parameter 3.2
KV per token (GQA) 2 × layers × KV heads × dimension per head × bytes per element 3.3
KV per token (MLA) layers × (latent dimension + positional encoding dimension) × bytes per element 3.3
Concurrency limit Number of tokens the KV pool can hold ÷ average context length 3.4
Expected advance per speculative decoding step (1 − αk+1) ÷ (1 − α) 4.3

B. Common parameters across the four engines

Purpose vLLM SGLang TensorRT-LLM llama.cpp
Tensor parallelism --tensor-parallel-size --tp --tp_size --split-mode tensor (experimental)
Pipeline parallelism --pipeline-parallel-size --pp-size --pp_size --split-mode layer (default)
Data parallelism --data-parallel-size --dp Multiple instances Multiple instances
Expert parallelism --enable-expert-parallel --ep --ep_size Not applicable
attention DP --data-parallel-size together with EP --attn-dp-size enable_attention_dp Not applicable
Memory budget --gpu-memory-utilization --mem-fraction-static kv_cache_config.free_gpu_memory_fraction --fit, -c
Max context --max-model-len --context-length max_seq_len -c
Max concurrency --max-num-seqs --max-running-requests max_batch_size -np
Per-step token limit --max-num-batched-tokens --chunked-prefill-size max_num_tokens -b / -ub
KV precision --kv-cache-dtype --kv-cache-dtype kv_cache_config.dtype -ctk / -ctv
Attention backend --attention-backend --attention-backend attention_backend -fa
EP communication backend --all2all-backend --moe-a2a-backend Determined by the MoE backend Not applicable
CUDA Graph On by default; --enforce-eager turns it off On by default; --cuda-graph-max-bs, --disable-cuda-graph cuda_graph_config Used by default on the CUDA backend
Speculative decoding --speculative-config --speculative-algorithm and others speculative_config --spec-type
PD disaggregation KV connector (experimental) --disaggregation-mode trtllm-serve disaggregated Not supported
Metrics /metrics by default --enable-metrics — --metrics
Load-test tool vllm bench serve python -m sglang.bench_serving trtllm-bench llama-bench

(Parameter names follow each engine's documentation as of October 2026 and may change in later versions.)

References

  1. Stanford HAI, AI Index Report 2025, Top Takeaways. https://hai.stanford.edu/ai-index/2025-ai-index-report
  2. Stanford HAI, AI Index Report 2026, Takeaway 2. https://hai.stanford.edu/ai-index/2026-ai-index-report
  3. deepseek-ai/DeepSeek-V4-Flash config.json: expert_dtype: "fp4", quantization_config: {quant_method: "fp8", fmt: "e4m3", weight_block_size: [128, 128]}. https://huggingface.co/deepseek-ai/DeepSeek-V4-Flash
  4. Kwon et al., Efficient Memory Management for Large Language Model Serving with PagedAttention, SOSP 2023. Compared against FasterTransformer and Orca.
  5. deepseek-ai/DeepInfer README, "Required for a complete inference service (not included in this release)". https://github.com/deepseek-ai/DeepInfer
  6. Zhong et al., DistServe: Disaggregating Prefill and Decoding for Goodput-optimized Large Language Model Serving, OSDI 2024.
  7. vLLM documentation, Architecture Overview, V1 Process Architecture. https://docs.vllm.ai/en/stable/design/arch_overview/
  8. TensorRT-LLM documentation, Architecture Overview (PyExecutor). https://github.com/NVIDIA/TensorRT-LLM/blob/main/docs/source/torch/arch_overview.md
  9. vLLM source vllm/v1/core/sched/scheduler.py, comment in schedule(): "There's no 'decoding phase' nor 'prefill phase' in the scheduler"; for chunked prefill being enabled by default, see the vLLM documentation Optimization and Tuning.
  10. NVIDIA H100 Tensor Core GPU Datasheet. BF16 dense 989 TFLOPS (sparse 1,979), HBM3 3.35 TB/s, NVLink 900 GB/s (bidirectional total).
  11. Qwen/Qwen3-32B config.json: num_hidden_layers: 64, hidden_size: 5120, num_attention_heads: 64, num_key_value_heads: 8, head_dim: 128, intermediate_size: 25600. The parameter count computed from the config is about 32.76 billion.
  12. deepseek-ai/DeepSeek-V3 config.json: num_hidden_layers: 61, kv_lora_rank: 512, qk_rope_head_dim: 64, qk_nope_head_dim: 128, v_head_dim: 128, num_attention_heads: 128.
  13. SGLang documentation, Hyperparameter Tuning: "reserving 5–8 GB of memory for activations is typically sufficient".
  14. vLLM Engine Arguments and CacheConfig; SGLang Server Arguments; llama.cpp tools/server/README.md and docs/multi-gpu.md; TensorRT-LLM KV Cache and LLM API configuration documentation.
  15. Yu et al., Orca: A Distributed Serving System for Transformer-Based Generative Models, OSDI 2022.
  16. Agrawal et al., Taming Throughput-Latency Tradeoff in LLM Inference with Sarathi-Serve, OSDI 2024.
  17. vLLM documentation, design notes on Automatic Prefix Caching. https://docs.vllm.ai/en/latest/design/prefix_caching/
  18. Zheng et al., SGLang: Efficient Execution of Structured Language Model Programs, NeurIPS 2024.
  19. Patel et al., Splitwise: Efficient Generative LLM Inference Using Phase Splitting, ISCA 2024.
  20. Qin et al., Mooncake: A KVCache-centric Disaggregated Architecture for LLM Serving, FAST 2025.
  21. DeepSeek, DeepSeek-V3 / R1 Inference System Overview, 2025. https://github.com/deepseek-ai/open-infra-index
  22. Kwon et al., Efficient Memory Management for Large Language Model Serving with PagedAttention, SOSP 2023.
  23. Leviathan et al., Fast Inference from Transformers via Speculative Decoding, ICML 2023; Chen et al., Accelerating Large Language Model Decoding with Speculative Sampling, 2023.
  24. Speculative Decoding documentation of vLLM, SGLang and TensorRT-LLM; llama.cpp docs/speculative.md.
  25. vLLM README and documentation (docs.vllm.ai); SGLang README and documentation (docs.sglang.io); TensorRT-LLM README, Support Matrix, and Release Notes (nvidia.github.io/TensorRT-LLM); llama.cpp README; Hugging Face blog GGML and llama.cpp join HF (2026-02-20); Ollama blog Multimodal models; LM Studio documentation.
  26. LMSYS Org, Deploying DeepSeek with PD Disaggregation and Large-scale Expert Parallelism on 96 H100 GPUs, 2025-05-05. https://lmsys.org/blog/2025-05-05-large-scale-ep/
  27. TensorRT-LLM Release Notes, versions 1.0 and 1.2. https://nvidia.github.io/TensorRT-LLM/latest/release-notes.html
  28. QbitAI, republished by 36Kr, DeepSeek's open source release is incredibly well-received, vLLM and SGLang have overtaken its performance overnight, 2026-10-26. All performance figures in the article are self-reported by the projects. https://eu.36kr.com/en/p/4042588576404358
  29. READMEs of SGLang Model Gateway (sgl-project/sglang), vLLM production-stack, llm-d, NVIDIA Dynamo, Mooncake, LMCache, and NIXL.
  30. NVIDIA, NVIDIA Hopper Architecture In-Depth; Hopper Tuning Guide; NVIDIA H100 Datasheet.
  31. NVIDIA Technical Blog, Introducing NVFP4 for Efficient and Accurate Low-Precision Inference.
  32. NVIDIA A100, L40S, H100, and GB200 NVL72 product spec pages; CUDA GPUs (compute capability list).
  33. DeepSeek-AI, DeepSeek-V3 Technical Report, 2024, §3.3 and §3.5.2. https://arxiv.org/abs/2412.19437
  34. NVIDIA CUTLASS documentation, Blackwell Functionality (block-scaled tcgen05.mma).
  35. Dao et al., FlashAttention: Fast and Memory-Efficient Exact Attention with IO-Awareness, NeurIPS 2022.
  36. Shah et al., FlashAttention-3: Fast and Accurate Attention with Asynchrony and Low-precision, 2024. https://arxiv.org/abs/2407.08608
  37. FlashAttention-4, 2026. https://arxiv.org/abs/2603.05451
  38. deepseek-ai/FlashMLA README. https://github.com/deepseek-ai/FlashMLA
  39. deepseek-ai/DeepGEMM README. https://github.com/deepseek-ai/DeepGEMM
  40. deepseek-ai/DeepEP README (v1.2.1 and the main branch). https://github.com/deepseek-ai/DeepEP
  41. AMD ROCm documentation (GPU architecture specs, Precision support) and ROCm/aiter, ROCm/rccl; AWS Neuron documentation (Trainium2, Trainium3).
  42. LMSYS Org, Deploying DeepSeek on GB200 NVL72, Part 1 (2025-06-16) and Part 2 (2025-09-25). https://lmsys.org/blog/2025-06-16-gb200-part-1/ ; https://lmsys.org/blog/2025-09-25-gb200-part-2/
  43. Qwen/Qwen3-30B-A3B config.json: 48 layers, hidden size 2048, 32 query heads and 4 KV heads, 128 experts with 8 selected per token, expert intermediate size 768. Computed from the config, total parameters are about 30.5 billion, and about 3 billion are read per token (including the output layer).
  44. llama.cpp GitHub Discussions #4167 (Apple Silicon) and #15013 (CUDA), llama-bench tg128 results.
  45. NVIDIA RTX PRO 6000 Blackwell and DGX Spark product pages; Apple M4 Max and M3 Ultra press releases. RTX 4090 bandwidth is taken as the 1,008 GB/s published by NVIDIA.
  46. TensorRT-LLM documentation, Performance Overview (v0.21 benchmarks). https://nvidia.github.io/TensorRT-LLM/performance/perf-overview.html
  47. vLLM documentation Metrics; SGLang documentation Production Metrics.
  48. vLLM blog, Large Scale Serving: DeepSeek @ 2.2k tok/s/H200 with Wide-EP, 2025-12-17. https://vllm.ai/blog/2025-12-17-large-scale-serving