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

DeFT:基于Flash树注意力的解码以实现高效的树结构LLM推理

DeFT: Decoding with Flash Tree-attention for Efficient Tree-structured LLM Inference

Westlake University(西湖大学);Zhejiang University(浙江大学);Carnegie Mellon University(卡内基梅隆大学);University of Illinois Urbana-Champaign(伊利诺伊大学厄巴纳-香槟分校);Hong Kong University of Science and Technology(香港科技大学)

Jinwei Yao, Kaiqi Chen, Kexun Zhang, Jiaxuan You, Binhang Yuan, Zeke Wang, Tao Lin

AI总结:

DeFT提出了一种基于Flash树注意力的硬件高效解码算法,通过KV-Guided Grouping和Flattened Tree KV Splitting优化树结构LLM推理中的KV缓存分区与负载均衡,显著减少IO冗余并提升GPU利用率,实现最高2.23倍端到端加速。

摘要:

大型语言模型(LLMs)越来越多地被用于处理树结构中具有共享前缀token的多次生成调用的复杂任务,包括少样本提示、多步推理、推测解码等。然而,现有的基于树结构应用的推理系统由于在注意力计算期间对查询和KV缓存的划分不当而效率低下。这导致了两个主要问题:(1)缺乏对共享前缀KV缓存的内存访问(IO)重用,以及(2)负载均衡差。结果是,GPU全局内存与共享内存之间存在冗余的KV缓存IO,同时GPU利用率低。为了应对这些挑战,我们提出了DeFT(Decoding with Flash Tree-Attention),一种具有前缀感知和负载均衡KV缓存分区的硬件高效注意力算法。DeFT通过KV-Guided Grouping减少注意力计算期间KV缓存的读/写操作次数,该方法避免了在注意力计算中重复加载共享前缀的KV缓存。此外,我们提出了Flattened Tree KV Splitting,一种确保在分区上均匀分布KV缓存且计算冗余极少的机制,从而提高了注意力计算期间的GPU利用率。通过减少73-99%的KV缓存IO和近100%的注意力计算期间部分结果的IO,DeFT在与最先进的注意力算法相比的三个实际基于树的工作负载中,实现了高达2.23倍/3.59倍的端到端/注意力延迟加速。我们的代码可在https://github.com/LINs-lab/DeFT获取。

英文摘要:

Large language models (LLMs) are increasingly employed for complex tasks that process multiple generation calls in a tree structure with shared prefixes of tokens, including few-shot prompting, multi-step reasoning, speculative decoding, etc. However, existing inference systems for tree-based applications are inefficient due to improper partitioning of queries and KV cache during attention calculation. This leads to two main issues: (1) a lack of memory access (IO) reuse for KV cache of shared prefixes, and (2) poor load balancing.As a result, there is redundant KV cache IO between GPU global memory and shared memory, along with low GPU utilization. To address these challenges, we propose DeFT(Decoding with Flash Tree-Attention), a hardware-efficient attention algorithm with prefix-aware and load-balanced KV cache partitions. DeFT reduces the number of read/write operations of KV cache during attention calculation through KV-Guided Grouping, a method that avoids repeatedly loading KV cache of shared prefixes in attention computation. Additionally, we propose Flattened Tree KV Splitting, a mechanism that ensures even distribution of the KV cache across partitions with little computation redundancy, enhancing GPU utilization during attention computations. By reducing 73-99% KV cache IO and nearly 100% IO for partial results during attention calculation, DeFT achieves up to 2.23/3.59x speedup in the end-to-end/attention latency across three practical tree-based workloads compared to state-of-the-art attention algorithms. Our code is available at https://github.com/LINs-lab/DeFT.

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

↑