AdaSplash: Adaptive Sparse Flash Attention

Nuno Gonçalves, Marcos Vinicius Treviso, Andre Martins · DOI

Abstract

Adaptive sparse attention mechanisms like $\alpha$-entmax offer mathematical benefits for long-context modeling by zeroing out irrelevant tokens. However, their practical adoption has been hindered by significant computational overhead compared to optimized dense attention like FlashAttention. We present AdaSplash, a hardware-aware implementation that bridges this gap. By combining a novel hybrid Halley-Bisection optimization algorithm with custom Triton kernels and dynamic block masking, AdaSplash achieves up to 15x speedups over standard implementations and enables training on sequence lengths up to 64k.

Introduction

Standard dense attention (softmax) scales quadratically $O(n^2)$ with sequence length, leading to "dispersion" where probability mass is wasted on irrelevant tokens. While adaptive sparsity via the $\alpha$-entmax family can mitigate this, previous implementations lacked GPU-optimized kernels, often running 10-15x slower than FlashAttention. AdaSplash addresses this by translating mathematical sparsity into actual wall-clock speedups.

Methods: Making Sparsity "Flashy"

AdaSplash relies on three primary technical innovations:

1. Hybrid Halley-Bisection Algorithm

Computing the $\alpha$-entmax threshold ($\tau$) is typically done via bisection, which is robust but requires many iterations. AdaSplash introduces a hybrid method using Halley’s second-order optimization for cubic convergence, falling back to bisection only for stability. This reduces the iterations required for machine precision from approximately 23 down to just 3.

Convergence of the hybrid Halley-bisection algorithm compared to standard bisection.

2. Triton Kernels with Tiling

Following the FlashAttention paradigm, AdaSplash uses custom Triton kernels to perform tiling and recomputation. This keeps computations within fast on-chip SRAM and avoids materializing the full $N \times N$ attention matrix in high-bandwidth memory (HBM).

3. Dynamic Block Masking

The kernel dynamically identifies and skips blocks of the attention matrix that are entirely zero. As sequence length increases and attention becomes naturally sparser, AdaSplash's relative efficiency improves, allowing it to scale effectively.

Key Results

AdaSplash was evaluated across various tasks, including continuous pre-training on FineWeb-edu and long-document classification.

Efficiency and Scalability

AdaSplash is approximately 15x faster and uses 1.75x less memory than standard PyTorch bisection implementations. Crucially, it scales to sequence lengths of 64k, whereas previous methods encounter Out-of-Memory (OOM) errors at 4k.

Runtime comparison across sequence lengths showing AdaSplash scaling to 64k.

Performance Benchmarks

On retrieval tasks (BEIR benchmark), sparse models ($\alpha=1.5$) using AdaSplash consistently outperformed dense counterparts. For GPT-2 training, AdaSplash (1.03s/step) nearly matched the speed of FlashAttention-2 (0.98s/step) while providing the benefits of adaptive sparsity.

Conclusion

AdaSplash demonstrates that sparsity is a powerful scaling lever when implemented with hardware awareness. By optimizing the underlying optimization algorithms and memory access patterns, it makes sparse transformers a viable and efficient alternative for large-scale, long-context language modeling. Future work includes exploring block-sparse patterns and scaling to 100B+ parameter models.

Summary updated

BibTeX
@inproceedings{goncalves2025adasplash,
  author = {Nuno Gonçalves and Marcos Vinicius Treviso and Andre Martins},
  title = {{AdaSplash: Adaptive Sparse Flash Attention}},
  booktitle = {International Conference on Machine Learning},
  year = {2025},
  url = {https://openreview.net/forum?id=OWIPDWhUcO},
}
Figure