Emergent Mind

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

(2405.04532)
Published May 7, 2024 in cs.CL , cs.AI , cs.LG , and cs.PF

Abstract

Quantization can accelerate 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/qserve.

Impact of quantization techniques on serving throughput and GPU memory in QServe using Llama-2-7B model.

Overview

  • QoQ and QServe are new innovations specifically designed to improve the efficiency of deploying LLMs by using unique quantization strategies.

  • The QoQ technique utilizes a 4-8-4 bit configuration for weights, activations, and KV caches, optimizing computations on INT8 tensor cores and reducing accuracy loss.

  • QServe is a system framework that implements QoQ on GPUs, enhancing operational efficiency by minimizing dequantization overhead and improving memory access during computation.

Exploring Improved Quantization Techniques for LLMs through QoQ and QServe

Introduction to Quantization in AI Models

Quantization is a technique used in machine learning model optimization that converts model parameters from floating-point numbers (which take significant memory and computational resources) to integers. This simplification can drastically speed up model inference, crucial for deployments needing high responsiveness or where resources are limited, like mobile devices or cloud environments with high user traffic.

The Challenge of Existing Quantization Methods

In the realm of LLMs, efficient deployment remains a challenge. Traditional quantization methods, such as transforming all model parameters to 8-bit integers, often miss the balance between model size reduction and performance upkeep. When delved into aggressive quantization (like 4-bit representations), models suffered from performance degradation due to accuracy loss and increased computational overhead, particularly in dequantization processes.

Enter QoQ and QServe

QoQ (Quattuor-Octō-Quattuor) introduces a fresh approach to the quantization mechanism, specifically tailored for LLMs. The method utilizes a 4-8-4 bit configuration—4-bit weights, 8-bit activations, and 4-bit KV caches. This setup strikes a favorable balance, allowing computations to be carried out mostly on INT8 tensor cores, hence minimizing accuracy loss traditionally seen in lower-bit formats.

QServe, on the other hand, is the system framework designed to efficiently implement the QoQ algorithm on GPUs. It addresses challenges specific to low-bit quantization, such as high runtime overhead in weight dequantization. QServe minimizes these through novel techniques, such as compute-aware weight reordering and progressive quantization, both of which crucially reduce the delay imposed by converting lower precision formats back to a usable state during computations.

Key Insights and Improvements

  1. Progressive Quantization: This unique strategy uses a two-stage approach. We first quantize the weights to an intermediate 8-bit format and then refine them down to 4-bits. This staged approach ensures operations remain efficient and executable on INT8 tensor cores.
  2. SmoothAttention for Accuracy Preservation: A novel addition that mitigates accuracy loss in KV quantization by focusing on manipulating key distributions to be more quantization-friendly.
  3. Operational Efficiency in QServe: By reordering weights and optimizing the memory access patterns during the quantize-compute cycle, QServe notably lowers the pointer arithmetic overhead, increasing the throughput.

Notable Results

Evaluating on GPU platforms like NVIDIA’s A100 and L40S, QServe demonstrated superior performance, achieving up to 3.5 times throughput improvement over existing state-of-the-art frameworks like TensorRT-LLM when executing models like Llama-3-8B. These improvements signal not only achievable advancements in runtime efficiencies but also potential cost reductions in deploying LLMs in server environments.

Future Directions

While QoQ and QServe already mark significant progress in LLM quantization and deployment, the journey towards perfectly balanced high-precision and high-performance LLMs continues. Future work could explore deeper integrations of mixed precision techniques, further refinement of quantization-aware training, and better hardware-accelerated support for ultra-low precision operations.

Conclusion

The combination of QoQ's innovative quantization approach and QServe's system optimizations introduces a compelling methodology for deploying highly efficient and performant LLMs, significantly advancing the frontiers of model serving technology.

Acknowledgements

Thanks are due to various support from academic and industry partners and ongoing collaborative efforts that continually push the boundaries of what's possible in artificial intelligence infrastructure.

Newsletter

Get summaries of trending comp sci papers delivered straight to your inbox:

Unsubscribe anytime.