[Paper Review] Faster Causal Attention Over Large Sequences Through Sparse Flash Attention
This paper introduces Sparse Causal Flash Attention (SCFA), a GPU kernel extension to FlashAttention that supports dynamic, irregular sparsity patterns in causal self-attention, enabling efficient computation over long sequences. SCFA achieves multi-fold speedups over FlashAttention—up to 3.3× faster training for 16k-token sequences—without sacrificing model perplexity, by efficiently handling hash-based and query/key-dropping sparsity patterns via optimized sparse kernel execution.
Transformer-based language models have found many diverse applications requiring them to process sequences of increasing length. For these applications, the causal self-attention -- which is the only component scaling quadratically w.r.t. the sequence length -- becomes a central concern. While many works have proposed schemes to sparsify the attention patterns and reduce the computational overhead of self-attention, those are often limited by implementations concerns and end up imposing a simple and static structure over the attention matrix. Conversely, implementing more dynamic sparse attentions often results in runtimes significantly slower than computing the full attention using the Flash implementation from Dao et al. (2022). We extend FlashAttention to accommodate a large class of attention sparsity patterns that, in particular, encompass key/query dropping and hashing-based attention. This leads to implementations with no computational complexity overhead and a multi-fold runtime speedup on top of FlashAttention. Even with relatively low degrees of sparsity, our method improves visibly upon FlashAttention as the sequence length increases. Without sacrificing perplexity, we increase the training speed of a transformer language model by $2.0 imes$ and $3.3 imes$ for sequences of respectively $8k$ and $16k$ tokens.
Motivation & Objective
- To address the computational bottleneck of causal self-attention in long-sequence Transformer models.
- To enable efficient, high-performance inference and training for dynamic and irregular attention sparsity patterns, such as those from hashing or query/key dropping.
- To extend FlashAttention’s efficiency to non-triangular causal masks, which are common in modern sparse attention mechanisms.
- To achieve practical speedups over FlashAttention without increasing computational complexity or sacrificing model quality.
- To provide a flexible, open-source GPU kernel that supports a wide class of sparsity patterns with minimal implementation overhead.
Proposed method
- Extends FlashAttention to support any sparsity pattern expressible as a range of keys per query, enabling irregular causal masks.
- Introduces a GPU kernel that computes sparse causal attention with zero computational complexity overhead, leveraging Triton for low-level optimization.
- Applies the kernel to dynamic sparsity via geometric hashing (e.g., Reformer-style LSH), but with exact computation and no approximation.
- Implements fine-grained query and key dropping per head, allowing proportional computation reduction without full-head pruning.
- Uses a block-wise memory access pattern to maintain high memory bandwidth utilization, even with sparse access patterns.
- Employs a custom kernel fusion strategy to minimize kernel launch overhead and maximize occupancy on modern GPUs.

Experimental results
Research questions
- RQ1Can we extend FlashAttention to support non-triangular causal masks, enabling efficient computation over irregular sparsity patterns?
- RQ2Can we achieve practical speedups over FlashAttention for sparse attention mechanisms without incurring additional computational complexity?
- RQ3Does dynamic, fine-grained sparsity (e.g., query/key dropping) lead to measurable training speedups while preserving model performance?
- RQ4How does the performance of hash-based attention via SCFA compare to the original Reformer LSH in terms of both speed and coverage?
- RQ5Can SCFA maintain or improve training efficiency as sequence length increases, especially beyond 8k tokens?
Key findings
- SCFA achieves up to 2.0× and 3.3× faster training for 8k and 16k-token sequences, respectively, without compromising perplexity.
- Hash-sparse attention via SCFA reduces training time by 1.4× and 1.8× compared to FlashAttention baseline for 8192-token sequences with 8 and 16 buckets.
- The method enables consistent speedups during training, with H-LM models accelerating early and maintaining high throughput.
- SCFA’s hash-based attention achieves exact computation with faster runtime than Reformer’s LSH, avoiding its low coverage and approximation issues.
- Query and key dropping via SCFA reduces computation proportionally to the fraction of dropped pairs, enabling fine-grained efficiency control.
- The runtime improvement scales with sequence length and sparsity, with diminishing returns as the number of buckets increases beyond a point.

Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.