# Block Sparse Flash Attention

*Daniel Ohayon, Itay Lamprecht, Itay Hubara, Israel Cohen, Daniel Soudry, Noam Elata*

[NeurIPS page](https://neurips.cc/virtual/2026/poster/155122) · [OpenReview](https://openreview.net/forum?id=8GItn9bqi9) · [alphaXiv](https://www.alphaxiv.org/abs/2512.07011) · [Open on the map](../papers.html#p155122)

Category: [Efficient LLM Inference & Training](../pcat/14.md) › [Sparse Long-Context Attention](../pgroup/226.md) · Type: new method · Keywords: sparse attention, long-context inference, FlashAttention, CUDA kernel, computational efficiency

Areas: [Memory](../areas/memory.md) › Model Memory Optimization › Efficient Attention for LLMs; [Long Context](../areas/longcontext.md) › Long-context mechanisms › Attention optimizations

## Summary
Block Sparse Flash Attention (BSFA) accelerates long-context inference by skipping about half of attention computations while preserving model quality.

## Explained to a 5-year-old
Computers that read many words need to compare each word with every other word. This takes a lot of time because there are many comparisons. We found a way to look at the comparisons and notice which ones are not important. By ignoring those unimportant comparisons, the computer can finish faster. The new idea does not change the way the computer works, it just adds a new step.

## Explained to a 5-year-old, longer
Computers that read many words need to compare each word with every other word. This takes a lot of time because there are many comparisons. We found a way to look at the comparisons and notice which ones are not important. By ignoring those unimportant comparisons, the computer can finish faster. The new idea does not change the way the computer works, it just adds a new step. It works like a shortcut that tells the computer which parts to skip. This shortcut is set up once on a small set of data. The computer still gives the same answers as before, just quicker. It helps when you need to read a long story or many documents. The improvement is noticeable on powerful computers like the A6000 and H100. The method has been tested on different models, such as Llama-3.1-8B and Qwen2.5-7B. Overall, it makes reading long texts faster without losing accuracy.

## For a technical reader
The kernel computes exact query-key dot products, groups values into blocks, and selects the top-k blocks per query based on calibrated thresholds, allowing entire blocks to be skipped. This is done without any training, using a one-time calibration on a small dataset to learn score distributions per layer and head. The implementation is a drop-in replacement for FlashAttention, providing up to 1.38× speedup on the attention kernel and end-to-end speedups of 1.13×-1.24× on standard long-context benchmarks while preserving accuracy.

## Problem
Large language models need long contexts, but standard attention scales quadratically, creating a severe computational bottleneck for inference. This quadratic cost limits practical deployment on limited hardware.

## Method
The approach computes exact query-key similarities, selects the top-k value blocks per query, and uses calibrated thresholds to prune entire blocks, skipping roughly half of the computation and memory transfers. It requires only a one-time threshold calibration on a small dataset to learn per-layer and per-head attention score distributions. A CUDA kernel implements this as a drop-in replacement for FlashAttention.

## Results
On Llama-3.1-8B, the approach achieves up to 1.13× end-to-end speedup on LongBench with only a 1.1% accuracy drop, and up to 1.24× on Needle-in-a-Haystack at a 1% drop. The attention kernel itself accelerates by up to 1.38×.

## Contributions
A training-free, drop-in attention kernel that prunes entire value blocks based on calibrated thresholds, achieving ~50% compute savings while preserving model quality. It includes a one-time calibration step and an open-source CUDA implementation.

## Practical relevance
Provides a practical, drop-in replacement that enables faster long-context inference on existing hardware, reducing computational cost for large language model deployments.

## Research questions this paper is counted under

- [How can we reduce the quadratic attention cost and memory usage of large language models for long contexts while preserving performance?](../q/4.md)

This page was written by language models from the title and abstract of each paper, and the answers were checked by two other models. It can be wrong: check the paper itself. [Suggest a correction](../feedback/?on=p/155122)
