Accurate and Efficient Fine-Tuning of Quantized Large Language Models Through Optimal Balance

Ao Shen, Qiang Wang, Zhiquan Lai, Xionglve Li, Dong-sheng LiarXiv 2024 · DOI

Introduction

Fine-tuning large language models (LLMs) on consumer-grade hardware typically necessitates the use of quantization and parameter-efficient fine-tuning (PEFT) techniques. While the combination of 4-bit quantization and Low-Rank Adaptation (LoRA)—often referred to as QLoRA—has democratized LLM training, it frequently incurs a "performance tax." Models fine-tuned this way often fail to reach the accuracy levels of their full-precision counterparts. This paper identifies an inherent structural imbalance in current adapter designs as a primary cause of this degradation and introduces two novel methods, Q-BLoRA and QA-BLoRA, to address it.

The Imbalance Problem

The authors identify a critical bottleneck in standard QLoRA: the adapter is forced to process extremely high-dimensional inputs (e.g., 4096 dimensions for LLaMA-7B) using a very small internal rank (typically 16 to 64). This creates a capacity mismatch where the low-rank adapter struggles to simultaneously learn new tasks and compensate for information lost during quantization. Furthermore, merging these adapters back into quantized models for deployment often leads to additional performance loss.

Proposed Solutions: Q-BLoRA and QA-BLoRA

Q-BLoRA: Balanced Low-Rank Adaptation

Q-BLoRA introduces a "balancing" mechanism to the LoRA architecture. It employs a non-parameterized AvgPool operation to reduce the input dimensionality of the adapter and a repeat_interleave operation to restore the output dimensionality. By reducing the input/output dimensions by a factor of $\lambda$, the internal rank of the LoRA matrices can be increased by the same factor $\lambda$ without increasing the total number of trainable parameters. This structural adjustment smooths the optimization landscape and allows the adapter to capture more complex patterns.

Performance comparison of Q-BLoRA against QLoRA and IR-QLoRA across various LLaMA model sizes.

QA-BLoRA: Quantization-Aware BLoRA

Designed specifically for 4-bit deployment, QA-BLoRA aligns the adapter's structure with the block-wise quantization (e.g., 4x8 or 8x8 blocks) used in pre-trained models. Unlike traditional methods where the adapter remains separate, QA-BLoRA allows trained weights to be merged directly into the quantization offsets ($\beta$ values) of the 4-bit model. This results in a pure 4-bit model that is ready for edge deployment without requiring post-training calibration steps like GPTQ.

Experimental Results

The proposed methods were evaluated using Alpaca and Flan v2 instruction-tuning datasets across benchmarks including MMLU, Commonsense QA, and human evaluation simulations.

Performance Gains

Q-BLoRA demonstrates significant improvements over standard QLoRA. For instance, on the MMLU benchmark, Q-BLoRA (LLaMA-7B) achieved an accuracy of 41.4%, compared to 38.4% for standard QLoRA and 40.8% for the competitive IR-QLoRA. These gains are consistent across model scales, as shown in Figure 2.

4-bit Deployment Excellence

QA-BLoRA consistently outperforms existing 4-bit inference methods. In several benchmarks, the 4-bit QA-BLoRA model even surpassed 16-bit baselines, suggesting that quantization-aware training can effectively recover precision lost during the initial quantization process. On LLaMA2, QA-BLoRA 4-bit achieved 46.3% accuracy, outperforming the QA-LoRA 4-bit baseline of 45.1%.

Accuracy comparison of Q-BLoRA and QA-BLoRA against baselines on LLaMA2-7B.

Key Insights

  • Dimensionality Reduction as a Regularizer: Reducing the resolution of the adapter's input via pooling helps filter out noise and outliers, leading to better convergence.
  • Optimal Balancing Factor: The balancing factor $\lambda$ is crucial. While $\lambda=2$ is optimal for LLaMA models, newer architectures like Mistral and Gemma benefit from a higher factor of $\lambda=8$.
  • Efficiency: Both methods maintain the low memory footprint of QLoRA, allowing a 7B model to be fine-tuned on approximately 13GB of VRAM.

Conclusion

Q-BLoRA and QA-BLoRA provide a robust framework for high-performance fine-tuning of quantized LLMs. By addressing the structural imbalance in adapters and enabling lossless integration into quantized weights, these methods achieve state-of-the-art results while remaining accessible for consumer-grade hardware.

Summary updated

BibTeX
@misc{shen2024accurate,
  author = {Ao Shen and Qiang Wang and Zhiquan Lai and Xionglve Li and Dong-sheng Li},
  title = {{Accurate and Efficient Fine-Tuning of Quantized Large Language Models Through Optimal Balance}},
  year = {2024},
  eprint = {2407.17029},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2407.17029},
}
Figure