Paper Reading AI Learner

AdaSplash: Adaptive Sparse Flash Attention

2025-02-17 17:56:23
Nuno Gon\c{c}alves, Marcos Treviso, Andr\'e F. T. Martins

Abstract

The computational cost of softmax-based attention in transformers limits their applicability to long-context tasks. Adaptive sparsity, of which $\alpha$-entmax attention is an example, offers a flexible data-dependent alternative, but existing implementations are inefficient and do not leverage the sparsity to obtain runtime and memory gains. In this work, we propose AdaSplash, which combines the efficiency of GPU-optimized algorithms with the sparsity benefits of $\alpha$-entmax. We first introduce a hybrid Halley-bisection algorithm, resulting in a 7-fold reduction in the number of iterations needed to compute the $\alpha$-entmax transformation. Then, we implement custom Triton kernels to efficiently handle adaptive sparsity. Experiments with RoBERTa and ModernBERT for text classification and single-vector retrieval, along with GPT-2 for language modeling, show that our method achieves substantial improvements in runtime and memory efficiency compared to existing $\alpha$-entmax implementations. It approaches -- and in some cases surpasses -- the efficiency of highly optimized softmax implementations like FlashAttention-2, enabling long-context training while maintaining strong task performance.

Abstract (translated)

基于softmax的注意力机制在变压器中的计算成本限制了其在长上下文任务中的适用性。自适应稀疏性,例如$\alpha$-entmax注意就是此类方法的一个例子,提供了一种灵活的数据依赖性替代方案,但现有的实现效率低下,并没有利用稀疏性来获得运行时间和内存的节省。在这项工作中,我们提出了AdaSplash,它结合了GPU优化算法的效率与$\alpha$-entmax的稀疏性优势。首先,我们引入了一个混合Halley-二分法算法,使得计算$\alpha$-entmax变换所需的迭代次数减少了7倍。然后,我们通过自定义Triton内核有效地处理适应性稀疏性问题。使用RoBERTa和ModernBERT进行文本分类和单向量检索的实验,以及GPT-2用于语言建模,证明了我们的方法在运行时间和内存效率方面相比现有的$\alpha$-entmax实现取得了显著改进。我们的方法接近于——并在某些情况下超过了——高度优化的softmax实现(如FlashAttention-2)的效率,这使得能够进行长上下文训练的同时保持强大的任务性能。

URL

https://arxiv.org/abs/2502.12082

PDF

https://arxiv.org/pdf/2502.12082.pdf


Tags
3D Action Action_Localization Action_Recognition Activity Adversarial Agent Attention Autonomous Bert Boundary_Detection Caption Chat Classification CNN Compressive_Sensing Contour Contrastive_Learning Deep_Learning Denoising Detection Dialog Diffusion Drone Dynamic_Memory_Network Edge_Detection Embedding Embodied Emotion Enhancement Face Face_Detection Face_Recognition Facial_Landmark Few-Shot Gait_Recognition GAN Gaze_Estimation Gesture Gradient_Descent Handwriting Human_Parsing Image_Caption Image_Classification Image_Compression Image_Enhancement Image_Generation Image_Matting Image_Retrieval Inference Inpainting Intelligent_Chip Knowledge Knowledge_Graph Language_Model LLM Matching Medical Memory_Networks Multi_Modal Multi_Task NAS NMT Object_Detection Object_Tracking OCR Ontology Optical_Character Optical_Flow Optimization Person_Re-identification Point_Cloud Portrait_Generation Pose Pose_Estimation Prediction QA Quantitative Quantitative_Finance Quantization Re-identification Recognition Recommendation Reconstruction Regularization Reinforcement_Learning Relation Relation_Extraction Represenation Represenation_Learning Restoration Review RNN Robot Salient Scene_Classification Scene_Generation Scene_Parsing Scene_Text Segmentation Self-Supervised Semantic_Instance_Segmentation Semantic_Segmentation Semi_Global Semi_Supervised Sence_graph Sentiment Sentiment_Classification Sketch SLAM Sparse Speech Speech_Recognition Style_Transfer Summarization Super_Resolution Surveillance Survey Text_Classification Text_Generation Time_Series Tracking Transfer_Learning Transformer Unsupervised Video_Caption Video_Classification Video_Indexing Video_Prediction Video_Retrieval Visual_Relation VQA Weakly_Supervised Zero-Shot