Bilevel ZOFO: Bridging Parameter-Efficient and Zeroth-Order Techniques for Efficient LLM Fine-Tuning and Meta-Training

Reza Shirkavand, Qi He, Peiran Yu, Heng Huang · Submission to ICLR 2025 · Rejected

TL;DR

Fine-tuning large language models (LLMs) with backpropagation demands prohibitive GPU memory, while zeroth-order (forward-pass-only) optimization is notoriously sensitive to fixed prompt phrasing. Bilevel ZOFO solves this dilemma by structuring fine-tuning as a bilevel optimization problem: an inner loop updates a tiny parameter-efficient module (PEFT) using exact first-order gradients, while an outer loop adapts the full base model using zeroth-order gradient approximations. This hybrid strategy matches or beats traditional first-order PEFT and zeroth-order fine-tuning in single-task benchmarks, while providing a fast, memory-lean meta-training framework for multi-task learning.

What Problem Does This Paper Address?

Full-parameter fine-tuning of modern LLMs via standard first-order (FO) optimizers (like Adam) requires backpropagation, which can consume up to 12 times more memory than inference alone. To curb this overhead, practitioners usually turn to one of two alternatives:

  1. Parameter-Efficient Fine-Tuning (PEFT): Methods like LoRA, prefix tuning, or prompt tuning freeze the base model and train only a tiny fraction of parameters. While memory-efficient, PEFT can lag behind full fine-tuning on complex, knowledge-intensive tasks.
  2. Zeroth-Order (ZO) Optimization: Methods like MeZO optimize the entire network using only forward passes by perturbing weights randomly and measuring the loss difference. However, ZO training depends heavily on hand-crafted "hard prompt" templates to align inputs with task labels. If the prompt template is suboptimal, performance degrades sharply.

Moreover, extending meta-learning (learning to adapt across multiple tasks) to billion-parameter LLMs has remained computationally impractical because existing meta-training approaches rely on full-model backpropagation.

Methods

The authors introduce Bilevel ZOFO (Zeroth-Order–First-Order), which decouples model adaptation into two hierarchical levels:

  • Lower-Level Problem (Task Alignment via PEFT): Finds the optimal PEFT parameters ($p$, such as soft prompts, prefix tokens, or LoRA adapters) given the current base model parameters ($\theta$). Because PEFT introduces very few parameters, the algorithm computes standard first-order gradients via backpropagation without substantial memory cost.
  • Upper-Level Problem (Base Model Adaptation): Optimizes the billions of base model weights $\theta$. To avoid backpropagation across the entire LLM, it approximates the gradient using zeroth-order stochastic perturbation (SPSA)—evaluating only forward passes with randomized perturbations.
  • Penalty-Based Minimax Formulation: Classical bilevel methods require Hessian-vector products (second-order gradients), which are impossible at LLM scale. Instead, the authors reformulate the bilevel constraint using a penalty term, converting the problem into a minimax objective that is optimized through alternating gradient steps without second-order derivatives.
  • Multi-Task Meta-Training: ZOFO naturally extends to multi-task learning by training the base model across diverse tasks with ZO steps at the upper level and PEFT updates at the lower level. At test time, the base model is frozen, and only a lightweight PEFT adapter is adapted on few-shot demonstrations.

The authors prove that under standard smoothness and low-effective-rank conditions, Bilevel ZOFO converges to an $\epsilon$-stationary point without the complexity scaling with the model dimension $d$.

Datasets

The authors evaluate Bilevel ZOFO across three distinct model families: OPT-1.3B, Llama2-7B, and GPT2-Large.

  • Single-Task Benchmarks: Evaluated on 10 classification, multiple-choice, and QA datasets: BoolQ, CB, COPA, ReCoRD, RTE, SST-2, WiC, WinoGrande, WSC, and SQuAD.
  • Multi-Task Meta-Learning Benchmarks: Evaluated using 142 English tasks drawn from CROSSFIT and UNIFIEDQA across four MetaICL splits:
  • Classification $\to$ Classification (43 train, 20 test tasks)
  • Non-Classification $\to$ Classification (37 train, 20 test tasks)
  • QA $\to$ QA (37 train, 22 test tasks)
  • Non-QA $\to$ QA (33 train, 22 test tasks)

Key Insights and Ideas

  • Symbiosis of ZO and FO: Rather than choosing between full-model ZO tuning or parameter-efficient FO tuning, combining them hierarchically yields the best of both worlds: the full model shifts globally via forward passes, while local task alignment is guided precisely by backpropagated PEFT gradients.
  • Bypassing the Prompt Engineering Bottleneck: Instead of manually guessing brittle prompt templates for zeroth-order tuning, soft PEFT parameters automatically discover effective alignments during lower-level updates.
  • Hessian-Free Bilevel Training: Traditional hypergradient optimization is computationally intractable for LLMs. Casting the constraint into a penalized minimax formulation makes bilevel optimization practical on a single GPU.
  • Inference Efficiency in Meta-Learning: Unlike MetaICL, which concatenates $k$ demonstration examples directly into the prompt context (slowing inference down by $\sim 4\times$), ZOFO adapts adapter weights quickly and tests without prepended demonstrations, drastically reducing test-time latency and memory.

Key Results

  • Single-Task OPT-1.3B:
  • Bilevel ZOFO averaged 71.58% across all tasks and PEFT types, outperforming pure zeroth-order MeZO (65.29%) and standard first-order PEFT (69.77%).
  • Bilevel ZOFO with LoRA reached 74.10% average accuracy vs. 73.30% for FO LoRA and 67.48% for MeZO LoRA.
  • Gains were most dramatic on smaller parameter budgets (prefix and prompt tuning), proving especially effective under strict parameter constraints.
  • Single-Task Llama2-7B: Bilevel ZOFO achieved 83.94% average accuracy across 4 tasks, outperforming FO PEFT (83.56%) and MeZO (78.25%).
  • Multi-Task Meta-Learning (GPT2-Large):
  • When adapted on 4 demonstration shots (10 LoRA steps), ZOFO outperformed MetaICL on 3 out of 4 splits:
  • Non-Classification $\to$ Classification: 42.4% vs. 37.7% (MetaICL)
    • Non-QA $\to$ QA: 41.9% vs. 40.2% (MetaICL)
    • Classification $\to$ Classification: 47.1% vs. 46.4% (MetaICL)
  • Computational Cost: Wall-clock step time for Bilevel ZOFO (Prefix) on OPT-1.3B (0.135s on Copa) was comparable to First-Order Prefix tuning (0.127s) and more than $2\times$ faster per step than MeZO (0.299s).

Limitations and Future Work

  • Slow Asymptotic Convergence of ZO: Because zeroth-order gradient approximations have high variance, the outer loop still requires tens of thousands of iterations; the authors note performance was still climbing at 50,000 steps without plateauing.
  • Hyperparameter Sensitivity: The penalty weight $\lambda$ exhibits non-linear behavior; although values between 10 and 100 worked consistently well, finding the ideal value requires tuning.
  • Inner-Loop Latency Trade-Off: Increasing the number of inner-loop PEFT updates per upper-level base model step improves convergence quality but increases overall wall-clock training duration.

Summary updated

BibTeX
@inproceedings{shirkavand2025bilevel,
  author = {Reza Shirkavand and Qi He and Peiran Yu and Heng Huang},
  title = {{Bilevel ZOFO: Bridging Parameter-Efficient and Zeroth-Order Techniques for Efficient LLM Fine-Tuning and Meta-Training}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2025},
  url = {https://openreview.net/forum?id=v6vBK4t8vB},
}
Figure