Zeroth-Order Optimization is Secretly Single-Step Policy Optimization

Junbin Qiu, Zhengpeng Xie, Xiangda Yan, Yongjie Yang, Yao Shu

TL;DR

This paper proves that Zeroth-Order Optimization (ZOO) using randomized finite differences is mathematically equivalent to single-step Policy Optimization (PO) using REINFORCE with baseline subtraction. Building on this equivalence, the authors introduce ZoAR, an algorithm that adapts two key reinforcement learning techniques—an averaged value baseline and replay-style query reuse—to slash gradient variance and accelerate convergence across synthetic benchmarks, black-box attacks, and memory-efficient LLM fine-tuning.

What Problem Does This Paper Address?

In many machine learning settings, computing exact gradients via backpropagation is impossible or excessively expensive. Applications like black-box adversarial attacks, hyperparameter tuning, and memory-constrained large language model (LLM) fine-tuning rely on Zeroth-Order Optimization (ZOO), which estimates gradients using only forward function evaluations.

However, classic ZOO estimators suffer from severe variance, which slows convergence and hurts final solution quality. Furthermore, while the community relies heavily on randomized finite differences, the conceptual link between ZOO and related gradient-free paradigms—specifically Reinforcement Learning (RL) and Policy Optimization (PO)—remained largely informal and unexplored.

Methods

The authors bridge this conceptual gap and build a practical algorithm on top of it:

  • Theoretical Equivalence (ZOO $\equiv$ Single-Step PO):
  • Objective Equivalence: The implicitly smoothed surrogate objective $F_\mu(\theta)$ targeted by ZOO is identical to a single-step PO expected reward objective $J(\theta)$ under a Gaussian parameter perturbation policy.
  • Estimator Equivalence: The standard Gaussian-smoothed ZOO gradient estimator is mathematically identical to a single-step REINFORCE estimator with the loss $f(\theta; \xi)$ acting as a variance-reducing baseline.
  • Generalization via Importance Sampling: Estimators sampling from unit spheres or coordinate bases correspond to REINFORCE with an importance sampling ratio $\gamma$.
  • ZoAR (ZOO with Averaged Baseline and Query Reuse):
  • Averaged Baseline: Instead of relying on a noisy single-point evaluation $f(\theta; \xi)$, ZoAR computes an empirical average baseline $b_t$ from recent function evaluations stored in a rolling history buffer $H_t$, mimicking value-function baseline estimation in PO.
  • Query Reuse: Inspired by experience replay in off-policy RL, ZoAR pools the $N \times K$ most recent queries across the last $N$ iterations to estimate the current gradient, effectively scaling the gradient batch size without executing extra queries.

Datasets

The authors evaluate their methods across three distinct domains without introducing new datasets:

  • Synthetic Optimization Benchmarks: Four non-convex, 10,000-dimensional test functions: Quadratic, Levy, Rosenbrock, and Ackley.
  • Black-box Adversarial Attacks: The MNIST dataset, using a 2-layer convolutional neural network (CNN) as the target black-box victim model.
  • Memory-Efficient LLM Fine-Tuning: The Stanford Sentiment Treebank (SST-2) and Choice of Plausible Alternatives (COPA) classification benchmarks from the GLUE benchmark suite, used to fine-tune OPT-1.3B and OPT-13B models with LoRA adapters.

Key Insights and Ideas

  • The Finite-Difference "Subtract-Current-Loss" Step is Secretly a Baseline: The conventional practice of subtracting $f(\theta; \xi)$ in finite differences was historically viewed through the lens of Taylor series approximations. This paper reinterprets it as the baseline subtraction mechanism in REINFORCE, designed purely to reduce variance without introducing bias.
  • Better Baselines via History: In PO, the optimal baseline is the expected return. Approximating this expectation via a moving average of recent query evaluations yields a much tighter variance reduction than single-point center evaluations.
  • A Managed Bias-Variance Trade-Off: Reusing past perturbation queries introduces a slight bias (because past evaluations evaluated earlier policy parameters $\theta_{t-n}$), but it shrinks variance by a factor of $1/NK\mu^2$. In high-dimensional regimes where variance heavily dominates, this trade-off dramatically improves convergence rates.

Key Results

  • Synthetic Benchmarks ($d = 10,000$): Using the ZO-AdaMM update rule, ZoAR ($N=6$) achieved an $8\times$ convergence speedup on Quadratic and Rosenbrock functions and a $16\times$ speedup on the Ackley function over Vanilla ZOO.
  • Adversarial Attacks: ZoAR required significantly fewer model queries to achieve successful misclassification on MNIST, delivering a $5.92\times$ speedup over Vanilla ZOO under ZO-AdaMM and $2.72\times$ under $\mathcal{R}$-AdaZO.
  • LLM Fine-Tuning: In LoRA fine-tuning of OPT-1.3B and OPT-13B on SST-2 and COPA, ZoAR consistently converged faster and attained lower training losses than Vanilla ZOO, with history sizes $N \in \{15, 50\}$ showing clear gains over non-history variants.

Limitations and Future Work

  • Historical Bias: Reusing queries introduces an optimization bias proportional to the historical drift $\|\theta_t - \theta_{t-n}\|$. While a small learning rate $\eta$ dampens this error, future work should explore dynamic history scheduling (e.g., adaptive buffer lengths).
  • Computation Overhead of Random Seed Replay: While storing seeds keeps memory low, regenerating random perturbation vectors from large historical buffers incurs additional compute overhead.
  • Quantization-Aware Training (QAT): Because query reuse effectively smooths gradients, ZoAR can operate stably with larger smoothing radii ($\mu = 0.01$ to $0.1$). The authors note this property could be applied to non-smooth, ultra-low-precision optimization (like FP4 quantization), avoiding the failures of straight-through estimators (STE).

Summary updated

BibTeX
@inproceedings{qiu2025zeroth,
  author = {Junbin Qiu and Zhengpeng Xie and Xiangda Yan and Yongjie Yang and Yao Shu},
  title = {{Zeroth-Order Optimization is Secretly Single-Step Policy Optimization}},
  booktitle = {TTODLer-FM @ ICML},
  year = {2025},
  url = {https://openreview.net/forum?id=HQwuvp7nc0},
}
Figure