[Paper Review] QuaRot: Outlier-Free 4-Bit Inference in Rotated LLMs
QuaRot introduces a novel quantization framework that uses randomized Hadamard transformations to eliminate outlier activations in LLMs, enabling end-to-end 4-bit inference across weights, activations, and KV cache without accuracy loss. By leveraging computational invariance, it achieves 2.16x prefill speedup and 3.39x memory reduction on Llama 2-70B with only 0.29 perplexity degradation on WikiText-2.
We introduce QuaRot, a new Quantization scheme based on Rotations, which is able to quantize LLMs end-to-end, including all weights, activations, and KV cache in 4 bits. QuaRot rotates LLMs in a way that removes outliers from the hidden state without changing the output, making quantization easier. This computational invariance is applied to the hidden state (residual) of the LLM, as well as to the activations of the feed-forward components, aspects of the attention mechanism, and to the KV cache. The result is a quantized model where all matrix multiplications are performed in 4 bits, without any channels identified for retention in higher precision. Our 4-bit quantized LLaMa2-70B model has losses of at most 0.47 WikiText-2 perplexity and retains 99% of the zero-shot performance. We also show that QuaRot can provide lossless 6 and 8 bit LLaMa2 models without any calibration data using round-to-nearest quantization. Code is available at: https://github.com/spcl/QuaRot.
Motivation & Objective
- Address the challenge of outlier activations in 4-bit quantization of LLMs, which severely degrade model accuracy.
- Enable end-to-end 4-bit quantization of all components—weights, activations, and KV cache—without retaining any channels in higher precision.
- Leverage computational invariance through orthogonal transformations to reconfigure the model’s coordinate system, eliminating outliers without altering model output.
- Achieve high-precision performance at low bit-widths, particularly for 4-bit inference, which remains a major bottleneck in efficient LLM deployment.
Proposed method
- Apply randomized Hadamard transformations to the input and output weight matrices of each transformer block, using computational invariance to preserve model output while removing outlier features in hidden states.
- Fuse the Hadamard transformations into the weight matrices during model construction, creating an equivalent network where activations no longer contain extreme outliers.
- Extend the transformation to the feed-forward network activations and the attention mechanism, specifically targeting keys and values to enable 4-bit quantization of the KV cache.
- Use group-wise asymmetric quantization with configurable group sizes for weights and activations, while maintaining high precision for KV cache when needed.
- Integrate the method with existing quantization schemes such as GPTQ and RTN for weight quantization, enabling compatibility with standard LLM inference pipelines.
- Apply online Hadamard transformations during inference to maintain robustness and avoid retraining, ensuring compatibility with dynamic autoregressive generation.
Experimental results
Research questions
- RQ1Can outlier features in LLM activations be systematically eliminated without altering model output, enabling 4-bit quantization across all components?
- RQ2To what extent can computational invariance via orthogonal transformations (e.g., Hadamard matrices) be used to reconfigure the model’s internal representation to reduce quantization error?
- RQ3Is end-to-end 4-bit inference feasible for large LLMs like Llama 2-70B when all components—weights, activations, and KV cache—are quantized to 4 bits?
- RQ4How does the performance of QuaRot compare to existing 4-bit quantization methods that retain some components in higher precision?
- RQ5What is the optimal trade-off between group size, quantization precision, and accuracy loss in the context of 4-bit activation quantization?
Key findings
- QuaRot enables end-to-end 4-bit quantization of Llama 2-70B with only 0.29 perplexity degradation on WikiText-2, retaining 99% of the zero-shot performance of the FP16 baseline.
- The method achieves up to 2.16x speedup in the prefill phase and up to 3.39x memory reduction during decoding on an RTX 3090 GPU.
- For Llama 2-7B, QuaRot achieves 2.16x prefill speedup and 3.39x memory savings with at most 0.63 perplexity loss on WikiText-2.
- 6-bit and 8-bit quantization of weights and activations using QuaRot is lossless across all tested models, with no measurable performance drop.
- KV cache quantization to 3-bit (with 4-bit keys and 3-bit values) results in only 0.07 perplexity degradation on Llama 2-70B, demonstrating high robustness.
- The method maintains superior quantization performance across all model sizes, with QuaRot-INT4 achieving 3.79 perplexity on Llama 2-70B, compared to 3.32 for the FP16 baseline.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.