MEFT: Memory-Efficient Fine-Tuning through Sparse Adapter

Jitai Hao, Weiwei Sun, Xin Xin, Qi Meng, Zhumin Chen, Pengjie Ren, Zhaochun Ren

Abstract

Parameter-Efficient Fine-Tuning (PEFT) methods, such as LoRA, have revolutionized the adaptation of Large Language Models (LLMs) by updating only a small fraction of parameters. However, these methods often struggle with knowledge-intensive tasks that require the model to internalize new factual information, a process that necessitates larger adapter capacities (up to 10% of total parameters). Such large adapters typically exceed the memory limits of consumer-grade GPUs. We introduce MEFT (Memory-Efficient Fine-Tuning), a framework that leverages the inherent activation sparsity of neural networks and a novel "Key-Experts" CPU-offloading mechanism. MEFT enables the training of 10% scale adapters on hardware with only 24GB of VRAM, reducing communication bottlenecks by 3.57x and significantly outperforming standard PEFT methods on open-domain question-answering benchmarks.

1. Introduction

While low-rank adaptation (LoRA) and similar PEFT techniques are effective for instruction following and style transfer, they encounter a "knowledge gap" when applied to tasks requiring the memorization of new facts. Research indicates that to effectively bridge this gap, the adapter capacity must increase significantly, often requiring the modification of roughly 10% of the model's parameters.

For a LLaMA-7B model, a 10% adapter requires over 48GB of GPU memory for training, which is double the capacity of common consumer hardware like the NVIDIA RTX 3090 or 4090. While CPU offloading (moving parameters to system RAM) is a potential solution, the massive data transfer required over the PCIe bus usually results in prohibitive training latencies. MEFT addresses this by exploiting the observation that most neurons in a network remain inactive for any given input, allowing for a more surgical approach to memory management.

2. Methodology

MEFT breaks the memory wall through three integrated strategies designed to minimize VRAM usage and communication overhead.

2.1 Sparse Activation Exploitation

In Feed-Forward Networks (FFNs), typically fewer than 5% of neurons are activated for a specific input. MEFT identifies these active neurons dynamically and ensures that only the necessary parameters are moved to the GPU for computation. By ignoring the "silent" 95% of the adapter, the system drastically reduces the active memory footprint.

2.2 CPU-GPU Hybrid Storage

The full large-scale adapter is stored in the system's CPU RAM. During the forward pass, the model identifies the required neurons and fetches them into a specialized "Copy-Adapter" on the GPU. This hybrid approach allows the model to benefit from the high capacity of system RAM while maintaining the computational speed of the GPU for the active components.

2.3 The Key-Experts Mechanism

Searching for active neurons across millions of parameters on the CPU can introduce significant latency. MEFT optimizes this search using a Mixture-of-Experts (MoE) inspired architecture. The adapter is partitioned into "experts," and a lightweight router on the GPU identifies relevant experts. The CPU then performs fine-grained neuron selection only within those identified experts. This reduces the computational complexity of the selection process from $O(dNM)$ to $O(dN\sqrt{M})$, where $M$ represents the number of neurons.

3. Experimental Evaluation

3.1 Setup

MEFT was evaluated using LLaMA-7B and Mistral-7B as base models. Testing spanned four distinct datasets:

  • Natural Questions (NQ): For open-domain question answering.
  • SQuAD: For reading comprehension.
  • ToolBench: For tool-use and API interaction.
  • GSM8K: For logical reasoning and grade-school mathematics.

3.2 Performance and Memory Efficiency

MEFT successfully fine-tuned a 10% parameter adapter for LLaMA-7B on a single 24GB VRAM GPU—a task previously requiring 48GB+. On the Natural Questions (NQ) dataset, MEFT achieved an Exact Match (EM) score of 0.413, a substantial improvement over LoRA (0.305) and Parallel Adapter (0.387) under the same memory constraints. In several instances, MEFT's performance was comparable to full-model fine-tuning.

3.3 Communication and Training Speed

By transferring only active neurons, MEFT achieved a 3.57x reduction in data transfer volume compared to standard frameworks like DeepSpeed-ZeRO. Despite the inherent overhead of CPU-GPU communication, MEFT maintained approximately 63% of the training speed of a theoretical "infinite memory" GPU baseline.

4. Discussion and Limitations

The study revealed that while increased adapter capacity is vital for knowledge-intensive tasks (QA), it offers diminishing returns for logic-heavy tasks like GSM8K. Reasoning capabilities appear to be more dependent on the base model's pre-training than on the size of the fine-tuning adapter. Additionally, as input sequence lengths increase, the number of unique active neurons grows, which can eventually increase the communication load on the PCIe bus.

5. Conclusion

MEFT demonstrates that large-scale adapters are both necessary for knowledge acquisition and achievable on consumer hardware. By leveraging activation sparsity and the Key-Experts mechanism, MEFT provides a path for researchers to train high-capacity models without the need for enterprise-grade server clusters. Future work will focus on optimizing CUDA kernels to further reduce latency and exploring the scaling behavior of sparse adapters in even larger model architectures.

Summary updated

BibTeX
@inproceedings{hao2024meft,
  author = {Jitai Hao and Weiwei Sun and Xin Xin and Qi Meng and Zhumin Chen and Pengjie Ren and Zhaochun Ren},
  title = {{MEFT: Memory-Efficient Fine-Tuning through Sparse Adapter}},
  booktitle = {Annual Meeting of the Association for Computational Linguistics},
  year = {2024},
  doi = {10.18653/v1/2024.acl-long.129},
}
Figure