MiLoRA: Efficient Mixture of Low-Rank Adaptation for Large Language Models Fine-tuning

Jingfan Zhang, Yi Zhao, Dan Chen, Xing Tian, Huanran Zheng, Wei Zhu

Abstract

Low-rank adaptation (LoRA) and its mixture-of-experts (MOE) variants are highly effective parameter-efficient fine-tuning (PEFT) methods. However, they introduce significant latency in multi-tenant settings due to the LoRA modules and MOE routers added to multiple linear modules in the Transformer layer. To address this issue, we propose Mixture of Low-Rank Adaptation (MiLoRA), a novel and efficient LoRA variant. MiLoRA differs from previous MOE-style LoRA methods by considering each LoRA module as an expert and employing a prompt-aware routing mechanism. This mechanism calculates expert routing results once before generating the first new token and reuses these results for subsequent tokens, reducing latency. Extensive experiments and analysis on commonsense reasoning tasks, math reasoning tasks, and widely used LLM evaluation benchmarks demonstrate that MiLoRA consistently outperforms strong PEFT baselines with comparable tunable parameter budgets. Additionally, MiLoRA significantly reduces latency in multi-tenant settings compared to previous LoRA-based methods.

Introduction

Parameter-Efficient Fine-Tuning (PEFT) has become the standard paradigm for adapting Large Language Models (LLMs) to specialized downstream tasks. Among these methods, Low-Rank Adaptation (LoRA) is widely adopted due to its ability to update a small fraction of parameters while keeping the base model weights frozen. Recently, researchers have integrated Mixture-of-Experts (MoE) architectures with LoRA to further enhance model capacity.

However, existing MoE-style LoRA variants often suffer from significant inference latency. Most of these methods utilize token-wise routing, where a routing decision must be calculated for every token at every layer during the generation process. In multi-tenant environments—where a single base model serves multiple users with distinct adapters—this computational overhead becomes a critical bottleneck. MiLoRA (Mixture of Low-Rank Adaptation) addresses these challenges by reimagining the routing mechanism and the definition of "experts" within the Transformer architecture.

The MiLoRA Framework

MiLoRA introduces three primary innovations designed to maximize performance while minimizing the computational footprint of the adaptation layer.

1. Prompt-Aware Routing

The core efficiency gain in MiLoRA stems from moving away from token-wise routing. Instead of recalculating expert weights for every generated token, MiLoRA employs a prompt-aware routing mechanism. The router analyzes the initial input prompt and makes a routing decision once. This decision is then cached and reused for all subsequent tokens in the sequence. This approach recognizes that the global context of a prompt is typically sufficient to determine the necessary adaptation logic, drastically reducing the decoding latency that plagues traditional MoE-LoRA methods.

2. LoRA Modules as Experts

In a standard Transformer layer, multiple linear projections (Query, Key, Value, Output, and Feed-Forward Network projections) are typically adapted. MiLoRA treats the LoRA adapter associated with each of these linear modules as an individual expert. The router selects the "Top-k" (often $k=1$) most relevant LoRA modules to activate for a specific layer based on the prompt's context. This allows the model to dynamically prioritize which weight matrices require the most significant adaptation for a given task.

3. Rational Activation Functions

To improve the flexibility of the routing logic, MiLoRA replaces fixed activation functions (like ReLU) with Rational Activation Functions. These are learnable functions that can adapt their shape during the training process. This allows routers at different depths of the network to develop specialized, non-linear logic for selecting experts, leading to more precise task adaptation.

Experimental Results

The researchers evaluated MiLoRA using Llama-2 (7B, 13B) and Gemma (2B) backbones across a comprehensive suite of benchmarks, including commonsense reasoning (ARC, PIQA, BoolQ), mathematical reasoning (GSM8k, AQuA), and general instruction tuning (Alpaca, MMLU, MT-Bench).

Performance and Accuracy

MiLoRA consistently outperformed both standard LoRA and advanced variants like DoRA. On a Llama-2 7B backbone, MiLoRA achieved an average accuracy of 61.5% across single-task benchmarks, compared to 58.4% for standard LoRA and 60.3% for DoRA. Notably, MiLoRA demonstrated superior robustness in multi-task learning scenarios, maintaining high accuracy where standard LoRA often experienced performance degradation due to task interference.

Inference Efficiency

The prompt-aware routing mechanism yielded substantial improvements in generation speed. In head-to-head latency tests, MiLoRA was approximately 21.7% faster than MOELoRA and 19.7% faster than DoRA during text generation. This efficiency makes MiLoRA particularly well-suited for high-throughput, multi-tenant serving environments.

Discussion and Insights

Analysis of the routing behavior revealed significant "layer specialization." The authors observed that different layers in the Transformer hierarchy consistently prefer different types of experts. For instance, certain layers may prioritize adapting the "Query" weights, while others focus on the "Up-projection" in the FFN. This suggests that the importance of specific weight matrices is not uniform across the model, and MiLoRA's sparse activation effectively captures this variance.

Furthermore, the transition from token-level to prompt-level routing did not result in a loss of accuracy. This supports the hypothesis that for many LLM tasks, the adaptation requirements are stable across a single sequence, making the overhead of token-wise routing unnecessary for LoRA-based experts.

Conclusion

MiLoRA represents a significant step forward in making MoE-style adaptation practical for real-world deployment. By combining prompt-aware routing with a novel expert definition and learnable activations, it achieves state-of-the-art accuracy with significantly lower latency than existing PEFT methods. Future work will involve scaling MiLoRA to larger model architectures (e.g., Llama-3 70B) and exploring its efficacy in multimodal domains.

Summary updated

Abstract

Low-rank adaptation (LoRA) and its mixture-of-experts (MOE) variants are highly effective parameter-efficient fine-tuning (PEFT) methods. However, they introduce significant latency in multi-tenant settings due to the LoRA modules and MOE routers added to multiple linear modules in the Transformer layer. To address this issue, we propose Mixture of Low-Rank Adaptation (MiLoRA), a novel and efficient LoRA variant. MiLoRA differs from previous MOE-style LoRA methods by considering each LoRA module as an expert and employing a prompt-aware routing mechanism. This mechanism calculates expert routing results once before generating the first new token and reuses these results for subsequent tokens, reducing latency. Extensive experiments and analysis on commonsense reasoning tasks, math reasoning tasks, and widely used LLM evaluation benchmarks demonstrate that MiLoRA consistently outperforms strong PEFT baselines with comparable tunable parameter budgets. Additionally, MiLoRA significantly reduces latency in multi-tenant settings compared to previous LoRA-based methods.
BibTeX
@inproceedings{zhang2024milora,
  author = {Jingfan Zhang and Yi Zhao and Dan Chen and Xing Tian and Huanran Zheng and Wei Zhu},
  title = {{MiLoRA: Efficient Mixture of Low-Rank Adaptation for Large Language Models Fine-tuning}},
  booktitle = {Conference on Empirical Methods in Natural Language Processing},
  year = {2024},
  url = {https://openreview.net/forum?id=Iflxf6Udni},
}
Figure