Explainer
The four kinds of LLM router, from model routing to KV-aware routing
What an LLM router does: model routing, replica load balancing, KV-aware routing and prefill-decode disaggregation are four decisions. How RouteLLM, NVIDIA Dynamo, llm-d, the SGLang router and vLLM production-stack score a request.
- LLM inference
- LLM router
- KV-aware routing
- Load balancing
- KV cache
"LLM router" names four different decisions: which model answers, which copy of the model serves it, which copy already holds the prompt's KV cache, and whether to split the request into prefill and decode. Each decision reads different inputs and fails in a different way. A production stack often runs all four in a row under one name.
I read the scoring code of five open-source routers at pinned commits to see what each one decides and how. This essay sorts them into the four layers, shows each default rule as it is written, and ends with the problems between the layers.
The four layers
| Layer | Question it answers | Main inputs | Typical failure |
|---|---|---|---|
| Model router | Which model should answer this prompt? | The prompt's text, each model's quality and cost | A hard prompt goes to the weak model |
| Replica router | Which copy of the model has room? | Queue length, running requests, health | A busy replica keeps getting work |
| KV-aware router | Which copy already holds this prompt's prefix? | Cached blocks per replica, plus load | Every request piles onto one warm replica |
| Disaggregation router | Should this request be split into prefill and decode, and where? | Prompt length, cache hits on each side, pool load | A long prefill runs on a decode GPU and slows every stream on it |
Layer 1: the model router
A model router reads the prompt and chooses between models of different strength and price. RouteLLM, from the LMSYS team, is the clearest open-source example. It routes between one strong and one weak model. A trained router scores how much the prompt needs the strong model, and a threshold turns that score into a choice. The threshold is set from data: the README calibrates it so that about half of Chatbot Arena prompts go to the strong model, which gives a threshold of 0.11593 for its matrix-factorization router.
NVIDIA's LLM Router blueprint and the vLLM Semantic Router work at the same layer: they classify the request and send it to the model best suited to the task.
The model router never sees the cluster. It does not know that the strong model's replicas are full, or that the weak model's replicas hold this user's conversation in cache. That blindness is the first gap between layers.
Layer 2: the replica router
A replica router spreads requests across identical copies of one model. Round robin is the simplest, and it is still the SGLang router's default on its legacy path. Better ones read load. With --chat-routing reorg, the SGLang router's default policy becomes power_of_two: it samples two engines and takes the less loaded one. For prefill and plain engines it compares estimated prefill queue time, then waiting uncached tokens, then waiting, running and in-flight requests. For decode engines it compares waiting and running requests, then KV usage.
Sampling two instead of scanning all is a known trick from load balancing: it avoids sending every request to the same "least loaded" replica when the load numbers are a little stale.
Layer 3: the KV-aware router
A KV-aware router adds one more input: which replica already holds the start of this prompt in its KV cache. A replica with a long cached prefix skips most of the prefill, so it can answer sooner even if it is busier. The four open-source routers below weigh that trade in four different ways.
NVIDIA Dynamo computes a cost for each worker and takes the lowest. Cached blocks earn a credit that depends on where they sit, so the router already knows about the tiers in where the KV cache goes:
overlap_credit = device_blocks × device_credit
+ host_blocks × 0.75
+ disk_blocks × 0.25
+ shared_blocks × shared_cache_multiplier
adjusted_prefill = max(prefill_blocks − overlap_credit, 0)
cost = prefill_load_scale × adjusted_prefill
+ decode_blocks
+ decode_active_request_weight × active_requestsThe defaults are a scale of 1.0, no weight on active requests, and a shared-cache multiplier of 0.5 when a shared store is on. At a temperature of 0, the lowest cost wins and ties break at random. Above 0, the router samples a softmax over the costs, so a slightly worse worker sometimes wins and the cache spreads.
Here is the rule at work on three replicas and one 8-block request, with the default parameters. Replica A holds 6 of the request's blocks on its GPU and is decoding 4, so its cost is 2 + 4 = 6. Replica B holds none and is decoding 1: cost 9. Replica C holds 2 blocks in host memory, credited at 0.75 each, and is decoding 2: cost 8.5. The request goes to A, the busiest of the three, because its cache saves more than its queue costs.
Hover a part to see its namellm-d runs a filter, score and pick pipeline. Its default profile adds three weighted scores: queue length with weight 2, KV-cache utilization with weight 2, and prefix-cache match with weight 3. The prefix match counts most, but two load scores together outweigh it.
The SGLang router's cache_aware policy prefers the engine with the longest cached prefix, as long as the match is at least 1,024 tokens. Below that, or when the preferred engine fails admission, it falls back to power_of_two. In balanced mode it switches away only when the preferred engine's load exceeds twice the alternative's and also exceeds it by a set gap.
vLLM production-stack's kvaware mode asks the LMCache controller which engine holds the longest prefix. It routes there only when at most 2,000 prompt tokens remain uncached. Otherwise it falls back to a consistent hash of the session.
| Router | Rule | How it learns cache state | Fallback |
|---|---|---|---|
| NVIDIA Dynamo | Lowest additive cost; cache credit by tier | KV events from each worker | Softmax sampling above temperature 0 |
| llm-d | Weighted sum: queue 2, utilization 2, prefix 3 | By default, an approximate index of its own past placements; a precise scorer reads engine KV events | None; the weights blend cache and load |
| SGLang router | Longest prefix of at least 1,024 tokens | A radix tree in the router fed by engine KV events, or an external indexer | Power of two choices |
| vLLM production-stack | Holder of the longest prefix, if at most 2,000 tokens are uncached | LMCache controller lookup | Session hash, or request-rate routing with no session ID |
By default, two of these are additive scores and two are thresholds with a fallback. Each project also ships the other style: Dynamo has a two-tier policy ported from SGLang's, and production-stack has a load-aware router that subtracts relative load from the match ratio. An additive score trades cache against load continuously. A threshold puts the cache first until the match is too short to pay. The two fail differently: a threshold router flips sharply when a prompt crosses the line, and an additive router can drift toward one warm replica if its load terms are small.
Layer 4: the disaggregation router
The fourth decision is the shape of the work. In disaggregated serving, prefill runs on one pool and decode on another, and the KV cache crosses between them. That split helps long prompts and hurts short ones, because the transfer costs more than it saves.
NVIDIA Dynamo's conditional disaggregation makes the choice per request. The router may send a request to a prefill worker and then a decode worker, or straight to a decode worker that runs prefill locally. It reads the decode workers' KV events to estimate how much of the prompt is already cached there, and so how much prefill is really left. A multi-turn request whose history sits in a decode worker's cache can skip the prefill pool entirely. Dynamo marks the feature experimental.
Hover a part to see its nameWhat breaks between the layers
Each router is sound on its own. The trouble is that each one decides with its own inputs and none sees the others'.
- The model router ignores cache and load. It may send a chat's next turn to the strong model while the weak model's replica holds that chat's whole history in cache. The cheaper answer was also the faster one.
- The replica and KV layers fight. Cache affinity concentrates work, and load balancing spreads it. Every KV-aware router above needs a fallback rule, a temperature or a weight to stop the cache from winning every time.
- The KV router and the disaggregation router count the same cache twice, or not at all. If the disaggregation router decides to skip prefill because a decode worker holds the prefix, the KV router must send the request to that exact worker. Dynamo solves this by making one component decide both.
- Cache state is always a little stale. Event-driven routers learn about an eviction after it happens. Approximate indexes guess. A router that trusts stale state sends requests to a cache that is no longer there, and the hit it counted becomes a full prefill.
Should these be four routers?
The layers exist for good reasons: each one can be built, tested and replaced on its own. But the best choice at each layer depends on the others. The right model depends on which replicas are saturated. The right replica depends on where the cache sits. The right shape depends on how much of the prompt is cached on the decode side.
The open-source routers are already merging layers 2, 3 and 4. Dynamo scores load and cache in one cost and makes the disaggregation choice in the same router. The SGLang router puts load and cache affinity behind one admission rule. The model router is the layer still outside: none of the open-source model routers here reads the cluster's cache or load before it chooses.
Questions engineers ask
What is KV-aware routing?
A KV-aware router sends each request to the replica whose KV cache already holds the longest start of its prompt, so that replica skips most of the prefill. It weighs that saving against the replica's load.
Is an LLM gateway the same as an LLM router?
A gateway such as LiteLLM routes by model name, provider and key, and handles retries and spend. That is layer 1 with a fixed rule. The routers in layers 2 to 4 run inside one model's serving cluster.
Is a KV-aware router worth it for single-turn traffic?
Only when prompts share long prefixes, such as a common system prompt or the same retrieved documents. With unique prompts, the cache credit is zero for every replica and a KV-aware router behaves like a load balancer.
What should the cache threshold be?
It should match the cost of a prefill. The SGLang router waits for 1,024 matched tokens and production-stack tolerates up to 2,000 uncached tokens. Measure your prefill rate and pick the length where skipping it saves more time than the busier replica's queue costs.
Does temperature in a KV-aware router change the answer?
No. Routing chooses the replica, not the tokens. Temperature here only spreads requests across replicas whose costs are close.
References
- Ong et al., RouteLLM: Learning to Route LLMs with Preference Data (opens in a new tab), and the RouteLLM README (opens in a new tab) at commit 0b64fda, for the threshold calibration.
- NVIDIA, LLM Router blueprint (opens in a new tab), and vLLM, Semantic Router (opens in a new tab).
- NVIDIA Dynamo, the worker selector's cost (opens in a new tab), the default parameters (opens in a new tab), the softmax picker (opens in a new tab) and conditional disaggregation (opens in a new tab), commit a552d9f.
- llm-d, the default scheduling profile (opens in a new tab), commit c4c19e6.
- SGLang, the router's routing policies (opens in a new tab), commit 4791be0.
- vLLM production-stack, routing logic (opens in a new tab) and the KV-aware fallback (opens in a new tab), commit 405a2fa.
- Mitzenmacher, The Power of Two Choices in Randomized Load Balancing (opens in a new tab), IEEE TPDS 2001.