TL;DR
Fine-tuning Large Language Models (LLMs) typically demands massive GPU memory to support backpropagation. Zeroth-Order (ZO) optimization methods like MeZO bypass this by using only forward passes, but they suffer from extreme gradient variance in high-dimensional parameter spaces. This paper introduces SubZero, a framework that projects perturbations into layer-wise low-rank random subspaces, drastically reducing gradient variance and accelerating convergence while maintaining inference-level memory efficiency.
What Problem Does This Paper Address?
Standard first-order (FO) tuning methods (like SGD or Adam) require backpropagation, which stores massive activation states and gradients in memory. This creates a severe hardware bottleneck when scaling up to billions of parameters.
Zeroth-order (ZO) optimization offers a clever workaround: it estimates gradients using only forward passes by evaluating the difference in loss after applying a tiny random perturbation to the weights. However, traditional ZO methods apply perturbations across the entire parameter space. The variance of these gradient estimates scales linearly with the total number of parameters ($d$). For an LLM, $d$ is massive, causing the variance to explode, which leads to slow convergence and degraded performance.
While prior mathematical frameworks suggested projecting perturbations into a lower-dimensional random subspace to fix this, doing so globally requires storing a massive projection matrix that scales with the model size, making it completely impractical for LLMs.
Methods
The authors propose SubZero (Subspace Zeroth-order optimization), which introduces three key innovations to make subspace ZO practical for LLMs:
-
Layer-wise Low-Rank Perturbations: Instead of a giant global projection matrix, SubZero applies independent low-rank perturbations to each layer's weight matrix ($W_i$). For any given layer, the perturbation matrix is constructed as: $$\tilde{Z}_i = U_i Z_i V_i^T$$ where $U_i$ and $V_i$ are small, column-orthogonal matrices generated via QR decomposition, and $Z_i$ is a tiny low-dimensional random Gaussian matrix. This creates a block-diagonal projection structure that eliminates the memory explosion.
-
Lazy Subspace Updates: Generating the orthogonal matrices $U_i$ and $V_i$ at every step is computationally heavy. SubZero uses a "lazy" strategy, keeping the subspace fixed for $F$ steps (e.g., every 1,000 or 2,000 steps) before regenerating it.
- Reshaping Strategy for Non-Square Matrices: In Parameter-Efficient Fine-Tuning (PEFT) methods like LoRA, weight matrices are highly non-square (e.g., $m \times 8$). SubZero reshapes these into approximate squares before applying the low-rank perturbation, ensuring the subspace rank remains effective.
Datasets
The authors evaluated SubZero across a wide range of NLP tasks using the following benchmarks:
- SuperGLUE: BoolQ, CB, COPA, MultiRC, ReCoRD, RTE, WiC, WSC.
- Classification & QA: SST-2, SST-5, MNLI, SNLI, SQuAD, DROP.
- Commonsense Reasoning: Winogrande.
Key Insights and Ideas
- Gradients Naturally Concentrate: A key motivation for this work is that backpropagation gradients in LLMs rapidly converge to a tiny, low-dimensional subspace during fine-tuning. Singular Value Decomposition (SVD) analysis of the gradient matrices confirms a sharp spectral decay across layers.
- Orthogonality Matters: Simply using standard Gaussian random matrices for subspace projection yields subpar results. Enforcing column-orthogonality via QR decomposition significantly improves the quality and alignment of the estimated gradient direction.
- Breaking the Dimensionality Curse: By bounding the perturbation to a subspace of dimension $q \ll d$, SubZero ensures that the gradient estimation error and variance depend on the subspace size $q$ rather than the massive model size $d$. This allows accurate gradient estimation even for models with billions of parameters.
Key Results
- Superior Performance: SubZero consistently outperforms MeZO across multiple architectures (RoBERTa-large, OPT-1.3B/13B, LLaMA2-7B, Mistral-7B) and fine-tuning paradigms (Full Tuning, LoRA, Prefix Tuning, Prompt Tuning). For example, it beats MeZO by 7.1% on LLaMA2-7B full tuning.
- Inference-Level Memory: SubZero achieves these gains with virtually zero memory overhead compared to MeZO. For instance, full-parameter tuning of OPT-1.3B requires 11.5GB with standard SGD, but only 6.8GB with SubZero—matching MeZO's footprint while delivering much faster convergence.
- Non-Differentiable Objectives: Because it relies only on forward passes, SubZero successfully optimizes non-differentiable metrics like token-level accuracy and F1-score directly, outperforming MeZO on tasks like SQuAD.
Limitations and Future Work
- Optimizer Combinations: The current work primarily pairs SubZero with a basic SGD optimizer. Exploring combinations with adaptive first-order optimizers (like Adam) or momentum-based zeroth-order methods remains an open area.
- Quantization Synergy: While SubZero is theoretically compatible with weight quantization techniques (like QLoRA), the practical performance and memory trade-offs of this combination have not yet been thoroughly explored.
- Reshaping Theory: The reshaping strategy for highly non-square matrices works well empirically, but a rigorous theoretical analysis of why it preserves gradient properties is left for future work.
Summary updated