Multilayer Dataflow: Orchestrate Butterfly Sparsity to Accelerate Attention Computation

Haibin Wu, Wenming Li, Kai Yan, Zhihua Fan, Peiyang Wu, Yuqun Liu, Yanhuan Liu, Ziqing Qiang, Meng Wu, Kunming Liu, Xiaochun Ye, Dongrui FanarXiv 2024

Abstract

Self-attention mechanisms are central to modern neural networks but impose significant computational and memory burdens. While structured butterfly sparsity can reduce complexity from $O(N^2)$ to $O(N \log N)$, its irregular data access patterns are poorly suited for block-oriented architectures like GPUs. This paper proposes a hardware-software co-design featuring a hybrid butterfly-sparsity network and a scalable multilayer dataflow method. By employing coarse-grained streaming parallelism and specialized memory structures, our design achieves up to $14.34\times$ speedup and $11.14\times$ energy efficiency improvement over NVIDIA Jetson Xavier NX.

Introduction

The quadratic scaling of self-attention is a major hurdle for processing long sequences in models like BERT and Vision Transformers (ViT). Butterfly sparsity offers a structured approximation to mitigate this, but its "strided" memory access leads to low hardware utilization on traditional GPUs. We address this by orchestrating butterfly sparsity on a reconfigurable dataflow architecture, which provides the necessary flexibility and data reusability.

Methodology: Multilayer Dataflow Orchestration

Our approach centers on a hardware-software co-design that maps butterfly computations onto a physical mesh of Processing Elements (PEs).

Transformer network architectures with butterfly pattern simplification.

Key components of the methodology include:

  • Layer-Level DFG Mapping: We decompose butterfly operations into multiple layers within a Dataflow Graph (DFG). This allows data to flow through the PE grid such that half the data remains local while the other half is streamed to neighbors, significantly reducing global memory traffic.
  • Coarse-grained Streaming Parallelism: A block-level scheduler treats instruction groups as "Micro Code Blocks," enabling the overlap of data movement and computation to maximize ALU throughput.
  • Transpose-free SIMD: We designed a multi-line Scratchpad Memory (SPM) capable of both row-wise and column-wise access. This eliminates the need for explicit matrix transpose operations, which are typically a major overhead in multi-stage butterfly computations.
  • Multi-stage Division: To handle sequences up to 8192 tokens with limited on-chip memory, we adapt the Cooley-Tukey FFT algorithm to process vectors in manageable stages.

Evaluation and Results

The design was evaluated using ViT and BERT models, synthesized in a 12nm process, and tested via cycle-accurate simulation.

Performance metrics across various ViT and BERT configurations.

Key Performance Metrics:

  • Speedup: The architecture achieved an average speedup of 9.29× (peaking at 14.34×) compared to the Jetson Xavier NX GPU.
  • Efficiency: It demonstrated a 12.3× energy efficiency improvement over the GPU and outperformed state-of-the-art butterfly accelerators by 3.36×.
  • Utilization: ALU utilization remained high, exceeding 64% for all butterfly kernels and reaching over 90% for large-scale computations.
  • Accuracy: Interestingly, replacing dense layers with butterfly layers often maintained or even slightly improved model accuracy, acting as a form of regularization.

Conclusion

By tailoring a reconfigurable dataflow architecture to the specific needs of butterfly sparsity, we significantly improve the efficiency of attention-based models. Our multilayer dataflow method overcomes the memory bottlenecks of traditional hardware, providing a scalable path for future high-performance Transformer acceleration.

Summary updated

BibTeX
@misc{wu2024multilayer,
  author = {Haibin Wu and Wenming Li and Kai Yan and Zhihua Fan and Peiyang Wu and Yuqun Liu and Yanhuan Liu and Ziqing Qiang and Meng Wu and Kunming Liu and Xiaochun Ye and Dongrui Fan},
  title = {{Multilayer Dataflow: Orchestrate Butterfly Sparsity to Accelerate Attention Computation}},
  year = {2024},
  eprint = {2411.00734},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2411.00734},
}
Figure