TL;DR
This paper introduces QAM-W, a novel quantization method for Large Language Models (LLMs) that significantly reduces model size while maintaining high accuracy. By treating weight rows as 2D coordinates and using a specialized codebook, QAM-W achieves state-of-the-art compression, matching BF16 precision at nearly half the bit-rate.
What Problem Does This Paper Address?
Large Language Models (LLMs) are incredibly powerful but also enormous, making them difficult to deploy on resource-constrained devices. Quantization is a key technique to shrink these models by representing their weights with fewer bits. However, existing methods often treat each weight independently (scalar quantization), ignoring the inherent structure and correlations within weight rows. This leads to a loss of information and a drop in model performance. QAM-W aims to bridge this gap by exploiting the geometric structure of weight rows to achieve better compression without sacrificing accuracy.
Methods
QAM-W employs a multi-pronged approach:
- Hadamard Rotation: Weights are first rotated using a deterministic block-Hadamard transform. This step is lossless and helps to decorrelate the weight coordinates.
- 2D Codebook Quantization: After rotation, pairs of coordinates are treated as 2D points. These points are then quantized using a single, learned 2D Lloyd-Max codebook trained on a unit circular Gaussian distribution. This is a key innovation, moving beyond scalar quantization to capture pairwise relationships.
- Activation-Aware Scaling: To further improve performance, QAM-W incorporates an activation-aware scaling mechanism inspired by AWQ. This scales weights based on the magnitude of activations, effectively prioritizing important weights and reducing the impact of quantization errors on model output.
Datasets
The paper evaluates QAM-W on five LLMs across four families: TinyLlama-1.1B-Chat, Qwen2.5-3B-Instruct, Mistral-7B-Instruct-v0.3, Llama-2-7B-base, and Llama-2-13B-base.
For training and evaluation, the following datasets are used:
- WikiText-2: For perplexity measurements.
- lm-evaluation-harness: A suite of six downstream tasks (PIQA, HellaSwag, COPA, RTE, OpenBookQA, LAMBADA) for evaluating model performance on various NLP capabilities.
- MMLU: A comprehensive benchmark for evaluating knowledge and reasoning abilities.
Key Insights and Ideas
- 2D Structure Matters: Treating weight rows as 2D points and quantizing them jointly, rather than individually, unlocks significant compression gains. This is because weight coordinates are often correlated, and this structure can be exploited.
- Hadamard Rotation is Efficient: The use of a deterministic block-Hadamard transform is computationally cheap and requires no additional learned parameters, making it practical for LLM quantization.
- Activation-Awareness is Crucial: Simply quantizing weights isn't enough. Scaling weights based on activation magnitudes is vital for maintaining performance, especially at lower bitrates.
- KL Divergence as a Diagnostic: The paper shows a strong correlation between paired KL divergence and perplexity, suggesting KL can be a useful proxy for model quality during quantization.
Key Results
- Near BF16 Quality at ~5.5 bpw: QAM-W-5.5 (5.5 bits per weight) achieves perplexity within ±0.4% of BF16 (16-bit floating point) on all tested models.
- Significant Bitrate Reduction: This quality is achieved at approximately 32% fewer weight bits compared to SmoothQuant W8A8 (8 bits per weight).
- Joint 2D vs. Polar Coding: QAM-W's joint 2D coding outperforms polar (amplitude-phase) coding by 2-15 pp of APPL at equal bitrates.
- Competitive Low-Bit Performance: A 3.5 bpw variant of QAM-W shows promise, especially on quantization-tolerant architectures.
- Robustness Across Models: The performance gains are consistent across a range of LLMs, from 1.1B to 13B parameters.
Limitations and Future Work
- Activation-Awareness Tuning: The scaling exponent for activation-aware scaling was chosen from a small grid and not learned per-model or per-layer. A more sophisticated tuning could yield further improvements, particularly on sensitive models like Qwen 2.5.
- Architecture Coverage: While tested on five models from four families, the authors suggest extending the evaluation to larger models (70B+) and more contemporary architectures to fully assess the generalization of the ~5.5 bpw envelope.
- Fused Kernels: The current implementation dequantizes to BF16 before matmul. Developing fused dequantization-matmul kernels would be crucial for realizing actual inference latency benefits.
- Learned Codebooks: While the current codebook is trained on a synthetic Gaussian, a learned codebook tailored to the empirical post-rotation pair distribution could potentially offer even higher precision.
- Beyond MLP Layers: The current study primarily quantizes MLP layers. Extending quantization to self-attention layers and LM heads is a natural next step.
Summary updated