EdgeTran: Co-designing Transformers for Efficient Inference on Mobile Edge Platforms

Shikhar Tuli, Niraj K. JhaarXiv 2023 · DOI

Abstract

The rapid growth of Transformer-based models has pushed state-of-the-art NLP beyond the reach of mobile edge devices. We present EdgeTran, a hardware-software co-design framework that optimizes Transformer architectures and hardware selection simultaneously. EdgeTran utilizes a massive heterogeneous search space (FlexiBERT 2.0), an active-learning-based hardware profiler (ProTran), and a Bayesian optimization engine (BOSHCODE) to identify optimal model-device pairs. Our results show that EdgeTran-optimized models are 2.8× smaller and 10× more energy-efficient than BERT-Base while improving GLUE scores by 0.8%.

Introduction

The "Transformer revolution" has yielded models with hundreds of billions of parameters, such as Megatron-Turing NLG. However, deploying these models on battery-powered edge devices remains a significant challenge. Existing Neural Architecture Search (NAS) methods often fall short by assuming homogeneous layer structures, ignoring critical hardware metrics like peak power draw, and optimizing for fixed hardware targets. EdgeTran addresses these limitations by treating the hardware platform as a searchable variable alongside the model architecture.

The EdgeTran Framework

EdgeTran integrates four primary components to navigate a vast design space of $1.7 \times 10^{88}$ possible architectures.

Overview of the EdgeTran framework, illustrating the integration of ProTran, FlexiBERT 2.0, BOSHCODE, and the GPTran refinement step.

FlexiBERT 2.0 and Heterogeneous Design

Unlike standard BERT models where every layer is identical, FlexiBERT 2.0 allows for heterogeneous architectures. Each layer can employ different operations, including vanilla Self-Attention (SA), Linear Transforms (LT/FNet), or Dynamic-Span Convolutions (DSC). This flexibility allows the search to find configurations that balance computational intensity with accuracy requirements across the model stack.

Efficient Search via ProTran and BOSHCODE

To handle the intractable search space, ProTran implements an active learning pipeline. It uses Gradient-Boosted Decision Trees (GBDT) to build surrogate models that predict latency, energy consumption, and peak power draw. These surrogates require only a few hundred real-world measurements on target hardware (e.g., Apple M1, Nvidia Jetson Nano) to achieve high predictive accuracy.

BOSHCODE then performs Bayesian optimization to find the best model-device pair. To accelerate this process, EdgeTran employs Ordered Transfer (OT) and Random Projection (RP), allowing candidate models to inherit weights from previously trained "neighboring" models.

Illustration of weight transfer mechanisms (OT/RP) that allow new candidate models to inherit weights from trained neighbors, significantly reducing search time.

GPTran: Grow-and-Prune Refinement

The final stage, GPTran, performs a local "grow-and-prune" refinement. It uses gradient information to dynamically add or remove attention heads and feed-forward layers, fine-tuning the selected model for maximum efficiency and accuracy.

Evaluation and Results

The framework was evaluated on the GLUE benchmark after pre-training on BookCorpus, Wikipedia, OpenWebText, and CC-News.

  • Efficiency and Accuracy: EdgeTran produced a model 2.8× smaller than BERT-Base that achieved a 0.8% higher GLUE score.
  • Hardware Performance: On the selected edge device, the model demonstrated 15.0% lower latency, 10.0× lower energy consumption, and 10.8× lower peak power draw compared to a standard model on a server-grade Nvidia A100 GPU.
  • Profiling Speed: The ProTran profiler can characterize a new edge device and generate an accurate surrogate model in just a few hours.

Conclusion

EdgeTran demonstrates that hardware-software co-design is essential for bringing state-of-the-art NLP to the edge. By embracing heterogeneity and treating the device as a variable, EdgeTran achieves significant gains in both efficiency and performance. Future work will explore dynamic scheduling and optimization for varying system loads on multi-tasking mobile devices.

Summary updated

BibTeX
@misc{tuli2023edgetran,
  author = {Shikhar Tuli and Niraj K. Jha},
  title = {{EdgeTran: Co-designing Transformers for Efficient Inference on Mobile Edge Platforms}},
  year = {2023},
  eprint = {2303.13745},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2303.13745},
}
Figure