Table of Contents
Fetching ...

Competitive Non-Clairvoyant KV-Cache Scheduling for LLM Inference

Yiding Feng, Zonghan Yang, Yuhao Zhang

TL;DR

The paper tackles the challenge of scheduling LLM inference when each request’s KV-cache memory grows with decoded tokens, under a hard memory budget and without knowledge of final response lengths. It introduces Geometric-Slicing-Algorithm (GSA), a non-clairvoyant offline batch policy that achieves a constant competitive ratio, by combining Staggered-Pipeline-Schedule (SPS) with geometrically phased execution and a memory-time area analysis. A clairvoyant counterpart, Geometric-Batching-Algorithm (GBA), yields strong approximation guarantees (approximately $10.67$ general and $6.75$ large-memory), serving as a structural benchmark to bound GSA’s performance against the optimum. Numerical experiments on real traces confirm robust practical performance while preserving worst-case guarantees. Overall, the work provides the first constant-competitive non-clairvoyant approach to KV-cache scheduling in LLM inference and offers insights into memory-aware batching via staggered execution and geometric phase structuring.

Abstract

Large Language Model (LLM) inference presents a unique scheduling challenge due to the Key-Value (KV) cache, where a job's memory footprint grows linearly with the number of decoded tokens. This growth couples scheduling decisions with feasibility: a scheduler must minimize latency under a hard memory budget, yet the response lengths of requests are inherently unknown. While recent works have explored this problem either assuming clairvoyance -- exact knowledge of response lengths -- or relying on machine-learned predictions, obtaining robust performance guarantees without any prior knowledge of job sizes remains a theoretically fundamental and practically important open problem. In this work, we propose the Geometric Slicing Algorithm (GSA), the non-clairvoyant policy to achieve the first constant competitive ratio for this problem in the offline batch setting. GSA manages uncertainty through a geometric phase structure that periodically restarts jobs to bound memory exposure, combined with a staggered pipeline mechanism that enables high concurrency by smoothing aggregate memory consumption. We prove that GSA achieves a competitive ratio of at most 61.92 for general instances, improving to 32 in the large-memory regime. Our algorithmic framework also yields a clairvoyant counterpart, the Geometric Batching Algorithm (GBA), which achieves an approximation ratio of 10.67 for general instances and 6.75 in the large-memory regime -- significantly improving upon the best previously known bound of over 9000. Numerical experiments on real request traces demonstrate that our algorithms perform robustly while preserving these worst-case guarantees.

Competitive Non-Clairvoyant KV-Cache Scheduling for LLM Inference

TL;DR

The paper tackles the challenge of scheduling LLM inference when each request’s KV-cache memory grows with decoded tokens, under a hard memory budget and without knowledge of final response lengths. It introduces Geometric-Slicing-Algorithm (GSA), a non-clairvoyant offline batch policy that achieves a constant competitive ratio, by combining Staggered-Pipeline-Schedule (SPS) with geometrically phased execution and a memory-time area analysis. A clairvoyant counterpart, Geometric-Batching-Algorithm (GBA), yields strong approximation guarantees (approximately general and large-memory), serving as a structural benchmark to bound GSA’s performance against the optimum. Numerical experiments on real traces confirm robust practical performance while preserving worst-case guarantees. Overall, the work provides the first constant-competitive non-clairvoyant approach to KV-cache scheduling in LLM inference and offers insights into memory-aware batching via staggered execution and geometric phase structuring.

Abstract

Large Language Model (LLM) inference presents a unique scheduling challenge due to the Key-Value (KV) cache, where a job's memory footprint grows linearly with the number of decoded tokens. This growth couples scheduling decisions with feasibility: a scheduler must minimize latency under a hard memory budget, yet the response lengths of requests are inherently unknown. While recent works have explored this problem either assuming clairvoyance -- exact knowledge of response lengths -- or relying on machine-learned predictions, obtaining robust performance guarantees without any prior knowledge of job sizes remains a theoretically fundamental and practically important open problem. In this work, we propose the Geometric Slicing Algorithm (GSA), the non-clairvoyant policy to achieve the first constant competitive ratio for this problem in the offline batch setting. GSA manages uncertainty through a geometric phase structure that periodically restarts jobs to bound memory exposure, combined with a staggered pipeline mechanism that enables high concurrency by smoothing aggregate memory consumption. We prove that GSA achieves a competitive ratio of at most 61.92 for general instances, improving to 32 in the large-memory regime. Our algorithmic framework also yields a clairvoyant counterpart, the Geometric Batching Algorithm (GBA), which achieves an approximation ratio of 10.67 for general instances and 6.75 in the large-memory regime -- significantly improving upon the best previously known bound of over 9000. Numerical experiments on real request traces demonstrate that our algorithms perform robustly while preserving these worst-case guarantees.
Paper Structure (25 sections, 22 theorems, 44 equations, 7 figures, 1 table)

This paper contains 25 sections, 22 theorems, 44 equations, 7 figures, 1 table.

Key Result

Theorem 1

Let $\mathcal{J}$ be a sequence of jobs with identical prompt length $s$ and identical response length $o$. Then the schedule produced by StaggeredPipelineSchedule with a proper choice of parameters has an approximation ratio at most $2$. Moreover, when prompt length $s$ and response length $o$ are

Figures (7)

  • Figure 1: The diagram illustrates the LLM inference process flowing from top to bottom. First, the user message is tokenized. Next, the prefill phase processes the prompt to generate the first decode token. Then, the decode phase generates output tokens auto-regressively until the End-Of-Sequence token. Note that the KV-cache (colored context) grows linearly with each step.
  • Figure 2: Illustration of \ref{['example:schedule comparison']}. Each color represents the memory usage of a single job across rounds.
  • Figure EC.1: Uniform-size distribution results for clairvoyant algorithms. The total flow times are indicated in the titles. The $x$-axis represents time (rounds), and the $y$-axis represents the usage of memory in each round, where each job is represented by a colored block.
  • Figure EC.2: Two-point distribution results for non-clairvoyant algorithms. The total flow times are indicated in the titles. The $x$-axis represents time (rounds), and the $y$-axis represents the usage of memory in each round, where each finished job is represented by a colored block, and each killed job is represented by a dotted block.
  • Figure EC.3: Response length distribution from the LMSYS-Chat-1M dataset, counted using cl100k_base, the tokenizer of GPT-4 OpenAI-GPT4-23.
  • ...and 2 more figures

Theorems & Definitions (28)

  • Example 1: A Toy Example with Identical Jobs
  • Theorem 1: Approximation of SPS for Identical Jobs
  • Lemma 1: Peak Memory Usage of
  • Lemma 2: Feasible Parallelism of
  • Definition 1: Memory-Time Area
  • Lemma 3: Area-Based Lower Bound on Optimal Flow Time
  • Lemma 4: Area-Based Packing Efficiency of
  • Remark 1
  • Example 2: Long-Job Trap for Conservative Heuristics
  • Theorem 2: Competitive Ratio Guarantee of GSA
  • ...and 18 more