Skip to main content
QUICK REVIEW

[论文解读] FlexGen: High-Throughput Generative Inference of Large Language Models with a Single GPU

Ying Sheng, Lianmin Zheng|arXiv (Cornell University)|Mar 13, 2023
Topic ModelingComputer Science被引用 47
一句话总结

FlexGen 提出一个基于卸载的框架,通过聚合 GPU/CPU/磁盘内存,利用线性规划搜索优化张量放置,并应用 4-bit 权重/KV-cache 压缩,在单一商用 GPU 上实现高吞吐的生成推理。

ABSTRACT

The high computational and memory requirements of large language model (LLM) inference make it feasible only with multiple high-end accelerators. Motivated by the emerging demand for latency-insensitive tasks with batched processing, this paper initiates the study of high-throughput LLM inference using limited resources, such as a single commodity GPU. We present FlexGen, a high-throughput generation engine for running LLMs with limited GPU memory. FlexGen can be flexibly configured under various hardware resource constraints by aggregating memory and computation from the GPU, CPU, and disk. By solving a linear programming problem, it searches for efficient patterns to store and access tensors. FlexGen further compresses the weights and the attention cache to 4 bits with negligible accuracy loss. These techniques enable FlexGen to have a larger space of batch size choices and thus significantly increase maximum throughput. As a result, when running OPT-175B on a single 16GB GPU, FlexGen achieves significantly higher throughput compared to state-of-the-art offloading systems, reaching a generation throughput of 1 token/s for the first time with an effective batch size of 144. On the HELM benchmark, FlexGen can benchmark a 30B model with a 16GB GPU on 7 representative sub-scenarios in 21 hours. The code is available at https://github.com/FMInference/FlexGen

研究动机与目标

  • 在有限 GPU 内存条件下,推动面向吞吐量的生成推理以提升 LLM 的性能。
  • 制定一个正式的卸载策略,优化 GPU/CPU/磁盘之间的张量放置与计算调度。
  • 提出 4-bit 组级量化方法,用于在不重新训练的情况下压缩权重和 KV-cache。
  • 证明协调的卸载与压缩在 OPT 模型上可获得显著吞吐提升,尤其在非常大规模时。

提出的方法

  • 对 compute schedule 的搜索空间形式化定义(逐行 row-by-row、逐列 column-by-column、zig-zag block),张量放置(权重/激活/KV cache 在 GPU/CPU/磁盘之间)以及计算委派(某些任务由 CPU 还是 GPU 完成)。
  • 使用基于线性规划的策略搜索,在具有分析成本模型的前提下,优化吞吐量并估算 I/O 与计算成本。
  • 提出 4-bit 细粒度分组量化,涵盖权重和 KV cache,以减少 I/O 与内存,计算时对 FP16 进行反量化。
  • 引入近似方法(分组量化和稀疏注意力),以在几乎不损失精度的情况下进一步提升吞吐量。
  • 将该方法扩展到多 GPU 设置,利用流水线并行实现解码吞吐量的潜在超线性扩展。

实验结果

研究问题

  • RQ1如何通过结合 GPU/CPU/磁盘内存,在单个商用 GPU 上实现高吞吐的 LLM 推理?
  • RQ2哪些卸载策略和张量放置策略能在对如 OPT-175B 这类大模型进行生成推理时最大化吞吐量?
  • RQ3是否能在不重新训练的前提下,通过对权重和 KV cache 进行 4-bit 量化来显著降低内存和 I/O 开销?
  • RQ4与现有卸载系统相比,FlexGen 在大模型上的吞吐优势及在具有代表性工作负载上的表现如何?

主要发现

  • FlexGen 在 OPT-175B 上的吞吐量显著高于最先进的卸载系统,在单个 16GB GPU 上达到 1 token/s,实际批大小为 144。
  • 在 HELM 基准的 30B 模型和 16GB GPU 上,FlexGen 能在 21 小时内对 7 个子场景进行基准测试。
  • 通过 4-bit 压缩,FlexGen 在将权重保留在 CPU 并移除磁盘卸载的情况下,最大吞吐量提升至 100×(实际批大小 144),延迟为 4000s。
  • 在 OPT-6.7B 和 OPT-30B 的规模下,FlexGen 通过更大的批量和 CPU/磁盘卸载实现超越 DeepSpeed Zero-Inference 与 Hugging Face Accelerate 的吞吐基线。
  • FlexGen 的 4-bit 压缩加上卸载相较基线带来显著吞吐提升,彰显了统一张量放置和 I/O 感知调度的好处。
  • 与 Petals 相比,FlexGen 实现了更高的按 GPU 吞吐量,在某些场景下也可能具有更低的延迟。

阅读本论文

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

在 Nubint 中阅读本论文

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