NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

Revisiting Zeroth-Order Optimization for Memory-Efficient LLM Fine-Tuning: A Benchmark

Yihua Zhang, Pingzhi Li, Junyuan Hong, Jiaxiang Li, Yimeng Zhang, Wenqing Zheng, Pin-Yu Chen, Jason D. Lee, Wotao Yin, Mingyi Hong, Zhangyang Wang, Sijia Liu, Tianlong Chen

Introduction

Fine-tuning Large Language Models (LLMs) has become the standard for adapting pre-trained models to specific downstream tasks. However, the computational cost—specifically the "memory tax"—remains a significant barrier. Standard first-order (FO) optimizers, such as Adam or SGD, rely on backpropagation (BP) to compute gradients. For a model like OPT-13B, the memory required to store these gradients and optimizer states can be up to 12 times the memory needed for simple inference. This bottleneck restricts fine-tuning to high-end server clusters and precludes on-device training.

This paper presents a comprehensive benchmark of Zeroth-Order (ZO) optimization, a "backpropagation-free" approach that estimates gradients using only forward passes. By bypassing the need for backpropagation, ZO methods offer a path toward fine-tuning massive models on consumer-grade hardware.

The Memory Bottleneck and the ZO Alternative

In traditional first-order optimization, the model must store intermediate activations to compute gradients during the backward pass. Zeroth-order optimization avoids this by estimating the gradient through function value differences. By perturbing the model weights and observing the change in the loss function, ZO methods can update parameters using only forward passes.

While recent work like MeZO (ZO-SGD) demonstrated the feasibility of this approach, this study expands the horizon by benchmarking five LLM families (RoBERTa, OPT, LLaMA, Vicuna, and Mistral) across various fine-tuning schemes, including Full-tuning, LoRA, and Prefix-tuning.

Methodological Innovations

The researchers evaluated several ZO variants and introduced novel enhancements to bridge the performance gap between ZO and FO methods:

Benchmarked Optimizers

  • ZO-SGD (MeZO): The current baseline for ZO fine-tuning.
  • ZO-SGD-Sign: Utilizes only the sign of the estimated gradient to mitigate noise in the estimation process.
  • ZO-SGD-MMT & ZO-Adam: These versions incorporate momentum and adaptive learning rates. While they improve convergence, the study notes a trade-off: the additional optimizer states increase memory consumption, potentially offsetting the primary benefit of ZO.
  • Forward-Grad: A method using forward-mode automatic differentiation. Unlike ZO, it provides an unbiased gradient estimate, though it requires more memory than pure ZO methods.

Proposed Enhancements

  1. Block-wise ZO: Instead of estimating a single gradient for the entire model, this technique updates the model block-by-block, significantly reducing the variance of the gradient estimate.
  2. Hybrid ZO-FO: A strategic approach that applies backpropagation to deeper layers while using ZO for shallower layers, balancing memory efficiency with gradient accuracy.
  3. Sparsity-induced ZO: By applying random pruning masks to weight perturbations, this method reduces noise in the gradient estimation, leading to more stable updates.

Key Insights and Results

Memory and Efficiency Gains

The empirical results highlight the dramatic efficiency of ZO methods. For the OPT-13B model, ZO-SGD enabled full fine-tuning on a single A100 GPU using only 64 GB of VRAM, whereas traditional FO-SGD required 148 GB across multiple GPUs. Furthermore, because ZO avoids the computationally intensive backpropagation step, it reduced the runtime cost per iteration by approximately 41.9%.

Performance and Task Alignment

The study found that ZO performance is highly dependent on "Task Alignment." If the fine-tuning task differs significantly from the model's pre-training objective (next-token prediction), ZO struggles. However, by using well-crafted prompts to align the downstream task with the pre-training objective, the researchers observed accuracy improvements of over 10% on certain tasks.

On simpler tasks like SST2 (sentiment classification), ZO methods achieved performance nearly identical to first-order methods. On more complex reasoning tasks like WinoGrande, a performance gap of 5-6% remains, largely due to the high variance in zeroth-order gradient estimation as task complexity increases.

The Role of LoRA

Low-Rank Adaptation (LoRA) emerged as a particularly robust partner for ZO optimization. Pairing ZO with LoRA provided a stable and reliable tuning approach across different model architectures, suggesting that reducing the parameter space helps mitigate the noise inherent in ZO estimation.

Conclusion and Future Directions

Zeroth-order optimization represents a viable path for memory-efficient LLM adaptation, successfully scaling to 13B-parameter models on single GPUs. The introduction of ZO-SGD-Block showed significant promise, raising SST2 accuracy on OPT-1.3B from 90.83% to 93.69% compared to the MeZO baseline.

Despite these gains, the scalability bottleneck on complex reasoning tasks remains a challenge. Future research will likely focus on reducing gradient variance and developing "stateless" implementations of Forward-Grad to achieve unbiased gradient estimation without the associated memory overhead. These advancements could eventually make high-performance fine-tuning accessible for on-device applications and resource-constrained research environments.

Summary updated

BibTeX
@inproceedings{zhang2024revisiting,
  author = {Yihua Zhang and Pingzhi Li and Junyuan Hong and Jiaxiang Li and Yimeng Zhang and Wenqing Zheng and Pin-Yu Chen and Jason D. Lee and Wotao Yin and Mingyi Hong and Zhangyang Wang and Sijia Liu and Tianlong Chen},
  title = {{Revisiting Zeroth-Order Optimization for Memory-Efficient LLM Fine-Tuning: A Benchmark}},
  booktitle = {International Conference on Machine Learning},
  year = {2024},
  url = {https://openreview.net/forum?id=THPjMr2r0S},
}
Figure