Abstract
Quantizing both weights and activations to 4-bits (W4A4) is a significant challenge in Large Language Model (LLM) inference due to the presence of outliers and high variance in activation distributions. This paper introduces Locally Optimal Block Clustered Quantization (LO-BCQ), a post-training quantization method that clusters tensor blocks and assigns them optimized, universal codebooks. LO-BCQ achieves near-lossless performance (under 1% accuracy loss) on models like Llama2-70B and GPT3 without retraining, outperforming existing state-of-the-art methods while maintaining hardware-friendly small codebook sizes.
The Challenge of 4-bit Activation Quantization
Quantization is the standard technique for fitting massive LLMs onto smaller hardware. While 4-bit weight-only quantization is well-established, quantizing activations to 4-bits remains difficult. Activations are dynamic and contain significant outliers, making them prone to high error rates when compressed. Previous solutions often required expensive Quantization-Aware Training (QAT) or large, hardware-unfriendly codebooks. LO-BCQ addresses these issues with a pure post-training approach that is both accurate and efficient.
Methods: Block Clustered Quantization
The proposed framework, Block Clustered Quantization (BCQ), follows a multi-step process to minimize quantization error:
- Decomposition: Tensors are partitioned into small, contiguous groups of scalars called blocks.
- Clustering: Blocks are grouped into clusters based on their statistical properties, allowing different regions of a tensor to use specialized quantization grids.
- Iterative Optimization (LO-BCQ): The algorithm iteratively refines the mapping of blocks to clusters and optimizes the 4-bit codebooks (sets of 16 representative values) using the Lloyd-Max algorithm.
- Universal Calibration: The researchers discovered that optimal codebook shapes are consistent across layers and models. By calibrating a set of "universal" codebooks once, the method avoids per-layer recalculation during inference.
This approach results in an effective bitwidth of approximately 4.5 to 4.6 bits, including the overhead for codebook selection metadata.
Key Results
LO-BCQ was evaluated on models ranging from GPT3 (1.3B to 22B) to Llama2 (70B) and Nemotron4 (340B).
Performance Comparison
On the Llama2-70B model, LO-BCQ achieved a perplexity loss of only 0.06 compared to the unquantized BF16 baseline. As shown in the figure below, LO-BCQ maintains a significantly better trade-off between compression and perplexity compared to other state-of-the-art methods like OPTQ, AWQ, and MXFP.
Accuracy and Efficiency
In zero-shot downstream tasks, LO-BCQ maintained high accuracy (e.g., ~64.7% on Llama2-7B), whereas competing methods often saw significant drops. Furthermore, the codebooks used are extremely small (less than 0.2 KB), allowing them to reside in fast on-chip SRAM, which is critical for high-throughput inference.
Conclusion and Future Work
LO-BCQ represents a major step toward practical W4A4 inference for LLMs. By combining block-level clustering with optimized universal codebooks, it achieves near-lossless accuracy without the need for weight updates or retraining. Future research will focus on developing specialized hardware kernels to translate these mathematical gains into real-world inference speedups.
Summary updated