FlashDecoding++:在GPU上加速大型语言模型推理
FlashDecoding++: Faster Large Language Model Inference on GPUs
AI总结:
本文提出快速LLM推理引擎FlashDecoding++,通过采用统一最大值的异步softmax、双缓冲扁平GEMM优化及硬件自适应的启发式数据流,解决了推理加速中的同步开销与计算利用不足问题,在NVIDIA和AMD GPU上实现了显著加速。
摘要:
随着大型语言模型(LLM)在各个领域变得日益重要,然而在加速LLM推理方面仍存在以下未解决的挑战:(1)同步的部分softmax更新。softmax操作需要在每个部分softmax结果之间进行同步更新操作,导致LLM中注意力计算产生约20%的开销。(2)扁平GEMM的计算利用不足。LLM推理中执行GEMM的矩阵形状是扁平的,导致计算利用不足,并且在以往的设计中补零后性能损失超过50%。(3)静态数据流导致的性能损失。LLM中的内核性能取决于不同的输入数据特征、硬件配置等。单一且静态的数据流可能导致LLM推理中不同形状GEMM面临50.25%的性能损失。我们提出了FlashDecoding++,这是一个支持主流LLM和硬件后端的快速LLM推理引擎。为解决上述挑战,FlashDecoding++创新性地提出:(1)采用统一最大值的异步softmax。FlashDecoding++为不同的部分softmax计算引入了统一最大值技术以避免同步。(2)采用双缓冲的扁平GEMM优化。FlashDecoding++指出不同形状的扁平GEMM面临不同的瓶颈,随后引入了双缓冲等技术。(3)具有硬件资源自适应的启发式数据流。FlashDecoding++考虑输入动态变化,利用不同的硬件资源启发式地优化数据流。由于FlashDecoding++中优化的通用性,与Hugging Face实现相比,FlashDecoding++在NVIDIA和AMD GPU上分别实现了高达4.86倍和2.18倍的加速。在主流LLM上,与最先进的LLM推理引擎相比,FlashDecoding++也实现了平均1.37倍的加速。
英文摘要:
As the Large Language Model (LLM) becomes increasingly important in various domains. However, the following challenges still remain unsolved in accelerating LLM inference: (1) Synchronized partial softmax update. The softmax operation requires a synchronized update operation among each partial softmax result, leading to ~20% overheads for the attention computation in LLMs. (2) Under-utilized computation of flat GEMM. The shape of matrices performing GEMM in LLM inference is flat, leading to under-utilized computation and >50% performance loss after padding zeros in previous designs. (3) Performance loss due to static dataflow. Kernel performance in LLM depends on varied input data features, hardware configurations, etc. A single and static dataflow may lead to a 50.25% performance loss for GEMMs of different shapes in LLM inference. We present FlashDecoding++, a fast LLM inference engine supporting mainstream LLMs and hardware back-ends. To tackle the above challenges, FlashDecoding++ creatively proposes: (1) Asynchronized softmax with unified max value. FlashDecoding++ introduces a unified max value technique for different partial softmax computations to avoid synchronization. (2) Flat GEMM optimization with double buffering. FlashDecoding++ points out that flat GEMMs with different shapes face varied bottlenecks. Then, techniques like double buffering are introduced. (3) Heuristic dataflow with hardware resource adaptation. FlashDecoding++ heuristically optimizes dataflow using different hardware resource considering input dynamics. Due to the versatility of optimizations in FlashDecoding++, FlashDecoding++ can achieve up to 4.86x and 2.18x speedup on both NVIDIA and AMD GPUs compared to Hugging Face implementations. FlashDecoding++ also achieves an average speedup of 1.37x compared to state-of-the-art LLM inference engines on mainstream LLMs.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。