Sparse MeZO: Less Parameters for Better Performance in Zeroth-Order LLM Fine-Tuning

Yong Liu, Zirui Zhu, Chaoyu Gong, Minhao Cheng, Cho-Jui Hsieh +1 more
2/24/2024
cs.LGcs.AIcs.CL

Official code: NUS-HPC-AI-Lab/SparseMeZO (9 stars, last commit 2026-02-14).

Abstract

While fine-tuning large language models (LLMs) for specific tasks often yields impressive results, it comes at the cost of memory inefficiency due to back-propagation in gradient-based training. Memory-efficient Zeroth-order (MeZO) optimizers, recently proposed to address this issue, only require forward passes during training, making them more memory-friendly. However, compared with exact gradients, ZO-based gradients usually exhibit an estimation error, which can significantly hurt the optimization process, leading to slower convergence and suboptimal solutions. In addition, we find that the estimation error will hurt more when adding to large weights instead of small weights. Based on this observation, this paper introduces Sparse MeZO, a novel memory-efficient zeroth-order optimization approach that applies ZO only to a carefully chosen subset of parameters. We propose a simple yet effective parameter selection scheme that yields significant performance gains with Sparse-MeZO. Additionally, we develop a memory-optimized implementation for sparse masking, ensuring the algorithm requires only inference-level memory consumption, allowing Sparse-MeZO to fine-tune LLaMA-30b on a single A100 GPU. Experimental results illustrate that Sparse-MeZO consistently improves both performance and convergence speed over MeZO without any overhead. For example, it achieves a 9\% absolute accuracy improvement and 3.5x speedup over MeZO on the RTE task. Code is available at https://github.com/NUS-HPC-AI-Lab/SparseMeZO.

View on arXivView PDF

Code Implementations(1)

[NeurIPS 2025] Sparse MeZO: Less Parameters for Better Performance in Zeroth-Order LLM Fine-Tuning

91Shell, PythonOct 14, 20258 months ago

Similar Papers

Cite this paper

@article{liu2024sparse,
  title  = {Sparse MeZO: Less Parameters for Better Performance in Zeroth-Order LLM Fine-Tuning},
  author = {Yong Liu and Zirui Zhu and Chaoyu Gong and Minhao Cheng and Cho-Jui Hsieh and Yang You},
  year   = {2024},
  eprint = {2402.15751},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2402.15751v2}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2402.15751.svg)](https://codeofpaper.com/paper/2402.15751)

Discussion