KerZOO: Kernel Function Informed Zeroth-Order Optimization for Accurate and Accelerated LLM Fine-Tuning

Zhendong Mi, Qitao Tan, Xiaodong Yu, Zining Zhu, Geng Yuan, Shaoyi Huang

TL;DR

Zeroth-order (ZO) optimization allows large language models (LLMs) to be fine-tuned using only forward passes, drastically reducing GPU memory requirements. However, ZO methods typically suffer from slow convergence due to gradient estimation bias. KerZOO addresses this by borrowing kernel smoothing techniques from mathematical physics to analytically eliminate lower-order estimation bias, slashing GPU training time by up to 74% while simultaneously boosting downstream task accuracy.

What Problem Does This Paper Address?

Fine-tuning LLMs using standard first-order (FO) optimizers like AdamW is incredibly memory-intensive because backpropagation requires storing massive activation and gradient tensors. To democratize LLM training on consumer hardware, researchers have turned to Zeroth-Order (ZO) optimization (such as MeZO). ZO methods estimate gradients purely through forward passes by adding small, random perturbations to the model parameters and measuring the change in loss.

While ZO optimization eliminates the memory overhead of backpropagation, it introduces a massive penalty: slow convergence. Because perturbations are sampled randomly in an immense, high-dimensional parameter space, the estimated gradients are often highly suboptimal. The authors identify that this stochastic sampling introduces a significant lower-order bias into the gradient estimation, causing the model to stall or diverge.

Methods

The authors perform a Taylor expansion on standard ZO gradient estimators to show that the difference between perturbed losses leaves behind a problematic second-order bias term linked to the third-order directional derivative.

To eliminate this bias, KerZOO introduces a novel framework informed by kernel smoothing:

  1. Controlled Perturbations: Instead of applying a fixed perturbation scale, KerZOO introduces a random scalar variable $r$ to modulate the magnitude of the random unit direction vector $u$.
  2. Kernel Function Integration: They modify the gradient estimator by introducing a kernel function, $K(r)$, designed using orthogonal Legendre polynomials.
  3. Moment Conditions: The kernel function is mathematically engineered to satisfy two strict conditions:
  4. First-moment condition: Ensures the estimator remains an unbiased approximation of the true gradient.
  5. Third-moment condition: Explicitly zeros out the leading second-order bias term, leaving behind only negligible, higher-order (fourth-order) bias.
  6. Dynamic Variance Control: Because fewer perturbations can increase variance, KerZOO gradually shrinks the range of the scalar $r$ as the training iterations progress, balancing the bias-variance trade-off dynamically.

Datasets

The authors evaluated KerZOO across a diverse suite of language processing tasks:

  • Classification Benchmarks: SST-2, SST-5, SNLI, MNLI, RTE, and TREC (evaluated on RoBERTa-large).
  • SuperGLUE Benchmarks: CB, BoolQ, WSC, WIC, and MultiRC (evaluated on autoregressive models like OPT and LLaMA).
  • Generation Benchmarks: SQuAD and DROP.

Key Insights and Ideas

  • Optimization as a Kernel Smoothing Problem: The core "aha moment" is treating the noisy, high-dimensional gradient estimation of ZO methods not just as a variance problem to be averaged out, but as a systematic bias problem that can be mathematically canceled using tools from mathematical physics.
  • Orthogonal Polynomials for Bias Cancellation: By leveraging Legendre polynomials, the authors provide a structured recipe to design kernels ($K_1, K_3, K_5$) that systematically eliminate specific polynomial bias terms. They find that the third-order kernel $K_3(r)$ strikes the best balance for LLM tuning.
  • Annealing the Perturbation Space: Restricting the perturbation scale $r$ over time acts similarly to a learning rate schedule, stabilizing the optimization trajectory as the model nears a local minimum.

Key Results

KerZOO consistently outperforms standard ZO baselines like MeZO and HiZOO in both convergence speed and final accuracy across multiple model families (RoBERTa, OPT, and LLaMA).

  • Drastic Speedups: On the OPT-2.7B model, KerZOO achieved up to a 74% reduction in total GPU training hours on the WSC dataset and a 44% reduction on MultiRC compared to MeZO.
Figure 2: Comparison of GPU hours for convergence across different datasets on OPT-2.7B between MeZO and KerZOO. Results are presented as normalized time
  • Faster Loss Descent: As shown in the training curves, KerZOO drops to lower loss thresholds up to 5 times faster than MeZO.
Training loss comparison of MeZO and KerZOO on RoBERTa-large
  • Improved Accuracy: KerZOO exceeded MeZO's accuracy by 2.9% on WSC and 2.6% on MultiRC. When scaling to LLaMA3-3B and 8B models, KerZOO maintained a clear edge, notably yielding a ~10% accuracy gain on the RTE dataset.
Figure 3: Results on LLaMA3-3B and LLaMA3-8B
  • Memory Footprint: KerZOO retains the massive memory savings characteristic of ZO methods. For example, full fine-tuning of OPT-2.7B requires 73.5GB of memory using first-order methods, whereas KerZOO requires only 16.9GB.

Limitations and Future Work

While KerZOO shows remarkable acceleration, the authors note that their current experiments focus strictly on text-based LLM fine-tuning. They highlight several promising avenues for future research:

  1. Cross-Domain Adaptation: Extending the kernel-informed ZO framework to vision-language models (VLMs).
  2. Model Compression: Applying KerZOO to non-differentiable or discrete optimization problems, such as LLM pruning and post-training quantization.

Summary updated

BibTeX
@misc{mi2025kerzoo,
  author = {Zhendong Mi and Qitao Tan and Xiaodong Yu and Zining Zhu and Geng Yuan and Shaoyi Huang},
  title = {{KerZOO: Kernel Function Informed Zeroth-Order Optimization for Accurate and Accelerated LLM Fine-Tuning}},
  year = {2025},
  eprint = {2505.18886},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2505.18886},
}
Figure