BatchLLM: 通过全局前缀共享和面向吞吐量的令牌批处理优化大批次LLM推理
BatchLLM: Optimizing Large Batched LLM Inference with Global Prefix Sharing and Throughput-oriented Token Batching
AI总结:
本文提出BatchLLM,通过全局前缀共享和面向吞吐量的令牌批处理优化大批次LLM推理,提高GPU利用率。
摘要:
大型语言模型(LLMs)在工业中的信息处理和管理任务中扮演越来越重要的角色。许多任务以大批次甚至离线方式执行,其性能指标为吞吐量。这些任务通常具有前缀共享的特征,即不同提示输入可能部分共享共同前缀。然而,现有LLM推理引擎倾向于优化流式请求,且在支持具有前缀共享特征的大批次任务时存在局限性。现有解决方案使用基于LRU的缓存来重用请求之间的共同前缀的KV上下文。即将被重用的KV上下文可能因隐式缓存管理而被提前驱逐。此外,流式系统不利用请求批次信息,无法将解码令牌与预填充块最佳混合,从而无法充分利用GPU。我们提出BatchLLM以解决上述问题。BatchLLM显式识别全局共同前缀。共享相同前缀的请求将被一起调度以最佳重用KV上下文。BatchLLM重新排列请求并调度解码比例较大的请求,以更好地混合解码令牌与后续预填充块,并应用以内存为中心的令牌批处理以扩大令牌批处理大小,从而帮助提高GPU利用率。广泛的评估显示,BatchLLM在多个微基准测试和典型工业工作负载下,在不同硬件环境中均优于vLLM和SGLang,性能提升达1.3倍至10.8倍。代码可在https://github.com/microsoft/MixLLM/tree/batchllm_vllm_064获取。
英文摘要:
Large language models (LLMs) increasingly play an important role in a wide range of information processing and management tasks in industry. Many of these tasks are performed in large batches or even offline, and the performance indicator for which is throughput. These tasks usually show the characteristic of prefix sharing, where different prompt input can partially show the common prefix. However, the existing LLM inference engines tend to optimize the streaming requests and show limitations of supporting the large batched tasks with the prefix sharing characteristic. The existing solutions use the LRU-based cache to reuse the KV context of common prefix between requests. The KV context that are about to be reused may be prematurely evicted with the implicit cache management. Besides, the streaming oriented systems do not leverage the request-batch information and can not mix the decoding tokens with the prefill chunks to the best for the batched scenarios, and thus fails to saturate the GPU. We propose BatchLLM to address the above problems. BatchLLM explicitly identifies the common prefixes globally. The requests sharing the same prefix will be scheduled together to reuse the KV context the best. BatchLLM reorders the requests and schedules the requests with larger ratio of decoding first to better mix the decoding tokens with the latter prefill chunks, and applies memory-centric token batching to enlarge the token-batch sizes, which helps to increase the GPU utilization. Extensive evaluation shows that BatchLLM outperforms vLLM and SGLang by $1.3\times$ to $10.8\times$ on a set of microbenchmarks and a typical industry workload under different hardware environments. Code is available at https://github.com/microsoft/MixLLM/tree/batchllm_vllm_064.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。