G-Bert: Enabling Green BERT Deployment on FPGA Via Hardware-Aware Hybrid Pruning
Yueyin Bai,Hao Zhou,Ruiqi Chen,Kuangjie Zou,Jialin Cao,Haoyang Zhang,Jianli Chen,Jun Yu,Kun Wang
DOI: https://doi.org/10.1109/icc45041.2023.10278567
2023-01-01
Abstract:Transformer-based models suffer from large num-ber of parameters and high inference latency, whose deployment are not green due to the potential environmental damage caused by high inference energy consumption. In addition, it is difficult to deploy such models on devices, especially on resource constrained devices such as FPGA. Various model pruning methods are proposed to shrink the model size and resource consumption, so as to fit the models on hardware. However, such methods often introduce floating point of operations (FLOPs) as an agent of hardware performance, which is not accurate. Furthermore, structural pruning methods are always in a single head-wise or layer-wise pattern, which fails to compress the models to the extreme. To resolve the above issues, we propose a green BERT deployment method on FPGA via hardware-aware and hybrid pruning, named g-BERT. Specifically, two hardware-aware metrics are introduced by High Level Synthesis (HLS) to evaluate the latency and power consumption of inference on FPGA, which can be optimized directly while pruning. Moreover, we simultaneously consider pruning of heads and full encoder layers. To efficiently find the optimal structure, g-BERT applies differentiable neural architecture search (NAS) with a special 0–1 loss function. Compared with the BERT-base, g-BERT achieves $2.1\times$ speedup, $1.9\times$ power consumption reduction and $1.8\times$ model size reduction with comparable accuracy, on par with the state-of-the-art methods.