Reducing Transformer Depth on Demand with Structured Dropout

Angela Fan, Edouard Grave, Armand Joulin

Abstract

Transformer-based architectures have set new benchmarks across natural language processing but suffer from significant computational overhead and overparameterization. We introduce LayerDrop, a structured dropout method that randomly omits entire layers during training. This technique provides a dual benefit: it acts as a powerful regularizer for training deeper, more stable models and enables "pruning on demand." Unlike traditional pruning or distillation, which require training separate models for different resource constraints, LayerDrop allows a single network to be dynamically shrunk to any depth at inference time. Our results across machine translation, language modeling, and summarization demonstrate that LayerDrop-pruned models maintain higher performance than those trained from scratch or via standard distillation.

Introduction

The success of Transformers in NLP is often tied to increasing model depth and parameter counts. However, this growth imposes a "computational tax," making deployment difficult on hardware with limited memory or latency requirements. Existing solutions like weight pruning and knowledge distillation are typically rigid, requiring a dedicated training cycle for every target model size. We propose a method to train a single "super-model" from which sub-networks of any depth can be extracted instantly.

Methodology: Structured Dropout for Plasticity

The core of our approach is LayerDrop, a form of structured dropout applied at the layer level.

Conceptual comparison between training separate networks and the LayerDrop approach for on-demand depth selection.

Training with LayerDrop

During training, instead of dropping individual neurons or weights, we randomly skip entire Transformer layers. This forces the network to develop redundancy and ensures that the remaining layers can still produce coherent representations. This "plasticity" is essential for the model to remain functional when components are removed at test time.

Inference and Pruning on Demand

Because the model is trained to be robust to missing layers, we can perform "on-demand" pruning at test time to meet specific hardware constraints. Among various strategies, the "Every Other" approach—keeping layers at regular intervals (e.g., layers 1, 3, 5...)—proved remarkably effective. This strategy preserves the critical input-processing and output-mapping stages while maintaining a balanced data flow throughout the network.

Experimental Results

We evaluated LayerDrop across diverse benchmarks, including WMT14 (Translation), WikiText-103 (Language Modeling), and GLUE (Language Understanding).

Robustness Across Tasks

LayerDrop demonstrates superior robustness compared to baseline models and those trained from scratch when subjected to pruning.

Performance degradation across Language Modeling, Machine Translation, and Summarization as a function of pruning percentage.

As shown in the performance curves above, LayerDrop (blue circles) consistently maintains lower perplexity in language modeling and higher BLEU/ROUGE scores in translation and summarization as the percentage of pruned layers increases. It significantly outperforms models trained from scratch to the same target size, highlighting the effectiveness of the structured dropout regularization.

Key Insights

  • Stability in Depth: LayerDrop stabilizes the training of very deep models. For instance, a 12-layer encoder that might otherwise diverge in machine translation tasks trains reliably with LayerDrop, reaching state-of-the-art performance (30.2 BLEU on WMT14).
  • Superior to Distillation: In GLUE tasks, a 6-layer RoBERTa model extracted via LayerDrop outperformed DistilBERT and other smaller models trained from scratch.
  • Efficiency: By dropping layers during training, we can reduce the memory footprint and potentially increase training speed by up to 2x.

Conclusion

LayerDrop provides a flexible framework for managing the depth-efficiency trade-off in Transformers. By training a single model that is inherently robust to layer removal, we eliminate the need for costly, task-specific distillation for every deployment scenario. This approach not only yields more accurate pruned models but also simplifies the deployment pipeline for large-scale NLP systems.

Summary updated

BibTeX
@inproceedings{fan2020reducing,
  author = {Angela Fan and Edouard Grave and Armand Joulin},
  title = {{Reducing Transformer Depth on Demand with Structured Dropout}},
  booktitle = {International Conference on Learning Representations},
  year = {2020},
}
Figure