SARATHI:通过分块预填充搭载解码实现高效LLM推理
SARATHI: Efficient LLM Inference by Piggybacking Decodes with Chunked Prefills
AI总结:
SARATHI通过分块预填充和解码最大化批处理,让解码搭载预填充计算,提升LLM推理吞吐量并减少流水线气泡,在多种模型上实现显著加速。
摘要:
大型语言模型(LLM)推理包含两个不同的阶段:预填充阶段处理输入提示,解码阶段自回归生成输出令牌。预填充阶段在较小的批处理大小下能有效饱和GPU计算,而解码阶段由于每个请求一次仅生成一个令牌,导致计算利用率较低。预填充和解码时间的差异在使用流水线并行时也会导致微批次之间的不平衡,从而因气泡问题造成进一步的效率低下。我们提出SARATHI来解决这些挑战。SARATHI采用分块预填充,将预填充请求拆分为大小相等的块,以及解码最大化批处理,该批处理使用单个预填充块构建批次,并用解码填充剩余槽位。在推理过程中,预填充块使GPU计算饱和,而解码请求则“搭载”执行,其成本比仅解码批次低一个数量级。分块预填充允许从单个预填充请求构建多个解码最大化批次,从而最大化可搭载的解码覆盖范围。此外,这些批次的均匀计算设计缓解了微批次之间的不平衡,显著减少了流水线气泡。我们的技术在多种模型和硬件上显著提升了推理性能。对于A6000 GPU上的LLaMA-13B模型,SARATHI将解码吞吐量提高了高达10倍,并将端到端吞吐量加速了高达1.33倍。对于A100 GPU上的LLaMa-33B模型,我们实现了1.25倍的端到端吞吐量提升和高达4.25倍的解码吞吐量提升。当与GPT-3上的流水线并行结合使用时,SARATHI将气泡减少了6.29倍,从而实现了1.91倍的端到端吞吐量提升。
英文摘要:
Large Language Model (LLM) inference consists of two distinct phases - prefill phase which processes the input prompt and decode phase which generates output tokens autoregressively. While the prefill phase effectively saturates GPU compute at small batch sizes, the decode phase results in low compute utilization as it generates one token at a time per request. The varying prefill and decode times also lead to imbalance across micro-batches when using pipeline parallelism, resulting in further inefficiency due to bubbles. We present SARATHI to address these challenges. SARATHI employs chunked-prefills, which splits a prefill request into equal sized chunks, and decode-maximal batching, which constructs a batch using a single prefill chunk and populates the remaining slots with decodes. During inference, the prefill chunk saturates GPU compute, while the decode requests 'piggyback' and cost up to an order of magnitude less compared to a decode-only batch. Chunked-prefills allows constructing multiple decode-maximal batches from a single prefill request, maximizing coverage of decodes that can piggyback. Furthermore, the uniform compute design of these batches ameliorates the imbalance between micro-batches, significantly reducing pipeline bubbles. Our techniques yield significant improvements in inference performance across models and hardware. For the LLaMA-13B model on A6000 GPU, SARATHI improves decode throughput by up to 10x, and accelerates end-to-end throughput by up to 1.33x. For LLaMa-33B on A100 GPU, we achieve 1.25x higher end-to-end-throughput and up to 4.25x higher decode throughput. When used with pipeline parallelism on GPT-3, SARATHI reduces bubbles by 6.29x, resulting in an end-to-end throughput improvement of 1.91x.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。