Introduction
Deploying Large Language Models (LLMs) on edge devices—such as smartphones or IoT sensors—is a significant challenge due to limited memory and the vast diversity of hardware. Traditionally, developers must fine-tune a separate model for every device profile, a process that is computationally expensive and difficult to scale.
IBM Research recently introduced MLFS (Multistage Low-rank Fine-tuning of Super-transformers) at NAACL 2024. This method produces a "palette" of high-quality models of varying sizes from a single training run, enabling efficient deployment across a wide spectrum of hardware.
The Deployment Gap
Enterprises require models that can fit diverse hardware and adapt to dynamic resource constraints, such as low battery levels. While existing solutions like DistilBERT produce a single compressed model, they lack the flexibility needed for heterogeneous device environments. Supernets offer a theoretical solution by sharing weights across multiple subnets, but training them from scratch is prohibitively expensive. MLFS bridges this gap by combining Supernet training with Low-Rank Adaptation (LoRA).
Methodology: The MLFS Approach
MLFS introduces three key innovations to make Supernet training efficient and effective:
- Multistage Training: The process begins with fine-tuning the full teacher model using LoRA (Stage 0). It then proceeds to sample subnets of different widths (Stage 1) and finally both widths and depths (Stage 2).
- Gradient Scaling: To prevent the large "maxnet" from dominating the optimization, the authors use a scaling scheme that boosts gradients for smaller subnets. This ensures that the entire range of models in the palette achieves high performance.
- Efficient Feature Distillation: A shared projection matrix is used to distill knowledge from the teacher's internal layers to the subnets without excessive memory overhead.
Key Insights: Gradient Scaling and the "Palette"
The "secret sauce" of MLFS is gradient scaling. As shown in the training loss curves, incorporating gradient scaling allows smaller subnets to converge more effectively, preventing them from underperforming relative to the larger models in the Supernet.
Once trained, the Supernet acts as a "palette," allowing users to "slice" out a model of almost any size (e.g., 45M or 80M parameters) without additional training. This flexibility is a major advantage over traditional distillation methods that produce a single fixed-size output.
Results and Performance
The researchers evaluated MLFS on both encoder (BERT) and decoder (CodeLlama) architectures.
Encoder Performance
On the GLUE benchmark, MLFS produced BERT models that were 1/4 the size and had 1/3 the latency of the original teacher. As illustrated below, MLFS maintains accuracy levels comparable to or better than state-of-the-art distillation methods like TinyBERT and BERT-PKD across various parameter counts.
Decoder Efficiency
For decoder models, MLFS significantly speeds up the creation of smaller versions. Slicing a 0.7B model from a 1.1B teacher reached low validation loss much faster than training a 0.7B model from scratch. However, the authors noted a "compression floor" for decoders; performance drops significantly if reduced beyond 2/3 of the teacher's size, suggesting generative capabilities are more parameter-dependent than understanding tasks.
Conclusion
MLFS offers a scalable solution for deploying LLMs on the edge. By producing a palette of models from a single training run using LoRA and gradient scaling, it reduces the computational burden of model compression while providing the flexibility needed for diverse hardware ecosystems. Future work will explore why decoders are more resistant to heavy compression and how to further optimize their "slicing" process.
Summary updated