部署长上下文Transformer的挑战:峰值性能理论分析
Challenges in Deploying Long-Context Transformers: A Theoretical Peak Performance Analysis
AI总结:
本研究提出并发编程框架,定量分析长上下文Transformer因KV缓存庞大引发的四类部署挑战,为相关部署分析提供基础并指明降本方向。
摘要:
基于Transformer的长上下文生成模型为时长一小时的视频理解、项目级编码智能体等新兴AI应用提供支撑。与短上下文(如4K tokens)模型变体相比,部署长上下文Transformer(如100K至10M tokens)的成本高得令人望而却步。从2024年起,降低长上下文Transformer的成本正成为一项紧迫的研究与工程挑战。\n本研究提出了一个并发编程框架,用于定量分析在GPU高带宽内存(HBM)容量受限的场景下,服务多个长上下文请求时的效率挑战。我们详细分析了相较于4K上下文的所有额外计算成本,其根源可追溯至**单一来源:KV缓存的庞大体积**。我们以搭载NVLink的A100上、上下文长度为50K的34B参数GPT-3.5级别模型为运行示例,阐述其庞大的KV缓存如何引发四类部署挑战:(1)长输入的预填充阶段比短输入需要长得多的计算时间和GPU内存;(2)预填充完成后,驻留在GPU HBM中的大型KV缓存大幅限制了可同时服务的并发用户数量;(3)解码阶段,反复从HBM向SM读取KV缓存会大幅增加延迟;(4)当KV缓存内存溢出时,将其从HBM交换到DDR会产生显著的上下文切换延迟。\n我们利用该框架分析了现有研究,并指出了整合这些研究以构建端到端系统的可能性。总体而言,本工作为分析长上下文Transformer部署提供了基础框架,并指明了将1M上下文推理成本降至与4K相当的研究方向。
英文摘要:
Transformer-based long context generative models power emerging AI applications like hour-long video understanding and project-level coding agent. Deploying long context transformers (e.g., 100K to 10M tokens) is prohibitively expensive compared to short context (e.g., 4K tokens) model variants. Reducing the cost of long-context transformers is becoming a pressing research and engineering challenge starting from the year of 2024. This work describes a concurrent programming framework for quantitatively analyzing the efficiency challenges in serving multiple long-context requests under limited size of GPU high-bandwidth memory (HBM) regime. We give a detailed analysis of how all additional computational costs, compared to 4K context, trace back to \textit{one single source: the large size of the KV cache}. We use a 34B GPT-3.5 level model of 50K context on A100 NVLink as a running example, and describe how its large KV cache causes four types of deployment challenges: (1) prefilling long inputs takes much longer compute time and GPU memory than short inputs; (2) after prefilling, the large KV cache residing on the GPU HBM substantially restricts the number of concurrent users being served; (3) during decoding, repeatedly reading the KV cache from HBM to SM largely increases latency; (4) when KV cache memory overflows, swapping it from HBM to DDR causes significant context switching latency. We use this framework to analyze existing works and identify possibilities of combining them to build end-to-end systems. Overall, this work offers a foundational framework for analyzing long context transformer deployment and identifies directions towards reducing the inference cost of 1M context to be as cheap as 4K.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。