SparseFlow: Accelerating Transformers by Sparsifying Information Flows

Yeachan Kim, SangKeun LeeACL 2024

Introduction

The rapid advancement of Transformer-based models has revolutionized artificial intelligence, yet their deployment remains constrained by significant computational costs. Standard Transformers scale quadratically ($O(n^2)$) with input sequence length, as every token must interact with every other token across all layers. While techniques like token pruning have emerged to mitigate this, they often permanently discard information that might be critical for downstream tasks.

SparseFlow introduces a paradigm shift: rather than deleting tokens, it simplifies the "information flows"—the complex web of pathways token representations traverse through the model. By dynamically gating these interactions, SparseFlow achieves up to a 2.4x speedup while maintaining near-original accuracy.

The SparseFlow Architecture

The core philosophy of SparseFlow is that not every token interaction is essential at every layer. Instead of a dense, all-to-all connectivity, SparseFlow learns a sparse connectivity pattern that preserves token data while reducing computational overhead.

Comparison between Dense Information Flow and the proposed SparseFlow architecture.

The system relies on three primary technical innovations:

  1. Parameterized Information Flows: Learnable "indicator" parameters act as binary gates for each Transformer block. A gate value of '1' allows processing, while '0' enables the token to bypass the computation entirely.
  2. Gumbel-Sigmoid Relaxation: To make these discrete gates trainable via gradient descent, the authors employ the Gumbel-Sigmoid trick, allowing the model to learn optimal sparsity patterns during training.
  3. Mixture of Sparse Flows: Recognizing that different inputs require different processing pathways, SparseFlow utilizes a Router to select from multiple learned sparse patterns (experts) based on the specific input, making the acceleration dynamic and context-aware.

Results and Performance

SparseFlow was rigorously evaluated across Natural Language Understanding (NLU), Generation (NLG), and Vision-Language tasks using models ranging from BERT to the 1.5-billion-parameter GPT2-XL.

Performance comparison of SparseFlow against state-of-the-art methods on SST-2 and QNLI benchmarks.

As shown in the performance plots, SparseFlow consistently outperforms existing state-of-the-art pruning methods like Transkimmer and LoT. Key highlights include:

  • Efficiency: The method achieved a 2.12x speedup on QNLI and 2.41x on MRPC while retaining 99% of the backbone's accuracy.
  • Hardware Realization: Real-world testing on NVIDIA RTX 2080Ti GPUs confirmed significant throughput increases and memory reductions, moving beyond theoretical FLOP savings.

Key Insights

The authors' analysis revealed several fascinating properties of learned information flows:

  • Depth-Wise Redundancy: Pruning becomes more aggressive in deeper layers. This suggests that as token representations converge and become more similar in later stages, many computations become redundant.
  • Modality-Specific Logic: In multimodal tasks, the model learned to prune background image patches more heavily than text tokens, effectively "discovering" that text often carries higher information density for the task at hand.
  • Automatic Center Bias: For vision tasks, the model naturally prioritized central image patches over peripheral ones, mimicking human visual attention patterns.

Conclusion

SparseFlow demonstrates that the "Transformer tax" can be significantly reduced without the destructive nature of token deletion. By treating model connectivity as a learnable, sparse resource, it paves the way for more efficient deployment of large-scale models on resource-constrained hardware. Future work will focus on extending these techniques to auto-regressive decoding and integrating with advanced KV-caching methods.

Summary updated

BibTeX
@inproceedings{kim2024sparseflow,
  author = {Yeachan Kim and SangKeun Lee},
  title = {{SparseFlow: Accelerating Transformers by Sparsifying Information Flows}},
  booktitle = {Annual Meeting of the Association for Computational Linguistics},
  year = {2024},
  doi = {10.18653/v1/2024.acl-long.323},
}
Figure