MeteoRA: Multiple-tasks Embedded LoRA for Large Language Models

Jingwei Xu, Junyu Lai, Yunpeng Huang

TL;DR

MeteoRA is a novel framework that embeds multiple task-specific LoRA adapters into a single Large Language Model (LLM) using a Mixture-of-Experts (MoE) architecture. It allows the LLM to autonomously route inputs to the correct LoRA adapter on the fly without explicit user instructions, even switching adapters mid-generation for complex, multi-part prompts. To make this practical, the authors also introduce custom GPU kernels that speed up the MoE forward pass by roughly 4x.

What Problem Does This Paper Address?

The "pretrain + fine-tune" paradigm has made Low-Rank Adaptation (LoRA) incredibly popular. Because LoRAs are lightweight, developers often accumulate dozens of task-specific adapters (e.g., one for math, one for summarization, one for coding).

However, serving multiple LoRAs simultaneously is clunky. Current frameworks (like Huggingface PEFT or S-LoRA) require the user or system to explicitly specify which LoRA to activate for a given prompt. The LLM cannot autonomously sense the user's intent and pick the right tool for the job. This limitation becomes glaringly obvious in "composite tasks"—prompts that contain multiple sub-problems requiring different skills. If a user asks a math question and then immediately asks for a translation in the same prompt, standard multi-LoRA setups struggle to switch adapters dynamically.

Methods

To solve this, the authors introduce MeteoRA (Multiple-tasks embedded LoRA).

MeteoRA Module Architecture
  • Full-Mode MoE Architecture: MeteoRA takes $n$ off-the-shelf, frozen LoRA adapters and embeds them into the base LLM's linear layers (both Attention and MLP modules) using a Mixture-of-Experts (MoE) setup.
  • Trainable Gating Network: Instead of training the adapters, MeteoRA freezes the base LLM and the LoRAs, training only a lightweight "Gating network." This gate calculates routing weights token-by-token, deciding which top-$k$ LoRA adapters should process the current input.
  • Forward Acceleration Strategies: A naive MoE implementation (looping through every expert) is devastatingly slow when dealing with many LoRAs (e.g., 28 adapters). The authors replace this with batched matrix multiplication (bmm-torch), which parallelizes the computation. Because bmm-torch is highly memory-intensive for long sequences, they also wrote a custom Triton GPU kernel (bmm-triton) that achieves similar speeds while keeping the memory footprint low.

Datasets

The authors evaluated MeteoRA across a diverse suite of 28 tasks:

  • Standard Benchmarks: 22 tasks from BigBench, 3 translation tasks from News-Commentary, GSM8K (math), CNN/DailyMail (summarization), and Alpaca (instruction tuning).
  • New "Composite-n" Benchmark: To test dynamic adapter switching, the authors created composite-3, composite-5, and composite-10 datasets. These are constructed by concatenating 3, 5, or 10 independent tasks into a single "test sheet" prompt, forcing the model to answer them sequentially in one inference pass.

Key Insights and Ideas

  • Autonomous Routing Works: A simple gating network can successfully learn to route tokens to the correct off-the-shelf LoRA adapters without needing the adapters themselves to be co-trained or merged.
  • Token-Level Agility: Because the gating network operates at the token level, the model can switch "experts" (LoRAs) mid-prompt.
Token-level routing in composite tasks

Visualizations in the paper show the model seamlessly handing off processing from a logical deduction LoRA to a question-answering LoRA exactly at the boundary between two concatenated questions.

  • The MoE Bottleneck is Real: Standard MoE implementations are practically unusable for a large library of LoRAs due to for-loop overhead. Custom memory-efficient kernels are absolutely necessary to make multi-LoRA MoE viable in production.

Key Results

  • Maintains Individual Task Performance: On the 28 individual tasks, MeteoRA (using a top-1 routing strategy on LLaMA3-8B) achieved an average accuracy of 0.811. This is nearly identical to the reference PEFT model (0.817), which had the unfair advantage of being explicitly told which LoRA to use.
  • Dominates Composite Tasks: On the grueling composite-10 task, MeteoRA correctly answered an average of 3.75 multiple-choice questions per prompt, compared to just 2.95 for a baseline model trained on a balanced mix of all tasks. It also achieved higher BLEU and ROUGE scores on the generative portions.
  • Significant Speedups: The custom bmm-torch and bmm-triton kernels achieved an average speedup of ~4x over the naive loop-original MoE implementation, making the system vastly more efficient for real-world inference.

Limitations and Future Work

  • Adapter Updates Break the Gate: If you update or swap out one of the underlying LoRA adapters, the hidden states shift. This means you have to retrain the Gating network to maintain performance.
  • Struggles with True Knowledge Fusion: MeteoRA is great at switching between tasks, but it struggles to fuse knowledge simultaneously. For example, when given a math problem in Italian, it failed to effectively combine an English math LoRA and an Italian translation LoRA to solve it better than the math LoRA alone.
  • Efficiency Ceiling: Despite the impressive 4x speedup, the MoE approach is still slower than running a single, standard LoRA. The authors note that developing even more efficient CUDA/Triton operators is necessary as the number of embedded adapters scales up.

Summary updated

BibTeX
@inproceedings{xu2025meteora,
  author = {Jingwei Xu and Junyu Lai and Yunpeng Huang},
  title = {{MeteoRA: Multiple-tasks Embedded LoRA for Large Language Models}},
  booktitle = {International Conference on Learning Representations},
  year = {2025},
  url = {https://openreview.net/forum?id=yOOJwR15xg},
}
Figure