Manuscript Offprint

arXiv:2610.02190

Trust the Direction, Search the Step: Zero-and-First-Order Methods for LLM Fine-Tuning

Cristian McGee, El Houcine Bergou, Aritra Dutta

Abstract

Step-size selection remains a central challenge in large-scale neural network optimization; conservative steps slow convergence, while aggressive steps can destabilize it. We combine Zero-and-First-Order optimization (ZFO) and propose a framework that decouples direction selection from step-size. ZFO uses a trusted first-order optimizer to determine the direction and performs zeroth-order evaluations only along this one-dimensional subspace to choose how far to move. Using the current gradient information and two additional objective function evaluations, ZFO instances construct a local model of the objective function along the proposed direction and select a curvature-aware step within a bounded search interval. This yields an adaptive step-selection mechanism that costs less than a full line search. We provide theoretical guarantees to show that shared-sample evaluations produce reliable finite-difference curvature estimates, that the induced local model selects a near-optimal step along the search interval, and that ZFO converges to a neighborhood of a stationary point. Across the evaluated settings, language models and datasets, ZFO frequently improves optimization and final performance relative to fixed-step first-order baselines, with the magnitude and preferred local model depending on the objective. Our code is publicly available at: https://github.com/nizswan/Zeroth-First-Order-Framework.

1 Introduction

Gradient-based first-order (FO) optimization methods are the main workhorse of modern deep neural network training [14, 25, 31]. During training, gradient information provides the direction to move along, which, coupled with a step size (or learning rate), updates the model parameters. While the gradient direction is generally informative, the step size used along that direction is typically chosen through schedules, heuristics, or hyperparameter tuning [18, 30, 48, 49]. For larger networks, whose local geometry can change rapidly during adaptation, a poorly chosen step size may lead to unstable training [13]. Despite these step-size instabilities, FO methods remain the standard choice for neural network adaptation because the FO gradient provides strong directional guidance.

In contrast, zeroth-order (ZO) methods [5–7, 16, 17, 26, 34, 38] do not compute gradients. They construct approximate gradient updates using only objective function evaluations, often via finite differences along random directions. Although ZO methods reduce computational overhead, gradient approximations are often noisy and high-variance in large-dimensional settings [2, 23]. However, when FO provides the update direction, the high-dimensional problem becomes a univariate step-

40th Conference on Neural Information Processing Systems (NeurIPS 2026).

(a) First-Order Direction

zt=gt/∥gt∥z_{t}=g_{t}/\|g_{t}\|

(b) Zeroth-Order Step Selection

ϕt(s)=Ft(θt+szt)\phi_{t}(s)=F_{t}(\theta_{t}+sz_{t})

Figure

Figure

Given: ϕt(0)\phi_t(0), ϕt′(0)\phi_t'(0)

Extra Evaluations: ϕt(−ϵ)\phi_t(-\epsilon), ϕt(+ϵ)\phi_t(+\epsilon)

ϕt′′^(0),ϕt′′′^(0)⟶sM∈arg⁡max⁡s∈ItM(s)⟶θt+1=θt+sMzt\widehat{\phi_{t}^{\prime\prime}}(0),\widehat{\phi_{t}^{\prime\prime\prime}}(0)\quad\longrightarrow\quad s_{M}\in\arg\max_{s\in\mathcal{I}_{t}}M(s)\quad\longrightarrow\quad\theta_{t+1}=\theta_{t}+s_{M}z_{t}

Figure 1: The Zeroth First-Order (ZFO) Framework. Left: A first-order optimizer proposes the direction ztz_t at θt\theta_t, which restricts the objective to the line θt+szt\theta_t + sz_t. Right: Along this line, θt+szt\theta_t + sz_t, the forward pass gives ϕt(0)\phi_t(0), the backward pass gives ϕt′(0)\phi_t'(0), and two symmetric probes at ±ϵ\pm\epsilon supply curvature estimates. ZFO fits a local model M(s)M(s) and takes the optimized step sMs_M over the interval [0,Rt][0, R_t]; see Algorithm 1.

selection problem; see Figure 1. Consequently, computationally inexpensive ZO evaluations become substantially informative for modeling local function behavior. This raises a natural question:

If FO methods are strong at choosing an update direction, can ZO evaluations be used to decide how far to move along that direction?

We investigate this question by using ZO evaluations not to replace gradients, but to select reliable step sizes. This idea is related to recent work on generalized Newton step selection GeN [9], which uses function evaluations along a first-order direction to construct a curvature-informed step. In contrast, ZFO takes a broader view: rather than committing to a particular step construction, we formulate fixed-budget directional step selection as a local modeling problem. This perspective is not restricted to a specific optimization setup; in principle, the framework applies whenever an approximate gradient direction is available, but its appropriate magnitude is uncertain, a pattern that recurs in existing step-size rules [33]. This uncertainty becomes especially relevant in noisy or stochastic optimization settings.

Large language model (LLM) fine-tuning is a natural setting for this hybridization. Modern fine-tuning pipelines construct minibatches of prompt-response examples and optimize a surrogate objective on these fixed examples. Once a minibatch is formed, nearby parameter evaluations can reuse the same data and require only additional forward evaluations of the perturbed model. This makes ZO probes especially useful—not as a replacement for gradients, but as a cheap mechanism for modeling objective variation along a trusted FO direction. In contrast, fully ZO LLM fine-tuning methods use forward evaluations to estimate high-dimensional gradients [26, 34]. ZFO exploits this structure by assigning direction selection to a base FO optimizer, such as AdamW [31] or Muon [25], while using a small number of ZO function evaluations to build a univariate local model of the objective function and select the step size along that direction. Taken together, the ZFO framework acts as a lightweight step-selection wrapper around a standard FO optimizer. This is particularly valuable in LLM fine-tuning, where local geometry can shift rapidly and poorly tuned learning rates can cause unstable or slow training [27, 50].

Problem Setup. Let fine-tuning an LLM be represented by a conditional distribution πθ(y∣x)\pi_{\theta}(y \mid x), where xx denotes an input prompt, yy denotes a model response, and θ∈Rd\theta \in \mathbb{R}^d are the model parameters. We initialize the model from a pretrained reference model and further optimize it using task-specific feedback. We summarize the main notation used throughout the paper in §D; see Table 14.

At a given iteration t, a FO fine-tuning algorithm constructs a minibatch of information, denoted by StS_t. This minibatch contains all quantities needed to define the current training objective. Depending on the method, StS_t may include prompts, sampled responses, supervised labels, etc. Conditioned on StS_t, the fine-tuning method defines a sampled surrogate objective optimized during the current update.

Ft(θ)=F(θ;St)F_t(\theta) = F(\theta; S_t). Different LLM fine-tuning algorithms instantiate this surrogate differently. Our framework does not require a particular choice of FtF_t, and only assumes that the surrogate can be evaluated on the fixed minibatch StS_t.

This fixed-batch viewpoint is standard in LLM fine-tuning [22, 26, 34, 46]. Once StS_t is constructed, it is held fixed within the update. Evaluating FtF_t at a nearby parameter value therefore does not require constructing a new batch or collecting new feedback; it only requires re-scoring the same prompt-response pairs under the perturbed model.

A standard fine-tuning step computes a stochastic gradient of the sampled surrogate at the current parameters, and passes it through an optimizer such as AdamW. If we denote the resulting update direction by gtg_t, the usual first-order gradient ascent update is: θt+1=θt+αgt\theta_{t+1} = \theta_t + \alpha g_t, where α>0\alpha > 0 is the learning rate. This update contains two decisions: the direction gtg_t and the step length controlled by α\alpha. The chosen fine-tuning surrogate and the optimizer determine the direction. The step length, however, is usually specified by a learning-rate schedule or hyperparameter tuning [32]. In LLM fine-tuning, this scalar choice can be sensitive; overly tiny steps may not entirely use the information in the current batch, while aggressive steps can destabilize training [51].

We improve the step-length decision while leaving the optimizer direction unchanged and formulate all objectives as maximization problems. Let gt≠0g_t \neq 0, and define the normalized direction

zt=gt∥gt∥.(1)z_{t}=\frac{g_{t}}{\left\|g_{t}\right\|}. \tag{1}

We restrict the current surrogate to the one-dimensional path along this direction:

ϕt(s)=Ft(θt+szt),for  s∈R.\phi_{t}(s)=F_{t}(\theta_{t}+s z_{t}),\quad\mathrm{f o r}\;s\in\mathbb{R}.

The standard optimizer step corresponds to sFO=α∥gt∥s_{\mathrm{FO}} = \alpha \| g_t \|. Thus, choosing the learning rate is equivalent to choosing a scalar displacement along the fixed-batch improvement of ϕt\phi_t.

Rather than relying only on a global learning-rate schedule, we ask whether the current surrogate FtF_t supports a better step along the direction already selected by the optimizer. We search over a bounded interval It=[0,Rt]\mathcal{I}_t = [0, R_t], Rt=βα∥gt∥R_t = \beta \alpha \| g_t \|, where β>0\beta > 0 controls the search radius relative to the baseline optimizer step. When β=1\beta = 1, the interval ends at the usual first-order update; larger values allow the method to consider longer steps while remaining constrained to the same direction:

st⋆≈arg⁡max⁡s∈Itϕt(s).(2)s_{t}^{\star}\approx\arg\max_{s\in\mathcal{I}_{t}}\phi_{t}(s). \tag{2}

A full line search would evaluate ϕt\phi_t at many candidate values of ss, which is costly for LLMs. Instead, we use a fixed-budget step-selection procedure: the current value ϕt(0)\phi_t(0) is obtained from the usual forward evaluation of the surrogate on StS_t, and the backward pass gives the directional derivative ϕt′(0)=⟨∇Ft(θt),zt⟩\phi_t'(0) = \langle \nabla F_t(\theta_t), z_t \rangle. We then evaluate the same fixed-batch surrogate at two symmetric perturbations along the update direction:

ϕt(ϵ)=Ft(θt+ϵzt),ϕt(−ϵ)=Ft(θt−ϵzt),forasmallϵ>0.\phi_{t}(\epsilon)=F_{t}(\theta_{t}+\epsilon z_{t}),\quad\phi_{t}(-\epsilon)=F_{t}(\theta_{t}-\epsilon z_{t}),\mathrm{f o r a s m a l l}\epsilon>0.

Together, these quantities {ϕt(0),ϕt′(0),ϕt(ϵ),ϕt(−ϵ)}\{\phi_t(0), \phi_t'(0), \phi_t(\epsilon), \phi_t(-\epsilon)\}, define a local model of the surrogate improvement along the optimizer direction. The selected step sts_t is obtained by maximizing this model over It\mathcal{I}_t, and the parameters are updated as θt+1=θt+stzt\theta_{t+1} = \theta_t + s_t z_t. In this formulation, the base LLM fine-tuning algorithm determines the surrogate FtF_t and the update direction gtg_t, while our method determines how far to move along that direction; see Figure 1. The procedure is therefore compatible with a broad class of LLM fine-tuning objectives. Due to space limitations, we defer the related work to §A.

Our contributions. We develop ZFO as a general framework that separates first-order direction selection from low-query zeroth-order step selection. This formulation allows different local step-selection models to be developed and analyzed within the same optimization framework. Below, we summarize our main contributions:

(i) A ZFO optimization framework. We propose the general ZFO framework in which a standard first-order optimizer proposes an update direction, and a small number of zeroth-order evaluations are used to choose an improved step size along this direction. Within this framework, we develop four practical ZFO instances based on Taylor and Padé local models. While existing methods such as GeN is a one step-selection rule, our ZFO is a fixed-budget directional modeling framework. GeN can be interpreted within the ZFO framework as a particular fixed-budget directional step-selection.

(ii) Theoretical justification of adaptive step selection. Our theoretical analysis of the one-dimensional objective follows from restricting the training objective to the first-order search direction. We show that the finite-difference curvature estimates with common random numbers (CRNs) concentrate around their population counterparts with high probability. We further prove that maximizing the resulting local model yields a step whose objective value is near-optimal within a bounded search region. Finally, we establish a global stationarity guarantee showing that ZFO converges to a stationary neighborhood whose size is controlled by the accumulated step-selection error.

(iii) Empirical validation across scales. We evaluate ZFO on both controlled low-dimensional problems and LLM fine-tuning tasks. The experiments show that ZFO is robust to the choice of initial learning rate and can match or outperform standard first-order and zeroth-order baselines on most benchmarks. These results demonstrate that lightweight zeroth-order step adaptation can improve the stability and reliability of first-order fine-tuning without incurring the cost of full line search or extensive hyperparameter tuning.

References (51)