优化大模型推理的缓存调度,降低延迟并提升资源利用率。
Online Scheduling for LLM Inference with KV Cache Constraints
- 提出基于后见之明最优的调度评估基准,量化性能上限。
- 证明任意到达模式下无常数竞争比的确定性在线算法存在理论极限。
- 设计多项式时间调度算法,在真实数据上显著优于现有方案。
大语言模型(LLM)推理需逐词生成文本,计算密集且依赖高效的调度以优化延迟与资源利用。关键挑战在于键值(KV)缓存管理:虽能减少冗余计算,却带来内存限制。本文从理论上建模带KV缓存约束的LLM推理,提出一种新型批处理与调度算法,以最小化推理延迟并有效管理缓存内存。首先,引入后见之明最优基准(hindsight optimal),通过整数规划计算在掌握全部未来信息下的最小总延迟。其次,证明当任务到达过程任意时,任何确定性在线算法均无法实现常数竞争比。第三,鉴于整数规划在大规模场景下不可行,提出一种多项式时间在线调度算法,并在特定条件下可达到常数竞争比。在合成数据集上对比后见之明最优解,验证其优异的实证性能;在真实世界公开数据集上,模拟Llama2-70B在A100 GPU上的推理,结果表明该算法显著优于基准方法。整体成果为更可持续、低成本的LLM部署提供可行路径。
原文摘要 · Abstract (English)
Large Language Model (LLM) inference, where a trained model generates text one word at a time in response to user prompts, is a computationally intensive process requiring efficient scheduling to optimize latency and resource utilization. A key challenge in LLM inference is the management of the Key-Value (KV) cache, which reduces redundant computations but introduces memory constraints. In this work, we model LLM inference with KV cache constraints theoretically and propose a novel batching and scheduling algorithm that minimizes inference latency while effectively managing the KV cache's memory. More specifically, we make the following contributions. First, to evaluate the performance of online algorithms for scheduling in LLM inference, we introduce a hindsight optimal benchmark, formulated as an integer program that computes the minimum total inference latency under full future information. Second, we prove that no deterministic online algorithm can achieve a constant competitive ratio when the arrival process is arbitrary. Third, motivated by the computational intractability of solving the integer program at scale, we propose a polynomial-time online scheduling algorithm and show that under certain conditions it can achieve a constant competitive ratio. We also demonstrate our algorithm's strong empirical performance by comparing it to the hindsight optimal in a synthetic dataset. Finally, we conduct empirical evaluations on a real-world public LLM inference dataset, simulating the Llama2-70B model on A100 GPUs, and show that our algorithm significantly outperforms the benchmark algorithms. Overall, our results offer a path toward more sustainable and cost-effective LLM deployment.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。