TL;DR
This paper introduces SubZero, a novel Zeroth-Order (ZO) optimization method for fine-tuning Large Language Models (LLMs) that significantly reduces memory consumption and improves performance. By employing a layer-wise low-rank perturbation in random subspaces, SubZero overcomes the high dimensionality challenge of LLMs, achieving comparable memory efficiency to inference-only methods while outperforming existing ZO techniques.
What Problem Does This Paper Address?
Fine-tuning Large Language Models (LLMs) is crucial for adapting them to specialized downstream tasks. However, as LLMs grow in size, the memory required for backpropagation (BP) becomes prohibitively large. Zeroth-Order (ZO) optimization methods offer a memory-efficient alternative by estimating gradients using only forward passes, thus avoiding BP. While promising, traditional ZO methods suffer from high gradient estimation variance that scales linearly with the model's parameter dimension, leading to performance degradation in LLMs. Existing approaches to mitigate this variance, such as increasing batch size or using random subspace methods, have their own drawbacks, including increased computational costs or the need to store large projection matrices, making them impractical for LLM fine-tuning.
Methods
The core contribution of this paper is SubZero, a layer-wise low-rank perturbation approach for ZO fine-tuning of LLMs. Instead of perturbing the entire model, SubZero applies perturbations to individual layers. Specifically, for each layer's parameter matrix $W_i$, it generates a low-rank perturbation $\tilde{W}_i$ by combining two column-orthogonal matrices (derived from QR decomposition of random matrices) with a low-dimensional random perturbation matrix. This layer-wise, low-rank strategy significantly reduces the variance of gradient estimates and the angle error compared to traditional ZO methods like MeZO.
Key innovations include:
- Layer-wise Low-Rank Perturbation: Applying perturbations at the layer level, rather than globally, and using low-rank matrices to approximate the perturbation direction.
- Random Subspace Projection: Utilizing random subspaces to reduce the dimensionality of the perturbation, which is crucial for high-dimensional LLMs.
- Lazy Subspace Update: Periodically regenerating projection matrices rather than at every step to further reduce computational overhead.
- Reshaping Strategy: A technique to handle non-square parameter matrices in certain fine-tuning schemes (like LoRA) by reshaping them to facilitate low-rank perturbation.
SubZero integrates with standard optimizers like SGD, offering a memory-efficient alternative to BP-based fine-tuning.
Datasets
The paper evaluates SubZero on various standard NLP benchmarks, including:
- SuperGLUE benchmark: Used for comprehensive evaluation across classification, multiple-choice, and generation tasks.
- SST-2, RTE, CB, BoolQ, WSC, WIC, MultiRC, COPA, ReCoRD, SQuAD, DROP: Specific datasets within the SuperGLUE benchmark.
- LLaMA2-7B, Mistral-7B, OPT-1.3B, OPT-13B, RoBERTa-large: Various LLMs used for fine-tuning.
The paper does not introduce new datasets.
Key Insights and Ideas
- Dimensionality is the Enemy: The core challenge in ZO for LLMs is the curse of dimensionality. SubZero's layer-wise low-rank approach directly tackles this by operating in much smaller, structured subspaces.
- Layer-wise Structure Matters: LLMs are not monolithic; their layer-wise structure can be exploited. SubZero leverages this by applying perturbations independently to each layer, which is more efficient and effective than global perturbations.
- Low-Rank is Sufficient: The paper's theoretical analysis and experimental results suggest that a low-rank approximation of the perturbation is sufficient to capture the essential gradient information for LLM fine-tuning, significantly reducing variance.
- Memory Efficiency is Achievable: SubZero demonstrates that it's possible to achieve fine-tuning performance comparable to or better than existing methods while using memory footprint close to inference-only approaches.
Key Results
- Performance Improvement: SubZero consistently outperforms MeZO across various LLMs (OPT-1.3B, LLaMA-7B) and fine-tuning schemes (full-parameter tuning, LoRA, prefix tuning, prompt tuning). For instance, SubZero improves upon MeZO by 7.1% on LLaMA-7B and 3.2% on OPT-1.3B in full-parameter tuning.
- Memory Efficiency: SubZero achieves memory consumption comparable to MeZO and significantly lower than SGD (e.g., 1.6x improvement for OPT-1.3B). This makes it practical for fine-tuning large models on limited hardware.
- Faster Convergence: Training loss curves show that SubZero generally converges faster and achieves lower losses compared to MeZO.
- Handles Non-Differentiable Objectives: SubZero effectively optimizes non-differentiable objectives, similar to MeZO.
- Robustness: The method is shown to be robust to variations in subspace rank, and the lazy update strategy is effective.
Limitations and Future Work
- Optimizer Combinations: The authors acknowledge that they have not thoroughly investigated combinations of SubZero with other first-order and zero-order optimizers, nor explored its interaction with techniques like parameter quantization.
- Reshaping Strategy Analysis: A theoretical analysis of the proposed reshaping strategy for non-square matrices is left for future work.
- Further Exploration: Future work could involve exploring more sophisticated combinations of SubZero with other memory-efficient techniques and developing theoretical guarantees for the reshaping strategy.
Summary updated