Table of Contents
Fetching ...

Optimizing LLM Inference: Fluid-Guided Online Scheduling with Memory Constraints

Ruicheng Ao, Gan Luo, David Simchi-Levi, Xinshang Wang

TL;DR

This work addresses memory-constrained LLM inference where the KV cache grows during decode, causing eviction risk and potential instability under online batching. It introduces a fluid-dynamics benchmark for throughput under memory limits and develops the WAIT policy for known output lengths, plus Nested WAIT for unknown lengths, leveraging threshold-based admission to approach a load-balanced equilibrium. The authors provide asymptotic optimality guarantees, decoupling analyses, and high-probability memory bounds, supported by experiments on Llama-7B that show superior throughput and reduced latency against vLLM and Sarathi. The framework offers a principled, theory-grounded approach to deploying LLMs under strict memory constraints and motivates future work on multi-GPU deployment and integration with cutting-edge KV-cache techniques.

Abstract

Large Language Models (LLMs) power many modern applications, but their inference procedure poses unique scheduling challenges: the Key-Value (KV) cache grows dynamically during response generation, and memory overflow triggers eviction that can cascade into system-wide failures. Even when memory capacity exceeds the theoretical requirement, conventional scheduling algorithms fail because they do not account for this dynamic memory growth -- a system that should be stable can become unstable under poor scheduling. This paper formulates LLM inference optimization as a multi-stage online scheduling problem. We develop a fluid dynamics approximation to establish a tractable benchmark and derive the Waiting for Accumulated Inference Threshold (WAIT) algorithm. WAIT uses threshold-based batching to prevent eviction by keeping the system near load balance, achieving near-optimal throughput when output lengths are known. For practical settings where output lengths are unknown at arrival, we introduce Nested WAIT. Rather than predicting output lengths, Nested WAIT classifies prompts on-the-fly: short prompts complete early and exit, while longer prompts naturally advance to later segments. A safety buffer provides high-probability protection against memory overflow with only logarithmic overhead. Theoretical analysis establishes near-optimal performance in the asymptotic regime. Experiments on Llama-7B with an A100 GPU demonstrate that our approach achieves superior throughput and reduced latency compared to vLLM and Sarathi. This work applies operations research principles to establish a theoretical framework for LLM deployment under memory constraints.

Optimizing LLM Inference: Fluid-Guided Online Scheduling with Memory Constraints

TL;DR

This work addresses memory-constrained LLM inference where the KV cache grows during decode, causing eviction risk and potential instability under online batching. It introduces a fluid-dynamics benchmark for throughput under memory limits and develops the WAIT policy for known output lengths, plus Nested WAIT for unknown lengths, leveraging threshold-based admission to approach a load-balanced equilibrium. The authors provide asymptotic optimality guarantees, decoupling analyses, and high-probability memory bounds, supported by experiments on Llama-7B that show superior throughput and reduced latency against vLLM and Sarathi. The framework offers a principled, theory-grounded approach to deploying LLMs under strict memory constraints and motivates future work on multi-GPU deployment and integration with cutting-edge KV-cache techniques.

Abstract

Large Language Models (LLMs) power many modern applications, but their inference procedure poses unique scheduling challenges: the Key-Value (KV) cache grows dynamically during response generation, and memory overflow triggers eviction that can cascade into system-wide failures. Even when memory capacity exceeds the theoretical requirement, conventional scheduling algorithms fail because they do not account for this dynamic memory growth -- a system that should be stable can become unstable under poor scheduling. This paper formulates LLM inference optimization as a multi-stage online scheduling problem. We develop a fluid dynamics approximation to establish a tractable benchmark and derive the Waiting for Accumulated Inference Threshold (WAIT) algorithm. WAIT uses threshold-based batching to prevent eviction by keeping the system near load balance, achieving near-optimal throughput when output lengths are known. For practical settings where output lengths are unknown at arrival, we introduce Nested WAIT. Rather than predicting output lengths, Nested WAIT classifies prompts on-the-fly: short prompts complete early and exit, while longer prompts naturally advance to later segments. A safety buffer provides high-probability protection against memory overflow with only logarithmic overhead. Theoretical analysis establishes near-optimal performance in the asymptotic regime. Experiments on Llama-7B with an A100 GPU demonstrate that our approach achieves superior throughput and reduced latency compared to vLLM and Sarathi. This work applies operations research principles to establish a theoretical framework for LLM deployment under memory constraints.

Paper Structure

This paper contains 91 sections, 18 theorems, 134 equations, 18 figures, 1 table, 2 algorithms.

Key Result

Proposition 1

When the condition $\lambda_j d_1 (l_j' + 1) \left( l_j + \frac{l_j'}{2} \right) \geq 1$ is satisfied, the system becomes unstable in the sense that the expected average latency under any scheduling policy with deterministic arrival rate $\lambda_j$ grows linearly with time. Formally,

Figures (18)

  • Figure 1: An example of LLM inference.
  • Figure 2: Example of batching and scheduling.
  • Figure 3: Inference time of Llama-7B and Llama-13B with different number of tokens in the batch on a single L20 GPU
  • Figure 4: Pipeline of Algorithm \ref{['alg:wait']}
  • Figure 5: Pipeline of the Nested WAIT Algorithm
  • ...and 13 more figures

Theorems & Definitions (26)

  • Example 1: Dynamic Memory Growth and Eviction
  • Proposition 1
  • Proposition 2
  • Remark 1: On the Assumption $C \geq M^*$
  • Proposition 3
  • Example 2: Eviction Cascade under FCFS
  • Theorem 1
  • Proposition 4
  • Example 3: Unknown Output Lengths
  • Proposition 5
  • ...and 16 more