Transformer中用于多头注意和位置前馈的硬件加速器
Hardware Accelerator for Multi-Head Attention and Position-Wise Feed-Forward in the Transformer
摘要:
为深度神经网络(DNN)设计硬件加速器一直是人们非常期望的。尽管如此,大多数现有的加速器都是为卷积神经网络(CNN)或递归神经网络(RNN)构建的。最近,Transformer模型正在自然语言处理(NLP)领域取代RNN。然而,由于涉及密集的矩阵计算和复杂的数据流,Transformer模型的硬件设计还没有报道。在本文中,我们提出了两个关键组件的第一个硬件加速器,即,多头注意(MHA)ResBlock和位置前馈网络(FFN)ResBlock,它们是Transformer中最复杂的两个层。首先,提出了一种有效的方法来划分Transformer中的大型矩阵,允许两个ResBlock共享大部分硬件资源。其次,设计了计算流程,保证了脉动阵列的高硬件利用率,脉动阵列是我们设计中最大的模块。第三,对复杂的非线性函数进行了高度优化,进一步降低了硬件复杂度,也降低了整个系统的延迟。我们的设计是使用硬件描述语言(HDL)编码,并在Xilinx FPGA上进行评估。与相同设置下的GPU实现相比,所提出的设计在MHA ResBlock中的速度提高了14.6倍,在FFN ResBlock中的速度提高了3.4倍。因此,本文的工作为构建高效的多Transformer网络硬件加速器奠定了良好的基础。
英文摘要:
Designing hardware accelerators for deep neural networks (DNNs) has been much desired. Nonetheless, most of these existing accelerators are built for either convolutional neural networks (CNNs) or recurrent neural networks (RNNs). Recently, the Transformer model is replacing the RNN in the natural language processing (NLP) area. However, because of intensive matrix computations and complicated data flow being involved, the hardware design for the Transformer model has never been reported. In this paper, we propose the first hardware accelerator for two key components, i.e., the multi-head attention (MHA) ResBlock and the position-wise feed-forward network (FFN) ResBlock, which are the two most complex layers in the Transformer. Firstly, an efficient method is introduced to partition the huge matrices in the Transformer, allowing the two ResBlocks to share most of the hardware resources. Secondly, the computation flow is well designed to ensure the high hardware utilization of the systolic array, which is the biggest module in our design. Thirdly, complicated nonlinear functions are highly optimized to further reduce the hardware complexity and also the latency of the entire system. Our design is coded using hardware description language (HDL) and evaluated on a Xilinx FPGA. Compared with the implementation on GPU with the same setting, the proposed design demonstrates a speed-up of 14.6x in the MHA ResBlock, and 3.4x in the FFN ResBlock, respectively. Therefore, this work lays a good foundation for building efficient hardware accelerators for multiple Transformer networks.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。