arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2405.04532cs.CLcs.AIcs.LGcs.PF
收藏

QServe:面向高效LLM服务的W4A8KV4量化与系统协同设计

QServe: W4A8KV4 Quantization and System Co-design for Efficient LLM Serving

MIT(麻省理工学院)

Yujun Lin, Haotian Tang, Shang Yang, Zhekai Zhang, Guangxuan Xiao, Chuang Gan, Song Han

AI总结:

针对INT4量化在云端LLM服务中反量化开销过高的问题,提出W4A8KV4量化算法QoQ及推理库QServe,通过渐进量化与系统协同设计显著提升服务吞吐量并降低成本。

摘要:

量化可以加速大语言模型(LLM)推理。超越INT8量化,研究界正积极探索更低的精度,如INT4。然而,最先进的INT4量化技术仅能加速低批次的边缘LLM推理,无法在大批次的云端LLM服务中带来性能提升。我们发现了一个关键问题:现有的INT4量化方法在GPU上对权重或部分和进行反量化时,会承受显著的运行时开销(20-90%)。为应对这一挑战,我们引入了QoQ,一种具有4位权重、8位激活和4位KV缓存的W4A8KV4量化算法。QoQ代表quattuor-octo-quattuor,在拉丁语中表示4-8-4。QoQ由实现了可测量加速的QServe推理库实现。推动QServe的关键洞见是,GPU上LLM服务的效率受到低吞吐量CUDA核心操作的严重影响。基于此洞见,在QoQ算法中,我们引入了渐进式量化,可降低W4A8 GEMM中的反量化开销。此外,我们开发了SmoothAttention,以有效缓解4位KV量化带来的精度下降。在QServe系统中,我们执行计算感知的权重重排,并利用寄存器级并行性来降低反量化延迟。我们还将融合注意力变为内存受限型,利用KV4量化带来的性能提升。结果表明,与TensorRT-LLM相比,QServe将Llama-3-8B在A100上的最大可实现服务吞吐量提高了1.2倍,在L40S上提高了1.4倍;将Qwen1.5-72B在A100上提高了2.4倍,在L40S上提高了3.5倍。值得注意的是,QServe在L40S GPU上甚至能实现比TensorRT-LLM在A100上更高的吞吐量。因此,QServe将LLM服务的美元成本降低了3倍。代码可在https://github.com/mit-han-lab/omniserve获取。

英文摘要:

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.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑