Debarshi Das

Explainer

Disaggregated prefill and decode on NVIDIA GPUs

How disaggregated prefill and decode works on NVIDIA GPUs: what the KV-cache handoff costs over NVLink and RDMA, how Dynamo and NIXL move it, and when not to split.

By Debarshi Das. Published . Updated .

21 min read

  • LLM inference
  • Disaggregated serving
  • NVIDIA Dynamo
  • KV cache
  • GPU infrastructure

Disaggregated prefill and decode splits one inference request across two groups of GPUs. One group reads the prompt and builds the key-value (KV) cache. A second group receives that cache and generates the answer token by token. The design pays off when the latency it removes is worth more than the cost of moving the cache between the two groups. On NVIDIA systems, the network topology sets that cost, and so decides whether the split is worth it.

This essay explains the trade in the order an infrastructure team meets it: why the two phases want different machines, what the handoff costs in bytes and milliseconds, how NVLink, InfiniBand, and RoCE (RDMA over Converged Ethernet, where RDMA is remote direct memory access) change that cost, and which parts of the NVIDIA stack do the work. It also covers four consequences that get too little attention:

  • whether the handoff can hide behind prefill depends on one ratio that does not change with prompt length;
  • grouped-query and latent attention, not serving frameworks, made the handoff cheap enough to split;
  • the prefill-to-decode ratio is also a fan-in ratio, so incast decides tail latency on the network;
  • a failed decode worker turns into a burst of prefill work that the prefill pool must absorb.

The worked example is Llama 3.1 70B in BF16, which has the same architecture as Llama 3 70B.

Why prefill and decode want different machines

Every request runs in two phases. Prefill processes the whole prompt at once, so the GPU runs large matrix multiplications that keep its tensor cores busy. Prefill sets the time to first token (TTFT).

Decode produces the output one token at a time. Each step reads the model weights and the growing KV cache to make one new token per request. That work moves far more bytes than it computes on, so memory bandwidth limits it. Decode sets the inter-token latency (ITL), which some tools call time per output token.

The usual summary is that prefill is compute-bound and decode is memory-bound. It is a good first approximation, not a law: large decode batches raise arithmetic intensity, short prompts make prefill cheap, and mixture-of-experts models and quantization move the balance again. Treat it as a reason to measure.

The practical problem appears when both phases share the same GPUs. A long prefill that arrives in the middle of a decode batch delays every token in that batch.

A shared server holds a full 8,192-token prompt cache in blue beside its decode batch, stopped in ember; 292 ms.Hover a part to see its name
One server runs both phases. While it prefills an 8,192-token prompt, about 292 ms on eight H100 GPUs by the estimate below, every answer in its decode batch stops.

Chunked prefill reduces the problem: it splits a long prompt into pieces and mixes them with decode steps. Disaggregation removes the interference: it puts the phases on separate workers.

What disaggregation changes, and what it does not

Each phase gets its own pool. Prefill workers can use a parallelism layout that minimizes TTFT; decode workers can use another layout and large batches that maximize tokens per second at a target ITL. The two pools scale independently.

Two stacks of GPU servers on plinths named PREFILL and DECODE, three servers and five, and a screen that reads 3 : 5.Hover a part to see its name
One fleet of GPU servers in two pools. Where the split sits is a decision you now own, and your traffic decides the right place.

DistServe (OSDI 2024) optimized for goodput, the request rate served within both the TTFT and the ITL targets. It reports up to 7.4 times more requests, or a 12.6 times tighter latency target, than the systems it compared against. Splitwise (ISCA 2024) ran the phases on different hardware: 1.4 times the throughput at 20 percent lower cost. Mooncake, the serving system behind Kimi, built its design around the KV cache as the object that moves. Each team measured its own systems, so read these as evidence that the idea works, not as a forecast for your fleet. By late 2025, the DistServe authors wrote that almost every production-grade serving framework had adopted disaggregation in some form.

Disaggregation does not raise raw throughput by itself. The vLLM documentation says so plainly: "Disaggregated prefill DOES NOT improve throughput." Its benefits are separate tuning of TTFT and ITL, and tighter control of tail ITL. The right goal is throughput at a latency target.

The handoff: how large the KV cache is

Every disaggregated request ends prefill with a KV cache that must reach a decode worker. Its size follows from the model:

KV bytes per token=2×layers×KV heads×head dimension×bytes per element\begin{aligned} \text{KV bytes per token} &= 2 \times \text{layers} \times \text{KV heads} \\ &\quad \times \text{head dimension} \times \text{bytes per element} \end{aligned}

The 2 counts keys and values. Llama 3.1 70B has 80 layers, 8 KV heads through grouped-query attention, and a head dimension of 128. In BF16, at 2 bytes per element, that is 327,680 bytes per token, or 320 KiB; FP8 halves it. KV cache size per token shows where this formula breaks for newer models.

Prefill and decode GPU boards joined by one 400G cable; a 2.5 GiB KV cache in eight slices rests on the decode tray; 54 ms.Hover a part to see its name
Prefill builds the KV cache of an 8,192-token prompt, one slice per 1,024 tokens, to 2.5 GiB. The whole cache then crosses one 400 Gb/s link to the decode GPU: 54 ms at line rate.

The times below are line-rate floors with no protocol overhead, computed as in the KV essay: 450 GB/s per direction for NVLink 4 on Hopper, 50 GB/s per 400 Gb/s network interface card (NIC), and 400 GB/s for eight NICs, one per GPU.

Prompt tokensKV cache, BF16NVLink 41 x 400G8 x 400G
2,0480.625 GiB1.5 ms13 ms1.7 ms
8,1922.5 GiB6.0 ms54 ms6.7 ms
32,76810 GiB24 ms215 ms27 ms
128,00039.1 GiB93 ms839 ms105 ms

A DGX B200 has eight ConnectX-7 NICs at 400 Gb/s. Blackwell's NVLink 5 gives each GPU 1.8 TB/s, about 900 GB/s each way: about 3 ms for the 8,192-token cache. Mooncake cites about 40 GB for 128k tokens on Llama 3 70B, which matches the last row. The KV cache calculator computes these rows for any model, context, and link.

Measurements agree. The Mooncake Transfer Engine reports up to 87 GB/s over four 200 Gb/s RoCE links and up to 190 GB/s over eight 400 Gb/s links. In an older DistServe example, one 512-token request on OPT-66B carries about 1.13 GB, so ten per second need about 90 Gb/s.

Against a TTFT budget of a few hundred milliseconds, 6 to 7 ms is small; 54 ms, or 215 ms for 32,768 tokens over one NIC, is not. Under load, many requests share the same links. Three techniques shrink the visible cost. An FP8 cache halves the bytes. Layer-wise transfer sends each layer's cache while prefill computes the next; Splitwise reports about 5 ms left without overlap on H100. Larger blocks help: Dynamo's tuning guide suggests 128 tokens for dense models, because small blocks make small transfer chunks.

A ratio that does not depend on prompt length

Can the handoff hide completely behind prefill? The answer is a property of the model and the hardware, not of the prompt. Both costs grow with the number of prompt tokens, nn: prefill does roughly 2 floating-point operations per parameter per token, and the handoff moves a fixed number of KV bytes per token. Divide one by the other and nn cancels out:

prefill time≈n×2×parameterseffective FLOPShandoff time=n×KV bytes per tokenbandwidthhandoff timeprefill time≈KV bytes per token×effective FLOPS2×parameters×bandwidth\begin{aligned} \text{prefill time} &\approx n \times \frac{2 \times \text{parameters}}{\text{effective FLOPS}} \\ \text{handoff time} &= n \times \frac{\text{KV bytes per token}}{\text{bandwidth}} \\ \frac{\text{handoff time}}{\text{prefill time}} &\approx \frac{\text{KV bytes per token} \times \text{effective FLOPS}}{2 \times \text{parameters} \times \text{bandwidth}} \end{aligned}

Attention adds work that grows faster than linearly for long prompts, which only makes prefill slower and the ratio more favorable.

Take public specifications: eight H100 GPUs at 989 dense BF16 TFLOPS each. I assume 50 percent model FLOPS utilization. Prefill of Llama 3.1 70B then runs at about 28,000 tokens per second: 292 ms for 8,192 tokens. With a BF16 cache, the transfer takes about 2 percent of prefill time over eight 400 Gb/s NICs, and about 18 percent over one. For DeepSeek-V3 over eight NICs it is about 1 percent. That counts only its activated parameters, about 37 billion, because a mixture-of-experts model computes with only those. Its FP8 weights, about 671 GB, do not fit in eight 80 GB H100s; eight H200s hold them with the same compute per GPU, so the ratio does not change.

Prefill and decode GPUs joined by one 400G cable, each with a full 80-layer KV cache column; screen reads +0.7 ms.Hover a part to see its name
Layer-wise transfer over one 400 Gb/s link. Each of the 80 layers takes 3.65 ms to compute and 0.67 ms to send, so the decode GPU has the whole cache 0.7 ms after a 292 ms prefill ends.

Below 100 percent, layer-wise transfer can in principle finish inside prefill and add almost nothing to TTFT. A team then needs one number per model and hardware pair, not a budget per prompt length, plus a check that the transfer is pipelined. This analysis is mine; it ignores queueing and protocol overhead.

Attention design made disaggregation practical

The same arithmetic shows why disaggregation arrived when it did: KV bytes per token depend on how the model stores attention, and that design changed. The table gives the handoff of 8,192 tokens over one 400 Gb/s NIC, and the ratio above for that NIC.

DesignExampleBytes per token, BF168,192 tokensHandoff / prefill
Multi-head (MHA)70B-class, 64 KV heads2,621,440 (2.5 MiB)430 ms147%
Grouped-query (GQA)Llama 3.1 70B, 8 KV heads327,680 (320 KiB)54 ms18%
Multi-head latent (MLA)DeepSeek-V370,272 (69 KiB)11.5 ms7.5%

GQA is 8 times smaller than MHA, and MLA 37 times. The MHA row is hypothetical: Llama 3.1 70B with a KV head for each of its 64 query heads. At 147 percent the transfer can never hide behind compute. DeepSeek-V3 stores one compressed row of 576 values per layer across 61 layers, and its ratio counts its activated parameters.

One token of KV cache at one scale: 64 head columns for MHA, a row of 8 for GQA, one column for MLA. Screen: MLA 12 ms.Hover a part to see its name
One token's KV cache under the three designs, each to scale by its bytes: every head, eight shared heads, one compressed vector. The corner time is an 8,192-token prompt over one 400 Gb/s NIC.

The papers and frameworks of 2024 and 2025 did not make disaggregation cheap on their own: model architects had already shrunk the object that moves. To evaluate a new model, start with KV bytes per token, which compares twelve model types side by side. For many models released since 2024, the formula above is only the first answer.

There are two very different places to put the cut. Inside an NVLink domain, GPUs read and write each other's memory at NVLink speed. In an HGX or DGX server, the domain is the eight GPUs in the box. A GB200 NVL72 rack joins 72 Blackwell GPUs in one domain with 130 TB/s of aggregate bandwidth, so prefill and decode groups in one rack hand off at NVLink speed, even across trays. That is the main reason rack-scale NVLink matters here.

Outside the domain, the handoff crosses the scale-out network, usually InfiniBand or RoCE through ConnectX NICs. GPUDirect RDMA lets the NIC read the cache straight from GPU memory, with no copy through host memory. It works only when drivers and memory registration are right, and when the GPU and the NIC share the same upstream PCIe root complex, which NVIDIA's documentation requires. Without RDMA, the transfer falls back to TCP; the last section shows the cost.

DistServe's placement makes the same point: with a fast cross-node network it places instances freely, and without one it keeps each prefill instance and its decode instance on one node, on NVLink. The topology decides the architecture as well as the speed.

Disaggregation also creates incast, a pattern that scale-out networks handle poorly. With several prefill workers per decode worker, several can finish at once and push their caches to the same decode node. Four 8,192-token caches carry about 10.7 GB; even across eight 400 Gb/s NICs, that burst occupies the links for about 27 ms, and later arrivals queue.

Four prefill servers sent KV caches to one decode port: one cache is at the port, three wait behind it in ember.Hover a part to see its name
Incast at one decode port. Caches from prefill servers that finish together queue, and the last waits for all the others: four 8,192-token caches over eight 400 Gb/s NICs.

So the prefill-to-decode ratio is also a fan-in ratio. On RoCE, congestion control, explicit congestion notification (ECN) marking, and priority flow control (PFC) pause behavior decide the tail latency. InfiniBand's credit-based flow control behaves differently but still queues. Size the fabric for the burst at the decode NIC, not for the cluster's average. Spreading handoffs across decode workers in the router helps as much as more bandwidth. Inside an NVL72 rack, the NVLink switch fabric absorbs the fan-in. In practice:

  • Measure the bandwidth your application achieves, not the switch's line rate.
  • Check that each GPU uses the NIC closest to it on the PCIe tree; a mismatch forces traffic through a slower path.
  • Treat InfiniBand and RoCE as configurations to measure: achieved bandwidth, congestion behavior, and tail latency matter more than the fabric's name.

Who does what in the NVIDIA stack

From the top down:

  • Dynamo: orchestration and routing. An open-source distributed serving framework above the engines; it does not run the model. Its KV-aware router sends each request to the worker that will recompute the least. Its Planner scales the prefill pool on queued tokens and the decode pool on KV-cache use, against TTFT and ITL targets. Its KV Block Manager offloads blocks to host memory, local disk, and object storage.
  • Engines: TensorRT-LLM, vLLM, and SGLang. The engine runs the model on each worker; Dynamo supports all three.
  • KV connectors. The engine hands the finished cache to a connector. vLLM's include NixlConnector, LMCacheConnectorV1, and MooncakeConnector; with NixlConnector, the decode worker pulls the blocks from the prefill worker over RDMA after a short handshake. SGLang offers Mooncake and NIXL as transfer engines; TensorRT-LLM uses NIXL over UCX by default.
  • NIXL, the transfer library. The NVIDIA Inference Xfer Library is "targeted for accelerating point to point communications in AI inference frameworks." It gives one interface over GPU memory, CPU memory, and storage through plugins such as UCX, GPUDirect Storage, and libfabric, and picks a backend from the source and destination memory types.
  • Transport and hardware. NVLink, or InfiniBand or RoCE with GPUDirect RDMA. On NVL72 racks, SGLang's Mooncake engine can also use multi-node NVLink.
Six layer boards named LINK up to DYNAMO, every status lamp lit blue, and the KV cache at the bottom on the link.Hover a part to see its name
Six layers: Dynamo routes and plans, the engine runs the model, the connector hands off the cache, NIXL chooses how it moves, and the transport and the link carry the bytes.

In vLLM, a minimal split is two engines and a proxy. This example follows the multi-instance setup in the NixlConnector usage guide for vLLM v0.31.0 (opens in a new tab). The guide uses Qwen/Qwen3-0.6B; this example swaps in Llama 3.1 70B and keeps every other setting.

Bash
# vLLM v0.31.0. Prefill engine on machine A: it produces KV caches.
VLLM_NIXL_SIDE_CHANNEL_HOST=${IP_A} \
VLLM_NIXL_SIDE_CHANNEL_PORT=5600 \
UCX_NET_DEVICES=all \
vllm serve meta-llama/Llama-3.1-70B-Instruct --port 8000 \
  --tensor-parallel-size 8 \
  --kv-transfer-config '{
    "kv_connector": "NixlConnector",
    "kv_role": "kv_producer",
    "kv_load_failure_policy": "fail"
  }'

# Decode engine on machine B: it reads the KV caches over RDMA.
VLLM_NIXL_SIDE_CHANNEL_HOST=${IP_B} \
VLLM_NIXL_SIDE_CHANNEL_PORT=5600 \
UCX_NET_DEVICES=all \
vllm serve meta-llama/Llama-3.1-70B-Instruct --port 8000 \
  --tensor-parallel-size 8 \
  --kv-transfer-config '{
    "kv_connector": "NixlConnector",
    "kv_role": "kv_consumer",
    "kv_load_failure_policy": "fail"
  }'

# Test proxy from the vLLM repository: prefill first, then decode.
python tests/v1/kv_connector/nixl_integration/toy_proxy_server.py \
  --port 8192 \
  --prefiller-hosts ${IP_A} --prefiller-ports 8000 \
  --decoder-hosts ${IP_B} --decoder-ports 8000

The side-channel port carries the NIXL handshake. The policy fail fails a request whose cache does not load, instead of prefilling it again on the decode engine. In production, a router such as Dynamo's replaces the test proxy.

One constraint runs through every layer: Dynamo requires prefill and decode workers to use the same model, data type, block size, and KV layout, because decode reads the blocks exactly as prefill wrote them. In short, NIXL picks a transport for each move, and Dynamo coordinates the engines that run the model.

Routing, prefix reuse, and multi-turn conversations

On a conversation's next turn, the most useful cache is on the decode worker. A naive design recomputes that history on a prefill worker.

A router sent the next turn of conversation 5 to the decode worker; it sits on top of its blue 8,192-token cache.Hover a part to see its name
A KV-aware router sends the next turn to the decode worker that already holds its history, so no prefill worker recomputes it. A longer history saves more work.

A router that knows where prefixes live can send a request to its cache, or move only the missing part. vLLM v0.31.0 adds the second option to NixlConnector: with bidirectional_kv_xfer set and a stateful proxy, the prefill worker pulls the earlier turns' blocks from the decode worker over RDMA and computes only the new tokens.

Three shared blocks stored once, with request A and request B each going on from them on their own blocks.Hover a part to see its name
Prefix reuse: two requests that start the same share their first KV blocks, and that part is not computed again. A system prompt that thousands of requests share works the same way.

Measure the prefix-cache hit rate before and after any change to routing: a split that destroys cache locality can lose more than it gains.

Sizing the prefill and decode pools

There is no universal ratio between prefill and decode workers. Long prompts need more prefill capacity, and long answers more decode capacity. Arrival rate and burstiness set each pool's headroom. A strict TTFT target needs spare prefill capacity; a strict ITL target limits decode batch size.

Memory also bounds a decode pool, because a decode worker holds each request's cache until its answer ends. Take an eight-GPU H100 server that serves Llama 3.1 70B in BF16 with tensor parallelism of 8: each GPU holds one eighth of the weights, 16.4 GiB, and one of the 8 KV heads of each request. With vLLM's default memory share, 0.92 in v0.31.0, the server holds at most 181 requests of 8,192 tokens at once, or 45 of 32,768 tokens, before activations and CUDA graph buffers.

One H100 of a decode server holds weights and 45 requests of 32,768 tokens under the 92% line; one more waits in ember.Hover a part to see its name
One of eight GPUs in a decode server for Llama 3.1 70B. After its share of the weights, 45 requests of 32,768 tokens fit under vLLM's 92 percent line, and the next one waits.

Each pool can use its own parallelism: prefill often gains from more tensor parallelism, decode from more replicas with large batches. Check that the engine and connector support your model architecture, KV-cache data type, and block size. Traffic shifts during the day, so a planner that moves workers between pools beats a fixed ratio.

Failure: a lost decode worker becomes a prefill storm

When a decode worker fails, every request it served must fail or return to the prefill pool and rebuild its cache from the prompt and the tokens generated so far.

A failed decode worker, empty with an ember fault ring, and its 300 lost KV caches piled in ember on the prefill worker.Hover a part to see its name
A decode worker fails. Every KV cache it held is gone, and each conversation returns to the prefill pool at once to be rebuilt from its full history.

That traffic lands at once on a pool sized for normal arrivals. A decode worker with 300 conversations of 8,192 tokens holds about 2.5 million tokens of context: at the prefill rate estimated above, close to 90 seconds of work for one prefill worker. New requests miss their TTFT targets while the backlog clears. Offloading KV blocks to host memory or storage, as Dynamo's KV Block Manager can, gives a copy to restore instead of recomputing. Either way, size prefill headroom for steady traffic plus the largest decode worker you can lose. A planner that scales down without draining in-flight requests causes the same storm on purpose; check how yours retires a worker.

How to benchmark disaggregated serving

Compare disaggregated serving against a well-tuned aggregated baseline with chunked prefill, on the same hardware and the same traffic.

A shared server holds a full 8,192-token prompt cache built in chunks beside a decode batch that kept growing; 36 ms.Hover a part to see its name
The baseline to beat: the first figure's server with chunked prefill. The prompt goes in 1,024-token chunks, one per decode step: about 36 ms of prefill in each step, and no 292 ms stop.

Report at least:

  • TTFT and ITL at p50, p95, and p99.
  • Goodput: the request rate served within both latency targets.
  • Achieved KV-transfer bandwidth in GB/s, and transfer time per request.
  • Queueing delay and GPU utilization in each pool.
  • Prefix-cache hit rate.

Use a realistic mix of prompt and output lengths. One fixed prompt length hides the case where disaggregation matters most: a long prompt that arrives while many short conversations are decoding.

What the published numbers say

The headline results come mostly from vendors, and each depends on its conditions. Read them as upper bounds on favorable workloads.

SourceModel and hardwareConditionsReported gainBasis
NVIDIA, Dynamo launch, March 2025DeepSeek-R1 on GB200 NVL72TensorRT-LLM, FP4 weights, 32K input, 8K output tokensUp to 30 times more requestsVendor result
NVIDIA, Dynamo launch, March 2025Llama 70B on HoppervLLM, FP8, 3K input, 50 output tokensMore than twice the throughputVendor result
NVIDIA blog, June 2025DeepSeek-R1 on GB200 NVL72Simulated, not measuredUp to 6 times the throughputGPU performance simulator
TensorRT-LLM teamDeepSeek-R1 on GB2004,400 input, 1,200 output tokens1.4 to 1.8 times, more with multi-token predictionVendor result
SemiAnalysisDeepSeek-R1 in FP4, GB200 NVL72 vs B200Dynamo and TensorRT-LLM, 125 tokens per second per user4.39 times the throughput per GPUIndependent measurement

SemiAnalysis attributes its result largely to the larger NVLink domain. The pattern is consistent: the largest gains come with long prompts, large mixture-of-experts models, and a big NVLink domain, exactly where the handoff is cheap and the interference is expensive.

When not to disaggregate

Treat disaggregation as an option to measure. NVIDIA's Dynamo documentation puts it directly: "For small models, short prompts, low concurrency, or clusters without a fast KV-transfer fabric, an aggregated deployment is simpler and often faster." Keep an aggregated deployment when:

  • Prompts are short, so prefill rarely disrupts decode. Dynamo's tuning guide notes that prefill runs inefficiently below roughly 1,000 input tokens.
  • Load is low, so there is little interference to remove.
  • Chunked prefill already keeps tail ITL inside your target.
  • The handoff must cross a slow or poorly configured network.
  • The team cannot yet operate two pools, a router, and a transfer path, and debug failures across all of them.

The network case is the sharpest. Dynamo's RDMA guide says that TCP over Ethernet is 200 to 500 times slower for this transfer: roughly 98 s to first token on TCP against 200 to 500 ms with RDMA.

A KV cache has crossed to the decode GPU over RDMA; the same cache over TCP waits at the prefill card in ember. 98 s.Hover a part to see its name
The same KV cache on two paths: over RDMA it has reached the decode GPU, and over TCP it has barely left.

Disaggregated serving is worth it when moving the KV cache costs less than letting prefill and decode interfere with each other. On NVIDIA hardware, the topology sets the price of that move.

Questions engineers ask

What is the difference between prefill and decode?

Prefill processes the whole prompt in one parallel pass and builds the KV cache; it sets the time to first token. Decode then generates the output one token at a time from that cache; it sets the time between tokens.

Is disaggregated inference the same as disaggregated serving?

In practice, yes: both mean prefill and decode on separate workers, with the KV cache moved between them. Papers often call it P/D disaggregation.

Does disaggregation need InfiniBand?

No. It needs a fast path for the KV cache: NVLink inside a server or an NVL72 rack, and InfiniBand or RoCE with GPUDirect RDMA across racks. What matters is the bandwidth you achieve and how stable it is under load.

Is chunked prefill an alternative?

Yes. It keeps both phases on the same GPUs and interleaves them, is simpler to operate, and is often good enough. Disaggregation isolates tail latency better, at the cost of a transfer path and a second pool.

References

Choose a style to copy