使用 Sarathi-Serve 驯服 LLM 推理中的吞吐-延迟权衡
Taming Throughput-Latency Tradeoff in LLM Inference with Sarathi-Serve
AI总结:
本文提出 Sarathi-Serve 调度器,通过分块预填充与无停顿统一批次调度,在尾延迟约束下显著提升 LLM 推理吞吐和服务容量。
摘要:
每个 LLM 服务请求都会经历两个阶段。第一阶段是 prefill(预填充),它处理整个输入提示并生成第一个输出 token;第二阶段是 decode(解码),它逐个生成其余输出 token。Prefill 迭代具有较高延迟,但由于对输入提示进行并行处理,能够使 GPU 计算达到饱和。相比之下,decode 迭代延迟较低,但计算利用率也较低,因为一次 decode 迭代对每个请求只处理单个 token。这使得 batching(批处理)对 decode 非常有效,并因此对整体吞吐非常有效。然而,将多个请求批处理会导致 prefill 与 decode 迭代交错,从而使同时实现高吞吐和低延迟具有挑战性。我们提出一种高效的 LLM 推理调度器 Sarathi-Serve,以解决这种吞吐-延迟权衡。Sarathi-Serve 引入 chunked-prefills(分块预填充),将 prefill 请求拆分为大小近乎相等的块,并创建无停顿调度,在不暂停正在进行的 decode 的情况下向批次中加入新请求。无停顿调度释放了通过大批量规模提升吞吐的机会,同时最大限度降低批处理对延迟的影响。此外,Sarathi-Serve 中的统一批次缓解了迭代之间的不平衡,从而使流水线气泡降至最少。我们的技术在尾延迟约束下,跨模型和硬件带来了显著的推理性能提升。对于单张 A100 GPU 上的 Mistral-7B,与 vLLM 相比,我们实现了 2.6 倍的服务容量提升;对于两张 A100 GPU 上的 Yi-34B 模型,服务容量最高提升 3.7 倍。当在 Falcon-180B 上与流水线并行结合使用时,Sarathi-Serve 在端到端服务容量方面带来最高 5.6 倍的增益。Sarathi-Serve 的源代码可在 https://github.com/microsoft/sarathi-serve 获取。
英文摘要:
Each LLM serving request goes through two phases. The first is prefill which processes the entire input prompt and produces the first output token and the second is decode which generates the rest of output tokens, one-at-a-time. Prefill iterations have high latency but saturate GPU compute due to parallel processing of the input prompt. In contrast, decode iterations have low latency but also low compute utilization because a decode iteration processes only a single token per request. This makes batching highly effective for decodes and consequently for overall throughput. However, batching multiple requests leads to an interleaving of prefill and decode iterations which makes it challenging to achieve both high throughput and low latency. We introduce an efficient LLM inference scheduler, Sarathi-Serve, to address this throughput-latency tradeoff. Sarathi-Serve introduces chunked-prefills which splits a prefill request into near equal sized chunks and creates stall-free schedules that adds new requests in a batch without pausing ongoing decodes. Stall-free scheduling unlocks the opportunity to improve throughput with large batch sizes while minimizing the effect of batching on latency. Furthermore, uniform batches in Sarathi-Serve ameliorate the imbalance between iterations resulting in minimal pipeline bubbles. Our techniques yield significant improvements in inference performance across models and hardware under tail latency constraints. For Mistral-7B on single A100 GPUs, we achieve 2.6x higher serving capacity and up to 3.7x higher serving capacity for the Yi-34B model on two A100 GPUs as compared to vLLM. When used with pipeline parallelism on Falcon-180B, Sarathi-Serve provides up to 5.6x gain in the end-to-end serving capacity. The source code for Sarathi-Serve is available at https://github.com/microsoft/sarathi-serve.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。