TL;DR
This paper introduces GPTVQ, a novel vector quantization (VQ) method that significantly improves the trade-off between LLM size and accuracy, especially for mobile deployment. By co-designing VQ with mobile CPU inference, GPTVQ achieves a 19% footprint reduction and 10% token rate increase over INT4 quantization, while maintaining accuracy.
What Problem Does This Paper Address?
Deploying large language models (LLMs) on mobile devices is a significant challenge due to limited DRAM footprint and bandwidth. These constraints directly impact model accuracy and token generation speed. While Vector Quantization (VQ) has shown promise in reducing model size, existing methods often suffer from large codebooks that are too slow for mobile inference, failing to deliver the expected speed gains. This paper aims to bridge this gap by developing a VQ approach optimized for mobile CPUs, focusing on efficient decoding and a favorable size-accuracy trade-off.
Methods
The core of this work is the GPTVQ algorithm, a post-training quantization (PTQ) method that extends the GPTQ framework for vector quantization. Key aspects include:
- Hardware-Aware VQ Representation: GPTVQ co-designs the VQ parameters (dimensionality, bitwidths, codebook size) with mobile CPU capabilities, specifically leveraging hardware lookup table (LUT) instructions for fast decoding. This results in smaller, per-block LUTs.
- Efficient Quantization Flow: The algorithm quantizes weights in a greedy, column-by-column manner, interleaving quantization of a block of columns with updates to the remaining unquantized weights. This update mechanism uses information from the Hessian of the per-layer output reconstruction MSE to absorb quantization errors.
- Data-Aware EM Initialization: Codebooks are initialized using a variant of the Expectation-Maximization (EM) algorithm that is data-aware, minimizing a weighted distance function that incorporates Hessian information.
- Codebook Compression: Codebooks are further compressed using INT4 quantization and, in some cases, Singular Value Decomposition (SVD) for dimensionality reduction.
- Custom LLM Inference Engine: A specialized LLM inference engine for mobile CPUs is developed to efficiently handle VQ decompression and leverage hardware LUT instructions.
Datasets
- Calibration Data: WikiText2 (Merity et al., 2016) is used for calibration, with 128 sequences of 2048 tokens.
- Evaluation Benchmarks:
- WikiText2 perplexity.
- Zero-shot language tasks: PIQA, ARC-easy, ARC-challenge, HellaSwag, WinoGrande.
- GSM8k (for LoRA adapter experiments).
- The paper also mentions using SlimPajama for fine-tuning codebooks.
Key Insights and Ideas
- Dimensionality is Key: Increasing VQ dimensionality (e.g., from 1D to 2D or 4D) significantly improves representational accuracy (SQNR) by allowing codebooks to better match the underlying data distribution.
- Mobile-First VQ Design: Traditional VQ methods with large codebooks are ill-suited for mobile. Co-designing VQ parameters (like using 6-bit indices for LUTs) is crucial for efficient on-device inference.
- VQ as a Storage Format: VQ is primarily used as a storage format, with weights decoded to a native data type for computation. This allows for significant footprint reduction without sacrificing compute efficiency.
- Complementarity with Adapters: GPTVQ can be effectively combined with LoRA adapters, not only recovering accuracy loss from aggressive quantization but also achieving state-of-the-art performance for adapter-based LLM serving on mobile.
- Hessian-Informed Quantization: Incorporating Hessian information into the quantization process (similar to GPTQ) is vital for minimizing quantization error and achieving high accuracy.
Key Results
- Mobile Performance: On a Snapdragon X Elite platform, GPTVQ achieves a 19% DRAM footprint reduction and a 10% token rate increase compared to INT4 quantization, outperforming llama.cpp.
- Accuracy: GPTVQ achieves competitive accuracy with INT4 quantization, and in many cases, outperforms it, especially at lower bitwidths and for larger models. For example, GPTVQ 2D on Llama-v2-70B shows nearly 2 perplexity points improvement over OmniQuant W2@g128.
- VQ Dimensionality: Increasing VQ dimensionality generally leads to better perplexity and accuracy. 2D VQ often outperforms 1D VQ, and 4D VQ shows even more significant improvements.
- Compression Time: GPTVQ is significantly faster than methods like AQLM. Compressing Llama-v2-7B takes 30 minutes to 3 hours on a single H100 GPU, compared to 35 hours for AQLM.
- Codebook Fine-tuning: Fine-tuning codebooks improves results, though the original GPTVQ algorithm provides comparable performance right after initialization.
- INT4 Codebooks: Quantizing codebooks to INT4 results in a minor increase in perplexity.
Limitations and Future Work
- Quantization Dimensionality vs. Runtime: While higher VQ dimensionality improves accuracy, it also increases the runtime of the GPTVQ algorithm, particularly due to the EM codebook initialization.
- Intra-layer Error Correction: GPTVQ does not explicitly correct intra-layer error effects, unlike AQLM's block-wise fine-tuning step. However, its results are competitive even without this step.
- Future Work: The paper suggests exploring higher dimensions for VQ and further optimizing the codebook initialization and update procedures. The authors also highlight the potential for GPTVQ to be combined with other techniques for even greater compression and efficiency.
Summary updated