TL;DR
Hi-ZFO is a hybrid fine-tuning framework that blends the precision of first-order (gradient-based) optimization with the exploratory power of zeroth-order (gradient-free) methods. By adaptively applying first-order updates to critical layers and zeroth-order updates to less sensitive ones, it introduces a "beneficial stochasticity" that helps LLMs escape suboptimal local minima, delivering superior generative performance with significantly reduced training time and memory overhead.
What Problem Does This Paper Address?
Fine-tuning Large Language Models (LLMs) typically relies on standard first-order (FO) optimizers like Adam. While highly precise, these deterministic methods often drive the model into sharp, poorly generalizing local minima within high-dimensional loss landscapes.
An alternative is zeroth-order (ZO) optimization, which estimates gradients by perturbing function values (forward passes only), bypassing memory-heavy backpropagation. However, pure ZO methods suffer from the curse of dimensionality. The authors reveal a critical bottleneck: in complex generative tasks, the massive token search space exponentially amplifies gradient estimation variance. This causes a severe "performance collapse" for pure ZO methods like MeZO, making them noisy and unstable when generating text rather than doing simple classification.
Methods
To bridge this gap, the authors introduce Hi-ZFO (Hierarchical Zeroth- and First-Order optimization), which strategically partitions the model's parameters into FO and ZO regimes:
- Cost-Aware Parameter Partitioning: Using a Dynamic Programming (DP) approach inspired by GreenTrainer, Hi-ZFO evaluates each layer's loss sensitivity relative to its backpropagation cost. High-importance tensors (typically upper layers) are assigned to the FO set ($\Theta_{FO}$), while computation-heavy lower layers are assigned to the ZO set ($\Theta_{ZO}$).
- Dual-Stream Forward Propagation: For every input batch, the framework runs two sequential forward passes. The Standard Stream uses unperturbed parameters to compute a baseline loss ($\mathcal{L}_{FO}$). The Perturbed Stream adds random Gaussian noise to the ZO parameters ($\Theta'_{ZO} = \Theta_{ZO} + \epsilon u$) to compute a post-perturbation loss ($\mathcal{L}_{ZO}$).
- Hybrid Optimization: The two losses are coupled into a single objective: $\mathcal{L}_{total} = \mathcal{L}_{FO} + \alpha \mathcal{L}_{ZO}$. The FO layers are updated via standard backpropagation, while the ZO layers utilize a finite-difference gradient estimator based on the difference between $\mathcal{L}_{ZO}$ and $\mathcal{L}_{FO}$.
To keep memory overhead minimal, perturbations and parameter restorations are performed in-place using fixed random seeds.
Datasets
The framework was evaluated across a diverse suite of generative and reasoning benchmarks:
- Abstractive Summarization: SciTLDR, DialogSum
- Generative QA: WebQuestions
- Mathematical & Code Reasoning: GSM8K, HumanEval, and the Math500 subset of MATH
Key Insights and Ideas
- ZO as "Beneficial Stochasticity": Traditionally, ZO is viewed merely as a cheap, memory-saving substitute for full backpropagation. Hi-ZFO flips this paradigm: the inherent noise of ZO estimation is intentionally harnessed as a regularizer. This controlled stochasticity perturbs the optimization trajectory just enough to kick the model out of local minima where pure FO methods get trapped.
- Activating vs. Freezing: Instead of completely freezing lower layers to save compute (as parameter-efficient methods like GreenTrainer do), Hi-ZFO reactivates them via low-cost ZO updates. This allows the model to undergo necessary representation shifts without the prohibitive memory cost of full backpropagation.
- Variance Control via Hierarchy: By confining ZO optimization to a partial dimension ($d_{ZO}$) rather than the full parameter space ($d$), the smoothing bias and estimation variance remain tightly bounded, preventing the performance collapse typical of pure ZO.
Key Results
Hi-ZFO consistently outperformed Full Fine-Tuning (Full FT), LoRA, and pure ZO baselines across OPT, BLOOM, and Qwen architectures.
- Downstream Accuracy: On the DialogSum task using BLOOMZ-3B, Hi-ZFO achieved a ROUGE-1 score of 38.9, markedly outperforming Full FT (34.1) and the hybrid baseline Bilevel-ZOFO (36.0).
- Reasoning Robustness: On GSM8K with Qwen2-7B, where pure MeZO collapsed to a score of 0.329 (below the 0.420 zero-shot baseline), Hi-ZFO achieved 0.810, even beating Full FT (0.773).
- Training Speedup: Hi-ZFO exhibits exceptional data efficiency, reaching peak performance in just 3 epochs compared to the standard 5 epochs required by baselines. This cut wall-clock training time on Qwen2.5/SciTLDR from 1.20 hours (Full FT) down to 0.49 hours.
Limitations and Future Work
- Stationary Partitioning: The current implementation uses a fixed parameter split determined before training begins. However, layer sensitivity shifts as a model converges. A dynamic mechanism that re-calibrates the FO/ZO boundaries in real-time could further boost convergence.
- Scope of Alignment: The empirical validation was restricted to Supervised Fine-Tuning (SFT). The authors note that exploring how this dual-stream optimization interacts with preference-based alignment frameworks, such as Direct Preference Optimization (DPO), is a vital next step.
Summary updated