Router Guide

Deployment modes, quick start, and page map for Dynamo routing docs
以 Markdown 格式查看

Overview

The Dynamo KV Router intelligently routes requests by evaluating their computational costs across different workers. It considers both decoding costs (from active blocks) and prefill costs (from newly computed blocks), using KV cache overlap to minimize redundant computation. Optimizing the KV Router is critical for achieving maximum throughput and minimum latency in distributed inference setups. This guide helps you get started with using the Dynamo router and points to the pages that cover routing concepts, configuration, disaggregated serving, and operations in more detail.

Quick Start

The router can be deployed using Python / CLI, Kubernetes, or as a standalone component.

Python / CLI Deployment

To launch the Dynamo frontend with the KV Router:

$python -m dynamo.frontend --router-mode kv --http-port 8000

This command:

  • Launches the Dynamo frontend service with KV routing enabled
  • Exposes the service on port 8000 (configurable)
  • Automatically handles all backend workers registered to the Dynamo endpoint

Backend workers register themselves using the register_model API. For accurate prefix-cache state, workers must also publish KV cache events with the backend-specific event flags; otherwise the router can run in approximate mode with --no-router-kv-events.

The Frontend Configuration Reference is the canonical list of embedded-router CLI arguments, environment variables, defaults, and boolean forms. Use Configuration and Tuning for workload-specific guidance, Router Filtering for candidate eligibility, and Routing Concepts for the prefill and decode cost model.

Kubernetes Deployment

To enable the KV Router in Kubernetes, add the DYN_ROUTER_MODE environment variable to your frontend service:

1apiVersion: nvidia.com/v1alpha1
2kind: DynamoGraphDeployment
3metadata:
4 name: my-deployment
5spec:
6 services:
7 Frontend:
8 componentType: frontend
9 replicas: 1
10 envs:
11 - name: DYN_ROUTER_MODE
12 value: kv # Enable KV Smart Router

Key Points:

  • Set DYN_ROUTER_MODE=kv on the Frontend service only
  • Configure worker-side KV event publishing when you want event-driven prefix-cache state
  • Use --no-router-kv-events for approximate cache-state prediction when workers are not publishing events

For exact environment-variable mappings, see the Frontend Configuration Reference. For complete Kubernetes examples and tuning guidance, see Kubernetes Examples and Configuration and Tuning. For A/B testing and advanced K8s setup, see the KV Router A/B Benchmarking Guide.

Standalone Router

You can also run the KV router as a standalone service (without the Dynamo frontend) for disaggregated serving (e.g., routing to prefill workers), multi-tier architectures, or any scenario requiring intelligent KV cache-aware routing decisions. See the Standalone Router component for more details.

Frontend-Embedded vs. Standalone Router

DeploymentProcessMetrics PortUse Case
Frontend-embeddedpython -m dynamo.frontend --router-mode kvFrontend HTTP port (default 8000)Standard deployment; router runs inside the frontend process
Standalonepython -m dynamo.routerDYN_SYSTEM_PORT (if set)Multi-tier architectures, advanced disaggregated prefill routing, custom pipelines

The standalone router does not include the HTTP frontend (no /v1/chat/completions endpoint). It exposes only the RouterRequestMetrics via the system status server. See the Standalone Router README.

Deployment Modes

The Dynamo router can be deployed in several configurations. The table below shows every combination and when to use it:

ModeCommandRouting LogicKV EventsTopologyUse Case
Frontend + Round-Robinpython -m dynamo.frontend --router-mode round-robinCycles through workersNoneAggregatedSimplest baseline; no KV awareness
Frontend + Randompython -m dynamo.frontend --router-mode randomRandom worker selectionNoneAggregatedStateless load balancing
Frontend + Power of Twopython -m dynamo.frontend --router-mode power-of-twoSamples two workers and chooses the less loaded oneNoneAggregated or disaggregated fallbackLow-overhead load balancing with better distribution than random selection
Frontend + KV (Aggregated)python -m dynamo.frontend --router-mode kvKV cache overlap + loadNATS Core / ZMQ / ApproxAggregatedProduction single-pool serving with cache reuse
Frontend + KV (Disaggregated)python -m dynamo.frontend --router-mode kv with prefill + decode workersKV cache overlap + loadNATS Core / ZMQ / ApproxDisaggregated (prefill + decode pools)Separate prefill/decode for large-scale serving
Frontend + Least-Loadedpython -m dynamo.frontend --router-mode least-loadedFewest active connectionsNoneAggregated or disaggregated fallbackSimple load-aware balancing without KV awareness
Frontend + Device-Aware Weightedpython -m dynamo.frontend --router-mode device-aware-weightedDevice-aware budget + least-loaded within selected device groupNoneAggregated or disaggregated fallbackHeterogeneous fleet balancing (CPU/non-CPU); degenerates to least-loaded when only one device class is present
Frontend + Directpython -m dynamo.frontend --router-mode directWorker ID from request hintsNoneAggregatedExternal orchestrator (e.g., EPP/GAIE) selects workers
Standalone Routerpython -m dynamo.routerKV cache overlap + loadNATS Core / ZMQAnyRouting without the HTTP frontend (multi-tier, custom pipelines)

Routing Modes (--router-mode)

ModeValueHow Workers Are Selected
Round-Robinround-robin (default)Cycles through available workers in order
RandomrandomSelects a random worker for each request
Power of Twopower-of-twoSamples two workers and routes to the one with fewer in-flight requests; in disaggregated prefill paths it falls back to synchronous prefill
KVkvEvaluates KV cache overlap and decode load per worker; picks lowest cost
Least-Loadedleast-loadedRoutes to the worker with fewest active connections; in disaggregated prefill paths it skips bootstrap optimization and falls back to synchronous prefill
Device-Aware Weighteddevice-aware-weightedPartitions workers into CPU and non-CPU groups, applies capability-normalized ratio budgeting using DYN_ENCODER_CUDA_TO_CPU_RATIO to decide which group receives the request, then selects the least-loaded worker within that group
DirectdirectReads the target worker_id from the request’s routing hints; no selection logic

Device-Aware Weighted Routing

device-aware-weighted is designed for heterogeneous fleets where workers of different compute capability, for example CPU embedding encoders alongside GPU embedding encoders, share the same endpoint.

Workers are split into CPU and non-CPU groups. The router compares a capability-normalized load across the two groups:

normalized_load = total_inflight(group) / (instance_count(group) x throughput_weight)

The throughput weight is 1 for CPU workers and DYN_ENCODER_CUDA_TO_CPU_RATIO for non-CPU workers. The next request is routed to the group with the lower normalized load, then to the least-loaded worker inside that group.

For multimodal requests, a full embedding-cache hit on one or more workers bypasses the CPU-to-non-CPU ratio. The router selects the least-loaded worker among those that hold every distinct embedding-cache key in the request. Partial hits continue through the normal weighted group selection. See Embedding Cache.

Use DYN_ENCODER_CUDA_TO_CPU_RATIO to approximate the throughput ratio of a non-CPU worker relative to one CPU worker. The default is 8.

When only one device class is present, the policy degenerates to standard least-loaded routing.

KV Event Transport Modes (within --router-mode kv)

When using KV routing, the router needs to know what each worker has cached. There are three ways to get this information:

Event ModeHow to EnableDescription
ZMQ (local indexer)Router default (no router flag)Workers maintain a local indexer and publish KV events via ZMQ PUB sockets; the router recovers state by querying live workers. This is the default event plane for all backends
NATS Core (local indexer)--event-plane nats (or DYN_EVENT_PLANE=nats)Same local-indexer model, but events flow over NATS Core instead of ZMQ.
Approximate (no events)--no-router-kv-eventsNo events consumed; router predicts cache state from its own routing decisions with TTL-based expiration

Aggregated vs. Disaggregated Topology

TopologyWorkersHow It Works
AggregatedSingle pool (prefill + decode in one process)All workers handle the full request lifecycle
DisaggregatedSeparate prefill and decode poolsFrontend routes to a prefill worker first, then to a decode worker; requires workers registered with WorkerType.Prefill

Disaggregated mode is activated automatically when prefill workers register alongside decode workers. See Disaggregated Serving for details.

More Router Docs