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

Simultaneous Computation and Memory Efficient Zeroth-Order Optimizer for Fine-Tuning Large Language Models

Fei Wang, Li Shen, Liang Ding, Chao Xue, Ye Liu, Changxing Ding · DOI

Introduction

Fine-tuning Large Language Models (LLMs) is a resource-intensive process. Standard First-Order (FO) optimizers, such as AdamW, require backpropagation, which necessitates storing massive amounts of activation data in memory. This often makes full-parameter fine-tuning impossible on consumer-grade hardware. To address this, Zeroth-Order (ZO) optimization methods like MeZO have been introduced. MeZO estimates gradients using only forward passes, significantly reducing memory overhead. However, ZO methods are typically slow to converge due to their reliance on stochastic estimates.

The Efficiency Bottleneck in Zeroth-Order Methods

Research into MeZO revealed a significant bottleneck: the administrative tasks of perturbing parameters and applying updates consume over 50% of the total fine-tuning time. This overhead is as computationally expensive as the forward passes themselves, limiting the overall speed of the training process.

Time distribution of MeZO operations, showing that perturbation and updating account for 50.9% of the total run time.

LeZO: Layer-wise Sparse Zeroth-Order Optimization

The authors introduce LeZO (Layer-wise sparse and efficient Zeroth-Order optimizer), a technique that applies layer-wise sparsity to the ZO process. Instead of perturbing every parameter at every step, LeZO treats layers as the fundamental units of sparsity.

How LeZO Works

  1. Dynamic Layer Selection: At each training step, LeZO randomly selects a subset of layers (e.g., 25%) to tune, while keeping the rest frozen.
  2. Sparse Perturbation and Update: Random noise for gradient estimation is only applied to the selected layers, and only those parameters are updated.
  3. Full Coverage: By dynamically changing the subset of layers at each step, the model eventually achieves full-parameter fine-tuning over the course of the run.

This approach reduces the number of floating-point operations (FLOPs) during the perturbation and update stages without requiring extra memory for masks or indices.

Key Results and Performance

LeZO was evaluated using the OPT model family (1.3B to 30B parameters) across benchmarks like SuperGLUE and generative tasks (SQuAD). The results demonstrate that LeZO is not only faster but often more accurate than MeZO.

Massive Speedups

LeZO achieved a 3.4× total run-time speedup compared to MeZO when fine-tuning OPT-13B on the SST-2 dataset. This gain comes from both faster computation per step and improved convergence rates. Theoretically, reducing the number of parameters perturbed at once (the sparsity ratio) decreases the noise in the gradient estimate, leading to a cleaner signal.

Accuracy vs. Run Time for LeZO and MeZO on SST-2. LeZO achieves a 3.4× total speedup, combining a 2.0× computational speedup with a 1.7× convergence speedup.

Accuracy and Scalability

Despite updating fewer parameters per step, LeZO outperformed MeZO on most datasets, with an average improvement of 1% in accuracy/F1 score for OPT-13B. These performance gains were even more pronounced on larger 30B models, indicating high scalability. Furthermore, LeZO is compatible with Parameter-Efficient Fine-Tuning (PEFT) methods like LoRA, providing additional efficiency boosts.

Conclusion

LeZO effectively addresses the time-efficiency gap in memory-efficient LLM fine-tuning. By sparsifying the administrative overhead of zeroth-order optimization, it provides a significant speedup while maintaining or improving model performance. While some tasks like WSC show sensitivity to the inherent noise of ZO methods, LeZO represents a major step forward in making large-scale model tuning accessible on limited hardware.

Summary updated

BibTeX
@misc{wang2024simultaneous,
  author = {Fei Wang and Li Shen and Liang Ding and Chao Xue and Ye Liu and Changxing Ding},
  title = {{Simultaneous Computation and Memory Efficient Zeroth-Order Optimizer for Fine-Tuning Large Language Models}},
  year = {2024},
  eprint = {2410.09823},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2410.09823},
}
Figure