Skip to main content
QUICK REVIEW

[论文解读] FlashDecoding++: Faster Large Language Model Inference on GPUs

Ke Hong, Guohao Dai|arXiv (Cornell University)|Nov 2, 2023
Topic ModelingComputer Science被引用 14
一句话总结

FlashDecoding++ 是一个快速的 LLM 推理引擎,通过优化注意力 softmax 同步、扁平 GEMM 的利用率以及数据流适应性,在相对于 Hugging Face 及其他基线的 NVIDIA 与 AMD GPU 上实现显著加速。

ABSTRACT

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.

研究动机与目标

  • 出于现实部署中高计算成本的原因,推动更快的 LLM 推理。
  • 识别解码阶段 GEMM/注意力的瓶颈并提出有针对性的优化方案。
  • 开发一个能够适应不同硬件后端和输入动态的统一框架。
  • 在多种模型和 GPU 上展示相对于最先进推理引擎的性能提升。

提出的方法

  • 引入带统一最大值的异步 softmax,以消除注意力中跨部分的同步开销。
  • 通过填充至 8 的方式优化扁平 GEMM,并应用双缓冲以隐藏内存延迟。
  • 开发一种启发式数据流,在 CUDA Core 与 Tensor Core 实现之间根据工作负载拐点进行选择。
  • 对 GEMV/GEMM 形状进行离线查找表驱动的决策流的剖面分析与构建,以映射到最优内核。
  • 在 NVIDIA 与 AMD GPU 上对比 Llama2、OPT、ChatGLM2 等模型与多种基线进行评估。

实验结果

研究问题

  • RQ1带统一最大值的异步 softmax 是否能够消除部分 softmax 计算中的同步开销?
  • RQ2如何在解码阶段 LLM 工作负载下优化扁平 GEMM,以在不产生填充浪费的前提下提升利用率?
  • RQ3是否存在一种启发式数据流,能够自适应地将 GEMV/GEMM 工作负载路由到最合适的硬件内核,以在不同输入动态和硬件配置下最大化吞吐量?
  • RQ4与 Hugging Face 及其他最先进的 LLM 推理引擎相比,FlashDecoding++ 在主流 GPU 上的性能提升是多少?

主要发现

  • 在 NVIDIA 与 AMD GPU 的解码阶段,实现了相对于 Hugging Face 的最高 4.86× 的加速。
  • 在 AMD GPU 上相对于 Hugging Face 的加速最高可达 3.93×。
  • 在不同模型上,相对于 FlashDecoding 这类最先进的 LLM 推理引擎,平均获得 1.37× 的加速。
  • 与 FlashDecoding 相比,在 Tesla A100 上的平均加速为 1.37×。
  • 在包括 Llama2、OPT、ChatGLM2 等多模型上提供了具有竞争力的性能。
  • 证明了非对称 softmax、双缓冲扁平 GEMM 以及跨后端的硬件自适应数据流的有效性。

阅读本论文

在 Nubint 阅读器中打开原文,边读边就任意段落提问。

在 Nubint 中阅读本论文

本解读由 AI 根据论文原文生成,引用前请核对原文。