Router Guide

Deployment modes, quick start, and page map for Dynamo routing docs
View as 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.

CLI Arguments

ArgumentDefaultDescription
--router-mode kvround-robinEnable KV cache-aware routing
--router-temperature <float>0.0Controls routing randomness (0.0 = deterministic, higher = more random)
--kv-cache-block-size <size>Backend-specificKV cache block size (should match backend config)
--router-kv-events / --no-router-kv-events--router-kv-eventsEnable/disable real-time KV event tracking
--load-aware / --no-load-aware--no-load-awareRoute by active load without cache-reuse signals; implies --router-mode kv on the frontend
--router-kv-overlap-score-credit <float>1.0Credit multiplier for device-local prefix overlap, from 0.0 to 1.0
--router-prefill-load-scale <float>1.0Scale adjusted prompt-side prefill load before adding decode blocks
--router-track-prefill-tokens / --no-router-track-prefill-tokens--router-track-prefill-tokensInclude prompt-side load in active worker load accounting
--router-prefill-load-model <none|aic>nonePrompt-side load model; see Routing Concepts and Configuration and Tuning
--router-queue-threshold <float>4.0Queue threshold fraction; enables priority scheduling via priority
--router-queue-policy <str>fcfsScheduling policy for the queue: fcfs (tail TTFT), wspt (avg TTFT), or lcfs (comparison-only reverse ordering)
--serve-indexerfalseServe the Dynamo-native remote indexer from this frontend/router on the worker component
--use-remote-indexerfalseQuery the worker component’s served remote indexer instead of maintaining a local overlap indexer

For all available options: python -m dynamo.frontend --help

For detailed configuration options and tuning parameters, see Configuration and Tuning. For how the router models prefill and decode load in the cost function, see Routing Concepts.

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

Environment Variables

All CLI arguments can be configured via environment variables using the DYN_ prefix:

CLI ArgumentEnvironment VariableDefault
--router-mode kvDYN_ROUTER_MODE=kvround-robin
--load-awareDYN_ROUTER_LOAD_AWARE=truefalse
--router-temperatureDYN_ROUTER_TEMPERATURE0.0
--kv-cache-block-sizeDYN_KV_CACHE_BLOCK_SIZEBackend-specific
--no-router-kv-eventsDYN_ROUTER_USE_KV_EVENTS=falsetrue
--router-kv-overlap-score-creditDYN_ROUTER_KV_OVERLAP_SCORE_CREDIT1.0
--router-prefill-load-scaleDYN_ROUTER_PREFILL_LOAD_SCALE1.0
--router-queue-policyDYN_ROUTER_QUEUE_POLICYfcfs
DYN_ENCODER_CUDA_TO_CPU_RATIO8Throughput ratio of a non-CPU worker relative to one CPU worker for device-aware-weighted routing

For complete K8s examples and advanced configuration, see K8s 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 + KV (Aggregated)python -m dynamo.frontend --router-mode kvKV cache overlap + loadNATS Core / JetStream / 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 / JetStream / 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 / JetStream / 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
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.

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 four ways to get this information:

Event ModeHow to EnableDescription
NATS Core (local indexer)Router default (no router flag)Workers maintain a local indexer; configure backend-side KV event publishing so the router can recover state and receive events via NATS Core
JetStream (durable)--router-durable-kv-eventsEvents persisted in NATS JetStream; supports snapshots and durable consumers. Deprecated.
ZMQ--event-plane zmqWorkers publish via ZMQ PUB sockets; the standalone dynamo.indexer service aggregates events
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 ModelType.Prefill

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

More Router Docs