Education › OSS Deep Dives › Stage 4: LLM inference infrastructure

NVIDIA Dynamo: distributed inference

Disaggregated prefill and decode, KV-aware routing, KV cache offload and the planner — serving LLMs across a datacenter.

Advanced ~35 min read Module 10 of 10

vLLM, SGLang and TensorRT-LLM make one GPU, or one node, serve a model well. NVIDIA Dynamo (ai-dynamo/dynamo, Apache-2.0, Rust core with Python extensions) is the layer above them: it turns a cluster of engine workers into one coordinated inference system. This lesson explains the problems that only appear at multi-node scale, and the four ideas Dynamo applies to them: KV-aware routing, disaggregated prefill and decode, tiered KV cache, and an SLA-driven planner. It also shows how to run it, from one container to Kubernetes, and when you do not need it.

After this module you can
  • Explain why naive load balancing wastes prefill work across LLM replicas
  • Describe disaggregated serving and the KV transfer it depends on
  • Run a Dynamo frontend with vLLM workers, aggregated and disaggregated
  • Explain what the KV Block Manager and the Planner add
  • Decide when an engine alone is enough and when Dynamo pays off

Problems that appear at cluster scale

Put ten vLLM replicas behind a round-robin load balancer and three problems show up. First, wasted prefill: a multi-turn conversation's next message lands on a replica that has never seen it, so the whole history is prefilled again, even though another replica holds that exact prefix in its KV cache. Second, interference: prefill is compute-heavy and bursty, decode is memory-bandwidth-bound and steady, and mixing them on the same GPU makes long prompts stall everyone else's token stream. Third, static sizing: the right number of GPUs for prefill versus decode changes with traffic, prompt lengths and output lengths throughout the day.

Dynamo addresses these without replacing the engine. Its README is explicit: it does not replace SGLang, TensorRT-LLM or vLLM; it coordinates them. If you run one model on one GPU, the engine alone is probably enough.

ComponentRole
FrontendOpenAI-compatible HTTP server (port 8000 by default); tokenizes and forwards
RouterChooses a worker per request, optionally by KV cache overlap and load
WorkersEngine processes (vLLM, SGLang, TensorRT-LLM), aggregated or split into prefill and decode
NIXLTransfer library that moves KV cache between GPUs and nodes over NVLink, RDMA or storage
KVBMKV Block Manager: offloads cache from GPU to CPU memory, SSD and remote storage
PlannerAutoscaler that sizes prefill and decode pools to meet latency targets

KV-aware routing

Workers publish KV events: which cache blocks they hold, keyed by hashes of token prefixes. The router keeps a global index and, for each request, scores workers by how much of the prompt they already have cached and how loaded they are, then sends the request where the least new prefill is needed without overloading anyone. A returning conversation, an agent loop that re-sends a long tool transcript, or many users sharing one long system prompt all benefit, and the visible gain is lower time to first token.

Frontend with KV-aware routing and two aggregated vLLM workers (inside a Dynamo vLLM runtime container)
bash
export MODEL_ID=YOUR_ORG/YOUR_MODEL

python3 -m dynamo.frontend --http-port 8000 --router-mode kv &

CUDA_VISIBLE_DEVICES=0 python3 -m dynamo.vllm --model "$MODEL_ID" &
CUDA_VISIBLE_DEVICES=1 python3 -m dynamo.vllm --model "$MODEL_ID" &
wait

Clients call http://localhost:8000/v1/chat/completions exactly as they would call vLLM. On Kubernetes, the same routing logic can run inside the standard Gateway API Inference Extension as an endpoint picker, so a cluster gateway makes KV-aware choices.

Disaggregated prefill and decode

Disaggregated serving runs prefill and decode on separate pools of GPUs. A request is prefilled on a prefill worker, its KV cache is transferred to a decode worker, and the decode worker streams the tokens. Each pool can be sized and configured for its own bottleneck, for example more parallelism for prefill and larger batches for decode, and long prompts no longer stall token streams.

requestrouteKV via NIXLoffloadstream tokensscale poolsClientOpenAI APIRouterfrontend, KV-awarePrefill workerprefill poolDecode workerdecode poolKVBMCPU, SSD, remotePlannerTTFT, ITL targets
Dynamo's router picks a prefill worker by cached prefix and load; the prefill worker computes the KV cache and hands it to a decode worker over NIXL, which streams the tokens.
One decode worker and one prefill worker, KV moved with NIXL (from the repo's vLLM disagg example)
bash
python3 -m dynamo.frontend &

CUDA_VISIBLE_DEVICES=0 python3 -m dynamo.vllm --model "$MODEL_ID" \
  --disaggregation-mode decode \
  --kv-transfer-config '{"kv_connector":"NixlConnector","kv_role":"kv_both"}' &

CUDA_VISIBLE_DEVICES=1 python3 -m dynamo.vllm --model "$MODEL_ID" \
  --disaggregation-mode prefill \
  --kv-transfer-config '{"kv_connector":"NixlConnector","kv_role":"kv_both"}' &
wait
Watch out

Disaggregation is not free. Every request's KV cache crosses the interconnect, so it pays off with fast links (NVLink, InfiniBand or RoCE) and with workloads where prompts are long or prefill and decode contend. On slow networks, or with short prompts, aggregated serving with KV-aware routing is often better. Benchmark both.

Tiered cache, planning and fast starts

  • KV Block Manager (KVBM) extends the KV cache beyond GPU memory into CPU memory, local SSD and remote or object storage. Blocks evicted from the GPU can be brought back instead of recomputed, which matters for long contexts and many idle conversations.
  • Planner watches time to first token and inter-token latency against targets and adds or removes prefill and decode workers, aiming to meet the SLA with the fewest GPUs.
  • ModelExpress streams weights GPU-to-GPU to new replicas, shortening the minutes-long cold start of large models.
  • Fault tolerance health-checks workers and migrates in-flight requests when one fails, so a crashed worker does not mean failed user requests.
  • Grove is a Kubernetes operator for topology-aware gang scheduling, placing the pods of one model across racks and NVLink domains sensibly.

Discovery and messaging are light by default: local development uses --discovery-backend file, and on Kubernetes Dynamo uses native resources, so etcd and NATS are optional rather than required.

Deploying on Kubernetes, and when not to

In production you install the Dynamo platform (operator and CRDs) and describe deployments declaratively. The newest path, in beta, is a DynamoGraphDeploymentRequest: you state the model, backend and latency targets, and Dynamo profiles candidate configurations, picks a topology and applies it. Ready-made recipes in the repository cover common model, engine and mode combinations.

State the SLA, let Dynamo choose the topology (beta)
yaml
apiVersion: nvidia.com/v1beta1
kind: DynamoGraphDeploymentRequest
metadata:
  name: chat
spec:
  model: YOUR_ORG/YOUR_MODEL
  backend: vllm
  sla:
    ttft: 200.0
    itl: 20.0
  autoApply: true
SituationReasonable choice
One model, fits on one GPU, modest trafficThe engine alone (vLLM, SGLang)
Several replicas, repeated prefixes, multi-turn chatEngine plus KV-aware routing
Long prompts, multi-node, fast interconnect, strict latency SLOsDisaggregated serving with Planner
Very long contexts or many idle sessionsAdd KVBM tiered cache

Measure before adopting: the repository's benchmarking guide uses AIPerf to compare aggregated and disaggregated topologies on your own prompt and output lengths. Keep the comparison honest by changing one variable at a time and recording time to first token, inter-token latency and throughput per GPU.

Hands-on practice

Aggregated versus KV-routed, on two GPUs

  1. On a machine with two NVIDIA GPUs (a cloud instance is fine), start the Dynamo vLLM runtime container from the README with --gpus all --network host.
  2. Start python3 -m dynamo.frontend --http-port 8000 --discovery-backend file and two dynamo.vllm workers with a small open model and --discovery-backend file, one per GPU.
  3. Send a chat request with curl to /v1/chat/completions and confirm it streams.
  4. Write a small script that sends 50 multi-turn conversations, each re-sending a growing history, and records time to first token per request.
  5. Restart the frontend with --router-mode kv and rerun the script; compare median and p95 time to first token.
  6. If your GPUs are linked by NVLink, try the disaggregated launch from this lesson and repeat the measurement; write down which topology won and why.
  7. Stop the instance when finished.
Cheat sheet

NVIDIA Dynamo: distributed inference — at a glance

Main things to focus on

  • Dynamo coordinates engines; it does not replace vLLM, SGLang or TensorRT-LLM.
  • KV-aware routing sends requests where their prefix is already cached: lower TTFT.
  • Disaggregation splits prefill and decode pools and moves KV with NIXL.
  • Disaggregation needs fast interconnect and long prompts to pay off.
  • KVBM tiers the KV cache to CPU, SSD and remote storage.
  • Planner scales prefill and decode pools against TTFT and ITL targets.

Run locally

uv pip install --prerelease=allow "ai-dynamo[vllm]"Install Dynamo with the vLLM backend
python3 -m dynamo.frontend --http-port 8000OpenAI-compatible frontend
--router-mode kvFrontend: route by KV cache overlap and load
python3 -m dynamo.vllm --model MODELStart a vLLM worker
--discovery-backend fileLocal discovery without etcd or NATS

Disaggregation

--disaggregation-mode prefill | decodeWorker role in disaggregated serving
--kv-transfer-config '{"kv_connector":"NixlConnector",...}'Move KV cache between workers with NIXL
CUDA_VISIBLE_DEVICES=NPin each worker to its own GPU

Kubernetes

kind: DynamoGraphDeploymentRequestModel + backend + SLA; Dynamo picks topology (beta)
spec.sla: {ttft: 200.0, itl: 20.0}Latency targets in milliseconds
recipes/Ready-made deployments per model, engine and mode
Gateway API Inference Extension + EPPKV-aware routing inside a cluster gateway

Decide and measure

TTFT = queue + prefill (+ KV transfer if disaggregated)Where disaggregation adds and saves time
ITL = time between streamed tokensWhat decode pools are sized for
AIPerfBenchmark topologies on your own workload

Common pitfalls

  • Adopting a distributed framework for one model on one GPU, where the engine alone is simpler.
  • Disaggregating over a slow network and making time to first token worse.
  • Round-robin load balancing across replicas, so prefixes are recomputed everywhere.
  • Judging topologies on someone else's benchmark instead of your own prompt and output lengths.
  • Changing several settings at once, so you cannot tell which one helped.
Quiz

Check your understanding

5 questions · 4 to pass · answers are explained as you go. Your best score is saved on this device only.

Progress and quiz scores are saved in this browser only. Back up or restore on the hub.

Was this lesson useful? Tell me what to improve →