Dual Grained Quantization: Efficient Fine-Grained Quantization for LLM

Luoming Zhang, Wen Fei, Weijia Wu, Yefei He, Zhenyu Lou, Hong Zhou · DOI

TL;DR

This paper introduces Dual Grained Quantization (DGQ), a novel A8W4 quantization technique for Large Language Models (LLMs) that achieves superior performance and efficiency. DGQ balances fine-grained quantization's accuracy benefits with coarse-grained methods' computational speed, enabling faster LLM inference with reduced memory footprint.

What Problem Does This Paper Address?

Large Language Models (LLMs) like GPT-4 and LLaMA are incredibly powerful but demand massive computational resources and memory, making them difficult to deploy. Quantization, a technique to reduce model size and speed up inference by using lower-precision numbers, is a promising solution. However, existing fine-grained quantization methods, while preserving accuracy, often lead to inefficient inference due to hardware limitations. Coarse-grained methods are faster but sacrifice accuracy. This paper tackles the challenge of achieving both high accuracy and efficient inference for LLMs through a novel quantization approach.

Methods

The core innovation is Dual Grained Quantization (DGQ), an A8W4 (8-bit activation, 4-bit weight) quantization scheme. DGQ addresses the inefficiency of fine-grained quantization by:

  • Dequantizing INT4 weights to INT8: Instead of directly using INT4 weights, DGQ converts them to INT8. This allows for matrix multiplication using efficient INT8 kernels, bridging the gap between fine-grained accuracy and coarse-grained speed.
  • Two-Phase Grid Search: To efficiently determine the optimal quantization scales (parameters that map floating-point numbers to integers), the authors propose a two-phase search. This method significantly reduces the search space compared to traditional single-step approaches.
  • Percentile Clipping Smoothing: To handle outliers in activations (values that can disproportionately affect quantization accuracy), DGQ employs a percentile clipping schema. This smooths out these extreme values without requiring complex optimization techniques.

Datasets

The paper evaluates DGQ on several standard LLM benchmarks and datasets:

  • WikiText-2: Used for perplexity evaluation.
  • Common Sense Question Answers (CSQA): Evaluated using five zero-shot tasks: HellaSwag, PIQA, Winogrande, BoolQ, and ARC.
  • Generation Tasks: Evaluated using WikiText-2, PTB, and C4 datasets.
  • Models: LLaMA (1-7B, 1-13B, 1-30B, 1-65B) and OPT (125M, 1.3B, 2.7B, 6.7B, 13B, 30B, 66B) families.

Key Insights and Ideas

  • Bridging the Quantization Gap: The paper demonstrates that it's possible to achieve the accuracy benefits of fine-grained quantization while leveraging the computational efficiency of coarse-grained methods by strategically dequantizing weights to an intermediate precision (INT8).
  • Efficient Scale Optimization: The two-phase grid search is crucial for making the quantization process practical, avoiding the combinatorial explosion of parameters that would otherwise make it intractable.
  • Robustness to Outliers: The percentile clipping smoothing is a simple yet effective way to handle activation outliers, a common challenge in LLM quantization, without complex training or optimization.
  • Hardware-Friendly Approach: By enabling INT8 GEMM operations, DGQ aligns well with existing hardware capabilities, avoiding the need for specialized hardware.

Key Results

  • Performance: DGQ consistently outperforms prior methods across various LLM architectures and tasks, achieving comparable or superior accuracy to existing techniques. For instance, on WikiText-2, DGQ achieves a perplexity loss of only 0.3 compared to floating-point A8W4.
  • Efficiency: The implemented CUTLASS kernels achieve significant speedups. Compared to an A16W4 implementation, DGQ offers up to 3.24x speed gains and 1.12x memory reduction. It also achieves A8W8-level inference times with half the memory usage.
  • Training Time: DGQ can quantize large models like BLOOM-176B in approximately one GPU hour on an A100-80G.

Limitations and Future Work

  • Two-Operation Challenge: The authors acknowledge a current limitation where two separate operations are needed in different situations, and they are actively working on a unified solution.
  • Memory Consumption in Self-Decoding: For tasks involving large self-attention matrices (e.g., 32K sequence length), memory consumption remains a challenge. The paper suggests exploring quantization methods for activation to mitigate this.
  • Activation Quantization: While the paper focuses on weight-activation quantization, it notes that layer-wise activation quantization strategies could further improve performance, especially concerning smooth scales.

Summary updated

BibTeX
@misc{zhang2023dual,
  author = {Luoming Zhang and Wen Fei and Weijia Wu and Yefei He and Zhenyu Lou and Hong Zhou},
  title = {{Dual Grained Quantization: Efficient Fine-Grained Quantization for LLM}},
  year = {2023},
  eprint = {2310.04836},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2310.04836},
  howpublished = {SSRN},
}
Figure