Thinking Forward: Memory-Efficient Federated Finetuning of Language Models

Finetuning large language models (LLMs) in federated learning (FL) settings has become increasingly important as it allows resource-constrained devices to finetune a model using private data. However, finetuning LLMs using backpropagation requires excessive memory (especially from intermediate activations) for resource-constrained devices. While Forward-mode Auto-Differentiation (AD) can significantly reduce memory footprint from activations, we observe that directly applying it to LLM finetuning results in slow convergence and poor accuracy. In this paper, we introduce Spry, an FL algorithm that splits trainable weights of an LLM among participating clients, such that each client computes gradients using forward-mode AD that are closer estimations of the true gradients. Spry achieves a low memory footprint, high accuracy, and fast convergence. We formally prove that the global gradients in Spry are unbiased estimators of true global gradients for homogeneous data distributions across clients, while heterogeneity increases bias of the estimates. We also derive Spry's convergence rate, showing that the gradients decrease inversely proportional to the number of FL rounds, indicating the convergence up to the limits of heterogeneity. Empirically, Spry reduces the memory footprint during training by 1.4-7.1x in contrast to backpropagation, while reaching comparable accuracy, across a wide range of language tasks, models, and FL settings. Spry reduces the convergence time by 1.2-20.3x and achieves 5.2-13.5% higher accuracy against zero-order methods. When finetuning Llama2-7B with LoRA, compared to the peak memory consumption of 33.9GB of backpropagation, Spry only consumes 6.2GB of peak memory. For OPT13B, the reduction is from 76.5GB to 10.8GB. Spry makes feasible previously impossible FL deployments on commodity edge devices. Our source code is available at https://github.com/Astuary/Spry.

Paper

Similar papers

Peer review

Reviewer sp7C5/10 · confidence 2/52024-06-26

Summary

This paper introduces SPRY, a federated learning (FL) algorithm designed to finetune large language models (LLMs) on resource-constrained devices by addressing the excessive memory requirements of traditional backpropagation methods. SPRY tackles the challenge of high memory usage from intermediate activations by utilizing Forward-mode Auto-Differentiation (AD) and splitting trainable weights among participating clients, allowing each client to compute accurate gradients with reduced memory. Theoretical analysis shows SPRY's global gradients are unbiased for homogeneous data and provides a convergence rate dependent on FL rounds and data heterogeneity. Empirical results demonstrate SPRY's efficiency, reducing memory usage by 1.4-7.1× and achieving faster convergence and higher accuracy compared to existing methods. This makes feasible the finetuning of LLMs on mobile and edge devices, significantly impacting FL deployments.

Strengths

* **S.1.** The proposed SPRY algorithm tackles a difficult task and is backed up with both empirical and theoretical results. * **S.2.** The paper is well written and the illustrations are helpful. * **S.3.** The empirical experiments are conducted on multiple datasets, models, and hardware configuration, while showing that SPRY outperforms previous works. * **S.4.** The paper provides an anonymous code repository of SPRY.

Weaknesses

* **W.1.** While SPRY shows promising results with a relatively small number of clients, the scalability to a larger number of clients, which is typical in FL scenarios, is not thoroughly investigated. The communication and computational overheads associated with increasing the number of participating clients, especially in terms of synchronization and gradient aggregation, are not discussed. This raises concerns about the practicality and efficiency of SPRY in large-scale deployments. * **W.2.** The empirical evaluation, although thorough in certain aspects, is limited in terms of the variety of datasets and models used. The evaluation focuses primarily on specific language tasks and a narrow range of LLMs. A broader evaluation including more diverse datasets and model architectures would strengthen the generalizability of the findings. Additionally, the impact of SPRY on tasks beyond natural language processing, such as computer vision or other modalities, is not explored. * **W.3.** While SPRY does outperform existing zero-order methods, it converges slower (time-wise) compared to traditional gradient based methods such as FedAvg.

Questions

* **Q.1.** Will the SPRY algorithm work in a large scale setting of 1k+ GPUs?

Rating

5

Confidence

2

Soundness

2

Presentation

3

Contribution

3

Limitations

n/a

Reviewer KHem7/10 · confidence 3/52024-07-07

Summary

This manuscript is focused on the memory-efficient federated finetuning of LLMs. The author first uses Forward-mode Auto-Differentiation to reduce memory. Then, the author observes that merely substituting backpropagation with Forward-mode AD in FL scenarios often results in poor accuracy and computational inefficiency. To address this challenge, the author recognizes that Forward-mode AD operates more efficiently and yields better gradient estimations when the trainable weight count is minimized. Therefore, SPRY only assigns each client a responsibility to compute gradients for only a subset of trainable weights. The experimental results show that the memory overhead can be reduced significantly. The topic is of interest and the presented numerical results seem, indeed, promising. However, there are still some questions/comments/suggestions for the current version of the paper, please refer to my comments under Questions.

Strengths

* The paper performs a number of experimental verifications as well as theoretical proofs. * The experimental results show that the method is enabled to significantly reduce GPU memory consumption while ensuring a competitive performance. * Additionally, the appendix contains valuable results.

Weaknesses

* This manuscript does not analyze the computational load of Forward-mode. * There are still some issues with the experimental setup, such as the need to consider the impact of the number of clients on performance.

Questions

* What is the computational overhead situation in each step (e.g., the training time for each gradient step)? A comparison of computational overheads is suggested in the experimental section. * Is each client's trained layer the same from start to finish? Or are the layers reassigned each communication round? * It seems that the layers for each client are fixed at the beginning. If we consider the dynamic distribution of layers, it might alleviate the issues caused by heterogeneous devices. * Communication overhead is an important metric in federal systems, and it is suggested that the authors give the communication data size in each communication round.

Rating

7

Confidence

3

Soundness

3

Presentation

3

Contribution

3

Limitations

The authors give a limitation analysis in the checklist section.

Reviewer RCwU6/10 · confidence 3/52024-07-12

Summary

This paper introduces a forward-mode AD federated learning algorithm (SPRY). They use SPRY to finetune LLMs and demonstrate a low memory footprint compared to backpropagation-based federated learning algorithms. The authors also derive SPRY’s convergence rate and provide theory behind why SPRY’s global gradients are unbiased for homogeneous data distributions across clients. The authors empirically evaluate SPRY on 8 language tasks as well as perform ablation studies.

Strengths

* The empirical evaluation on eight language tasks while testing multiple different language models is a key strength of the paper. * The paper is organized clearly with nice figures and a clear structure to the sections. The empirical evaluation section is particularly well structured. * The ablation studies further strengthen the results of the paper. * The section of peak memory consumption is clear and highlights the superior memory performance of both zero-order and first-order forward mode AD compared to backpropagation. * Splitting forward-mode across multiple layers seems a novel way to perform federated learning.

Weaknesses

* The baseline FWDLLM is described as a zero-order-based approach but upon reading this paper, it seems like it uses a first-order forward mode AD update rule in the federated setting (https://arxiv.org/pdf/2308.13894). Why does the paper categorize this approach as a zero-order-based method? Also, Figure 10 in that paper shows a better performance of all the baselines on the different data sets. Why is there such a significant discrepancy? E.g. RoBERTa-large gets a performance of much greater than 80 % for FwdLLM in the original paper for AG News and is over 60 % for Yahoo. * Equation (4) is challenging to interpret. Why is the summation over classes? What do the subscripts in square brackets mean? Does the paper define data distribution only according to how class labels are distributed among the clients? This did not appear obvious in the paper. * The implications of theorem 4.2 are not clear. Is this bound related to the variance of the gradient estimator? Generally the variance is related to $E[x^2]$.

Questions

* Are the authors aware of AsyncFGD (https://openreview.net/pdf?id=45RBLZBJid)? They also implement FGD in parallel by splitting weights across workers. They do not reach the model and experiment size of this paper, but there does appear to be some similarity in the approach. Would it be possible to identify these differences? * A general limitation of FGD as a learning method is the variance of the gradient estimator with increasing dimension of the parameter space. How does SPRY overcome this challenge? Is there a theory that updating individual layers on different clients reduces this variance? * For per-iteration communication, is there any advantage to having clients, since the server needs to generate all the tangent vectors and then update all the weights of the model. Since there is no matrix multiplication, perhaps there is no need for a GPU on the server-side? Also, generally what would the communication and compute cost be for the server? * What is the current state-of-the-art in federated learning?

Rating

6

Confidence

3

Soundness

2

Presentation

3

Contribution

3

Limitations

Authors have done a good job at describing limitations and memory usage of their approach.

Reviewer KHem2024-08-09

Thank you for your responses. I have increased the score from 5 to 7.

Authorsrebuttal2024-08-10

Thank you for your insights

We are pleased that our responses have addressed the reviewer’s concerns. We will incorporate their valuable insights to enhance our manuscript further. We greatly appreciate the reviewer’s feedback, which is instrumental in improving our work.

Reviewer sp7C2024-08-10

Thank you for the detailed answers. The provided results and details satisfy some of my concerns, however, I find the empirical results somewhat limited in their variety and therefore I'll be keeping my score of slightly leaning towards accept.

Authorsrebuttal2024-08-13

Thank you for the feedback

We are glad to know that we were able to address the reviewer's concerns on the scalability and computation/communication overhead of our work. We will work towards incorporating all the discussed points into our manuscript.

Reviewer RCwU2024-08-12

Thanks for the Rebuttal

The rebuttal helped remove some of the weaknesses so I will raise my score.

Authorsrebuttal2024-08-12

Thank you

We thank the reviewer for taking the time to provide helpful feedback and for the thoughtful reconsideration of their assessment. We will be sure to incorporate the feedback into the manuscript.

Program Chairsdecision2024-09-25

Decision

Accept (poster)

© 2026 NYSGPT2525 LLC