Skip to content

Commit ec04692

Browse files
authored
docs: update main router doc (#5812)
Signed-off-by: PeaBrane <yanrpei@gmail.com>
1 parent b10d103 commit ec04692

2 files changed

Lines changed: 65 additions & 2 deletions

File tree

docs/router/README.md

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,69 @@ The router uses KV events from workers by default to maintain an accurate global
216216
- **NATS is not needed** - suitable for simpler deployments without NATS infrastructure
217217
- Suitable for testing or when event processing becomes a bottleneck
218218

219+
## Event Transport Modes
220+
221+
The router supports two event transport modes for KV cache state synchronization:
222+
223+
- **JetStream (default)**: Persistent event stream with durable consumers. State persists across router restarts via snapshots in NATS object store. Best for production with multi-replica consistency.
224+
225+
- **NATS Core with Local Indexer** (`--enable-local-indexer` on workers): Fire-and-forget pub/sub where workers maintain local radix trees. Router rebuilds state by querying workers on startup. Lower latency, simpler setup.
226+
227+
See [KV Cache Routing](kv_cache_routing.md#global-kv-cache-state-synchronization) for architecture diagrams and details.
228+
229+
## Disaggregated Serving
230+
231+
Dynamo supports disaggregated serving where prefill and decode are handled by separate worker pools. Register prefill workers with `ModelType.Prefill` and the frontend automatically activates an internal prefill router.
232+
233+
Key points:
234+
- Prefill router auto-activates when both prefill and decode workers register with the same model name
235+
- Supports vLLM and TensorRT-LLM backends (SGLang requires separate router setup)
236+
- Use `--no-track-active-blocks` for prefill-only workers
237+
238+
See [KV Cache Routing - Disaggregated Serving](kv_cache_routing.md#disaggregated-serving-prefill-and-decode) for setup examples.
239+
240+
## Router Replicas and State Persistence
241+
242+
For high availability, run multiple router replicas with `--router-replica-sync` to synchronize active block tracking via NATS.
243+
244+
State persistence options:
245+
- **JetStream mode**: Automatic persistence via event stream and object store snapshots
246+
- **Local Indexer mode**: State rebuilds from workers on startup
247+
- **Reset state**: Use `--router-reset-states` to start fresh (use with caution)
248+
249+
See [KV Cache Routing - Serving Multiple Router Replicas](kv_cache_routing.md#serving-multiple-router-replicas) for details.
250+
251+
## Busy Thresholds
252+
253+
Control worker saturation with busy thresholds:
254+
- `--active-decode-blocks-threshold <0.0-1.0>`: Mark workers busy when KV cache utilization exceeds threshold
255+
- `--active-prefill-tokens-threshold <count>`: Mark workers busy when active prefill tokens exceed threshold
256+
257+
Thresholds can be updated at runtime via the `/busy_threshold` HTTP endpoint. See [Dynamic Threshold Configuration](kv_cache_routing.md#dynamic-threshold-configuration).
258+
259+
## Python API
260+
261+
For programmatic routing control, use the `KvPushRouter` class directly:
262+
263+
```python
264+
from dynamo.llm import DistributedRuntime, KvPushRouter, KvRouterConfig
265+
266+
router = KvPushRouter(endpoint=endpoint, block_size=16, kv_router_config=KvRouterConfig())
267+
stream = await router.generate(token_ids=tokens, model="model-name")
268+
```
269+
270+
Key methods: `generate()`, `best_worker()`, `get_potential_loads()`, `mark_prefill_complete()`, `free()`.
271+
272+
See [KV Cache Routing - Python API](kv_cache_routing.md#using-kvpushrouter-python-api) for complete examples.
273+
274+
## Prerequisites and Limitations
275+
276+
- **Dynamic endpoints only**: KV router requires `register_llm()` with `model_input=ModelInput.Tokens`
277+
- **No multimodal support**: Currently tracks token-based blocks only
278+
- **No static endpoints**: Use `--router-mode round-robin` for static endpoint deployments
279+
280+
See [KV Cache Routing - Prerequisites](kv_cache_routing.md#prerequisites-and-limitations) for details.
281+
219282
## Tuning Guidelines
220283

221284
### 1. Understand Your Workload Characteristics

docs/router/kv_cache_routing.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -536,7 +536,7 @@ python -m dynamo.vllm --model meta-llama/Llama-2-7b-hf
536536

537537
```python
538538
import asyncio
539-
from dynamo._core import DistributedRuntime, KvPushRouter, KvRouterConfig
539+
from dynamollm import DistributedRuntime, KvPushRouter, KvRouterConfig
540540

541541
async def main():
542542
# Get runtime and create endpoint
@@ -647,7 +647,7 @@ Here's an example of using `get_potential_loads()` to implement custom routing t
647647

648648
```python
649649
import asyncio
650-
from dynamo._core import DistributedRuntime, KvPushRouter, KvRouterConfig
650+
from dynamo.llm import DistributedRuntime, KvPushRouter, KvRouterConfig
651651

652652
async def minimize_ttft_routing():
653653
# Setup router

0 commit comments

Comments
 (0)