DRONE: Data-aware Low-rank Compression for Large NLP Models

Patrick CHen, Hsiang-Fu Yu, Inderjit S Dhillon, Cho-Jui HsiehNeurIPS 2021

TL;DR

DRONE (Data-aware Low-rank Compression) is a novel method for shrinking large NLP models like BERT without sacrificing performance. By recognizing that while model weights are high-rank, the data they process actually lies in a low-dimensional subspace, DRONE achieves up to 1.92x speedup on its own and over 12x speedup when combined with model distillation.

The Challenge: High-Rank Weights in Large Models

Large-scale Transformer models have revolutionized Natural Language Processing (NLP), but their massive size makes them difficult to deploy on mobile devices or use in real-time applications. The primary computational bottleneck lies in the matrix multiplications within the feed-forward and self-attention layers.

Standard compression techniques often rely on Singular Value Decomposition (SVD) to find "low-rank" approximations of these matrices. However, a critical problem arises: BERT’s weight matrices are not inherently low-rank. Applying standard SVD to these matrices results in massive reconstruction errors and a significant drop in accuracy. The challenge is finding a way to compress these "stubbornly" high-rank matrices without breaking the model's underlying logic.

BERT Inference Time Breakdown

The DRONE Approach: Focus on the Data

The core innovation of DRONE is shifting the compression focus from the weights to the data.

The authors observe that the latent representations (the features passed between layers) usually lie in a low-dimensional subspace. Even if a weight matrix $W$ is full-rank, it only needs to be accurate for the specific types of inputs $X$ it actually encounters during inference.

Key Technical Contributions: * Optimization Objective: Instead of minimizing the difference between the original and compressed weights (the standard SVD approach), DRONE minimizes the difference between the original and compressed outputs ($\|WX - WMX\|$). * Closed-form Solution: The authors provide a provably optimal, closed-form solution for this data-aware decomposition. It involves performing SVD on a transformed matrix that incorporates the covariance of the input data. * Topological Compression: Because compressing one layer changes the input distribution for the subsequent layer, DRONE compresses the model layer-by-layer in its topological order. It adjusts the "error budget" based on how much each module contributes to the total inference time.

Key Insights

  • Weights $\neq$ Data: The most important realization is that a matrix doesn't have to be low-rank to be approximated by a low-rank matrix, provided you know the distribution of the vectors it will multiply.
  • SVD is a Sub-optimal Baseline: "Vanilla" SVD fails on BERT because it treats every direction in the weight space as equally important. DRONE uses actual training data to identify which directions matter most for the model's predictions.
  • Attention isn't always the Bottleneck: Contrary to the popular belief that self-attention is the main culprit for slowness, in many common use cases (like shorter sequences), the large feed-forward layers actually consume the most computation time.
  • Synergy with Distillation: DRONE is orthogonal to model distillation. While distillation (like TinyBERT) reduces the number of layers or hidden dimensions, DRONE can be applied on top of a distilled model to squeeze out even more efficiency.

Key Results

The researchers evaluated DRONE across a variety of standard benchmarks, including the GLUE Benchmark, Penn Treebank (PTB), and En-De Translation tasks.

Performance Comparison on GLUE Benchmark
  • Stand-alone Performance: On the MRPC task, DRONE achieved a 1.92x speedup on CPU with only a 1.5% loss in accuracy (dropping from 89.5% to 88.0% with retraining).
  • Comparison to SVD: In every test, DRONE significantly outperformed standard SVD. For example, on the CoLA task, SVD dropped accuracy to an unusable 12.4%, while DRONE maintained 52.5% (remarkably close to the original 53.4%).
  • Combined Power: When combined with TinyBERT (a distilled model), DRONE reached massive speedups of 12.3x to 15.3x across various natural language inference tasks while maintaining competitive accuracy.
  • Hardware Variance: Speedups were generally more pronounced on CPUs than GPUs. This is because GPUs rely on massive parallelism, and the overhead of sequential computations in low-rank fragments can sometimes diminish the gains of having fewer total operations.

Limitations and Future Work

  • Pre-processing Cost: DRONE requires a "data-gathering" pass to observe the input distributions. While relatively fast (2 to 20 minutes depending on the task), it is an extra step compared to simple magnitude pruning.
  • GPU Optimization: The current implementation shows lower speedup ratios on GPUs. Low-level CUDA kernel optimization is likely needed to fully realize the benefits of low-rank structures on highly parallel hardware.
  • Training Integration: The paper focuses on post-training compression. A promising future direction is "DRONE-aware training," where the model is explicitly encouraged to find data-aware low-rank structures during the initial learning phase.

Summary updated

BibTeX
@inproceedings{chen2021drone,
  author = {Patrick CHen and Hsiang-Fu Yu and Inderjit S Dhillon and Cho-Jui Hsieh},
  title = {{DRONE: Data-aware Low-rank Compression for Large NLP Models}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2021},
  url = {https://openreview.net/forum?id=sthiz9zeXGG},
}
Figure