arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2403.08845cs.LGcs.AI
收藏

分叉注意力:通过大语言模型中的共享前缀加速大规模并行解码

Bifurcated Attention: Accelerating Massively Parallel Decoding with Shared Prefixes in LLMs

AWS NGDE Science;GE HealthCare(GE医疗);Amazon AGI(亚马逊AGI);Goldman Sachs(高盛)
Ben Athiwaratkun, Sujan Kumar Gonugondla, Sanjay Krishna Gouda, Haifeng Qian, Hantian Ding, Qing Sun, Jun Wang, Jiacheng Guo, Liangfu Chen, Parminder Bhatia, Ra… 展开作者

Ben Athiwaratkun, Sujan Kumar Gonugondla, Sanjay Krishna Gouda, Haifeng Qian, Hantian Ding, Qing Sun, Jun Wang, Jiacheng Guo, Liangfu Chen, Parminder Bhatia, Ramesh Nallapati, Sudipta Sengupta, Bing Xiang

AI总结:

本研究提出分叉注意力方法,将增量解码的注意力拆分为两个GEMM运算,在保持计算量不变下降低内存IO,在7B模型8k以上上下文场景下实现显著加速,适配实时并行生成需求。

摘要:

本研究提出了分叉注意力(bifurcated attention)方法,旨在提升共享上下文批量解码场景下的语言模型推理效率。该方法解决了冗余内存IO开销的难题——这是导致高批量大小和长上下文长度下延迟升高的关键因素。分叉注意力通过在增量解码过程中将注意力机制策略性地拆分为两个独立的GEMM(通用矩阵乘法)运算来实现这一目标:一个聚焦于预填充阶段生成的KV缓存,另一个则专注于解码过程本身。在保持标准注意力机制计算量(FLOPs)不变的同时,分叉注意力确保了计算的精确性,且大幅降低了内存IO开销。我们的实验结果表明,在采用多头注意力的7B模型上,当上下文长度超过8k个token时,采样16条输出序列可实现2.1倍以上的加速,采样32条序列时加速比超过6.2倍。分叉注意力带来的效率提升可降低延迟,尤其适用于实时应用场景。例如,它能够在不显著增加延迟的情况下实现大规模并行答案生成,从而在与重排序等后处理技术结合时提升性能。

英文摘要:

This study introduces bifurcated attention, a method designed to enhance language model inference in shared-context batch decoding scenarios. Our approach addresses the challenge of redundant memory IO costs, a critical factor contributing to latency in high batch sizes and extended context lengths. Bifurcated attention achieves this by strategically dividing the attention mechanism during incremental decoding into two separate GEMM operations: one focusing on the KV cache from prefill, and another on the decoding process itself. While maintaining the computational load (FLOPs) of standard attention mechanisms, bifurcated attention ensures precise computation with significantly reduced memory IO. Our empirical results show over 2.1$\times$ speedup when sampling 16 output sequences and more than 6.2$\times$ speedup when sampling 32 sequences at context lengths exceeding 8k tokens on a 7B model that uses multi-head attention. The efficiency gains from bifurcated attention translate into lower latency, making it particularly suitable for real-time applications. For instance, it enables massively parallel answer generation without substantially increasing latency, thus enhancing performance when integrated with post-processing techniques such as re-ranking.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑