arXiv(opens in a new tab)cs.LGOct 2026Cited by 1 paper on PaperVantage

Manuscript Offprint

arXiv:2610.11134

QUILT: Rethinking Sparse-Attention Prefill through Shared Query Execution

Zhenduo Zhao, Qihui Zhou, Mingcong Song, Zhiyi Chen, Chuangguan Ye, Fengfan Hou, Zequn Gong, Jing Li, Hongjie Si, Guoping Long

Zhenduo Zhao ∗^{*}

zhaozhenduo@huawei.com

Huawei Technologies Co., Ltd.

China

Zhiyi Chen

chenzhiyi17@huawei.com

Huawei Technologies Co., Ltd.

China

Zequn Gong

gongzequn1@huawei.com

Huawei Technologies Co., Ltd.

China

Qihui Zhou ∗^{*}

zhouqihui3@huawei.com

Huawei Technologies Co., Ltd.

China

Chuangguan Ye

yechuangguan@huawei.com

Huawei Technologies Co., Ltd.

China

Jing Li

joy.lijing@huawei.com

Huawei Technologies Co., Ltd.

China

Mingcong Song ∗^{*}

songmingcong@huawei.com

Huawei Technologies Co., Ltd.

China

Fengfan Hou

houfengfan@huawei.com

Huawei Technologies Co., Ltd.

China

Hongjie Si

sihongjie@huawei.com

Huawei Technologies Co., Ltd.

China

Guoping Long

robin3@huawei.com

Huawei Technologies Co., Ltd.

China

Abstract

Sparse attention has emerged as a promising approach to reduce the rapidly growing cost of long-context attention. Existing sparse-attention kernels typically adopt query-parallel execution, where different queries independently load, dequantize, and process their selected KV entries. However, such execution is largely workload-agnostic and overlooks the strong correlation among sparse workloads across queries. We observe that neighboring queries frequently select substantially overlapping KV entries. Consequently, processing them independently repeatedly loads and dequantizes the same KV data, resulting in significant redundant memory traffic and computation.

To solve this issue, we present QUILT, a new workload-aware sparse-attention execution mechanism with group-based query execution that explicitly exploits cross-query reuse. QUILT jointly processes neighboring queries and reuses KV entries shared across their sparse workloads, reducing redundant KV data processing and improving hardware utilization. To efficiently realize such execution, QUILT introduces Shift-and-Compare Set Decomposition (SCSD), a new data-parallel algorithm that transforms irregular set operations into regular data-parallel primitives that can be efficiently executed on modern accelerators. QUILT further pipelines SCSD with attention computation to hide its remaining overhead. To accommodate heterogeneous sharing patterns, QUILT is equipped with cascaded sharing to

Layer 77 Layer 60 Layer 40 Layer 20 Layer 0

Figure

Query-Token Distance

Query-Token Distance

Layer 77 Layer 60 Layer 40 Layer 20 Layer 0

Window Size (Tokens)

Window Size (Tokens)

Figure 1. Top-K KV overlap ratios among neighboring queries across model layers and query-group sizes for GLM-5.3 [15] on the Qasper and GovReport datasets in LongBench.

capture cross-query reuse hierarchically at multiple granularities. Finally, QUILT adopts a tile-aware execution strategy that jointly considers sharing granularity and hardware tile utilization, while selectively removing low-importance query-specific tails to eliminate underutilized tiles.

We evaluate QUILT on LongBench using GLM-5.3 and DeepSeek-3.2 under both tensor and sequence parallelism. Compared with the state-of-the-art sparse-attention kernel, QUILT reduces average kernel latency by up to 55.1% and the amount of processed KV data by up to 55.9%, while reducing time-to-first-token (TTFT) latency by up to 36.8% with negligible accuracy degradation.

∗^{*}These authors contributed equally to this work.

1 Introduction

The rapid expansion of context windows has enabled large language models (LLMs) to tackle increasingly complex and long-horizon workloads, including long-document understanding [1, 2], repository-level code analysis [18, 23], and agentic applications that maintain extensive interaction histories [25, 38]. However, supporting such long contexts comes at a substantial inference cost. In particular, during the prefill phase, the model must process the entire input context before generating the first output token, making prefill latency directly visible to users as time-to-first-token (TTFT). As sequence length increases, attention incurs rapidly growing computation and data movement over the expanding key-value (KV) context. Consequently, attention constitutes an increasing fraction of prefill latency at long context lengths, motivating more efficient attention execution for responsive long-context LLM inference.

Sparse attention has emerged as a promising approach to mitigate the growing cost of long-context attention [4, 5, 9, 17, 20, 24, 28, 32, 33, 37]. Instead of attending to the entire KV context, each query token employs a lightweight indexer to dynamically identify a small subset of important KV entries and performs attention only over the selected Top-K entries. Since K is typically much smaller than the context length and can remain bounded as the context grows, sparse attention substantially reduces the computation and memory traffic of long-context prefill. To further reduce the memory footprint and bandwidth cost of KV accesses, sparse attention is often combined with KV quantization, where KV entries are stored in a low-precision format and dequantized on demand when selected for attention computation.

However, sparsity fundamentally changes how attention can be efficiently mapped onto accelerators. In conventional dense attention, multiple queries can be packed together and jointly processed against regular KV tiles on the same compute core, forming sufficiently large matrix operations for efficient execution [6, 34]. In dynamic sparse attention, different queries generally select different KV entries, introducing query-specific access patterns that make such efficient multi-query packing largely impractical. Existing sparse-attention kernels [3, 21] therefore typically adopt a query-parallel execution strategy, where different queries are mapped to separate compute cores and independently gather, dequantize, and process their selected KV entries.

While query-parallel execution effectively exploits the massive parallelism of modern accelerators, it treats the KV accesses of different queries independently and overlooks an important workload characteristic: neighboring queries often exhibit highly correlated sparse attention patterns and select substantially overlapping KV entries. To quantify this behavior, we profile GLM-5.3 [15] on LongBench [2] across different datasets, layers, and query-group sizes. As shown

KV Loading & Dequantization Others

Figure

Figure 2. Latency breakdown of the existing sparse-attention kernel for GLM-5.3 and DeepSeek-4.1 on an Ascend 910C NPU across different prefill sequence lengths (SP) and query heads (TP).

in Figure 1, substantial cross-query overlap consistently exists across model layers and group sizes, and is particularly pronounced in early layers and for smaller query groups. Specifically, when the group size is two, the overlap ratio consistently exceeds 85.91% and 78.06% across all layers on Qasper [8] and GovReport [16], respectively, and further reaches over 90.03% in the first layer. As the group size increases, the fraction of KV entries shared by all queries in the group gradually decreases, yet considerable overlap persists across most layers. These results reveal substantial opportunities for cross-query KV reuse during prefill, while also showing that the degree of sharing varies across datasets, layers and sharing granularities.

Unfortunately, existing query-parallel execution cannot exploit such cross-query reuse. The root cause is that existing sparse-attention kernels are workload-agnostic: they execute each query according to its own Top-K selection without considering the correlation or sharing structure of sparse workloads across queries. Consequently, KV entries shared by neighboring queries are repeatedly loaded from HBM into on-chip memory and independently dequantized on different compute cores, resulting in redundant data movement and computation. As shown in Figure 2, our profiling on an Ascend 910C NPU shows that KV loading and dequantization together account for a large portion of the execution time of the existing sparse-attention kernel across different prefill sequence lengths on GLM-5.3 [15] and DeepSeek-4.1 [11]. This substantial overhead suggests that explicitly exploiting cross-query KV reuse can provide significant opportunities to further improve sparse-attention execution efficiency.

To exploit these cross-query reuse opportunities, we propose QUILT, a new workload-aware sparse-attention execution mechanism with group-based query execution. Instead of processing each query independently, QUILT groups neighboring queries and jointly executes their correlated sparse workloads according to the sharing structure of their

KV accesses. KV entries shared by multiple queries are loaded from HBM and dequantized only once before being reused across the group, thereby reducing redundant KV data processing. Moreover, jointly processing neighboring queries increases the effective computation granularity of sparse attention and improves accelerator utilization. However, translating such cross-query sharing into actual performance gains is non-trivial and introduces several key design challenges.

Firstly, group-based execution introduces additional overhead for identifying the shared and query-specific KV entries among neighboring queries. A naive implementation based on scalar traversal, explicit loops, or pairwise membership checking can incur substantial set-processing overhead, which may offset or even exceed the benefit of cross-query sharing. To address this challenge, we propose Shift-and-Compare Set Decomposition (SCSD), a data-parallel algorithm for efficiently computing the intersections and differences of sparse KV sets. SCSD concatenates and sorts the KV indices, transforming irregular set operations into regular shift, comparison, and Boolean primitives that map efficiently onto the parallel execution units of modern accelerators. Moreover, we overlap SCSD with attention computation by embedding it into the existing kernel pipeline, largely hiding its latency behind useful computation. As a result, the kernel can expose cross-query sharing opportunities with near-zero additional overhead on the critical path.

Secondly, the degree of cross-query KV sharing varies substantially across datasets, layers, and sharing granularities, making a fixed query-group size inherently suboptimal. A small group size captures strong local overlap but misses reuse opportunities across groups, whereas a large group size requires KV entries to be shared by more queries and therefore retains only a smaller common subset. To address such heterogeneous sharing patterns, we introduce cascaded sharing, which hierarchically decomposes sparse KV workloads across multiple granularities. Starting from a relatively large query group, the mechanism first extracts KV entries shared by the entire group, then recursively identifies additional sharing within smaller subgroups, and finally processes the remaining query-specific entries. This hierarchical decomposition captures both coarse-grained and fine-grained reuse without committing to a single fixed sharing granularity.

Thirdly, cascaded sharing produces shared and query-specific segments whose sizes are often misaligned with the native attention tile size, causing poorly utilized tail tiles. To address this issue, we introduce tile-aware clipping for the sharing process. For each shared segment, we examine the occupancy of its tail tile. If the occupancy falls below a configurable threshold, we push the tail down to the next cascade level, where it is merged with finer-grained workloads to improve tile utilization. Otherwise, we pad the tail to a full tile and process it at the current sharing level. This push-down is exact and trades a small amount of sharing for improved tile utilization. At the final query-specific level, where no further push-down is possible, we observe that the remaining KV entries are predominantly concentrated near the tail of the original Top-K ranking and thus tend to have lower importance scores. We therefore apply importance-aware clipping, pruning the lowest-ranked residual entries to eliminate the final underutilized tile. This approximation further reduces attention-tile execution while introducing negligible accuracy degradation.

We evaluate QUILT on LongBench [2] using GLM-5.3 [15] and DeepSeek-3.2 [9] under both tensor and sequence parallelism. Compared with the state-of-the-art sparse-attention kernel, QUILT reduces the average kernel execution latency by up to 55.1% and the amount of processed KV data by up to 55.9%. These kernel-level improvements translate into substantial end-to-end benefits, reducing the average time-to-first-token (TTFT) latency by up to 36.8% while introducing negligible accuracy degradation. These results demonstrate that exploiting cross-query workload structure can effectively translate the inherent correlation in sparse attention into tangible system-level performance gains. To summarize, this paper makes the following contributions:

  • We identify substantial cross-query reuse opportunities in sparse-attention workloads and reveal a mismatch between their correlated workload characteristics and existing query-parallel execution, which processes queries independently and results in redundant KV data processing and inefficient hardware utilization.

  • We propose QUILT, a new workload-aware sparse-attention mechanism with group-based query execution to exploit cross-query reuse. We develop Shift-and-Compare Set Decomposition for efficient data-parallel set processing and pipeline it with attention computation to hide its overhead. We further introduce cascaded sharing to capture reuse at multiple granularities and tile-aware execution to jointly optimize sharing granularity and hardware utilization.

  • We conduct comprehensive experiments on representative long-context models and workloads under different parallel configurations. Compared with the state-of-the-art sparse-attention implementation, QUILT substantially reduces processed KV data and kernel execution latency, translating these improvements into significant TTFT improvement with negligible accuracy degradation.

References (10)