Debarshi Das

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.

By Debarshi Das. Published . Updated .

9 min read

  • 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

Four routing decisions, in the order a request meets them.
LayerQuestion it answersMain inputsTypical failure
Model routerWhich model should answer this prompt?The prompt's text, each model's quality and costA hard prompt goes to the weak model
Replica routerWhich copy of the model has room?Queue length, running requests, healthA busy replica keeps getting work
KV-aware routerWhich copy already holds this prompt's prefix?Cached blocks per replica, plus loadEvery request piles onto one warm replica
Disaggregation routerShould this request be split into prefill and decode, and where?Prompt length, cache hits on each side, pool loadA 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:

Text
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_requests

The 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.

A router scores an 8-block request: replica A, 6 blocks cached on its GPU, costs 6; B costs 9; C costs 8.5. A wins.Hover a part to see its name
Dynamo's default cost on one 8-block request: replica A, with 6 blocks cached on its GPU, costs 6 and wins against B at 9 and C at 8.5.

llm-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.

Four KV-aware rules, at the commits in the references.
RouterRuleHow it learns cache stateFallback
NVIDIA DynamoLowest additive cost; cache credit by tierKV events from each workerSoftmax sampling above temperature 0
llm-dWeighted 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 routerLongest prefix of at least 1,024 tokensA radix tree in the router fed by engine KV events, or an external indexerPower of two choices
vLLM production-stackHolder of the longest prefix, if at most 2,000 tokens are uncachedLMCache controller lookupSession 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.

A router sent the next turn of conversation 5 to the decode worker; it sits on top of its blue 8,192-token cache.Hover a part to see its name
A KV-aware router sends the next turn to the decode worker that already holds its history, so no prefill worker recomputes it. A longer history saves more work.

What 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'.

  1. 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.
  2. 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.
  3. 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.
  4. 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

Choose a style to copy