LEMON: Lossless model expansion

Yite Wang, Jiahao Su, Hanlin Lu, Cong Xie, Tianyi Liu, Jianbo Yuan, Haibin Lin, Ruoyu Sun, Hongxia Yang

Abstract

Scaling of deep neural networks, especially Transformers, is pivotal for their surging performance and has further led to the emergence of sophisticated reasoning capabilities in foundation models. Such scaling generally requires training large models from scratch with random initialization, failing to leverage the knowledge acquired by their smaller counterparts, which are already resource-intensive to obtain. To tackle this inefficiency, we present LosslEss MOdel ExpansioN (LEMON), a recipe to initialize scaled models using the weights of their smaller but pre-trained counterparts. This is followed by model training with an optimized learning rate scheduler tailored explicitly for the scaled models, substantially reducing the training time compared to training from scratch. Notably, LEMON is versatile, ensuring compatibility with various network structures, including models like Vision Transformers and BERT. Our empirical results demonstrate that LEMON reduces computational costs by 56.7% for Vision Transformers and 33.2% for BERT when compared to training from scratch.

Introduction

In the current era of foundation models, the prevailing mantra is "bigger is better." However, scaling up usually involves a wasteful cycle: researchers train a small model, realize more capacity is needed, and then discard the small model to train a larger version from scratch with random initialization. This process is incredibly expensive; for instance, training GPT-3 cost an estimated $4.6 million.

Comparison between training from scratch and LEMON expansion.

While methods like "Knowledge Inheritance" exist, they often require complex teacher-student pipelines. Previous model expansion techniques, such as Net2Net, frequently suffered from "symmetry breaking" issues—where duplicated neurons learn identical features, effectively wasting new capacity—or were limited to simply doubling a model's width. LEMON addresses these inefficiencies by providing a truly lossless and versatile expansion framework.

Methodology

LEMON is a suite of algorithms designed to make model expansion efficient and "lossless," meaning the large model starts with the exact same functional mapping as the small model.

Comparative Advantages

Unlike prior work, LEMON is the first method to simultaneously support depth expansion, divisible/indivisible width expansion, and free parameter initialization while remaining data-free.

Comparison of LEMON against existing model expansion methods.

Key Components

  • Symmetry Breaking: Unlike previous methods that duplicated neurons with equal weights, LEMON sets the "fan-out" weights of replicated neurons to be unequal while ensuring their sum remains constant. This prevents neurons from becoming stuck in identical states, allowing the model to utilize its new capacity immediately.
  • Handling Indivisible Widths: Most prior work only handled doubling the width (e.g., 512 to 1024). LEMON introduces "average expansion" for LayerNorm, allowing for arbitrary increments (e.g., 512 to 768).
  • Lossless Depth Expansion: The framework proposes two ways to add layers such that the initial output of the block is zero (via zero-weights or canceling contributions), ensuring the residual connection carries the original signal forward perfectly.
  • Optimized Training Recipe: Expanded models are essentially "warm-started." The authors found that keeping the standard high learning rate but employing a faster cosine decay is the most efficient way to reach peak performance.

Experimental Setup

The researchers evaluated LEMON across both computer vision and natural language processing tasks:

  • Vision: Vision Transformer (ViT) models trained on ImageNet-1k.
  • Language: Pre-LN BERT models trained on the English Wikipedia corpus.
  • Downstream Evaluation: The GLUE benchmark was used to test the final performance of the expanded BERT models on various linguistic tasks.

Key Results and Insights

LEMON sets a new benchmark for training efficiency and performance:

  • Efficiency Gains: Achieved a 56.7% reduction in computational cost for ViT and a 33.2% reduction in training iterations for BERT compared to training from scratch.
  • Performance Gains: On the GLUE benchmark, BERT models expanded via LEMON actually outperformed models of the same size trained from scratch. This suggests that models benefit from the "curriculum" of learning on a smaller architecture first.
  • Versatility: LEMON is compatible with various Transformer flavors, including Post-Norm, Pre-Norm, and models using RMS Norm (like LLaMA).

Conclusion and Future Work

LEMON demonstrates that scaling does not require starting from zero. By breaking symmetry and ensuring lossless initialization, researchers can significantly reduce the carbon footprint and financial cost of AI development. Future work will focus on automating hyperparameter selection for the training duration and extending these methodologies to massive foundation models with billions of parameters.

Summary updated

BibTeX
@inproceedings{wang2024lemon,
  author = {Yite Wang and Jiahao Su and Hanlin Lu and Cong Xie and Tianyi Liu and Jianbo Yuan and Haibin Lin and Ruoyu Sun and Hongxia Yang},
  title = {{LEMON: Lossless model expansion}},
  booktitle = {International Conference on Learning Representations},
  year = {2024},
  url = {https://openreview.net/forum?id=3Vw7DQqq7U},
}
Figure