Source-linked AI summary

LQ-LoRA: Low-rank Plus Quantized Matrix Decomposition for Efficient Language Model Finetuning

Han Guo, Philip Greengard, Eric P. Xing, Yoon Kim

arXiv:2311.12023v4cs.CLcs.LG

TL;DR

Full finetuning makes adapting large pretrained language models expensive, motivating memory-efficient alternatives. LQ-LoRA decomposes pretrained matrices into fixed quantized and trainable low-rank components, and experiments report improvements over strong baselines alongside low-bit compression.

  • Problem

    Large language models are expensive to adapt through full finetuning because of their size, despite the value of adapting them to new datasets.

    Source: §1 · p. 1
  • Method

    LQ-LoRA iteratively decomposes each pretrained matrix into a fixed quantized component and a trainable low-rank component, using integer linear programming to configure quantization per matrix under a target memory budget.

    Source: §1 · p. 2, §3.2 · p. 5
  • Results

    LQ-LoRA meaningfully improves on QLoRA (Dettmers et al., 2023a) and GPTQ-LoRA (Frantar et al., 2022; Chai et al., 2023), and its LLaMA-2-70B compression setting reaches 2.85 bits with small perplexity degradation.

    Source: §1 · p. 2
  • Takeaways & Limitations

    LQ-LoRA also serves as a weight-only post-training quantization method on standard language-modeling datasets and supports flexible target memory budgets.

    Source: §1 · p. 2

    LQ-LoRA relies on adaptation through low-rank updates and is not generally applicable to other parameter-efficient finetuning methods.

    Source: §5 · p. 10

Abstract

from arXiv · show

We propose a simple approach for memory-efficient adaptation of pretrained language models. Our approach uses an iterative algorithm to decompose each pretrained matrix into a high-precision low-rank component and a memory-efficient quantized component. During finetuning, the quantized component remains fixed and only the low-rank component is updated. We present an integer linear programming formulation of the quantization component which enables dynamic configuration of quantization parameters (e.g., bit-width, block size) for each matrix given an overall target memory budget. We further explore a data-aware version of the algorithm which uses an approximation of the Fisher information matrix to weight the reconstruction objective during matrix decomposition. Experiments on finetuning RoBERTa and LLaMA-2 (7B and 70B) demonstrate that our low-rank plus quantized matrix decomposition approach (LQ-LoRA) outperforms strong QLoRA and GPTQ-LoRA baselines and enables aggressive quantization to sub-3 bits with only minor performance degradations. When finetuned on a language modeling calibration dataset, LQ-LoRA can also be used for model compression; in this setting our 2.75-bit LLaMA-2-70B model (which has 2.85 bits on average when including the low-rank components and requires 27GB of GPU memory) performs respectably compared to the 16-bit baseline.

1 INTRODUCTION

Full finetuning makes large language models expensive to adapt, motivating memory-efficient methods. LQ-LoRA decomposes pretrained weights into fixed quantized and trainable low-rank components, improving on strong baselines and supporting low-bit compression.

1 INTRODUCTION

  • LoRA reparameterizes pretrained weights with a trainable low-rank update, reducing finetuning memory by leaving the pretrained parameters fixed.This avoids storing gradients and optimizer states for those parameters.Source: §1 · p. 1
  • An iterative decomposition represents each pretrained matrix as a quantized component Q plus low-rank factors L1L2, keeping Q fixed while finetuning the factors.The low-rank component captures high-variance subspaces and accounts for quantization error in its initialization.Source: §1 · p. 2
  • An integer linear program assigns different quantization configurations to each matrix under an overall target bit rate.Configurations can vary in bit width and block size.Source: §1 · p. 2
  • A data-aware variant weights the decomposition objective using an approximation of the Fisher information matrix from calibration samples.Source: §1 · p. 2
  • LQ-LoRA meaningfully improves on QLoRA (Dettmers et al., 2023a) and GPTQ-LoRA (Frantar et al., 2022; Chai et al., 2023); its LLaMA-2-70B compression setting reaches 2.85 bits with small perplexity degradation.The comparison covers adaptation of RoBERTa and LLaMA-2 models.Source: §1 · p. 2

2 BACKGROUND

The background introduces low-rank adaptation and weight quantization as approaches relevant to memory-efficient language-model finetuning. It describes LoRA’s trainable low-rank update and QLoRA’s quantized-weight baseline.

2.1 LOW-RANK ADAPTATION OF LARGE LANGUAGE MODELS

  • LoRA reparameterizes a pretrained linear layer as X(W + L1L2), with L2 initialized to zero, and finetunes only the low-rank factors.L1 is initialized from Gaussian noise.Source: §2.1 · p. 2

2.2 WEIGHT QUANTIZATION OF LARGE LANGUAGE MODELS

  • Sub-4-bit round-to-nearest quantization is difficult, and recent methods generally use calibration samples for data-aware quantization.Source: §2.2 · p. 2
  • QLoRA applies NF-4 quantization to pretrained weights and learns low-rank updates, serving as the paper’s main baseline.Its double-quantization strategy quantizes the per-block absmax values.Source: §2.2 · p. 3

3 METHOD: LQ-LORA

LQ-LoRA decomposes pretrained matrices into quantized and low-rank components, then adapts the low-rank component. It extends this decomposition with per-matrix quantization choices under a memory budget and optional Fisher-weighted reconstruction.

3.1 LOW-RANK PLUS QUANTIZED MATRIX DECOMPOSITION

  • The iterative factorization alternates between optimizing the low-rank component and quantized component, but uses a heuristic stopping criterion rather than a convergence guarantee.It tracks reconstruction error and stops when that error increases.Source: §3.1 · p. 3
  • LQ decomposition reduces quantization error relative to NF-3 quantization across all layers, although projection-matrix errors vary by layer.The figure also tracks decomposition error over LQ steps for query projections.Source: §3.1 · p. 4, Figure 1 · p. 4

3.2 MIXED-CONFIGURATION QUANTIZATION VIA AN INTEGER LINEAR PROGRAM

  • NF-4 double quantization requires 4.127 bits per parameter on average, while the configuration search varies quantization and block parameters.The configuration tuple is (b0, b1, b2, B0, B1).Source: §3.2 · p. 4
  • An integer linear program assigns each matrix a quantization configuration to minimize reconstruction error within a target memory budget.The method precomputes errors and storage costs across configurations before solving for assignments.Source: §3.2 · pp. 4–5

3.3 DATA-AWARE MATRIX DECOMPOSITION VIA FISHER-WEIGHTED SVD

  • The data-aware variant weights reconstruction with a diagonal empirical Fisher approximation and uses row- and column-averaged weights in its SVD procedure.The authors report that this approach works in practice despite the homogeneous row/column assumption not holding for the Fisher matrix.Source: §3.3 · p. 6
  • An alternative calibration-activation-weighted reconstruction objective underperformed the Fisher-weighted approach.Source: §3.3 · p. 6

4 EMPIRICAL STUDY

Across language-modeling, instruction-tuning, and GLUE evaluations, LQ-LoRA generally matches or outperforms quantized baselines at similar bit budgets. Compression and analysis examine its accuracy, quantization allocation, rank, and memory trade-offs.

4 EMPIRICAL STUDY

  • Experiments cover continual language modeling and instruction tuning with LLaMA-2, plus GLUE finetuning with RoBERTa-Large, using QLoRA and GPTQ-LoRA as main baselines.GPTQ-LoRA was excluded from instruction-tuning experiments because training was unstable.Source: §4 · p. 7

4.1 RESULTS

  • LQ-LoRA almost always outperforms QLoRA and GPTQ-LoRA at near-similar bit budgets, and it outperforms QLoRA at similar bit-widths on GLUE.At 7B, Fisher-weighted LQ-LoRA outperforms the unweighted version across target bit widths; the difference shrinks at 70B.Source: §4.1 · p. 8, Table 2 · p. 8

4.2 LQ-LORA FOR MODEL COMPRESSION

  • 2.95 bits/param for LLaMA-2 7B and 2.85 bits/param for 70B are the effective costs of 2.75-bit LQ-LoRA, which generally outperforms other sub-4-bit PTQ methods.Effective bits include LoRA components quantized to 8 bits.Source: §4.2 · p. 8, Table 3 · p. 8
  • Some zero/few-shot benchmarks, including GSM8K and ARC, show nontrivial degradation, so perplexity changes do not always track downstream performance.The evaluation uses six Open LLM benchmarks.Source: §4.2 · p. 9, Table 4 · p. 9

4.3 ANALYSIS

  • At a 2.75-bit target, the ILP assigns different quantization configurations across matrices, and those allocations differ between Fisher-weighted and unweighted LQ-LoRA.Figure 4 shows bits per parameter by layer and matrix type for QLoRA and both LQ-LoRA variants.Source: §4.3 · p. 9, Figure 4 · p. 9
  • With NF-3 fixed at 3.127 bits/param, QLoRA is insensitive to LoRA rank, while LQ-LoRA uses additional ranks to reduce initialization error and improve performance.The comparison uses LLaMA-2-7B and reports C4 and WikiText perplexity as a function of rank.Source: §4.3 · p. 9, Table 5 · p. 10
  • At sub-3 bits, a 70B model can run on one 40GB GPU, while full forward and backward passes fit on one 80GB GPU at batch size 2 and sequence length 2048.The memory breakdown distinguishes quantized parameters, LoRA parameters, and other components.Source: §4.3 · pp. 9–10, Figure 3 · p. 9

5 DISCUSSION AND LIMITATIONS

LQ-LoRA’s iterative algorithm is empirically effective but heuristic, and the approach relies on adaptation through low-rank updates. The authors also report unsuccessful variants and identify extensions for future work.

5 DISCUSSION AND LIMITATIONS

  • The iterative decomposition algorithm is empirically effective but remains heuristic, motivating more theoretically principled alternatives.The authors also note that applying LQ decomposition to quantization approaches beyond NF may yield further gains.Source: §5 · p. 10
  • Periodic matrix refactorization and a hybrid initialization combining LQ-LoRA with standard LoRA did not improve results.The hybrid used half of the adaptable low-rank component from each initialization.Source: §5 · p. 10
  • LQ-LoRA relies on low-rank updates and is therefore not generally applicable to other parameter-efficient finetuning methods.The authors suggest extending the ILP approach to assign different quantization precisions and ranks to different matrices.Source: §5 · p. 10

6 RELATED WORK

Related work spans parameter-efficient finetuning, low-rank plus quantized decomposition, and LLM compression. The paper’s ILP allocation objective minimizes decomposition error rather than downstream performance.

6 RELATED WORK

  • Parameter-efficient finetuning methods reduce memory by keeping pretrained parameters fixed and training a smaller extension, with approaches including adapters, prompts, and partial parameter updates.Prior work also combines parameter-efficient finetuning with quantization.Source: §6 · p. 10
  • Low-rank plus sparse decomposition is well studied, while prior deep-learning applications include smaller models and recent work on quantized low-rank approximations and LLM adaptation.The cited smaller-model compression work covers models with fewer than 100M parameters.Source: §6 · p. 10
  • Low-rank compression for LLMs with 1B+ parameters remains underexplored, while existing LLM compression approaches have generally focused on quantization.The passage notes that slowly decaying singular values may help explain the limited exploration of low-rank approaches.Source: §6 · p. 10
  • Data-aware quantization strategies use calibration data to improve weight quantization, while the ILP objective here minimizes decomposition error rather than downstream performance.The authors note that weighting LoRA parameters as less costly could address this objective mismatch.Source: §6 · pp. 10–11

7 CONCLUSION

The paper extends LoRA with a low-rank plus quantized decomposition and dynamic quantization configurations. The authors report meaningful improvements over strong baselines.

7 CONCLUSION

  • LQ-LoRA factorizes pretrained matrices into low-rank and quantized components, allows dynamic quantization configurations, and yields meaningful improvements over strong baselines.Source: §7 · p. 11

A IMPLEMENTATION DETAILS

The implementation uses PyTorch to support dynamic quantization strategies and reports speed comparable to QLoRA’s bitsandbytes implementation. Optional optimizer offloading reduces memory use, while just-in-time dequantization adds relatively little overhead for reasonably sized matrices.

A IMPLEMENTATION DETAILS

  • The PyTorch-only implementation supports experimentation with dynamic quantization strategies without configuration-specific custom CUDA extensions.Sub-8-bit weights are packed into supported data types and unpacked during dequantization.Source: A IMPLEMENTATION DETAILS · p. 16
  • The compiled PyTorch implementation was as fast as QLoRA’s bitsandbytes implementation for LoRA finetuning.It compiles bit unpacking, dequantization, linear algebra, transpose, and casting operations.Source: A IMPLEMENTATION DETAILS · p. 16
  • 14% memory savings on the 70-billion-parameter model came with a marginal (<2%) increase in training speed from CPU-based optimizer offloading.The method keeps a CPU copy of trainable parameters, moves gradients to CPU for optimizer steps, and overlaps per-matrix updates with asynchronous transfers.Source: A IMPLEMENTATION DETAILS · p. 16
  • Table 6 reports rank-64 LLaMA-2 results, with C4, Wikipedia, and MMLU based on C4 finetuning and Vicuna evaluation based on OpenAssistant finetuning.The QLoRA and GPTQ-LoRA results use the authors’ reimplementations.Source: Table 6 · p. 17
  • Just-in-time dequantization makes runtime no lower than dense FP32 matrix multiplication, with relatively small overhead for reasonably sized matrices.The runtimes were collected with PyTorch Profiler using TF32.Source: A IMPLEMENTATION DETAILS · p. 17

B FULL RESULTS

Table 6 presents the full numeric results comparing LQ-LoRA with QLoRA and GPTQ-LoRA.

  • Table 6 presents the full numeric results comparing LQ-LoRA with QLoRA and GPTQ-LoRA.Source: B FULL RESULTS · p. 17
Loading 2311.12023v4…