Abstract
Designing hardware accelerators for deep neural networks (DNNs) has become essential for efficient deployment. While many accelerators exist for CNNs and RNNs, the Transformer model—which is rapidly replacing RNNs in Natural Language Processing (NLP)—presents unique challenges due to intensive matrix computations and complex data flows. This paper proposes the first hardware accelerator specifically for the Multi-Head Attention (MHA) and Position-Wise Feed-Forward Network (FFN) ResBlocks, the two most computationally demanding layers in the Transformer. By introducing efficient matrix partitioning, optimized computation flows for systolic arrays, and streamlined non-linear function units, our FPGA-based design achieves significant performance gains. Compared to a GPU implementation, the proposed accelerator demonstrates a 14.6× speedup for MHA and a 3.4× speedup for FFN ResBlocks.
What Problem Does This Paper Address?
Transformers have revolutionized NLP, but their massive computational requirements hinder deployment on mobile or embedded devices. Unlike CNNs or RNNs, Transformers rely on massive General Matrix-Matrix Multiplications (GEMMs) and dynamic "attention" mechanisms with complex data dependencies. Furthermore, non-linear functions like Softmax and Layer Normalization (LayerNorm) often become performance bottlenecks on the critical path.
Methods
The proposed accelerator focuses on the MHA and FFN ResBlocks, implemented on a Xilinx FPGA. The design is built around three primary pillars:
1. Matrix Partitioning and Resource Sharing
The authors identified that weight matrices in both MHA and FFN can be partitioned into uniform $s \times 64$ blocks (where $s$ is the sequence length). This uniformity allows a single high-performance Systolic Array (SA)—the heart of the accelerator—to be reused for both layer types, significantly reducing the hardware footprint.
2. Optimized Non-linear Units
- Softmax: To avoid expensive division and exponentiation, a "log-sum-exp" approximation is used. This transforms these operations into simple additions and shifts, reducing hardware complexity without sacrificing numerical stability.
- Layer Normalization: Traditionally, LayerNorm waits for an entire matrix row to be calculated. The authors reformulated the variance equation to allow LayerNorm to start "in advance," overlapping its execution with the systolic array's output to parallelize the process.
3. Hardware-Friendly Data Flow
The computation flow is meticulously designed to ensure high hardware utilization of the systolic array. The architecture supports 8-bit integer (INT8) quantization, which reduces memory and power requirements while maintaining translation quality.
Key Results
The design was implemented on a Xilinx xcvu13p FPGA running at 200MHz and evaluated using the IWSLT 2016 German-English translation task.
- Performance Speedup: The accelerator achieved a 14.6× speedup in MHA ResBlocks and a 3.4× speedup in FFN ResBlocks compared to an NVIDIA V100 GPU.
- Energy Efficiency: Total on-chip power was measured at 16.7W, offering superior energy efficiency compared to high-end server GPUs.
- Accuracy Preservation: The INT8 quantized model achieved a BLEU score of 23.57, slightly exceeding the FP32 baseline of 23.48, proving that the hardware-specific optimizations do not degrade translation quality.
Conclusion
This work establishes a foundation for efficient Transformer hardware accelerators. By addressing the core computational bottlenecks of MHA and FFN through co-designed hardware and algorithms, the proposed architecture enables high-speed, low-power Transformer inference. Future work will focus on integrating embedding layers and the final output stages to create a complete end-to-end Transformer ASIC.
Summary updated