TL;DR
This paper introduces HEAT, a framework that automates tensor decomposition for compressing Transformer models, achieving significant energy efficiency gains (up to 5.7x reduction in energy-delay product) with minimal accuracy loss. HEAT uniquely incorporates hardware cost into the optimization process, intelligently searching for optimal tensorization shapes and ranks, and uses a novel distillation technique to overcome trainability challenges.
What Problem Does This Paper Address?
Transformers have revolutionized NLP and computer vision, but their massive size, particularly in self-attention and feedforward layers, makes them computationally expensive and energy-hungry. This limits their deployment on resource-constrained devices. Tensor decomposition offers a way to reduce this redundancy by factorizing large weight matrices. However, previous methods often relied on manual or heuristic choices for decomposition parameters (like tensorization shape and rank), which didn't translate well to actual hardware efficiency, leading to performance degradation. The core challenge is to find a way to automatically discover tensor decompositions that are both effective in compression and highly efficient on real hardware, while also maintaining model accuracy.
Methods
HEAT tackles this problem through a three-stage, hardware-aware framework:
- Pareto Optimal Tensorization Shape Search (Level 1): Instead of relying on heuristics, HEAT systematically explores a vast space of possible tensorization shapes for each weight matrix. It uses hardware cost simulation (energy-delay product) and decomposition error to identify Pareto optimal shapes that balance compression and efficiency. This stage also optimizes tensor contraction paths and maps them efficiently to hardware.
- Per-Tensor Rank Optimization (Level 2): Recognizing that different weight matrices have varying "low-rankness," HEAT employs a novel "Rank SuperNet" approach. This technique allows for efficient exploration of per-tensor rank settings by sharing weights across different rank configurations. It then uses an evolutionary search guided by an accuracy predictor to find optimal rank settings that minimize hardware cost and maximize task performance.
- Trainability Boost with Two-Stage Distillation (Level 3): Tensor decomposition can introduce trainability issues. HEAT addresses this with a two-stage knowledge distillation process. First, it performs layer-wise distillation to minimize approximation error. Then, it distills knowledge from the teacher model's attention maps and hidden states to the factorized student model, effectively recovering accuracy.
Datasets
The paper uses the following datasets:
- SQuAD-v1.1: Used for training and evaluating the primary BERT-base and DistilBERT models.
- SST-2: Used for evaluating the generalization of the decomposition settings found on SQuAD.
Key Insights and Ideas
- Hardware Cost is Paramount: The paper strongly emphasizes that standard compression metrics like MACs or parameter count are poor indicators of actual hardware efficiency. Energy-delay product (EDP) is a more reliable metric.
- Heterogeneous Low-Rankness: Different weight matrices within a Transformer exhibit varying degrees of low-rankness. HEAT's per-tensor rank optimization exploits this heterogeneity, unlike previous global settings.
- Rank SuperNet for Efficient Search: The proposed Rank SuperNet significantly speeds up the search for optimal per-tensor ranks by enabling weight sharing, making the exploration of the exponential rank space feasible.
- Two-Stage Distillation is Crucial: Simply re-training factorized models is difficult. The proposed two-stage distillation effectively bridges the gap between theoretical compression and practical accuracy recovery.
- Embedding Layers are Not Ideal for Decomposition: The paper argues that decomposing embedding layers, while saving parameters, doesn't yield hardware efficiency benefits due to the cost of tensor dot products outweighing storage savings.
Key Results
- HEAT achieves up to 5.7x reduction in energy-delay product (EDP) on a customized accelerator with less than 1.1% accuracy loss on BERT-base for SQuAD-v1.1.
- Compared to manual and heuristic tensor decomposition methods, HEAT-variants show 1-3% higher accuracy while achieving ~30% less hardware cost on average.
- For TTM decomposition, HEAT improves F1 score by +0.65% with 8% fewer parameters and 8.8% lower hardware cost.
- For Tucker decomposition, HEAT-series boosts F1 score by +1.03% with +30% higher efficiency than handcrafted settings.
- For CP decomposition, HEAT-series boosts F1 score by +3.45% with 25.3% less hardware cost.
- On SST-2, HEAT-variants can maintain accuracy with 4-10x higher hardware efficiency for Tucker and CP, and 3-10x higher hardware cost savings for TTM.
Limitations and Future Work
- Computational Cost of Search: While HEAT significantly reduces the search space compared to brute-force, the initial search for optimal shapes and ranks can still be computationally intensive.
- Hardware Specificity: The framework is optimized for a specific accelerator architecture (Simba-L). Adapting it to other hardware might require re-simulation and re-optimization.
- Future Work: The authors suggest that HEAT can be jointly applied with other orthogonal compression methods (like weight pruning or quantization) for even greater compression and efficiency. They also highlight the potential for further exploration of tensor decomposition for other Transformer components.
Summary updated