Abstract
Fine-tuning Large Language Models (LLMs) on resource-constrained edge devices is frequently prohibited by the "memory wall"—the massive VRAM requirements necessitated by backpropagation. This paper presents FedMeZO, a federated learning (FL) framework that integrates memory-efficient zeroth-order (ZO) optimization. By estimating gradients using only forward passes, FedMeZO reduces GPU memory consumption by over 50% compared to traditional first-order methods. Furthermore, we provide the first rigorous theoretical convergence analysis for ZO optimization in the context of federated LLM tuning, demonstrating that the low effective rank of the LLM Hessian allows for stable optimization despite high-dimensional parameter spaces. Experimental results on LLaMA-3B and LLaMA2-7B across diverse NLP tasks confirm that FedMeZO achieves performance parity with backpropagation-based methods while enabling training on consumer-grade hardware.
1. Introduction
The deployment and personalization of Large Language Models (LLMs) in decentralized environments are often hindered by the hardware limitations of edge devices. In Federated Learning (FL), where data remains local to preserve privacy, clients must perform local updates. However, standard fine-tuning via backpropagation (BP) requires storing not only the model weights but also gradients and optimizer states, often tripling or quadrupling the memory footprint relative to inference.
To address this, we propose FedMeZO, which leverages Zeroth-Order (ZO) optimization. Unlike BP, ZO methods estimate gradients by observing changes in the loss function resulting from small weight perturbations. While historically considered too slow for high-dimensional problems, we demonstrate that the specific geometric properties of LLM loss surfaces make them uniquely suited for ZO-based federated tuning.
2. The FedMeZO Framework
FedMeZO combines the communication efficiency of Federated Learning with the memory efficiency of the MeZO (Memory-efficient Zeroth-Order) optimizer.
2.1 Two-Point Gradient Estimator
The core of the local update is a two-point gradient estimator. Instead of computing an exact gradient, the client samples a random vector from a Gaussian distribution. The gradient is estimated by performing two forward passes—one with weights perturbed in a positive direction and one in a negative direction—and using the difference in loss to approximate the gradient. This requires zero backpropagation, keeping memory usage at "inference-level."
2.2 In-Place Implementation and LoRA
To further optimize resources, FedMeZO utilizes random seeds to resample perturbation vectors on the fly, avoiding the need to store large random matrices in memory. Additionally, the framework integrates Low-Rank Adaptation (LoRA). By only updating and transmitting a small set of adapter parameters rather than the full model, FedMeZO significantly reduces the communication overhead between the central server and edge clients.
3. Theoretical Insights
A primary contribution of this work is the theoretical justification for why ZO optimization succeeds in LLMs despite the "curse of dimensionality."
3.1 The Low Effective Rank of the Hessian
We prove convergence by leveraging the observation that LLM Hessian matrices typically exhibit a "low effective rank." Although the parameter space is in the billions, the optimization trajectory effectively resides in a much lower-dimensional subspace. This "Hessian Shortcut" explains why a random search for a gradient direction (the basis of ZO) is surprisingly effective for these models.
3.2 Learning Rate and Heterogeneity
Our analysis indicates that the optimal learning rate for FedMeZO is anchored at $1/\sqrt{d}$ (where $d$ is the number of parameters). Exceeding this bound leads to immediate training instability and "loss surges." Furthermore, we find that moderate data heterogeneity (non-IID data) can, counter-intuitively, accelerate convergence in a federated ZO setting, provided that local learning rates are adjusted adaptively based on local data variance.
4. Experimental Evaluation
We evaluated FedMeZO using LLaMA-3B and LLaMA2-7B models across four benchmark datasets:
- Fed-Alpaca & Fed-Dolly: General instruction following and NLP tasks.
- Fed-GSM8K: Mathematical reasoning requiring Chain-of-Thought (CoT).
- Fed-CodeAlpaca: Multi-language code generation.
To simulate real-world conditions, we employed various data partitioning strategies, including IID, Latent Dirichlet Allocation (LDA), and Meta-info splits to represent varying degrees of client heterogeneity.
5. Key Results
- Memory Efficiency: FedMeZO consistently reduced GPU memory usage by 50% to 60%. For a LLaMA-3B model, VRAM requirements dropped from ~26GB (standard BP) to ~10GB, making it feasible for consumer-grade GPUs like the RTX 3080.
- Convergence and Stability: In tasks such as Dolly-Meta, FedMeZO reached convergence within 300 rounds, often stabilizing faster than standard BP-based FedAvg.
- Task Performance: On the GSM8K benchmark, FedMeZO achieved a 35.48% improvement over the base model, notably outperforming the 29.03% gain achieved by BP-based FedAvg. This suggests that the noise inherent in ZO estimation may act as a regularizer in complex reasoning tasks.
6. Discussion and Limitations
While FedMeZO offers a path forward for edge-based LLM tuning, several areas remain for future exploration. We propose a "Rank Correlation" conjecture, suggesting that the optimal LoRA rank is proportional to the Hessian's effective rank, though this requires further empirical validation. Additionally, while memory-efficient, the requirement for two forward passes per step introduces a computational trade-off. Future work will focus on scaling these methods to models exceeding 70B parameters and further optimizing the time-to-convergence in extremely low-power environments.
7. Conclusion
FedMeZO bridges the gap between high-performance LLM tuning and the constraints of federated edge computing. By providing both a practical framework and a rigorous theoretical foundation, this work demonstrates that zeroth-order optimization is a viable and necessary alternative to backpropagation for the next generation of decentralized AI.
Summary updated