LoftQ: LoRA-Fine-Tuning-Aware Quantization for Large Language Models

Yixiao Li, Yifan Yu, Chen Liang, Pengcheng He, Nikos Karampatziakis, Weizhu Chen, Tuo Zhao · DOI

Abstract

As Large Language Models (LLMs) scale, the computational cost of fine-tuning becomes a significant barrier. While quantization and Low-Rank Adaptation (LoRA) offer solutions, their sequential application in methods like QLoRA often leads to a "discrepancy gap" that degrades performance, particularly at low bit-widths. We present LoftQ (LoRA-Fine-Tuning-aware Quantization), a framework that jointly optimizes quantization and adapter initialization. By iteratively minimizing the approximation error between original and quantized weights, LoftQ enables robust fine-tuning even in 2-bit regimes, often matching or exceeding full-precision performance.

Introduction: The Discrepancy Gap

The deployment of LLMs necessitates efficient compression techniques. Quantization reduces weight precision (e.g., from 16-bit to 4-bit), while LoRA fine-tunes a small set of external adapter matrices. The current state-of-the-art, QLoRA, quantizes the model backbone first and then initializes adapters to zero.

However, this sequential approach introduces a fundamental discrepancy. Quantization noise significantly alters the model's initial state. While manageable at 4 bits, this gap becomes catastrophic at 2 bits, leading to severe performance degradation or a total failure to converge on downstream tasks.

Perplexity increases sharply as the number of bits decreases, illustrating the challenge of low-bit quantization.

Methods: Joint Optimization via LoftQ

LoftQ addresses this by treating quantization and adapter initialization as a joint optimization problem. Instead of isolating the quantized backbone $Q$, LoftQ seeks to find $Q$ and low-rank matrices $A$ and $B$ such that their sum $(Q + AB^T)$ closely approximates the original high-precision weight matrix $W$. This "compensatory initialization" turns the adapter into a corrective lens for the "blurry" quantized model.

The core of the framework is an Alternating Optimization algorithm:

  1. Initialization: Start with zero-initialized adapters.
  2. Quantization Step: Quantize the difference between the original weights and the current low-rank approximation: $Q_t = \text{quantize}(W - A_{t-1}B_{t-1}^T)$.
  3. SVD Step: Apply Singular Value Decomposition (SVD) to the residual error $R_t = W - Q_t$ to update the low-rank matrices $A_t$ and $B_t$.
  4. Iteration: Repeat this process (typically $T=5$ times) to minimize the discrepancy.
LoftQ significantly reduces the discrepancy between original and quantized weights compared to QLoRA across various bit-widths and quantization schemes.

Evaluation and Key Results

LoftQ was evaluated across diverse architectures (DeBERTaV3, BART, Llama-2) and tasks (GLUE, SQuAD, GSM8K).

  • 2-Bit Breakthrough: In extreme 2-bit regimes, LoftQ maintains high performance where QLoRA often fails to converge. For example, on MNLI with 2-bit uniform quantization, LoftQ achieved 88.0% accuracy, compared to 79.9% for QLoRA.
  • Superior Summarization: On the XSum dataset with BART-large, 4-bit LoftQ (44.51 ROUGE-1) outperformed both QLoRA (43.29) and full-precision LoRA (43.95).
  • Implicit Regularization: In tasks like mathematical reasoning (GSM8K), LoftQ occasionally outperformed full-precision models, suggesting that the combination of quantization and low-rank constraints may act as a beneficial regularizer.

Conclusion

LoftQ bridges the gap between model compression and fine-tuning by using adapters as a corrective mechanism for quantization noise. By enabling high-performance 2-bit fine-tuning, it significantly lowers the barrier to entry for customizing state-of-the-art LLMs. Future work will explore activation quantization and extending the framework to other parameter-efficient fine-tuning methods.

Summary updated

BibTeX
@inproceedings{li2024loftq,
  author = {Yixiao Li and Yifan Yu and Chen Liang and Pengcheng He and Nikos Karampatziakis and Weizhu Chen and Tuo Zhao},
  title = {{LoftQ: LoRA-Fine-Tuning-Aware Quantization for Large Language Models}},
  booktitle = {International Conference on Learning Representations},
  year = {2024},
  url = {https://openreview.net/forum?id=LzPWWPAdY4},
}
Figure