Large language model applications often spend significant time generating tokens, but token generation is only part of the performance problem. When users send repeated or related requests, the model may repeatedly process similar prompt prefixes. That repeated computation can increase latency, GPU usage, and infrastructure costs.
KV cache routing is one approach to reducing this repeated work.
Instead of sending every request to an arbitrary inference worker, a routing layer can direct a request to a worker that already has the relevant Key-Value (KV) cache in GPU or other fast-access memory. The model can then reuse previously computed attention states rather than rebuilding them from scratch.
This article explains how KV caching works, why routing matters, and how the technique can improve LLM inference systems.
What Is the KV Cache?
Transformer models use self-attention to determine how each token relates to other tokens in the input sequence.
During inference, the model calculates Key and Value tensors for tokens that have already been processed. These tensors can be stored and reused when generating subsequent tokens.
This stored data is called the KV cache.
Consider a request such as:
You are a customer-support assistant for Contoso.
Company policy:
1. ...
2. ...
3. ...
What is the refund policy for annual subscriptions?
The system may repeatedly receive requests containing the same company policy prefix.
Without caching, the model repeatedly processes that prefix.
With KV caching, the previously calculated attention states can be reused.
Conceptually:
Request
|
v
Tokenization
|
v
Transformer
|
+----> Compute K/V for prefix
|
v
KV Cache
|
v
Generate new tokens
For long prompts, this can represent a significant amount of computation.
Why KV Cache Routing Matters
A KV cache is generally associated with a particular inference worker or cache location.
Suppose four GPU workers are running the same model:
Load Balancer
|
+--------------+--------------+
| | |
GPU 1 GPU 2 GPU 3
Cache A Cache B Cache C
A request containing a prefix already cached on GPU 2 may benefit from being sent to GPU 2.
If the load balancer sends it to GPU 3 instead, GPU 3 may need to recompute the prefix.
This creates a trade-off:
Traditional routing
Request -> Least busy GPU
KV-aware routing
Request -> GPU with useful KV cache
The second approach is often called KV cache-aware routing or KV cache routing.
How KV Cache Routing Works
A KV-aware inference architecture normally has several components:
Client
Routing layer
Cache metadata or index
Inference workers
KV caches
A simplified architecture looks like this:
Client
|
v
+---------------+
| KV-Aware |
| Router |
+---------------+
/ | \
/ | \
v v v
GPU 1 GPU 2 GPU 3
KV KV KV
Cache Cache Cache
When a request arrives, the router determines which worker has the most useful cached prefix.
Step 1: Identify the Prompt Prefix
The routing system examines the request and determines whether part of the prompt matches a previously processed prefix.
For example:
System instructions
+
Company documentation
+
User question
The first two portions may remain unchanged across many requests.
Step 2: Find Cache Ownership
The router maintains information about which worker contains the relevant cache.
Conceptually:
Prefix Hash Worker
abc123 GPU 1
def456 GPU 3
xyz789 GPU 2
The exact implementation varies by inference stack.
Step 3: Select the Worker
The router can combine cache locality with runtime conditions.
For example:
Candidate Worker Cache Match Load
GPU 1 80% High
GPU 2 70% Low
GPU 3 0% Low
The router does not necessarily have to choose the worker with the highest cache match. It can balance cache reuse against current system load.
Step 4: Reuse the Cache
Once the request reaches the selected worker, the inference engine can reuse the available KV blocks.
Only the uncached portion needs to be processed.
KV Cache Routing vs Traditional Load Balancing
Traditional load balancing generally focuses on distributing requests across available workers.
For example:
Request 1 -> GPU 1
Request 2 -> GPU 2
Request 3 -> GPU 3
Request 4 -> GPU 1
This can keep GPU utilization relatively balanced.
However, it ignores computation already performed for a specific request prefix.
KV-aware routing adds another dimension.
Routing Strategy | Main Goal | Cache Awareness |
|---|---|---|
Round robin | Even distribution | No |
Least connections | Balance active requests | No |
Least latency | Reduce observed latency | Usually no |
KV-aware routing | Reuse cached computation | Yes |
Hybrid routing | Balance cache reuse and load | Yes |
For workloads with long repeated prefixes, cache locality can become an important routing signal.
Why Long Contexts Make This More Important
KV caching becomes particularly relevant as context windows grow.
Imagine an application that sends:
System Prompt: 2,000 tokens
Company Documentation: 10,000 tokens
Conversation History: 4,000 tokens
User Question: 50 tokens
If the system repeatedly processes similar requests, recomputing thousands of tokens can be wasteful.
With prefix reuse, much of the previous computation can potentially remain available.
The benefit depends on several factors:
Prefix length
Prefix reuse frequency
Cache hit rate
GPU memory availability
Model architecture
Request scheduling
Cache eviction policy
Number of inference workers
Therefore, simply enabling a KV cache does not automatically guarantee a large performance improvement.
Prefix Caching and KV Cache Routing
KV cache routing is closely related to prefix caching.
Prefix caching allows an inference system to reuse computation for a repeated prompt prefix.
For example:
Request A:
[System Prompt][Documentation][Question A]
Request B:
[System Prompt][Documentation][Question B]
The shared portion is:
[System Prompt][Documentation]
The inference engine may reuse the KV cache associated with that prefix.
Routing becomes important when the cached prefix exists on only one or a subset of workers.
Shared Prefix
|
v
+----+----+----+
| | |
GPU 1 GPU 2 GPU 3
| | |
Cache None None
Sending the second request to GPU 1 can avoid recomputing the shared prefix.
A Simple Routing Algorithm
A conceptual implementation might look like this:
Jasen FiciPosted Oct 19, 2026, 12:27 PM
This was included in DotNetNews here: https://dotnetnews.beehiiv.com/p/new-post-000c