TL;DR
This paper introduces PT$^2$-LLM, a novel post-training ternarization framework that compresses large language models (LLMs) to an average of 1.58 bits per parameter without retraining. PT$^2$-LLM achieves competitive accuracy with state-of-the-art 2-bit quantization methods while significantly reducing model size and accelerating inference, making LLMs more deployable on resource-constrained devices.
What Problem Does This Paper Address?
Large Language Models (LLMs) are incredibly powerful but also notoriously resource-intensive, requiring massive amounts of memory and computational power for training and deployment. This limits their use in many real-world applications. While quantization techniques aim to reduce these demands, post-training ternarization (reducing weights to {-1, 0, +1}) has been underexplored in the post-training quantization (PTQ) setting. This is primarily due to two challenges: (1) optimizing ternary parameters without any training is difficult, and (2) the presence of outliers and dispersed weights in LLMs makes them prone to significant quantization errors. PT$^2$-LLM tackles these challenges to enable efficient, training-free ternarization of LLMs.
Methods
PT$^2$-LLM introduces several key innovations:
- Asymmetric Ternary Quantizer (ATQ): Unlike traditional symmetric ternarization, ATQ accounts for non-zero means in LLM weights by introducing an asymmetric scheme with a learned offset ($\mu$). ATQ employs a two-stage refinement pipeline:
- Iterative Ternary Fitting (ITF): This stage iteratively optimizes the ternary grid parameters (scaling factor $\alpha$ and offset $\mu$) and the ternary matrix ($T$) to minimize quantization error. It alternates between constructing an optimal ternary grid and using flexible rounding to map weights to the ternary values.
- Activation-aware Grid Alignment (AGA): This stage further refines the ternary grid by considering the interaction between weights and activations, using calibration data to minimize the output error and better align quantized outputs with full-precision ones.
- Structural Similarity-based Reordering (SSR): To address the issue of outlier columns and dispersed weights, SSR is a plug-and-play strategy that reorders weight columns within blocks based on their structural similarity. This helps to create more homogeneous blocks, easing quantization and mitigating the impact of outliers. It's integrated efficiently within the GPTQ framework.
Datasets
The paper uses the following datasets:
- Calibration: WikiText2 (Merity et al., 2017) is used for calibration, with 128 samples each of sequence length 2048. C4 (Raffel et al., 2020) and PTB are also explored for calibration set type ablation.
- Evaluation:
- Perplexity: WikiText2 and C4.
- Zero-shot Accuracy: Seven QA benchmarks: ARC-c, ARC-e, BoolQ, HellaSwag, OBQA, PIQA, and Winogrande.
Key Insights and Ideas
- Asymmetry Matters for LLMs: LLM weight distributions are often not symmetric, meaning a simple symmetric ternary mapping can lead to significant errors. Introducing an asymmetric scheme with an offset ($\mu$) is crucial for capturing this bias in a PTQ setting.
- Two-Stage Refinement is Key: Simply optimizing for weight quantization error isn't enough. The iterative fitting (ITF) followed by activation-aware alignment (AGA) provides a more robust approach, ensuring that the quantized model's outputs better reflect the original model's behavior.
- Structure-Aware Reordering Boosts Ternarization: Naive block-wise ternarization struggles with outliers. Reordering columns based on structural similarity (SSR) creates more coherent blocks, significantly improving quantization quality and reducing sensitivity to outliers.
- PTQ Ternarization is Viable and Powerful: The paper demonstrates that achieving competitive results with ternarization in a PTQ setting is possible, offering a compelling alternative to 2-bit quantization with even greater compression and speedup.
Key Results
- Accuracy: PT$^2$-LLM achieves competitive accuracy compared to state-of-the-art (SOTA) 2-bit PTQ methods. For example, on LLaMA-7B, it achieves an average accuracy of 45.07% while using only 1.58 bits per parameter, outperforming GPTQ, AWQ, and QuIP.
- Model Size: PT$^2$-LLM achieves the smallest model size, with LLaMA-7B compressed to 1.88 GB (7.17x reduction from FP16), surpassing even some binarization methods.
- Inference Speed: PT$^2$-LLM consistently improves throughput across prefill, decode, and end-to-end generation stages, achieving up to 2.1x acceleration on LLaMA-65B compared to 2-bit quantization.
- Compression Time: PT$^2$-LLM is efficient, compressing LLaMA-7B in just 32 minutes, which is significantly faster than methods like Slim-LLM.
Limitations and Future Work
- Calibration Data: While the paper shows robustness to calibration set size, the choice of calibration data (e.g., WikiText2 vs. C4) can impact perplexity on specific datasets. Future work could explore more sophisticated calibration strategies.
- Overfitting: The paper notes that updating the ternary matrix $T$ after AGA can lead to overfitting on the calibration set, so they freeze $T$ in that stage. This suggests potential for further exploration in balancing adaptation and generalization.
- Foundation for Future Research: The authors position PT$^2$-LLM as a strong baseline for sub-2-bit compression in LLMs, laying the groundwork for future research in this area. They suggest exploring more advanced reordering techniques or further optimizing the ATQ framework.
Summary updated