Intelligent Router for LLM Workloads: Improving Performance Through Workload-Aware Scheduling

Kunal Jain, Anjaly Parayil, Ankur Mallick, Esha Choukse, Xiaoting Qin, Jue Zhang, Íñigo Goiri, Chetan Bansal, Victor Rühle, Anoop Kulkarni, Steve Kofsky, Saravan Rajmohan

TL;DR

Standard cluster schedulers treat Large Language Model (LLM) requests as uniform jobs, ignoring the massive compute-and-memory mismatch between prompt processing (prefill) and token generation (decode). This paper introduces an intelligent, reinforcement learning–based cluster router that predicts request output lengths, models the interference penalty of co-locating diverse requests on the same GPU, and cuts end-to-end serving latency by over 11% compared to traditional heuristics.

What Problem Does This Paper Address?

Serving LLMs at scale involves two distinct computational phases:

  1. Prefill (Prompt Processing): Compute-bound, highly parallel matrix operations processing all input tokens simultaneously.
  2. Decode (Generation): Memory-bandwidth–bound, autoregressive generation of tokens one by one.

When a multi-instance cluster uses naive routing algorithms (like Round Robin or Join-Shortest-Queue), incoming requests with long prompts often get dispatched to GPU instances actively decoding long responses. Because modern iteration-level schedulers batch these requests together, the heavy prefill phase introduces severe latency spikes into every decode step running alongside it. In the worst case, memory saturation triggers request preemption, forcing prompt recomputation from scratch.

While significant effort has been poured into instance-level scheduling (e.g., Orca, vLLM), cluster-level routing remains an overlooked bottleneck: an instance scheduler can only optimize the mix of requests it is given.

Methods

The authors propose a heuristic-guided Reinforcement Learning (RL) router composed of three core modules:

Incoming Request ──► [Task & Output Length Predictor] ──┐
                                                         ├──► [RL Routing Agent] ──► LLM Instances (vLLM)
Cluster State    ──► [Workload Impact Estimator]    ──┘    (Action: Instance or Delay)
  1. Lightweight Decode Length Predictor: Output token counts vary widely by task. The authors fine-tune a lightweight DistilBERT classifier to predict output length into non-uniform completion-time buckets (e.g., $0$–$250$, $250$–$1000$ tokens). They drastically improve accuracy by first predicting the prompt's task type (achieving 93.79% task accuracy) and appending it as context to the length predictor.
  2. Workload Impact Estimator: By empirically profiling model batch execution times on hardware (measuring linear token-time gradients for prompt processing, $\text{grad}_1$, vs. decoding, $\text{grad}_2$), the system formulates an analytic penalty, $r_{\text{mixing}}$, that quantifies how much an incoming prompt will delay existing decodes and vice versa.
  3. Workload-Guided RL (Double-DQN): The cluster router is modeled as a discrete-time Markov Decision Process (MDP). At each time step, the agent chooses to dispatch a request to one of $m$ model instances or strategically delay assignment. To avoid sample inefficiency and reward bias, the analytical mixing penalty is injected via heuristic guidance (decaying across training episodes with factor $\lambda_k = e^{-\beta_d k}$), warm-starting the agent before it transitions to purely optimizing end-to-end completion latency.

Datasets

The authors construct a multi-task workload benchmark comprising 31,329 prompts (capped at 1,000 input tokens) across five tasks with widely differing input/output distributions:

  • Books (Translation): Short prompt, short decode.
  • ELI5 / Reddit (Long-form Q&A): Short prompt, heavy decode.
  • IMDb (Sentiment Analysis): Heavy prompt, short decode.
  • SQuAD (In-context Q&A): Medium prompt, medium/heavy decode.
  • WNUT 2017 (Named Entity Recognition): Short prompt, short decode.

Key Insights and Ideas

  • Interference is asymmetric and spiky: Adding a 500-token prompt request to an instance already generating 1,000 decode tokens can inflate the original request's latency from 17 seconds to 31 seconds purely due to periodic prefill spikes.
  • General scheduling heuristics fail for LLMs: Classical heuristics like Join Shortest Queue or Min-Min (Shortest Job First) only improve latency by 0.46% to 1.50% over Round Robin because they treat request lengths linearly, missing the non-linear interference between prefill and decode.
  • Strategic waiting beats greedy routing: Rather than routing instantly, the RL router occasionally holds requests in a central queue for an average of ~2 seconds. This short buffer prevents requests from flooding a GPU, avoiding memory exhaustion and preemption delays that otherwise add dozens of seconds downstream.
  • Task hints rescue length prediction: Off-the-shelf sequence length predictors (like $S^3$) collapse on multi-task workloads (dropping to ~5.5% accuracy on unequal buckets). Prepending a lightweight task-type hint raises bucket prediction accuracy to 79.15%.

Key Results

Experiments were conducted on 4 to 8 instances of LLaMA-2-7B on NVIDIA V100 GPUs managed by vLLM (FCFS iteration-level scheduler) under an arrival rate of $\lambda = 20\text{ requests/sec}$:

  • End-to-End Latency Reduction: Workload-Guided RL lowered mean end-to-end latency by 11.43% (19.18 seconds) compared to Round Robin, easily outperforming unguided Baseline RL (4.35%) and fixed-penalty Workload-Aware RL (7.79%).
  • First-Token and Streaming Latency: The proposed policy halved Time-To-First-Token (TTFT) for late-arriving requests and drastically reduced Time-Between-Tokens (TBT) outliers and variance by preventing prompt-induced decoding stalls.
  • Scalability: When scaled to an 8-GPU cluster with 4,000 requests ($\lambda = 40\text{/s}$), Workload-Guided RL maintained an 11.62% improvement over Round Robin.
  • Negligible Overhead: DistilBERT inference takes $\sim 10\text{ ms}$ on GPU per batch of 64, and the DQN forward pass takes under $10^6$ operations (< 1 ms), making routing overhead negligible compared to token generation times ($>20\text{ ms}$).

Limitations and Future Work

  • Hardware & Model Portability: Profiling gradients ($\text{grad}_1, \text{grad}_2$) were collected specifically on NVIDIA V100s serving LLaMA-2-7B; adapting to newer architectures (A100, H100) requires re-benchmarking the prompt/decode hardware slopes.
  • FCFS Assumptions: The central router assumes First-Come-First-Served arrival without handling multi-tier Service Level Agreements (SLAs) or variable request priorities.
  • Static Model Instances: The paper assumes homogeneous model replicas; future work could extend routing policies to heterogeneous GPU clusters or dynamic model-parallel deployments.

Summary updated

BibTeX
@misc{jain2024intelligent,
  author = {Kunal Jain and Anjaly Parayil and Ankur Mallick and Esha Choukse and Xiaoting Qin and Jue Zhang and Íñigo Goiri and Chetan Bansal and Victor Rühle and Anoop Kulkarni and Steve Kofsky and Saravan Rajmohan},
  title = {{Intelligent Router for LLM Workloads: Improving Performance Through Workload-Aware Scheduling}},
  year = {2024},
  eprint = {2408.13510},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2408.13510},
}
Figure