WorksComputer Science
DTS: Delta-Based Tile Scoring for Efficient Long-Context Sparse Attention
Abstract
Large language models (LLMs) increasingly need to process long documents and codebases, making long-context attention a major prefill bottleneck. Block sparse attention reduces computation by skipping unimportant blocks of the attention matrix, but scoring blocks accurately can itself be expensive. We propose Delta-Based Tile Scoring (DTS), a training-free, content-adaptive tile scoring method for sparse block attention. DTS selects query and key anchors according to local vector changes, using fewer representatives in redundant regions while retaining more detail in heterogeneous regions. To accelerate anchor selection, parallel delta packing partitions the query and key sequences into tile-aligned chunks and performs bounded local scans over these chunks concurrently. The selected tiles are then computed using the original query, key, and value vectors. On LLaMA-3.1-8B-Instruct, DTS keeps average RULER and LongBench scores within 0.10 percentage points of full attention, with RULER evaluated up to 128K tokens. At 128K tokens, DTS reduces measured scoring-pipeline latency by 38% compared with XAttention. On four NVIDIA H100 GPUs, it achieves a 3.3 prefill speedup over a PyTorch full-attention baseline using FlashAttention-2 at 512K tokens.
Introduction
Large language models (LLMs) increasingly process long documents, retrieved passages, and codebases [1, 2, 3, 4, 5, 6, 7]. These workloads can produce long input prompts, increasing the time required before a model generates its first response token. During the prefill stage, the model processes the input prompt and computes attention across its tokens. The number of query–key interactions grows quadratically with the input length, making attention a major source of prefill latency.
Efficient dense attention kernels address part of this problem. FlashAttention [9, 10, 11] reduces frequent memory traffic and avoids storing the full attention matrix, but still computes all query–key interactions. Its arithmetic cost therefore remains quadratic. In fact, attention matrices are sparse: most tokens attend strongly to only a small fraction of others. Sparse attention seeks further savings by skipping key–query interactions that contribute little to the attention output. Early approaches [12, 13, 14] observed that trained Transformer attention matrices concentrate on local windows and a few distant positions. They proposed using fixed sparse patterns (local windows combined with strided or fixed summary positions) to approximate full attention with fewer operations.
Corresponding author: Qinyu Chen ([email protected])
The authors acknowledge the Dutch Research Council (NWO) Veni Talent Program (21828) and the LIACS strategic PhD program for funding this work.
The limitation is that a fixed pattern cannot adapt to the content of a given input. This motivated a shift to dynamic sparse attention, where the sparsity pattern is determined on the current input. For efficient execution on GPUs, block-sparse methods group interactions into blocks, or tiles, and compute the selected blocks using dense operations.
Recent dynamic sparse attention methods exploit recurring attention patterns to guide sparse computation. Minference [15] observes that LLM attention heads follow consistent structural patterns (A-shape, Vertical-Slash, and Block-Sparse) across inputs. It assigns each head its dominant pattern offline and builds sparse indices accordingly at inference time. FlexPrefill [16] selects a head’s attention pattern online. It compares a pooled estimate with a reference attention distribution for a subset of queries using Jensen–Shannon distance. When the estimate is sufficiently close, it uses query-aware block selection; otherwise, it uses a Vertical-Slash pattern. For block importance estimation, Minference’s block-sparse path and FlexPrefill’s query-aware path both reduce each query or key block to a single average vector. Such pooling is cheap, but it collapses within-block variation into one vector and can obscure the contribution of a few important token interactions.
SpargeAttn [17] mitigates the risk by combining such pooled representatives with a check of similarity within each query and key block. Tiles involving a query or key block that fail the similarity check are retained at this stage. This protects potentially important interactions, but reduces the number of tiles that the initial predictor can discard. XAttention [8] (Figure 1(a)) takes a different approach: it estimates block importance by summing query–key scores sampled along strided antidiagonals within each block. It selects high-scoring blocks until their cumulative normalized score reaches a specified threshold, then computes attention only on the selected blocks. However, at a given stride, its sampling density does not adapt to local differences. Regions containing many similar vectors still incur the predefined sampling cost. Increasing the stride reduces this cost but can miss important attention patterns. These trade-offs motivate a scoring representation that uses fewer vectors in redundant regions while retaining more detail where the vectors change.
Figure 1. Comparison of XAttention [8] and DTS. (a) XAttention samples strided diagonals at a fixed density. (b) DTS selects query and key anchors based on local vector changes, reducing redundant scoring in similar regions.
To address these limitations, we propose Delta-based Tile Scoring (DTS) to reduce block importance estimation cost while maintaining inference accuracy. As shown in Figure 1(b), building on the local similarity of query [18], [19] and key vectors, DTS selects representative vectors, called anchors. Within each chunk, it starts with the first vector and selects a new anchor when the current vector differs sufficiently from the last selected anchor. Similar regions therefore use fewer scoring vectors, while blocks with greater variation can use multiple anchors.
Our contributions are summarized as follows:
We propose a delta-based tile scoring method that leverages the similarity to select query and key representatives based on local vector changes. It uses fewer representatives in regions with similar vectors to reduce redundant scoring computations while maintaining accuracy.
We design parallel delta packing with independent scans over tile-aligned chunks, limiting sequential dependencies while preserving the token positions needed to score the original tiles.
We evaluate DTS on RULER and LongBench. On LLaMA-3.1-8B-Instruct, DTS with cosine threshold 0.72 keeps text benchmark averages within 0.10 points of full attention and reduces measured scoring time by 38% relative to XAttention (stride 16) at 128K tokens.
Observations
We examine whether neighboring tokens produce similar query and key vectors. We evaluate LLaMA-3.1-8B-Instruct and Qwen2.5-7B-Instruct-1M on 50 distinct PG-19 books [20] and 50 non-overlapping WikiText-103 source windows at 4K, 32K, and 128K tokens. Each shorter input is a prefix of its 128K counterpart. We collect query and key vectors after rotary positional encoding (RoPE) from full-attention forward passes and compute cosine similarity between adjacent vectors. Results average all layers and heads, with equal weight given to each input; duplicated key heads are counted once.
To test whether similarity is associated with local adjacency, we randomly permute the positions of the collected vectors and repeat the measurement. Natural order compares neighboring positions in the original sequence, whereas shuffled order compares neighboring entries after permutation. Both use the same computed vectors, so the control changes their adjacency without changing the vectors themselves.
As shown in Figure 2, natural-order mean cosine similarity ranges from 0.878 to 0.900 for queries and from 0.835 to 0.864 for keys across the two models and three context lengths. Both consistently exceed their shuffled-order counterparts; the same pattern holds when the two corpora are analyzed separately. These results show that local similarity is present in both queries and keys across the evaluated settings. They suggest an opportunity to estimate tile importance using fewer vectors from locally similar regions, reducing repeated scoring work.

Figure 2. Mean cosine similarity of neighboring query () and key () vectors in natural and shuffled order across context lengths. Results average all layers and heads over 50 PG-19 books and 50 WikiText-103 windows per model.
Methodology
This section demonstrates three stages of DTS: 1) parallel delta packing, 2) delta-based tile scoring, and 3) tile selection and sparse attention (Figure 3 and Algorithm 2). Per-head tile-selection thresholds are calibrated offline.
Figure 3. DTS workflow. Parallel delta packing selects query and key anchors. Their causal scores are summed by original tile indices to guide tile selection. Sparse attention uses the original , , .
Parallel Delta Packing
For one attention head, let , where is the sequence length and is the head dimension. Stage 1 applies delta packing independently to and . For either matrix , we divide the sequence into chunks of tokens, matching the boundaries of the attention tiles. Each chunk starts with its first vector as an anchor and is processed independently.
Within each chunk, we compare each vector with the most recently selected anchor . A new anchor is selected when
Algorithm 1 Parallel Delta Packing
Input: $X \in \mathbb{R}^{N \times D}$, threshold $\tau$, chunk size $B$
Output: Packed vectors $\hat{X}$ and original token indices $t$
1: procedure DELTAPACK$(X,\tau,B)$
2: $\Delta \leftarrow 0 \in \{0,1\}^{N}$ ▷ Anchor flags
3: for $c = 0,\ldots,\lceil N/B\rceil-1$ in parallel do
4: $s \leftarrow cB$; $e \leftarrow \min(s+B,N)$
5: $a \leftarrow s$; $\Delta[s] \leftarrow 1$ ▷ First anchor
6: for $i=s+1,\ldots,e-1$ do
7: if $\cos(X[i],X[a]) < \tau$ then
8: $\Delta[i] \leftarrow 1$; $a \leftarrow i$ ▷ New anchor
9: end if
10: end for
11: end for
12: $p \leftarrow \operatorname{cumsum}(\Delta)-1$ ▷ Packed positions
13: $n \leftarrow \sum_i \Delta[i]$ ▷ Anchor count
14: Allocate $\hat{X} \in \mathbb{R}^{n \times D}$ and $t \in \mathbb{N}^{n}$
15: for each $i$ with $\Delta[i]=1$ in parallel do
16: $\hat{X}[p[i]] \leftarrow X[i]$
17: $t[p[i]] \leftarrow i$ ▷ Original position
18: end for
19: return $\hat{X},t$
20: end procedure
where is the packing threshold. Otherwise, is dropped from scoring and the anchor stays unchanged. This uses fewer scoring vectors in locally similar regions and adds anchors when vectors change. Selected anchors are original vectors, without averaging. This cosine rule is used in text experiments.
Anchor updates are sequential within a chunk, while different chunks are scanned in parallel. Each scan processes at most vectors, while the total comparison work across all chunks remains . After anchor selection, the binary mask marks selected vectors with . A prefix sum counts the selected vectors up to each position and assigns each selected vector a packed position . We then copy the selected vectors into at these positions in parallel and record their original token indices in . Algorithm 1 gives the cosine variant, applied separately to and to obtain and .
Delta-Based Tile Scoring and Selection
DTS scores interactions between the query anchors and key anchors (Stage 2). We compute scaled dot products from , exponentiate them, and apply a causal mask to obtain anchor-pair scores:
Here and index rows of and .
Let be the number of blocks along each axis. The packed anchor indices belonging to query block and key block are
We sum their pair scores to obtain the tile importance matrix :
Algorithm 2 DTS for Sparse Block Attention
Input: $Q,K,V \in \mathbb{R}^{N \times D}$, tile size $B$, packing threshold $\tau$, selection threshold $\theta_h \in (0,1]$
Output: Attention output $O$
1: $T \leftarrow \lceil N/B\rceil$
Stage 1: Parallel Delta Packing
2: $(\hat{Q},t^{Q}) \leftarrow \operatorname{DELTAPACK}(Q,\tau,B)$
3: $(\hat{K},t^{K}) \leftarrow \operatorname{DELTAPACK}(K,\tau,B)$
Stage 2: Tile Scoring
4: $S \leftarrow 0 \in \mathbb{R}^{T\times T}$
5: for each $(a,b)$, $0 \le b \le a < T$, in parallel do
6: $\mathcal{U}_{a} \leftarrow \{u:t^{Q}_{u}/B=a\}$
7: $\mathcal{V}_{b} \leftarrow \{v:t^{K}_{v}/B=b\}$
8: $S_{ab} \leftarrow \operatorname{ReduceSum}_{u\in\mathcal{U}_{a},v\in\mathcal{V}_{b}}\exp\left(\hat{q}_{u}^{\mathsf{T}}\hat{k}_{v}/\sqrt{D}\right)$
9: end for
Stage 3: Tile Selection and Sparse Attention
10: $M \leftarrow 0 \in \{0,1\}^{T\times T}$
11: for $a=0,\ldots,T-1$ in parallel do
12: $w_{ab} \leftarrow S_{ab}/\sum_{j=0}^{a}S_{aj}$ for $b=0,\ldots,a$
13: $\pi \leftarrow$ indices $0,\ldots,a$ sorted by decreasing $w_{ab}$
14: $m \leftarrow 0$
15: for $b$ in $\pi$ do
16: if $m \ge \theta_h$ then
17: break
18: end if
19: $M_{ab} \leftarrow 1$; $m \leftarrow m+w_{ab}$
20: end for
21: $M_{a0} \leftarrow 1$; $M_{aa} \leftarrow 1$ ▷ Required tiles
22: end for
23: $O \leftarrow \operatorname{CAUSALBLOCKSPARSEATTENTION}(Q,K,V,M)$
24: return $O$
Thus, only selected anchor pairs contribute to tile scoring. We use an unnormalized sum so that the tile score reflects both anchor-pair affinity and local variation within the query and key blocks. Blocks with greater variation produce more anchors and therefore receive higher selection priority. Stage 3 normalizes each causal tile row into estimated tile weights,
We sort these weights in descending order and select the shortest prefix whose cumulative weight reaches . Here identifies a head within a layer. We then add the first and diagonal tiles to form the binary mask . Sparse attention uses and the original , with token-level causal masking inside selected tiles. Algorithm 2 combines all three stages.
Per-Head Calibration
Because only approximates the true tile-level attention distribution, selecting tiles whose cumulative estimated weight reaches 0.9 does not necessarily retain 90% of the full-attention mass. We therefore calibrate cutoff offline for each layer and head using a target attention coverage .
For calibration, we compute full-attention probabilities from the original using a causal softmax for each query. For each tile , we sum these probabilities over keys in block and average over queries in block . The resulting reference tile weights sum to one for each query block. Summing these weights over the selected key blocks gives the attention coverage for query block .
For each query block, we sort tiles by their reference weights and select the shortest prefix whose cumulative weight reaches , forming a reference set. We then follow the DTS ordering in Algorithm 2 and find the shortest prefix containing every tile in the reference set. The cumulative estimated weight of this prefix is the candidate cutoff for that query block. For each layer and head, we average the candidate cutoffs over query blocks within each document, then take the 90th percentile of these document averages as . We reuse XAttention’s calibration set [8]: 156 documents, with 12 from each of 13 RULER task types and contexts up to 80K tokens. For fixed , , and , the model-specific threshold table is computed once and reused for RULER and LongBench. Experiments use . The calibrated thresholds target the desired coverage empirically, without guaranteeing it for every query block.
Experimental Setup
Models and Baselines
We evaluate text workloads with LLaMA-3.1-8B-Instruct [1] and Qwen2.5-7B-Instruct-1M [2]. We compare DTS with full attention, MInference [15], FlexPrefill [16], and XAttention [8], using the baselines’ public implementations. The full-attention baseline uses PyTorch’s scaled dot-product attention [21, 22] with the FlashAttention-2 backend [10]. SpargeAttn is excluded because the implementation couples sparsity with quantization.
DTS uses the cosine packing rule with on LLaMA and on Qwen. Per-head thresholds are calibrated with target coverage . XAttention uses strides and a coverage target of 0.90; FlexPrefill uses . These parameters specify each method’s operating point and do not imply identical achieved coverage.
Benchmarks and Metrics
RULER [23] evaluates retrieval and reasoning over long contexts. We use 13 tasks with 100 samples per task at each of six context lengths: 4K, 8K, 16K, 32K, 64K, and 128K. We report task-averaged accuracy at each length and the average across lengths.
LongBench [24] covers question answering, summarization, few-shot learning, synthetic tasks, and code completion. Following XAttention [8], our main evaluation uses 16 tasks with 100 samples per task. We report each task’s benchmark score and their unweighted average. The packing-threshold sweep uses reduced sets: nine RULER tasks with 30 samples per task, and nine LongBench tasks.
Implementation and Latency Measurement
Experiments use batch size 1. DTS uses for both packing chunks and attention tiles. The latency experiment distributes model layers across four NVIDIA H100 GPUs. Following the context-length latency evaluation in MInference [15], we benchmark prefill independently of downstream task evaluation using sampled WikiText-103 input at lengths from 4K to 512K. We also measure prefill latency on 10 inputs from each of the 13 RULER tasks at 128K, giving 130 latency measurements per model for the accuracy–latency comparison. We measure wall-clock time for the Transformer backbone forward pass, excluding the language-model output head and decoding, with the key–value cache disabled and all GPUs synchronized before and after each run. We perform 2 warm-up runs and 10 measured runs and report mean latency.
Density is the fraction of causal tiles selected for attention. Estimated scoring ratio multiplies the query and key anchor fractions, each averaged over heads, and then averages over layers. It estimates scoring work rather than elapsed time. Score (ms) sums the profiled packing, scoring, and selection stages; Attn (ms) measures the selected-tile attention kernel.
Results
Accuracy on Long-Context Tasks
| Method | 4K | 8K | 16K | 32K | 64K | 128K | Avg |
| LLaMA-3.1 8B Instruct | |||||||
| Full attention | 96.16 | 93.77 | 93.43 | 90.47 | 86.14 | 74.46 | 89.07 |
| MInference | 96.04 | 93.95 | 92.60 | 88.43 | 84.66 | 63.73 | 86.57 |
| FlexPrefill | 95.37 | 92.29 | 91.23 | 88.02 | 83.56 | 74.23 | 87.45 |
| XAttn | 96.17 | 93.97 | 93.43 | <u>90.56</u> | 83.04 | 70.96 | 88.02 |
| XAttn | 95.57 | 93.92 | 92.71 | 90.60 | 81.83 | 71.57 | 87.70 |
| DTS cos 0.72 (ours) | 95.83 | 94.22 | 93.36 | 90.42 | 83.19 | <u>74.82</u> | 88.97 |
| DTS cos 0.78 (ours) | 96.14 | 93.70 | 93.44 | 90.35 | 84.93 | 75.55 | <u>89.02</u> |
| Qwen2.5-7B-Instruct-1M | |||||||
| Full attention | <u>94.10</u> | <u>93.67</u> | 93.54 | 91.17 | <u>88.07</u> | 81.41 | <u>90.33</u> |
| MInference | 94.16 | 94.00 | 94.03 | 90.99 | 87.68 | 81.23 | 90.35 |
| FlexPrefill | 94.01 | 91.67 | 91.25 | 86.37 | 83.50 | 79.07 | 87.65 |
| XAttn | 94.02 | 93.55 | <u>93.66</u> | 90.85 | 88.21 | 81.22 | 90.25 |
| XAttn | 94.06 | 93.53 | 93.60 | <u>91.02</u> | 87.86 | 81.23 | 90.23 |
| DTS cos 0.75 (ours) | 93.87 | 93.25 | 93.24 | 90.02 | 86.09 | 79.90 | 89.39 |
| DTS cos 0.78 (ours) | 93.98 | 93.49 | 93.33 | 89.47 | 86.95 | <u>81.28</u> | 89.75 |
Table 1. RULER accuracy (%) comparing delta-based tile scoring against baseline and block-sparse methods on LLaMA-3.1 8B Instruct and Qwen2.5-7B-Instruct-1M. Best and second-best scores are shown in bold and <u>underlined</u>.
a) RULER: On LLaMA, DTS at achieves an average score of 89.02, within 0.05 points of full attention (89.07) and 1.00–2.45 points above all baseline sparse methods (Table I). At 128K, DTS attains the highest score of 75.55, exceeding full attention by 1.09 points and XAttention by 3.98–4.59 points. On Qwen, DTS at averages 89.75, remaining within 0.60 points of full attention and the strongest sparse baselines. At 128K, it achieves 81.28, only 0.13 points below full attention and the highest score among the sparse methods, slightly exceeding MInference (81.23) and XAttention (81.22–81.23).
b) LongBench: On LLaMA, DTS at achieves an average score of 47.51, within 0.02 points of full attention and 1.01–1.04 points above XAttention (Table II). It achieves the best scores on both code tasks, LCC and RepoBench-P, and matches full attention on PassageRetrieval-en; the setting additionally leads on Qasper, MultifieldQA-en, and GovReport. On Qwen, DTS at obtains the highest average score of 46.84, exceeding full attention by 0.08 points, MInference by 0.12 points, and XAttention by 0.18–0.38 points, while remains competitive at 46.82. Across the two operating points, DTS achieves the best score on eight of the 16 tasks and ties for the best on PassageRetrieval-en, demonstrating strong performance across question answering, retrieval, and code tasks.
| Method | NQA | Qas | MFQ | HotP | 2Wiki | Mus | GovR | QMS | MNews | TREC | TQA | SAM | PCnt | PassR | LCC | RepoB | Avg |
| LLaMA-3.1 8B Instruct | |||||||||||||||||
| Full attention | 31.91 | 43.06 | 56.25 | 54.87 | 47.97 | 34.88 | 34.47 | 25.27 | 27.15 | 67.00 | 89.47 | 44.56 | 7.58 | 99.00 | 51.94 | 45.12 | 47.53 |
| MInference | 31.74 | 42.25 | 56.50 | 54.70 | 50.17 | 31.80 | 34.51 | 25.27 | 27.13 | 67.00 | 89.69 | 44.09 | 5.00 | 94.00 | 52.14 | 47.32 | 47.08 |
| FlexPrefill | 26.02 | 39.00 | 55.19 | 55.11 | 38.53 | 28.73 | 33.44 | 25.53 | 26.93 | 67.00 | 89.29 | 44.58 | 2.00 | 83.00 | 54.02 | 48.07 | 44.78 |
| XAttn | 31.01 | 37.56 | 56.65 | 53.35 | 48.37 | 32.71 | 34.83 | 24.37 | 26.46 | 67.00 | 89.80 | 45.42 | 5.33 | 92.00 | 53.94 | 44.74 | 46.47 |
| XAttn | 29.84 | 41.08 | 54.43 | 53.23 | 47.59 | 31.01 | 34.49 | 26.37 | 26.46 | 67.00 | 89.77 | 44.53 | 4.00 | 93.00 | 52.67 | 48.61 | 46.50 |
| DTS cos 0.72 (ours) | 31.62 | 42.86 | 57.04 | 53.29 | 47.88 | 32.87 | 34.67 | 25.66 | 26.97 | 64.00 | 89.30 | 44.74 | 6.50 | 99.00 | 54.32 | 49.48 | 47.51 |
| DTS cos 0.78 (ours) | 31.81 | 43.60 | 57.19 | 54.51 | 45.27 | 32.72 | 35.26 | 25.35 | 26.67 | 66.00 | 89.30 | 43.83 | 6.83 | 99.00 | 50.62 | 49.26 | 47.33 |
| Qwen2.5-7B-Instruct-1M | |||||||||||||||||
| Full attention | 29.26 | 45.12 | 51.49 | 58.34 | 55.45 | 32.70 | 35.22 | 23.99 | 25.69 | 71.00 | 83.31 | 45.24 | 10.00 | 100.00 | 48.40 | 32.92 | 46.76 |
| MInference | 29.38 | 45.36 | 51.85 | 56.77 | 54.65 | 33.47 | 35.20 | 24.18 | 25.98 | 71.00 | 83.31 | 46.32 | 10.00 | 99.00 | 47.63 | 33.44 | 46.72 |
| FlexPrefill | 24.68 | 39.46 | 50.63 | 48.72 | 50.58 | 21.06 | 33.61 | 24.67 | 25.42 | 70.00 | 78.64 | 46.11 | 2.00 | 59.00 | 45.18 | 33.61 | 40.84 |
| XAttn | 29.84 | 44.74 | 51.41 | 57.63 | 55.62 | 32.60 | 34.84 | 24.00 | 26.09 | 70.00 | 83.18 | 46.00 | 12.00 | 100.00 | 46.70 | 31.97 | 46.66 |
| XAttn | 30.26 | 45.77 | 52.31 | 58.16 | 53.78 | 31.62 | 35.18 | 24.09 | 26.00 | 71.00 | 83.51 | 45.83 | 9.00 | 100.00 | 45.14 | 31.70 | 46.46 |
| DTS cos 0.75 (ours) | 30.98 | 45.18 | 53.00 | 58.91 | 51.57 | 31.73 | 35.58 | 24.57 | 25.95 | 72.00 | 84.55 | 46.29 | 4.00 | 100.00 | 48.78 | 36.42 | 46.84 |
| DTS cos 0.78 (ours) | 29.10 | 44.66 | 53.08 | 56.61 | 54.63 | 33.21 | 35.47 | 24.12 | 25.64 | 74.00 | 84.19 | 46.13 | 6.00 | 100.00 | 48.49 | 33.71 | 46.82 |
Table II. LongBench scores on LLaMA-3.1 8B Instruct and Qwen2.5-7B-Instruct-1M. NQA = NarrativeQA, Qas = Qasper, MFQ = MultifieldQA-en, HotP = HotpotQA, 2Wiki = 2WikiMultiHopQA, Mus = MuSiQue, GovR = GovReport, QMS = QMSum, MNews = MultiNews, TREC = TREC, TQA = TriviaQA, SAM = SAMSum, PCnt = PassageCount, PassR = PassageRetrieval-en, LCC = LCC, and RepoB = RepoBench-P. Best and second-best scores are shown in bold and _underlined_.
Prefill Latency and Scoring Cost
Figure 4a and (b) show how prefill speedup changes with sequence length. DTS becomes beneficial as the context grows and reaches on LLaMA and on Qwen at 512K. At 128K, DTS achieves and , respectively, compared with for XAttention on LLaMA and on Qwen for . MInference and FlexPrefill can be faster at the longest lengths, so speed alone does not capture the quality trade-off.
Figure 4. Prefill efficiency and accuracy. (a)–(b) Prefill speedup relative to full attention across context lengths, measured using WikiText-103. (c)–(d) RULER accuracy versus prefill latency at 128K, measured on RULER, for LLaMA and Qwen, 100% corresponds to 17.33 s and 13.82 s, respectively.
Figure 4c and (d) therefore combine the 128K RULER scores with latency measured on RULER inputs. Latency is shown as
| Context | XAttn Density (%) | DTS Density (%) | XAttn Est. score (%) | DTS Est. score (%) | XAttn Scoring pipeline (ms) | DTS Scoring pipeline (ms) |
| 4K | 66.1 | 55.5 | 6.25 | 4.41 | 19 | 45 |
| 16K | 36.4 | 31.3 | 6.25 | 3.05 | 37 | 92 |
| 32K | 27.6 | 24.9 | 6.25 | 2.77 | 141 | 206 |
| 64K | 20.5 | 19.9 | 6.25 | 2.61 | 542 | 541 |
| 128K | 17.1 | 17.6 | 6.25 | 2.26 | 2,571 | 1,592 |
| 256K | 15.4 | 17.0 | 6.25 | 1.65 | 8,018 | 4,786 |
| 512K | 11.4 | 15.2 | 6.25 | 0.84 | 28,270 | 14,407 |
Table III. Scoring-pipeline cost comparison between XAttention () and DTS () on LLaMA-3.1-8B-Instruct. The scoring pipeline includes all stages required to construct the sparse tile mask and excludes block-sparse attention. Times are summed over all 32 layers.
a percentage of full attention to make the reduction comparable across models. On LLaMA, DTS attains the highest score, 75.55, while using 60.8% of full-attention latency. It is both faster and 4.59 points more accurate than XAttention with ; XAttention with and FlexPrefill are faster, but score 3.98 and 1.32 points lower, respectively. On Qwen, DTS reaches 81.28 at 72.2% of full-attention latency. At the evaluated operating points, it is faster than MInference and both XAttention settings while giving a slightly higher score. FlexPrefill reduces latency further but lowers the score to 79.07. These results place DTS on the measured Pareto frontier and show its advantage in the near-full-accuracy regime.
Table III compares the recorded scoring time of DTS and XAttention from 4K to 512K tokens. The measured scoring-pipeline time includes packing, scoring, and selection. We use on LLaMA because it yields a tile density closely matched to XAttention with , enabling a controlled scoring-cost comparison. DTS has a lower estimated scoring ratio at every length, but is slower through 32K and has nearly the same recorded scoring time at 64K. At 128K, the recorded time decreases from 2,571 to 1,592 ms, a 38.1% reduction, at similar tile densities (17.6% for DTS and 17.1% for XAttention). The reductions reach 40.3% at 256K and 49.0% at 512K. These longer settings evaluate latency scaling, and their tile densities differ more substantially: at 512K, DTS selects 15.2% of tiles, compared with 11.4% for XAttention.
| Context | Packing only Seq. (ms) | Packing only Par. (ms) | Packing only Speedup | DTS attention pipeline Seq. (ms) | DTS attention pipeline Par. (ms) | DTS attention pipeline Speedup |
| 8K | 451.7 | 24.4 | 18.53× | 540.5 | 110.4 | 4.90× |
| 32K | 1,782.4 | 76.4 | 23.34× | 2,205.5 | 482.1 | 4.57× |
| 64K | 3,555.5 | 144.2 | 24.65× | 4,700.3 | 1,271.1 | 3.70× |
| 128K | 7,128.5 | 295.8 | 24.10× | 10,931.6 | 4,094.0 | 2.67× |
Table 5. Effect of parallel delta packing on LLaMA-3.1-8B-Instruct at . Packing only measures delta packing, whereas the DTS attention pipeline includes delta packing, tile scoring, tile selection, and block-sparse attention. The sequential and parallel implementations differ only in the chunk-scan schedule. All times cover the 32 attention layers. Timings are profiled independently of Table IV.
Ablation Studies
Effect of Packing Threshold
We vary the cosine packing threshold with calibration target . Table 4 combines 128K latency measurements with task scores on the reduced evaluation sets described in § 4-B. Increasing selects more anchors for scoring. From to , the estimated scoring ratio increases from 1.6% to 8.7%, and measured scoring time rises from 1,447 to 2,885 ms. Meanwhile, selected tile density decreases from 19.0% to 13.3%, reducing sparse-attention time from 3,094 to 2,140 ms. These opposing costs limit the change in prefill speedup, which ranges from 1.97× to 2.10×. RULER scores stay within 0.28 points of full attention throughout this sweep. Among the tested settings, gives both the highest speedup (2.10×) and LongBench score (39.21), while gives the highest RULER score (91.80) at 2.04×. These two settings illustrate the balance between scoring cost and task performance.
| Speedup | Density | Est. score ratio (%) | Phase time (ms) Scoring | Phase time (ms) Attention | RULER | LongBench | |
| Full | 1.00× | 100% | – | – | – | 91.52 | 39.54 |
| 0.70 | 2.08× | 19.0% | 1.6% | 1,447 | 3,094 | 91.69 | 38.95 |
| 0.72 | 2.10× | 17.6% | 2.3% | 1,592 | 2,853 | 91.51 | 39.21 |
| 0.75 | 2.09× | 15.7% | 3.8% | 1,954 | 2,545 | 91.42 | 39.08 |
| 0.78 | 2.04× | 14.2% | 6.3% | 2,445 | 2,284 | 91.80 | 39.15 |
| 0.80 | 1.97× | 13.3% | 8.7% | 2,885 | 2,140 | 91.58 | 38.61 |
Table 4. Cosine-threshold sweep on LLaMA-3.1-8B-Instruct. Latency results are measured at 128K.
Effect of Parallel Packing
We compare two Triton implementations that scan chunks sequentially or in parallel. As shown in Table V, parallel chunk scans accelerate delta packing by 18.53–24.65×. The benefit remains substantial when tile scoring, tile selection, and block-sparse attention are included: the complete DTS attention pipeline is accelerated by 2.67–4.90×. At 128K tokens, packing latency decreases from 7,128.5 to 295.8 ms, while attention-pipeline latency decreases from 10,931.6 to 4,094.0 ms. The smaller pipeline-level speedup at longer contexts occurs because tile scoring, selection, and sparse attention account for a larger fraction of the total latency.
Effect of Anchor Selection
We replace delta-based anchors with random anchors while matching the query/key anchor counts in every layer, head, and chunk, as well as the selected-tile count of every query block. At 128K with on Qwen RULER, delta-based anchors achieve 81.28, compared with an average of 79.22 for random anchors over three seeds.
Conclusion
DTS introduces a content-adaptive tile-scoring method that selects query and key anchors at local vector changes and parallelizes packing across tile-aligned chunks. DTS keeps RULER and LongBench averages within 0.10 points of full attention on LLaMA, reduces scoring-pipeline latency by 38.1% relative to XAttention at comparable tile density at 128K, and achieves a 3.3× end-to-end prefill speedup at 512K. These results show that adaptive anchor selection can reduce redundant scoring while retaining a favorable accuracy–latency trade-off for long-context prefill.
References
References
- [1]A. Grattafiori et al., “The Llama 3 herd of models,” arXiv preprint arXiv:2407.21783, 2024.arxiv.org/abs/2407.21783
- [2]Qwen et al., “Qwen2.5 technical report,” arXiv preprint arXiv:2412.15115, 2024.
- [3]P. Wang et al., “Qwen2-VL: Enhancing vision-language model’s perception of the world at any resolution,” arXiv preprint arXiv:2409.12191, 2024.arxiv.org/abs/2409.12191
- [4]Gemini Team et al., “Gemini 1.5: Unlocking multimodal understanding across millions of tokens of context,” arXiv preprint arXiv:2403.05530, 2024.
- [5]H. Liu, M. Zaharia, and P. Abbeel, “Ring attention with blockwise transformers for near-infinite context,” arXiv preprint arXiv:2310.01889, 2023.arxiv.org/abs/2310.01889
- [6]J. Yang et al., “SWE-agent: Agent-computer interfaces enable automated software engineering,” in Advances in Neural Information Processing Systems, vol. 37, 2024, pp. 50 528–50 652.arxiv.org/abs/2405.15793
- [7]P. Lewis et al., “Retrieval-augmented generation for knowledge-intensive NLP tasks,” in Advances in Neural Information Processing Systems, vol. 33, 2020, pp. 9459–9474.arxiv.org/abs/2005.11401
- [8]R. Xu, G. Xiao, H. Huang, J. Guo, and S. Han, “XAttention: Block sparse attention with antidiagonal scoring,” in Proceedings of the 42nd International Conference on Machine Learning, ser. Proceedings of Machine Learning Research, vol. 267. PMLR, 2025, pp. 69 819–69 831.arxiv.org/abs/2503.16428
- [9]T. Dao, D. Y. Fu, S. Ermon, A. Rudra, and C. Ré, “FlashAttention: Fast and memory-efficient exact attention with IO-awareness,” in Advances in Neural Information Processing Systems, vol. 35, 2022, pp. 16 344–16 359.arxiv.org/abs/2205.14135
- [10]T. Dao, “FlashAttention-2: Faster attention with better parallelism and work partitioning,” in International Conference on Learning Representations, 2024, pp. 35 549–35 562.arxiv.org/abs/2307.08691
- [11]J. Shah, G. B. Choudhuri, Y. Zhang, V. Thakkar, P. Ramani, and T. Dao, “FlashAttention-3: Fast and accurate attention with asynchrony and low-precision,” arXiv preprint arXiv:2407.08608, 2024.arxiv.org/abs/2407.08608
- [12]R. Child, S. Gray, A. Radford, and I. Sutskever, “Generating long sequences with sparse transformers,” arXiv preprint arXiv:1904.10509, 2019.arxiv.org/abs/1904.10509
- [13]I. Beltagy, M. E. Peters, and A. Cohan, “Longformer: The long-document transformer,” arXiv preprint arXiv:2004.05150, 2020.arxiv.org/abs/2004.05150
- [14]M. Zaheer et al., “Big Bird: Transformers for longer sequences,” in Advances in Neural Information Processing Systems, vol. 33, 2020, pp. 17 283–17 297.arxiv.org/abs/2007.14062
- [15]H. Jiang et al., “MInference 1.0: Accelerating pre-filling for long-context LLMs via dynamic sparse attention,” in Advances in Neural Information Processing Systems, vol. 37, 2024, pp. 52 481–52 515.arxiv.org/abs/2407.02490
- [16]X. Lai, J. Lu, Y. Luo, Y. Ma, and X. Zhou, “FlexPrefill: A context-aware sparse attention mechanism for efficient long-sequence inference,” in International Conference on Learning Representations, 2025, pp. 963–989.arxiv.org/abs/2502.20766
- [17]J. Zhang et al., “SpargeAttention: Accurate and training-free sparse attention accelerating any model inference,” in Proceedings of the 42nd International Conference on Machine Learning, ser. Proceedings of Machine Learning Research, vol. 267. PMLR, 2025, pp. 76 397–76 413.arxiv.org/abs/2502.18137
- [18]Z. Wang, B. Jin, Z. Yu, and M. Zhang, “Model tells you where to merge: Adaptive KV cache merging for LLMs on long-context tasks,” arXiv preprint arXiv:2407.08454, 2024.arxiv.org/abs/2407.08454
- [19]J. Qi, C. Gao, Z. Ren, and Q. Chen, “DeltaLLM: A training-free framework exploiting temporal sparsity for efficient edge LLM inference,” arXiv preprint arXiv:2507.19608, 2025.
- [20]J. W. Rae, A. Potapenko, S. M. Jayakumar, C. Hillier, and T. P. Lillicrap, “Compressive transformers for long-range sequence modelling,” arXiv preprint arXiv:1911.05507, 2019.arxiv.org/abs/1911.05507
- [21]A. Paszke et al., “PyTorch: An imperative style, high-performance deep learning library,” in Advances in Neural Information Processing Systems, vol. 32, 2019.arxiv.org/abs/1912.01703
- [22]A. Vaswani et al., “Attention is all you need,” in Advances in Neural Information Processing Systems, vol. 30, 2017.arxiv.org/abs/1706.03762
- [23]C.-P. Hsieh et al., “RULER: What’s the real context size of your long-context language models?” arXiv preprint arXiv:2404.06654, 2024.arxiv.org/abs/2404.06654
- [24]Y. Bai et al., “LongBench: A bilingual, multitask benchmark for long context understanding,” arXiv preprint arXiv:2308.14508, 2023.arxiv.org/abs/2308.14508


