Introduction: The Efficiency Gap
Transformers have revolutionized Natural Language Processing, but their computational demands make them difficult to deploy on resource-constrained edge devices. A common pitfall in optimizing these models is the reliance on Floating-point operations (FLOPs) as a proxy for efficiency. However, FLOPs are often a misleading metric because they do not correlate consistently with actual measured latency across different hardware platforms.
As illustrated in Figure 4, hardware platforms exhibit unique bottlenecks. For instance, increasing embedding dimensions significantly impacts ARM CPU latency but has a negligible effect on Nvidia GPUs. This "hardware pickiness" necessitates specialized architectures tailored to specific devices rather than a one-size-fits-all approach.
The HAT Framework
Hardware-Aware Transformers (HAT) is a framework designed to automate the creation of these specialized models using Neural Architecture Search (NAS) with significantly reduced overhead. The process involves three main stages:
- Defining a Large Design Space: HAT introduces flexibility by allowing heterogeneous layers (where different layers have different numbers of heads or hidden dimensions) and arbitrary encoder-decoder attention, breaking the traditional information bottleneck.
- Training a SuperTransformer: Instead of training thousands of candidate models, HAT trains a single "SuperTransformer" that encompasses all possible sub-networks. Through weight-sharing, any "SubTransformer" can be extracted and evaluated without additional training.
- Hardware-Aware Evolutionary Search: To find the best model for a specific device, HAT uses a Latency Predictor—a simple neural network trained on a small dataset of architecture-latency pairs—to provide instant feedback to an evolutionary search engine.
Key Results and Insights
HAT was evaluated on standard machine translation benchmarks (WMT’14, WMT’19, IWSLT’14) across three distinct hardware platforms: Raspberry Pi-4 (ARM CPU), Intel Xeon CPU, and Nvidia TITAN Xp GPU.
- Speed and Efficiency: On a Raspberry Pi, HAT achieved a 3x speedup and was 3.7x smaller than Transformer-Big while maintaining the same BLEU score.
- Search Cost Revolution: By training the SuperTransformer once, the search cost dropped by over 12,000x compared to previous methods like the Evolved Transformer. The total GPU-hours required for HAT is roughly equivalent to training a single standard Transformer-Big.
- Hardware Specialization: The search revealed distinct architectural preferences: GPUs favor wide and shallow models to maximize parallelism, while ARM CPUs perform better with deep and thin models.
Conclusion
HAT demonstrates that hardware-specific optimization is essential for efficient NLP deployment. By leveraging weight-sharing and latency predictors, the framework makes high-performance, specialized models accessible without the need for massive compute clusters. Future work will look to extend this hardware-aware approach to other architectures like BERT and GPT.
Summary updated