Randomization Boosts KV Caching, Learning Balances Query Load: A Joint Perspective

Fangzhou Wu, Sandeep Silwal, Qiuyi, Zhang

TL;DR

Multi-LLM serving systems face a fundamental conflict between balancing query loads across workers and maximizing local key-value (KV) cache hit rates. This paper introduces the first unified mathematical framework to model this trade-off, alongside two novel algorithms: Randomized Leaf Token (RLT) eviction and Learning-Based Greedy Routing (LBGR). Together, they leverage the power of randomness and online learning to achieve up to an 11.96× reduction in latency and a 77.4% increase in throughput over state-of-the-art methods.

What Problem Does This Paper Address?

To speed up Large Language Model (LLM) inference, systems use KV caching to store and reuse previously processed tokens (like system prompts or chat histories). However, when scaling up to multi-LLM serving environments, a massive tug-of-war emerges between cache affinity and load balancing:

  1. Cache Affinity First: Routing similar queries to the same LLM worker maximizes cache reuse but creates severe load imbalances and massive queuing delays.
  2. Load Balancing First: Distributing queries evenly across workers minimizes queuing but destroys cache hit rates, forcing the system to recompute tokens and increasing processing time.

Existing systems rely on the traditional Least Recently Used (LRU) eviction policy and static routing heuristics. The authors demonstrate that LRU is highly fragile under dynamic or adversarial query arrivals, often evicting the exact tokens needed by the very next query.

Figure 1: Key trade-offs between single LLM cache affinity and global load balancing in the KV cache-aware load balancing problem.

Methods

The paper tackles this problem from both a theoretical and practical perspective by introducing two core algorithms:

  • Randomized Leaf Token Eviction (RLT): Instead of deterministically evicting the oldest leaf tokens in a prefix-sharing radix tree (like standard LRU), RLT introduces a randomized marking strategy. It marks active tokens and, when the cache is full, evicts an unmarked leaf token uniformly at random. This simple injection of randomness breaks adversarial query patterns, exponentially improving the theoretical worst-case competitive ratio from $O(n)$ to $O(\log n)$.
  • Learning-Based Greedy Routing (LBGR): To handle routing, LBGR dynamically estimates the end-to-end latency of an incoming query for each LLM worker. It breaks latency down into estimated service time (using a global cache tracker) and queue load. Crucially, it applies an exponential decay factor to the queue load to simulate its natural reduction over time and deploys an online linear regression model to continuously correct residual latency biases during runtime.

Datasets

The authors evaluated their approach across four distinct benchmarks spanning synthetic and real-world workloads:

  • GSP (Generated Shared Prefix): A synthetic benchmark used to test prefix-caching efficiency with highly controlled sharing ratios.
  • ShareGPT & UltraChat: Real-world multi-turn conversation logs used to simulate realistic, dynamic user interactions.
  • Loogle: A long-document QA benchmark used to evaluate performance under heavy context lengths (up to 8k tokens).

These workloads were tested on dense architectures (Llama-3.1-8B-Instruct and Llama-3.1-70B-Instruct) as well as sparse Mixture-of-Experts models (Mixtral-8×7B-Instruct-v0.1).

Key Insights and Ideas

  • LRU’s Fatal Flaw: The paper mathematically proves that standard Leaf-LRU performs poorly in the worst case because structured, alternating query sequences can systematically clear out useful prefixes right before they are reused.
  • The Power of Randomness: By switching to a randomized eviction strategy (RLT), the system prevents adversarial query sequences from forcing worst-case cache thrashing.
  • Moving Beyond Raw Query Counts: Traditional load balancers estimate queue delay simply by counting pending queries. LBGR recognizes that queries have highly variable lengths and cache states; by tracking cumulative execution time and applying online regression, it maps true system congestion far more accurately.

Key Results

The combination of LBGR and RLT consistently outperformed all baseline configurations across every benchmark:

  • Latency & Speed: Compared to the current state-of-the-art (Cache-Aware+LRU), LBGR+RLT achieved up to an 11.96× reduction in median latency and a 14.06× reduction in time-to-first-token (TTFT) on Llama-3.1-8B.
  • Throughput & Cache Efficiency: Under worst-case query arrival patterns, RLT delivered up to a 6.92× higher cache hit rate and a 77.4% increase in throughput over LRU-based systems.
  • Low Overhead: The entire optimization framework adds only about 2ms of runtime overhead per query, making it highly practical for real-world deployment.

Limitations and Future Work

While highly effective, the authors note a few limitations:

  1. Text-Only Focus: The current implementation is designed strictly for text-based KV caches and does not yet support multi-modal inference (e.g., interleaved image/video tokens).
  2. Evaluation Scale: Due to hardware constraints, the experiments were limited to a maximum of 10 workers in a single-domain setup. The behavior of these algorithms in massive, geo-distributed LLM clusters remains an open question for future research.

Summary updated

Abstract

KV caching is a fundamental technique for accelerating Large Language Model (LLM) inference by reusing key-value (KV) pairs from previous queries, but its effectiveness under limited memory is highly sensitive to the eviction policy. The default Least Recently Used (LRU) eviction algorithm struggles with dynamic online query arrivals, especially in multi-LLM serving scenarios, where balancing query load across workers and maximizing cache hit rate of each worker are inherently conflicting objectives. We give the first unified mathematical model that captures the core trade-offs between KV cache eviction and query routing. Our analysis reveals the theoretical limitations of existing methods and leads to principled algorithms that integrate provably competitive randomized KV cache eviction with learning-based methods to adaptively route queries with evolving patterns, thus balancing query load and cache hit rate. Our theoretical results are validated by extensive experiments across 4 benchmarks and 3 prefix-sharing settings, demonstrating improvements of up to 6.92$\times$ in cache hit rate, 11.96$\times$ reduction in latency, 14.06$\times$ reduction in time-to-first-token (TTFT), and 77.4% increase in throughput over the state-of-the-art methods. Our code is available at https://github.com/fzwark/KVRouting.
BibTeX
@inproceedings{wu2026randomization,
  author = {Fangzhou Wu and Sandeep Silwal and Qiuyi and Zhang},
  title = {{Randomization Boosts KV Caching, Learning Balances Query Load: A Joint Perspective}},
  booktitle = {International Conference on Learning Representations},
  year = {2026},
  url = {https://openreview.net/forum?id=R7fv5NWfMm},
}
Figure