[论文解读] QServe: W4A8KV4 Quantization and System Co-design for Efficient LLM Serving
论文提出 QoQ W4A8KV4 量化和协同设计的 QServe 系统以加速 LLM 服务,相对于 TensorRT-LLM 及以往的 4-bit 方法实现显著吞吐提升。
Quantization can accelerate large language model (LLM) inference. Going beyond INT8 quantization, the research community is actively exploring even lower precision, such as INT4. Nonetheless, state-of-the-art INT4 quantization techniques only accelerate low-batch, edge LLM inference, failing to deliver performance gains in large-batch, cloud-based LLM serving. We uncover a critical issue: existing INT4 quantization methods suffer from significant runtime overhead (20-90%) when dequantizing either weights or partial sums on GPUs. To address this challenge, we introduce QoQ, a W4A8KV4 quantization algorithm with 4-bit weight, 8-bit activation, and 4-bit KV cache. QoQ stands for quattuor-octo-quattuor, which represents 4-8-4 in Latin. QoQ is implemented by the QServe inference library that achieves measured speedup. The key insight driving QServe is that the efficiency of LLM serving on GPUs is critically influenced by operations on low-throughput CUDA cores. Building upon this insight, in QoQ algorithm, we introduce progressive quantization that can allow low dequantization overhead in W4A8 GEMM. Additionally, we develop SmoothAttention to effectively mitigate the accuracy degradation incurred by 4-bit KV quantization. In the QServe system, we perform compute-aware weight reordering and take advantage of register-level parallelism to reduce dequantization latency. We also make fused attention memory-bound, harnessing the performance gain brought by KV4 quantization. As a result, QServe improves the maximum achievable serving throughput of Llama-3-8B by 1.2x on A100, 1.4x on L40S; and Qwen1.5-72B by 2.4x on A100, 3.5x on L40S, compared to TensorRT-LLM. Remarkably, QServe on L40S GPU can achieve even higher throughput than TensorRT-LLM on A100. Thus, QServe effectively reduces the dollar cost of LLM serving by 3x. Code is available at https://github.com/mit-han-lab/omniserve.
研究动机与目标
- 激发在云环境中对高效 LLM 服务的需求,超越 W8A8 和 W4A16 量化。
- 引入 4-bit 权重、8-bit 激活、4-bit KV 缓存量化(W4A8KV4),以在最大化吞吐量的同时控制精度损失。
- 开发系统-软件与算法的协同设计(QoQ 与 QServe),在推理阶段尽量减少 GPU 上的运行时开销。
- 通过 SmoothAttention 及其他量化优化,减轻 KV4 量化导致的精度下降。
- 展示在 A100 与 L40S GPU 上,多种 LLM 的真实世界吞吐提升。
提出的方法
- 引入 QoQ(Quattuor-Octō-Quattuor)量化,采用渐进分组量化以在 INT8 張量核心上实现 W4A8KV4 计算。
- 开发 SmoothAttention,通过塑形键激活来减少 KV4 量化带来的精度损失。
- 设计计算感知的权重重排和寄存器级并行性,以减少 W4A8 GEMM 主循环中的去量化延迟。
- 将去量化融入 GEMM 内核以维持高吞吐并实现一个内存绑定的注意力内核。
- 实现一个 QServe 运行时,处理 W4A8 输入、FP16 输出、逐头动态 KV 缓存量化以及在制批处理。
- 提供优化,使注意力内核成为内存绑定,并尽量减少主循环中的 CUDA 核心开销。
实验结果
研究问题
- RQ1在云环境中,使用 QoQ 的 W4A8KV4 量化是否能给端到端的 LLM 服务吞吐量带来高于现有 8-bit 和 4-bit 系统的提升?
- RQ2哪些量化、调度和内核设计策略能最小化 LLM 的 GEMM 主循环中的去量化开销?
- RQ3SmoothAttention 在 Llama 与 Qwen 模型的 KV4 量化下保持精度的效果如何?
- RQ4计算感知的权重重排和融合 KV4 注意力对不同 GPU 架构(A100 与 L40S)的整体服务吞吐量有何影响?
- RQ5在真实场景中,QServe 相比 TensorRT-LLM、Atom 与 QuaRot 的实际吞吐量与成本优化有哪些?
主要发现
- QServe 在 A100 GPU 上相对于最佳 TensorRT-LLM 配置,在 Llama-3-8B 上实现 1.2-2.4× 的吞吐提升,在 Qwen1.5-72B 上实现 2.4×。
- QServe 在 A100 GPU 上对测试模型的吞吐量比 Atom 与 QuaRot 高出 2.5-2.9×。
- 在 L40S GPU 上,QServe 比 TensorRT-LLM 提升 1.5-3.5×,八个模型中有六个达到或超过 A100 性能,同时降低成本。
- QServe 将 LLM 服务成本大约降低约 3 倍。
- QoQ 通过确保计算在 INT8 张量核心上运行、最小化主循环开销,实现高效的 W4A8 KV4 GEMM。
- SmoothAttention 有效减轻 KV4 注意力中的精度损失。
阅读本论文
在 Nubint 阅读器中打开原文,边读边就任意段落提问。
在 Nubint 中阅读本论文本解读由 AI 根据论文原文生成,引用前请核对原文。