LongCat Recall 稀疏注意力:面向长上下文推理的键组织与检索协同设计

arXiv cs.CL 论文

摘要

美团 LongCat 团队提出了 LongCat 召回稀疏注意力(LRSA),这是一种基于检索的稀疏注意力方案,通过协同设计分页键组织与由粗到细的检索机制,突破长上下文推理中的键选择瓶颈。该方案已集成到 SGLang 中,在 1024K 词元长度下,键选择速度达到 DSA 的 4.70 倍,整体速度达到全注意力的 35.60 倍。

arXiv:2611.27233v1 Announce Type: new Abstract: Retrieval-based sparse attention, exemplified by DeepSeek Sparse Attention (DSA), reduces attention computation by selecting a small subset of key-value entries. However, selecting these entries can still require searching the entire visible history. For long sequences, retrieval becomes a major bottleneck, limiting the efficiency gains from sparse attention. To address this problem, we propose LongCat Recall Sparse Attention (LRSA), which combines fine-grained representatives with paged retrieval in an incrementally maintained index. LRSA partitions the sequence into time buckets that can be indexed independently as new keys arrive, without regrouping existing history. Within each bucket, it organizes indexing keys into capacity-balanced directional groups and packs a fixed number of complete groups into each page, retaining a separate center for every group. These centers provide fine-grained representatives for page selection, after which refinement scores members of the selected pages together with sink, sliding-window, and visible unindexed candidates to select the final Top-$K$ logical positions. To execute this retrieval process efficiently, we store members in reordered pages, fuse construction stages according to group size, and share storage for overlapping fixed candidates across queries during chunked prefill. These choices support regular member access while reducing kernel launches during construction and repeated candidate transfers. Moreover, we integrate LRSA into SGLang to maintain the index during inference, overlapping asynchronous index construction for new buckets with subsequent computation and reusing compatible bucket indices and member pages after a prefix match in the original key-value pool. With a 1024K-token context, LRSA accelerates key selection by 4.70$\times$ over DSA and combined selection and attention by 35.60$\times$ over full attention.
查看原文
查看缓存全文

缓存时间: 2026/11/23 09:18

# LongCat Recall Sparse Attention: Co-Designing Key Organization and Retrieval for Long-Context Inference
Source: [https://arxiv.org/html/2611.27233](https://arxiv.org/html/2611.27233)
Bin XiaoKefeng ZhangMeituan LongCat Team\*Equal contribution\. Project lead and corresponding author

###### Abstract

Retrieval\-based sparse attention, exemplified by DeepSeek Sparse Attention \(DSA\), reduces attention computation by selecting a small subset of key–value entries\. However, selecting these entries can still require searching the entire visible history\. For long sequences, retrieval becomes a major bottleneck, limiting the efficiency gains from sparse attention\. To address this problem, we propose LongCat Recall Sparse Attention \(LRSA\), which combines fine\-grained representatives with paged retrieval in an incrementally maintained index\. LRSA partitions the sequence into time buckets that can be indexed independently as new keys arrive, without regrouping existing history\. Within each bucket, it organizes indexing keys into capacity\-balanced directional groups and packs a fixed number of complete groups into each page, retaining a separate center for every group\. These centers provide fine\-grained representatives for page selection, after which refinement scores members of the selected pages together with sink, sliding\-window, and visible unindexed candidates to select the final Top\-KKlogical positions\. To execute this retrieval process efficiently, we store members in reordered pages, fuse construction stages according to group size, and share storage for overlapping fixed candidates across queries during chunked prefill\. These choices support regular member access while reducing kernel launches during construction and repeated candidate transfers\. Moreover, we integrate LRSA into SGLang to maintain the index during inference, overlapping asynchronous index construction for new buckets with subsequent computation and reusing compatible bucket indices and member pages after a prefix match in the original key–value pool\. With a 1024K\-token context, LRSA accelerates key selection by 4\.70×\\timesover DSA and combined selection and attention by 35\.60×\\timesover full attention\.

![Refer to caption](https://arxiv.org/html/2611.27233v1/lrsa-overview.png)Figure 1:Overview of LRSA\. \(a\) Each completed bucket is independently partitioned into capacity\-balanced directional groups, which are packed into member pages\. With the default capacities, the expanded page contains eight groups of eight keys, with one center per group\. \(b\) Queries score group centers and select the Top\-KpageK\_\{\\mathrm\{page\}\}pages using the maximum group score within each page\. Retrieved members are combined with sink, sliding\-window, and visible unindexed candidates, deduplicated, and scored to select the final Top\-KKpositions for attention\. The position map supports deduplication and recovery of original logical positions\. Reordered page and slot addresses are depicted as one\-dimensional indices for simplicity\.###### Contents

1. [1Introduction](https://arxiv.org/html/2611.27233#S1)
2. [2Retrieval\-Based Sparse Attention and Design Motivation](https://arxiv.org/html/2611.27233#S2)1. [2\.1DeepSeek Sparse Attention and Subsequent Developments](https://arxiv.org/html/2611.27233#S2.SS1) 2. [2\.2Motivating the Design of Efficient Sparse Retrieval](https://arxiv.org/html/2611.27233#S2.SS2)
3. [3LongCat Recall Sparse Attention \(LRSA\)](https://arxiv.org/html/2611.27233#S3)1. [3\.1Temporal Bucketing and Incremental Index Maintenance](https://arxiv.org/html/2611.27233#S3.SS1) 2. [3\.2Capacity\-Balanced Grouping and Page Construction](https://arxiv.org/html/2611.27233#S3.SS2) 3. [3\.3Coarse\-to\-Fine Retrieval and Candidate Selection](https://arxiv.org/html/2611.27233#S3.SS3)
4. [4Kernel Design and Execution Optimizations](https://arxiv.org/html/2611.27233#S4)1. [4\.1Paged Index Storage and Logical Position Mapping](https://arxiv.org/html/2611.27233#S4.SS1) 2. [4\.2Recursive Index Construction and Kernel Fusion](https://arxiv.org/html/2611.27233#S4.SS2) 3. [4\.3Shared Candidate Storage for Chunked Prefill](https://arxiv.org/html/2611.27233#S4.SS3)
5. [5Runtime Index Management and Reuse in SGLang](https://arxiv.org/html/2611.27233#S5)1. [5\.1Request State and Asynchronous Index Construction](https://arxiv.org/html/2611.27233#S5.SS1) 2. [5\.2Prefix\-Based Reuse of Bucket Indices and Member Pages](https://arxiv.org/html/2611.27233#S5.SS2) 3. [5\.3Index Retention Policies and Storage Tradeoffs](https://arxiv.org/html/2611.27233#S5.SS3)
6. [6Experiments and Results](https://arxiv.org/html/2611.27233#S6)1. [6\.1Setup](https://arxiv.org/html/2611.27233#S6.SS1) 2. [6\.2Performance on Downstream Tasks](https://arxiv.org/html/2611.27233#S6.SS2) 3. [6\.3Impact of Kernel Fusion and Candidate Sharing](https://arxiv.org/html/2611.27233#S6.SS3) 4. [6\.4Efficiency of Long\-Context Inference](https://arxiv.org/html/2611.27233#S6.SS4) 5. [6\.5Ablation Studies](https://arxiv.org/html/2611.27233#S6.SS5) 6. [6\.6Evaluating Overlap in Index Maintenance](https://arxiv.org/html/2611.27233#S6.SS6)
7. [7Conclusion and Future Work](https://arxiv.org/html/2611.27233#S7)
8. [References](https://arxiv.org/html/2611.27233#bib)

## 1Introduction

Long\-context processing addresses the need for large language models \(LLMs\) to draw on extensive documents, code, and interaction histories in applications such as book\-length summarization\([Wu et al\., 2021](https://arxiv.org/html/2611.27233#bib.bib10)\), repository\-level code completion\([Zhang et al\., 2023](https://arxiv.org/html/2611.27233#bib.bib12)\), and memory\-based interactive agents\([Park et al\., 2023](https://arxiv.org/html/2611.27233#bib.bib11)\)\. However, dense attention attends to all causally visible positions for each query, so the total computation over a sequence grows quadratically with its length\. Retrieval\-based sparse attention, exemplified by DeepSeek Sparse Attention \(DSA\)\([DeepSeek\-AI, 2025](https://arxiv.org/html/2611.27233#bib.bib1)\), reduces this cost by identifying relevant key–value \(KV\) entries and restricting the main attention computation to the selected subset\. DSA performs this selection with a lightweight learned indexer that scores visible keys and returns their Top\-KKpositions\. Although a fixed selection budget limits the number of entries used by the main attention, selecting these entries still requires the indexer to score every visible key\. The cost of this exhaustive search grows with context length\. For long sequences, retrieval becomes a major bottleneck, limiting the efficiency gains from sparse attention\. Therefore, reducing the cost of key selection in sparse attention is central to efficient long\-context inference\.

Recent work reduces key\-selection costs through complementary approaches\. HISA\([Xu et al\., 2026](https://arxiv.org/html/2611.27233#bib.bib2)\)uses pooled representations of contiguous blocks to narrow the search before scoring individual keys, while IndexCache\([Bai et al\., 2026](https://arxiv.org/html/2611.27233#bib.bib3)\)reuses selected indices across layers\. LiteTopK\([Yin et al\., 2026](https://arxiv.org/html/2611.27233#bib.bib6)\)fuses scoring with exact Top\-KKselection to reduce selection overhead\. LongCat Sparse Attention\([Zan et al\., 2026](https://arxiv.org/html/2611.27233#bib.bib5)\)combines hierarchical retrieval with cross\-layer index reuse and streaming\-aware budget allocation\. These approaches highlight the need to consider both the search procedure and its execution\. In this work, we focus on how historical keys are organized for retrieval, since this organization shapes both how well group representatives capture relevant keys and how efficiently group members can be accessed\.

This organization must reconcile several requirements\. Directional grouping, as used by ClusterKV\([Liu et al\., 2024](https://arxiv.org/html/2611.27233#bib.bib9)\), provides a basis for coherent group representatives\. Unconstrained group sizes, however, complicate the mapping of groups to fixed\-capacity pages: groups may span page boundaries, and using them as retrieval units produces uneven refinement workloads across groups\. Capacity\-constrained groups can instead be packed as complete units into pages, giving each page a regular group structure for member access\. Retaining a separate center for each small group also avoids obscuring a relevant subset within a single page\-wide mean\. The index must also grow as new keys arrive without repeatedly regrouping existing history, while keeping visible unindexed keys eligible for selection\. These requirements suggest separating the granularity of representation from that of access, while giving construction its own fixed update units\.

To meet these requirements, we propose*LongCat Recall Sparse Attention \(LRSA\)*, which organizes historical keys into a hierarchy of time buckets, directional groups, and retrieval pages\. Each bucket can be indexed independently, without regrouping keys in existing buckets\. Within each bucket, recursive directional grouping produces capacity\-balanced groups, and each page packs a fixed number of complete groups while retaining a separate center for each\. A query scores these centers and selects pages using the maximum center score within each page, allowing a relevant subgroup to influence retrieval without averaging its score with those of other groups\. Refinement then combines the retrieved members with fixed candidates from the sink prefix, sliding window, and visible unindexed suffix, and applies the indexer’s scoring function to select the final Top\-KKlogical positions\. The page budget bounds the number of historical members retrieved through the index, while the fixed candidates remain eligible regardless of which pages are selected\.

This page structure also provides the basis for efficient execution\. We materialize the groups as reordered member pages for contiguous access, with a mapping to original logical positions for duplicate handling and subsequent attention\. To construct these pages, recursive partitioning updates compact member indices instead of repeatedly moving full vectors, and group\-size\-dependent kernel fusion reduces launches and intermediate memory traffic\. For refinement, we copy the fixed candidates into the reordered pool so that they can be scored together with retrieved members through the same paged interface\. Because their ranges overlap across neighboring queries during chunked prefill, we store their union once per chunk, avoiding repeated transfers of the same keys while preserving each query’s candidate set\.

Maintaining this index as inference proceeds requires coordinating its updates with model execution and managing the lifetime of its resources within and across requests\. We integrate LRSA into SGLang, where indices for newly filled buckets are constructed asynchronously after the current layer’s attention so that construction can overlap with subsequent computation\. The bucket and page structure also supports reuse across requests\. After a prefix match in the original KV pool, valid and compatible indices for buckets fully covered by the matched prefix can be reused to skip construction; when a bucket within that prefix must be rebuilt, matching member pages can be shared after assembly to avoid duplicate storage\. Retention policies govern how long these resources remain available for reuse, trading index memory occupancy against reconstruction cost\. Experiments show that, at a context length of 1024K tokens, LRSA achieves a 4\.70×\\timesspeedup in key selection over DSA and a 35\.60×\\timesspeedup in combined key selection and attention computation over full attention\.

Our main contributions can be summarized as follows:

- •We propose a retrieval hierarchy that combines fine\-grained directional representatives with fixed\-capacity pages through capacity\-constrained grouping, supporting regular member access and predictable historical refinement workloads\. Time buckets enable independent index updates without regrouping existing keys\.
- •We develop a kernel implementation that reduces kernel launches during index construction and repeated candidate transfers through group\-size\-dependent fusion and shared candidate storage for chunked prefill\.
- •We integrate LRSA into SGLang, coordinating asynchronous index construction, prefix\-based reuse, and resource retention throughout the index lifecycle\.

## 2Retrieval\-Based Sparse Attention and Design Motivation

We review DeepSeek Sparse Attention and related approaches to reducing retrieval overhead, then motivate our joint design of key organization, paged access, and incremental maintenance\.

### 2\.1DeepSeek Sparse Attention and Subsequent Developments

Retrieval\-based sparse attention first identifies relevant historical positions and computes attention over the corresponding KV entries\. DeepSeek Sparse Attention \(DSA\)\([DeepSeek\-AI, 2025](https://arxiv.org/html/2611.27233#bib.bib1)\)implements this approach with a learned*lightning indexer*\. For a query at positiontt, the indexer assigns each causally visible indexing keykiIk\_\{i\}^\{I\}the score

st​\(i\)=∑h=1HIwt,h​ReLU⁡\(\(qt,hI\)⊤​kiI\),i≤t,s\_\{t\}\(i\)=\\sum\_\{h=1\}^\{H\_\{I\}\}w\_\{t,h\}\\,\\operatorname\{ReLU\}\\\!\\left\(\(q\_\{t,h\}^\{I\}\)^\{\\top\}k\_\{i\}^\{I\}\\right\),\\qquad i\\leq t,\(1\)whereHIH\_\{I\}is the number of indexing heads,qt,hIq\_\{t,h\}^\{I\}is the projected query for headhh, andwt,hw\_\{t,h\}is its query\-dependent weight\. TheKKhighest\-scoring positions determine the KV entries accessed by the main attention\. The indexer uses lightweight, FP8\-compatible scoring and is supervised by the main attention distribution through a KL\-divergence loss\. Its scores guide selection, while the main attention computes its own scores and normalization over the retrieved entries\. For a sequence of lengthLLand a fixed selection budgetKK, the main attention requiresO⁡\(L​K\)O\(LK\)work\. However, scoring every visible key for every query retains anO⁡\(L2\)O\(L^\{2\}\)indexing cost\.

Recent work reduces retrieval costs through search reduction, cross\-layer reuse, and execution optimizations\. These directions address different sources of overhead and can be combined\.

*Search reduction\.*HISA\([Xu et al\., 2026](https://arxiv.org/html/2611.27233#bib.bib2)\)pools indexing keys in contiguous blocks, selects blocks using their representatives, and scores individual keys within the selected blocks for refinement\. MISA\([Zhou et al\., 2026](https://arxiv.org/html/2611.27233#bib.bib4)\)activates a subset of indexing heads for each query, optionally refining the resulting candidates with all heads\. SPIN\([Fu et al\., 2026](https://arxiv.org/html/2611.27233#bib.bib23)\)predicts block importance from historical indexer scores and evaluates the current query only against selected blocks, using exploration to refresh the statistics of skipped blocks\.

*Cross\-layer reuse\.*IndexCache\([Bai et al\., 2026](https://arxiv.org/html/2611.27233#bib.bib3)\)reuses final Top\-KKindices across layers\. MLIPS\([Jain et al\., 2026](https://arxiv.org/html/2611.27233#bib.bib8)\)instead shares a larger candidate pool from which each consumer layer independently selects its entries\. Prism Attention\([Tian et al\., 2026](https://arxiv.org/html/2611.27233#bib.bib24)\)similarly transmits expanded proposals from designated layers and refines them using the receiving layer’s scores; quantized keys reduce proposal\-generation cost\. These approaches amortize retrieval across layers while differing in how much layer\-specific selection they retain\.

*Execution efficiency\.*LiteTopK\([Yin et al\., 2026](https://arxiv.org/html/2611.27233#bib.bib6)\)fuses scoring with exact Top\-KKselection, and LiteDSA shares selected KV loads across neighboring queries using per\-query membership masks\. DoSA\([Meng and Fang, 2026](https://arxiv.org/html/2611.27233#bib.bib7)\)uses score bounds to avoid full evaluation of some candidates while preserving exact Top\-KKselection under its stated conditions\. JSSA\([Song et al\., 2026](https://arxiv.org/html/2611.27233#bib.bib25)\)combines a joint low\-dimensional query–key scoring subspace with a gather\-free indexed\-attention kernel\. LongCat Sparse Attention\([Zan et al\., 2026](https://arxiv.org/html/2611.27233#bib.bib5)\)combines hierarchical retrieval, cross\-layer reuse with distillation, and streaming\-aware indexing, bringing together search reduction, reuse, and locality optimizations\.

*Positioning LRSA\.*LRSA focuses on how the organization of keys connects representative\-based retrieval to paged execution\. HISA pools keys within contiguous blocks, while LongCat Sparse Attention retains a mean vector for each contiguous sub\-block within a page and sums the resulting sub\-block scores\. LRSA instead forms capacity\-balanced directional groups within each time bucket and packs complete groups into reordered pages\. It scores each page by its highest\-scoring group, so the strongest group\-level match determines the page’s retrieval priority\. This couples fine\-grained directional representatives with fixed\-capacity access units: representation follows key similarity, while member retrieval follows a regular paged layout\.

Semantic grouping is also central to ClusterKV\([Liu et al\., 2024](https://arxiv.org/html/2611.27233#bib.bib9)\), which ranks clusters and accumulates their sizes to meet a token budget, trimming the last cluster when needed\. LRSA imposes capacity constraints during grouping, then separates page retrieval from member\-level Top\-KKselection\. Group capacity determines representation granularity, page capacity determines access granularity, and member\-level scoring selects the final entries under a separate attention budget\. Small groups can therefore guide retrieval while their members are accessed in fixed\-capacity pages\.

Beyond key organization, LRSA differs in how it obtains and prepares candidates\. SPIN predicts block importance from historical scores, whereas LRSA evaluates group centers with the current query\. IndexCache, MLIPS, and Prism Attention reuse indices or proposals across layers; LRSA searches an index maintained within each layer\. JSSA changes the scoring representation and final KV access, while LRSA narrows the candidate set through approximate page retrieval and retains the indexing function in Eq\. \([1](https://arxiv.org/html/2611.27233#S2.E1)\) for member\-level refinement\.

At the execution level, LiteDSA shares selected KV loads during attention, whereas LRSA shares the indexing keys of fixed candidates before refinement\. These candidates comprise sink, sliding\-window, and visible unindexed positions\. Shared storage avoids repeatedly copying their overlapping ranges for neighboring queries\. To maintain the retrieval organization as new keys arrive, LRSA builds each time bucket independently, preserving the groups in previously indexed buckets\. Together, these choices connect directional representation and fixed\-capacity page access to candidate preparation and incremental maintenance\.

### 2\.2Motivating the Design of Efficient Sparse Retrieval

Our design addresses three related aspects of retrieval efficiency: reducing the history scanned by each query, organizing keys into groups that support informative representatives and align with paged access, and managing index updates and candidate preparation as the context grows\. The following considerations explain why these aspects must be addressed together\.

*Full\-history scoring remains a bottleneck under a fixed attention budget\.*WithHIH\_\{I\}indexing heads of dimensiondId\_\{I\}, scoringnnvisible keys for one query requiresO⁡\(HI​dI​n\)O\(H\_\{I\}d\_\{I\}n\)work\. ForRRqueries with visible lengthsnqn\_\{q\}, the total scoring cost isO⁡\(HI​dI​∑q=1Rnq\)O\(H\_\{I\}d\_\{I\}\\sum\_\{q=1\}^\{R\}n\_\{q\}\), with additional work to select the Top\-KKentries for each query\. Over a causal prefix of lengthLL,∑q=1Lq=L⁡\(L\+1\)/2\\sum\_\{q=1\}^\{L\}q=L\(L\+1\)/2, so exhaustive indexing incurs quadratic scoring work even when the final attention budget is fixed\. This cost motivates a hierarchical search: score a smaller set of group representatives first, then refine the search by scoring individual keys within the selected pages\.

*Grouping must support informative representatives and regular paged access\.*Retrieval quality depends on how well each representative captures the keys in its group\. Temporal proximity alone does not ensure directional similarity: the mean of keys with different directions may poorly represent a member that scores highly for a given query\. Grouping by directional similarity, as in ClusterKV, provides a basis for more coherent representations\. However, without capacity constraints, groups can differ substantially in size\. Using these groups as retrieval units produces uneven refinement workloads across groups, and packing them into fixed\-capacity pages may split groups across page boundaries and complicate the mapping between centers and member pages\. We therefore combine directional grouping with capacity constraints so that each page contains a fixed number of complete groups\. This preserves small\-group representatives while supporting regular member access\. Fixed page capacity then translates a page\-selection budget into a bound on the number of retrieved historical members and the associated member\-level scoring work\.

*Maintenance and candidate preparation determine the net benefit of search\.*The organization used for retrieval must also accommodate newly arriving keys\. Rebuilding the full index repeats work on historical data, while searching only the existing index leaves visible but unindexed keys outside the candidate set\. We therefore extend the index incrementally and make completed buckets available for retrieval\. Visible keys awaiting indexing are included directly as refinement candidates, preserving their eligibility for selection during index construction\. Candidate preparation also incurs data movement: neighboring queries often require overlapping fixed prefix and tail ranges, so copying them separately for each query transfers the same data repeatedly\. Sharing storage for these candidates, while retaining each query’s visibility constraints, avoids this duplication\. Search, index maintenance, and candidate preparation must therefore be considered together: reduced historical scanning yields a net benefit only when its savings exceed the additional costs of organizing and maintaining retrieval\.

## 3LongCat Recall Sparse Attention \(LRSA\)

LRSA reduces historical scanning through a hierarchy of time buckets, directional groups, and retrieval pages\. Time buckets delimit independent index updates\. Within each bucket, small groups provide representative centers, while pages combine several groups into units for coarse retrieval\. A query uses group centers to select pages, then scores their member keys together with keys from the sink, sliding window, and unindexed suffix\. This separates the organization of history from query\-dependent selection, allowing the index to grow without repeatedly regrouping existing keys\. We first describe how buckets are maintained during inference, then explain their internal construction and the two\-stage retrieval process\.

### 3\.1Temporal Bucketing and Incremental Index Maintenance

For each attention layer, we partition indexing positions in temporal order into consecutive buckets of capacityBB:

ℬm=\{mB\+1,…,\(m\+1\)B\},m=0,1,…\.\\mathcal\{B\}\_\{m\}=\\\{mB\+1,\\ldots,\(m\+1\)B\\\},\\qquad m=0,1,\\ldots\.\(2\)A bucket is the unit of index construction and publication, rather than the unit selected by a query\. Directional grouping is confined to each bucket, and the resulting groups and centers remain unchanged after construction\. As new keys arrive, only newly filled buckets require index construction\. The bucket boundaries stay fixed as the context grows, while sink and sliding\-window membership are handled during retrieval\. Moving the window does not require rebuilding the historical index\.

We set the prefill chunk size equal to the bucket capacity, withB=1024B=1024by default\. A chunk is a unit of model execution, whereas its corresponding bucket determines which keys are indexed together\. Each full prefill chunk supplies one bucket per layer\. Its queries use the previously published index, and the current bucket is submitted for construction after that layer’s attention computation\. Decoding uses the same granularity: arriving positions gradually fill the next bucket, and construction is triggered when that bucket containsBBpositions\. Any partially filled bucket left by prefill is completed by subsequent arrivals\. Thus both stages update the index in increments ofBB, with prefill supplying these positions together and decoding accumulating them over time\.

A full bucket becomes queryable only after construction has finished and its records have been published\. LetEEdenote the last position in the contiguous published prefix\. The centers, member pages, and position mapping for positions1,…,E1,\\ldots,Eform a consistent index snapshot\. Every visible position beyondEEremains a direct refinement candidate, including positions in an incomplete bucket\. Once the next bucket is completed and added to the index, the searchable prefix extends byBBpositions, andEEis updated toE\+BE\+B\. This separates data visibility from index readiness: a new key can participate in selection before its bucket becomes searchable\.

We launch index construction asynchronously after the current layer’s attention, allowing it to overlap with subsequent layers and other independent computation\. This schedule aims to complete construction before the next query batch reaches the same layer, hiding the index\-building latency behind ongoing model computation\.

### 3\.2Capacity\-Balanced Grouping and Page Construction

Each full bucket is organized into groups of capacityCgrpC\_\{\\mathrm\{grp\}\}, which are packed into pages of capacityCpageC\_\{\\mathrm\{page\}\}\. We requireCgrpC\_\{\\mathrm\{grp\}\}to divideCpageC\_\{\\mathrm\{page\}\}andCpageC\_\{\\mathrm\{page\}\}to divideBB\. With the defaultsCgrp=8C\_\{\\mathrm\{grp\}\}=8andCpage=64C\_\{\\mathrm\{page\}\}=64, each page containsNgrp=Cpage/Cgrp=8N\_\{\\mathrm\{grp\}\}=C\_\{\\mathrm\{page\}\}/C\_\{\\mathrm\{grp\}\}=8groups\. A bucket ofB=1024B=1024positions consequently produces 128 groups and 16 pages\. Groups determine the resolution of the representation, while pages determine the granularity of retrieval and member access\. The divisibility conditions allow each page to contain a fixed number of complete groups, with no group spanning member\-page boundaries\.

To construct the groups, we normalize each indexing key for directional comparisons:

ui=kiImax⁡\(∥kiI∥2,ϵ\),u\_\{i\}=\\frac\{k\_\{i\}^\{I\}\}\{\\max\(\\lVert k\_\{i\}^\{I\}\\rVert\_\{2\},\\epsilon\)\},\(3\)whereϵ\>0\\epsilon\>0protects against zero norms\. We initialize the member listIIin the bucket’s temporal order and recursively partition it\. At each split, we use the first membervvof the current list as the initial reference and select two directional anchors, indexed byi−i\_\{\-\}andi\+i\_\{\+\}, through successive minimum\-similarity searches:

i−=arg​mini∈I⁡ui⊤​uv,i\+=arg​mini∈I⁡ui⊤​ui−\.i\_\{\-\}=\\operatorname\*\{arg\\,min\}\_\{i\\in I\}u\_\{i\}^\{\\top\}u\_\{v\},\\qquad i\_\{\+\}=\\operatorname\*\{arg\\,min\}\_\{i\\in I\}u\_\{i\}^\{\\top\}u\_\{i\_\{\-\}\}\.\(4\)The preferenceδi=ui⊤​ui\+−ui⊤​ui−\\delta\_\{i\}=u\_\{i\}^\{\\top\}u\_\{i\_\{\+\}\}\-u\_\{i\}^\{\\top\}u\_\{i\_\{\-\}\}measures how strongly memberiifavors anchori\+i\_\{\+\}over anchori−i\_\{\-\}\. We stably sort members by decreasingδi\\delta\_\{i\}and assign the first

nleft​\(I\)=Cgrp​⌊⌈\|I\|/Cgrp⌉2⌋n\_\{\\mathrm\{left\}\}\(I\)=C\_\{\\mathrm\{grp\}\}\\left\\lfloor\\frac\{\\lceil\|I\|/C\_\{\\mathrm\{grp\}\}\\rceil\}\{2\}\\right\\rfloor\(5\)members to one child and the remainder to the other\. Recursion stops when\|I\|≤Cgrp\|I\|\\leq C\_\{\\mathrm\{grp\}\}\. With full buckets and the stated divisibility conditions, every leaf group hasCgrpC\_\{\\mathrm\{grp\}\}members\.

After grouping, letGGdenote the set of member positions in a group\. We compute its center from the original, unnormalized indexing keys:

μG=1\|G\|​∑i∈GkiI\.\\mu\_\{G\}=\\frac\{1\}\{\|G\|\}\\sum\_\{i\\in G\}k\_\{i\}^\{I\}\.\(6\)Normalization guides membership without removing magnitude information from the centers or subsequent candidate scoring\. We packNgrpN\_\{\\mathrm\{grp\}\}consecutive groups in recursive output order into pagejj\. Let𝒢j\\mathcal\{G\}\_\{j\}denote the collection of groups on pagejj\. Its member set is𝒫j=⋃G∈𝒢jG\\mathcal\{P\}\_\{j\}=\\bigcup\_\{G\\in\\mathcal\{G\}\_\{j\}\}G\. Each page thus holdsCpageC\_\{\\mathrm\{page\}\}members described byNgrpN\_\{\\mathrm\{grp\}\}centers, one per group\. Retaining these small\-group centers avoids collapsing the whole page into a single mean, so a relevant subgroup can influence retrieval even when other groups on the page are less relevant\.

Member keys are stored contiguously within each page, with centers stored separately in the corresponding group order\. A position map records the original indexing position of the member in each page slot\. This layout combines fine\-grained representations with regular page access while preserving the identities needed for causal filtering and final attention lookup\.

### 3\.3Coarse\-to\-Fine Retrieval and Candidate Selection

Retrieval separates the choice of historical pages from the choice of individual positions for attention\. For querytt, coarse selection retrievesKpageK\_\{\\mathrm\{page\}\}pages from the published index\. Fine selection combines the members of these pages with sink, sliding\-window, and unindexed candidates, scores each candidate using the original scoring function, and selects theKKhighest\-scoring positions for attention\.

*Coarse page selection\.*Let𝒥E\\mathcal\{J\}\_\{E\}be the set of page indices in the published prefix ending atEE\. For each groupGGon pagejj, we score its centerμG\\mu\_\{G\}using the same query heads and weights as in Eq\. \([1](https://arxiv.org/html/2611.27233#S2.E1)\)\. The group scorest,Ggrps^\{\\mathrm\{grp\}\}\_\{t,G\}and page scorest,jpages^\{\\mathrm\{page\}\}\_\{t,j\}are

st,Ggrp\\displaystyle s^\{\\mathrm\{grp\}\}\_\{t,G\}=∑h=1HIwt,h​ReLU⁡\(\(qt,hI\)⊤​μG\),\\displaystyle=\\sum\_\{h=1\}^\{H\_\{I\}\}w\_\{t,h\}\\,\\operatorname\{ReLU\}\\\!\\left\(\(q\_\{t,h\}^\{I\}\)^\{\\top\}\\mu\_\{G\}\\right\),\(7\)st,jpage\\displaystyle s^\{\\mathrm\{page\}\}\_\{t,j\}=maxG∈𝒢j⁡st,Ggrp\.\\displaystyle=\\max\_\{G\\in\\mathcal\{G\}\_\{j\}\}s^\{\\mathrm\{grp\}\}\_\{t,G\}\.Here𝒢j\\mathcal\{G\}\_\{j\}is the collection of groups on pagejj, defined in Section[3\.2](https://arxiv.org/html/2611.27233#S3.SS2)\. Taking the maximum allows a high\-scoring group to bring its page into refinement without averaging across groups\. This avoids dilution by lower\-scoring groups that could otherwise cause the page to be overlooked during coarse selection\. We select pages globally across all published buckets:

𝒥t=Topmin⁡\(Kpage,\|𝒥E\|\)⁡\{st,jpage:j∈𝒥E\}\.\\mathcal\{J\}\_\{t\}=\\operatorname\{Top\}\_\{\\min\(K\_\{\\mathrm\{page\}\},\|\\mathcal\{J\}\_\{E\}\|\)\}\\\{s^\{\\mathrm\{page\}\}\_\{t,j\}:j\\in\\mathcal\{J\}\_\{E\}\\\}\.\(8\)The selected page indices form𝒥t\\mathcal\{J\}\_\{t\}\. Center\-based scores guide page selection, while the subsequent refinement stage uses individual key scores to determine the final attention positions\.

*Fine candidate selection\.*The selected pages provide historical candidates, which we combine with sink positions, the sliding window, and visible positions beyond the published index\. Letntn\_\{t\}be the number of positions visible to querytt,SSthe sink length, andWWthe window length\. The three directly included sets are

𝒮t\\displaystyle\\mathcal\{S\}\_\{t\}=\{1,…,min⁡\(S,nt\)\},\\displaystyle=\\\{1,\\ldots,\\min\(S,n\_\{t\}\)\\\},\(sink\),\\displaystyle\\text\{\(sink\)\},\(9\)𝒲t\\displaystyle\\mathcal\{W\}\_\{t\}=\{max⁡\(1,nt−W\+1\),…,nt\},\\displaystyle=\\\{\\max\(1,n\_\{t\}\-W\+1\),\\ldots,n\_\{t\}\\\},\(sliding window\),\\displaystyle\\text\{\(sliding window\)\},𝒰t\\displaystyle\\mathcal\{U\}\_\{t\}=\{i:E<i≤nt\},\\displaystyle=\\\{i:E<i\\leq n\_\{t\}\\\},\(unindexed suffix\)\.\\displaystyle\\text\{\(unindexed suffix\)\}\.Their unionℱt=𝒮t∪𝒲t∪𝒰t\\mathcal\{F\}\_\{t\}=\\mathcal\{S\}\_\{t\}\\cup\\mathcal\{W\}\_\{t\}\\cup\\mathcal\{U\}\_\{t\}contains each position only once\. Using𝒫j\\mathcal\{P\}\_\{j\}for the member positions of pagejj, the complete candidate set is

𝒞t=ℱt∪\{i∈⋃j∈𝒥t𝒫j:1≤i≤min⁡\(E,nt\)\}\.\\mathcal\{C\}\_\{t\}=\\mathcal\{F\}\_\{t\}\\cup\\left\\\{i\\in\\bigcup\_\{j\\in\\mathcal\{J\}\_\{t\}\}\\mathcal\{P\}\_\{j\}:1\\leq i\\leq\\min\(E,n\_\{t\}\)\\right\\\}\.\(10\)The union removes duplicate positions shared by the retrieved pages and the directly included ranges\. We identify these overlaps using the stored original positions, since directional grouping changes the temporal order of members within each page\.

Each candidate is then scored using its actual indexing keykiIk\_\{i\}^\{I\}and the original scoring functionst​\(i\)s\_\{t\}\(i\)from Eq\. \([1](https://arxiv.org/html/2611.27233#S2.E1)\)\. The final selected positions are

𝒜t=Topmin⁡\(K,\|𝒞t\|\)⁡\{st​\(i\):i∈𝒞t\}\.\\mathcal\{A\}\_\{t\}=\\operatorname\{Top\}\_\{\\min\(K,\|\\mathcal\{C\}\_\{t\}\|\)\}\\\{s\_\{t\}\(i\):i\\in\\mathcal\{C\}\_\{t\}\\\}\.\(11\)All candidates compete in this single Top\-KK\. Sink, window, and unindexed positions are always included in the candidate set, but none receives a reserved place in𝒜t\\mathcal\{A\}\_\{t\}\. The candidate count satisfies\|𝒞t\|≤Cpage​Kpage\+\|ℱt\|\|\\mathcal\{C\}\_\{t\}\|\\leq C\_\{\\mathrm\{page\}\}K\_\{\\mathrm\{page\}\}\+\|\\mathcal\{F\}\_\{t\}\|\. We useS=64S=64sink positions and a sliding window ofW=512W=512indexing positions by default\. The page budgetKpageK\_\{\\mathrm\{page\}\}controls how many historical pages enter refinement, whileKKcontrols how many positions are selected from the combined candidate set for attention\.

During prefill, candidates shared by overlapping directly included ranges are stored once, with per\-query references and masks preserving each query’s visible set\. Selected candidate slots are mapped to original logical positions and expanded to token positions when required\. The main attention then computes its own scores and normalization over the corresponding KV entries\.

## 4Kernel Design and Execution Optimizations

The LRSA implementation organizes indexing keys and group centers in a paged layout, with a member\-position map linking reordered keys to their original logical positions\. This layout supports recursive index construction and page\-based retrieval, with kernel fusion reducing their execution overhead\. During refinement, queries within a prefill chunk share storage for overlapping fixed candidates, reducing repeated data transfers\. This section describes how these storage and execution choices implement the retrieval procedure\.

### 4\.1Paged Index Storage and Logical Position Mapping

The grouping procedure in Section[3\.2](https://arxiv.org/html/2611.27233#S3.SS2)defines which keys belong to each retrieval page\. We materialize these pages in a reordered member pool, where each reordered physical page containsCpageC\_\{\\mathrm\{page\}\}keys organized asNgrpN\_\{\\mathrm\{grp\}\}complete groups\. Construction copies the source FP8 keys and their scales into this pool according to the final grouping permutation\. Keys within a reordered physical page occupy consecutive slots, but different pages may be allocated at noncontiguous locations\. Refinement reads the indexing keys from the reordered pages selected by coarse retrieval\.

Within each reordered page, the scoring backend stores FP8 vector elements and one FP32 scale per vector\. The vector elements form a contiguous block followed by the scales\. WithCpage=64C\_\{\\mathrm\{page\}\}=64and indexing dimensiondI=128d\_\{I\}=128, the packed layout is

64×128​bytes⏟FP8 keys:8192bytes∥64×4​bytes⏟FP32 scales:256bytes,\\underbrace\{64\\times 128\\ \\text\{bytes\}\}\_\{\\text\{FP8 keys: \}8192\\ \\text\{bytes\}\}\\;\\\|\\;\\underbrace\{64\\times 4\\ \\text\{bytes\}\}\_\{\\text\{FP32 scales: \}256\\ \\text\{bytes\}\},\(12\)where∥\\\|denotes concatenation in memory\. Each page occupiesDpage=8448D\_\{\\mathrm\{page\}\}=8448bytes\.

Centers use the same packed format\. Each member page containsNgrpN\_\{\\mathrm\{grp\}\}groups, each represented by one center\. TheseNgrpN\_\{\\mathrm\{grp\}\}centers are stored consecutively so that their scores can be reduced to a single member\-page score\. A*center storage page*holdsCpageC\_\{\\mathrm\{page\}\}centers and therefore describes multiple member pages\. Coarse selection reads the centers, while refinement reads the keys in the selected reordered member pages\. With the default capacities, one bucket produces 16 member pages and two center storage pages\.

To preserve each key’s original logical indexing position after reordering, we construct a member\-position map alongside the reordered pages\. When a key is copied to reordered physical pagepreordp\_\{\\mathrm\{reord\}\}at within\-page slotoo, the map records its original logical positionii:

i=π⁡\(preord,o\)\.i=\\pi\(p\_\{\\mathrm\{reord\}\},o\)\.\(13\)This map recovers each historical candidate’s logical position from its reordered page and slot\. Before final Top\-KK, these positions identify retrieved members that also appear in the sink or sliding\-window ranges\. Masking these historical duplicates retains one candidate per logical position\. After Top\-KKselection, the same map converts the selected historical slots into logical positions\. The attention backend uses these positions to access the corresponding KV entries and compute attention\.

### 4\.2Recursive Index Construction and Kernel Fusion

Index construction consists of initialization, recursive partitioning, and final assembly\. Initialization reads a complete bucket ofBBFP8 indexing keys, dequantizes them using their associated scales, and normalizes the vectors for directional grouping\. Recursive partitioning then divides the bucket into groups ofCgrpC\_\{\\mathrm\{grp\}\}members\. Assembly copies the keys into the resulting page order, records their logical positions, and computes the group centers\.

A straightforward implementation of one partitioning round uses six successive kernel launches\. Within each current group, it \(1\) computes dot products with the reference member, \(2\) selects the first anchori−i\_\{\-\}, \(3\) computes dot products with that anchor, \(4\) selects the second anchori\+i\_\{\+\}, \(5\) computes each member’s directional preferenceδi\\delta\_\{i\}, and \(6\) stably sorts the members by preference\. The sorted members are split into two capacity\-balanced child groups for the next round\. All groups at the same recursion depth are processed in parallel; the next round begins once the current round completes\.

ForB=1024B=1024andCgrp=8C\_\{\\mathrm\{grp\}\}=8, the group size decreases as

1024→512→256→128→64→32→16→8\.1024\\rightarrow 512\\rightarrow 256\\rightarrow 128\\rightarrow 64\\rightarrow 32\\rightarrow 16\\rightarrow 8\.\(14\)These seven rounds produce 128 leaf groups of eight members each\. With one launch per stage across all groups at a given depth, the straightforward schedule requires 42 partitioning launches per bucket, excluding initialization and assembly\. We reduce data movement by updating only member indices during recursion, and reduce kernel launches by fusing stages according to group size\.

We keep normalized vectors in their original bucket order and update only integer member indices between rounds\. LetΠin\\Pi\_\{\\mathrm\{in\}\}map the current list positions to original bucket members\. For a positionzzin the output list, letρ⁡\(z\)\\rho\(z\)denote the input position of the member placed atzzby the within\-group sort\. Each round writes

Πout​\[z\]=Πin​\[ρ⁡\(z\)\]\.\\Pi\_\{\\mathrm\{out\}\}\[z\]=\\Pi\_\{\\mathrm\{in\}\}\[\\rho\(z\)\]\.\(15\)Sorting reads member indices fromΠin\\Pi\_\{\\mathrm\{in\}\}and writes the updated order toΠout\\Pi\_\{\\mathrm\{out\}\}\. Separate input and output buffers prevent newly written indices from overwriting those that other threads still need to read\. The buffers exchange roles for the next round\. Updating only member indices avoids moving full key vectors at every recursion depth\.

We choose the fusion granularity according to group size\. Fusing an entire partitioning round for a large group would increase the working set held by each cooperative thread array \(CTA\), raising register pressure and potentially causing register spilling that degrades performance\. For large groups, we therefore fuse only two pairs of stages: first\-anchor selection with the subsequent anchor scoring, and second\-anchor selection with preference scoring, resulting in four kernel launches per round\. For small groups, the smaller working set allows a single CTA to fuse all six stages into one kernel, reusing loaded vectors and avoiding intermediate score writes between stages\. WithB=1024B=1024andCgrp=8C\_\{\\mathrm\{grp\}\}=8, group sizes 1024, 512, 256, and 128 use the four\-launch schedule, while sizes 64, 32, and 16 use the fully fused schedule\. The seven partitioning rounds therefore require 19 launches\. This group\-size\-dependent design balances register demand and parallelism against launch overhead and intermediate memory traffic\.

Once partitioning reaches the leaf groups, a single assembly pass follows the final permutation to write reordered member pages and their position maps\. The same loaded keys are used to compute group centers from their dequantized, unnormalized values\. Member keys retain their source FP8 values and scales, while centers are quantized with their own scales\. The completed bucket is then published through the asynchronous schedule described in Section[3\.1](https://arxiv.org/html/2611.27233#S3.SS1)\.

*Fused Page Reduction and Selection\.*After center scoring, coarse retrieval computes page scores, selects pages, and writes their reordered physical page indices for refinement\. We fuse these three operations into a single routing kernel, assigning one CTA to each query\. For each member page, the CTA takes the maximum of itsNgrpN\_\{\\mathrm\{grp\}\}center scores to obtain the page score\. It then selects the Top\-KpageK\_\{\\mathrm\{page\}\}pages using block\-level radix sorting and directly writes their reordered physical page indices for refinement\. This fusion of max reduction, Top\-KpageK\_\{\\mathrm\{page\}\}selection, and output writing avoids intermediate page\-score writes to global memory and reduces kernel launches\.

### 4\.3Shared Candidate Storage for Chunked Prefill

Refinement jointly scores retrieved historical keys and the fixed candidates comprising sink, sliding\-window, and unindexed keys\. These two sets initially reside in different layouts: historical keys are stored in the reordered member pool, while fixed candidates remain in the source indexing\-key storage\. The DeepGEMM paged scoring backend accepts a single key\-pool base address, so we copy the fixed candidates into a reserved region of the reordered pool\. Both sets can then be scored through the same paged interface\. During chunked prefill, however, neighboring queries use largely overlapping sink and fixed\-tail ranges\. Preparing a separate copy for each query would repeatedly transfer the same keys and scales\.

To avoid these repeated transfers, we construct a single shared copy of the fixed candidates for one prefill chunk\. Consider itsRRconsecutive queries with nondecreasing visible lengthsn1,…,nRn\_\{1\},\\ldots,n\_\{R\}and a common published index boundaryEE\. Each query’s fixed candidates consist of a sink prefix and a fixed tail covering its sliding window and visible unindexed suffix\. After excluding overlap with the sink prefix, letτ1\\tau\_\{1\}denote the logical boundary immediately before the first query’s fixed tail\. This tail contains positions\{τ1\+1,…,n1\}\\\{\\tau\_\{1\}\+1,\\ldots,n\_\{1\}\\\}\. Across the chunk, the first query determines the start of the required fixed\-tail range, while the last query determines the final visible positionnRn\_\{R\}\. The logical positions to copy are therefore

ℱshared=\{1,…,min⁡\(S,nR\)\}⏟sink positions∪\{τ1\+1,…,nR\}⏟fixed\-tail positions\.\\mathcal\{F\}\_\{\\mathrm\{shared\}\}=\\underbrace\{\\\{1,\\ldots,\\min\(S,n\_\{R\}\)\\\}\}\_\{\\text\{sink positions\}\}\\;\\cup\\;\\underbrace\{\\\{\\tau\_\{1\}\+1,\\ldots,n\_\{R\}\\\}\}\_\{\\text\{fixed\-tail positions\}\}\.\(16\)This union covers the fixed candidates needed by every query in the chunk, including the full visible unindexed suffix, and counts overlapping positions only once\.

We copy the keys and scales forℱshared\\mathcal\{F\}\_\{\\mathrm\{shared\}\}into a reserved region of the reordered pool, where they are stored as shared pages in the same packed format as the historical member pages\. The shared region stores the sink portion followed by the remaining fixed\-tail portion\. Copies are page\-aligned, and each required source page is transferred only once\. Page alignment may include positions outside the required ranges; query\-specific boundaries exclude those positions during refinement\.

During refinement, each query references its selected reordered historical pages and the shared pages covering its own sink and fixed\-tail ranges\. These references allow queries to reuse the shared storage without creating additional per\-query copies\. Query\-specific lengths and masks exclude page padding and future positions, while the logical position map identifies historical members duplicated by the sink or sliding\-window ranges\. Thus, the queries share stored keys but retain their own candidate sets and scores\.

The reduction in copying depends on the overlap among fixed candidate ranges\. Let𝒱t\\mathcal\{V\}\_\{t\}denote the source\-page set covering the fixed candidates of querytt\. WithDpageD\_\{\\mathrm\{page\}\}bytes per packed page, the copied data volumes for separate per\-query copies and shared storage are

Dprivate=Dpage​∑t=1R\|𝒱t\|,Dshared=Dpage​\|⋃t=1R𝒱t\|\.D\_\{\\mathrm\{private\}\}=D\_\{\\mathrm\{page\}\}\\sum\_\{t=1\}^\{R\}\|\\mathcal\{V\}\_\{t\}\|,\\qquad D\_\{\\mathrm\{shared\}\}=D\_\{\\mathrm\{page\}\}\\left\|\\bigcup\_\{t=1\}^\{R\}\\mathcal\{V\}\_\{t\}\\right\|\.\(17\)A source page needed by several queries contributes once to the shared copy, instead of once per query\.

## 5Runtime Index Management and Reuse in SGLang

The LRSA runtime in SGLang maintains index state for each request and attention layer, coordinating asynchronous construction with queries over the published index\. Prefix matches in the original KV pool enable reuse of complete bucket indices or assembled member pages, while retention policies determine how long these resources remain available to subsequent requests\. This section describes how request management, index reuse, and retention support ongoing inference while balancing index storage against repeated construction\.

### 5\.1Request State and Asynchronous Index Construction

The attention backend connects retrieval to model execution\. Once the current layer’s indexing keys and original KV entries are available, LRSA retrieves from the published index and returns logical positions to the model’s attention backend\. After attention, the backend submits construction tasks for newly filled buckets\. Model projections and the original KV cache retain their existing roles; the additional runtime state tracks the index used to select attention positions\.

Prefix matching in the original KV cache identifies reusable source state, while a lookup in the derived index determines whether an existing bucket record can be reused without reconstruction\. Each query’s visible length determines which positions may participate in retrieval\. The original KV cache, reordered index pool, and request\-local page references have distinct roles and lifetimes\.

For a fixed request, layer, and indexing\-key head, we represent the retrieval state as

ℛ=\(id,ℒ,𝖳mem,𝖳ctr,E,ℰ\),\\mathcal\{R\}=\\left\(\\mathrm\{id\},\\mathcal\{L\},\\mathsf\{T\}\_\{\\mathrm\{mem\}\},\\mathsf\{T\}\_\{\\mathrm\{ctr\}\},E,\\mathcal\{E\}\\right\),\(18\)whereid\\mathrm\{id\}uniquely identifies the request,ℒ\\mathcal\{L\}is the ordered list of bucket records,𝖳mem\\mathsf\{T\}\_\{\\mathrm\{mem\}\}and𝖳ctr\\mathsf\{T\}\_\{\\mathrm\{ctr\}\}contain member\-page and center\-page references, andℰ\\mathcal\{E\}contains the completion events associated with index updates\. As in Section[3\.1](https://arxiv.org/html/2611.27233#S3.SS1),EEmarks the end of the published index prefix available to queries\. Each bucket record associates its logical range with its centers, reordered member pages, and position maps\. Queries access these records and the published boundary together as a consistent index snapshot\. Visible positions beyondEEremain fixed refinement candidates, as defined in Section[3\.3](https://arxiv.org/html/2611.27233#S3.SS3)\.

Index updates begin on the CPU, which checks tensor shapes and available capacity, allocates new buckets, and prepares source\-page metadata\. Host\-side locks protect record allocation and updates to request containers and record metadata\. After the current layer’s attention, the CPU submits the prepared work to a dedicated CUDA stream\. CUDA event dependencies ensure that preceding operations on shared construction workspaces and the reordered\-page allocator, including its free\-page stack, complete before this stream accesses those resources\. The GPU then groups the keys, assembles pages, and verifies potential matches in the reordered pool\. It atomically increments reference counts for reusable pages and allocates storage from the free pool for unmatched pages\. Allocation, publication, and reclamation follow the same cross\-stream ordering so that shared resources remain valid throughout their use\.

Once the new index records have been published, the construction stream records a completion event\. While construction proceeds, the foreground stream continues with subsequent layers and independent computation, enabling the asynchronous overlap described in Section[3\.1](https://arxiv.org/html/2611.27233#S3.SS1)\. Before the next query batch uses the updated index at the same layer, its stream waits on that event and then reads the page references, centers, member position maps, andEEfrom the completed update\.

### 5\.2Prefix\-Based Reuse of Bucket Indices and Member Pages

Following a prefix match in the original KV pool, index reuse can occur before bucket construction or after page assembly\. These two forms of reuse avoid different costs: reusing a complete bucket avoids rebuilding its index, while sharing assembled member pages reduces duplicate storage\.

*Complete bucket reuse\.*The matched original KV prefix must extend through the end of the bucket, covering both the entire bucket and its preceding context\. We associate each such cached prefix with its complete bucket record\. For bucketℬm\\mathcal\{B\}\_\{m\}, the reuse identity is

ℐm=\(ξm,ℬm,λ,hI,θ\),\\mathcal\{I\}\_\{m\}=\\left\(\\xi\_\{m\},\\mathcal\{B\}\_\{m\},\\lambda,h\_\{I\},\\theta\\right\),\(19\)whereξm\\xi\_\{m\}identifies the logical prefix through the end of the bucket,λ\\lambdaandhIh\_\{I\}identify the layer and indexing\-key head, andθ\\thetaspecifies the model state, key representation, and construction configuration\. When the prefix match covers the complete bucket and the remaining compatibility fields agree, the backend checks that the associated record and its index resources remain valid\. It then acquires a reference, establishes the record’s completion dependency, and attaches the existing center\-page and member\-page references to the request\. This path skips grouping, center construction, and page assembly\. If the associated index has been reclaimed, the bucket must instead be rebuilt from valid source keys\. Complete bucket reuse therefore requires both a matching original KV prefix and a valid index record for that bucket\.

*Page reuse after construction\.*When a bucket within the matched prefix requires construction, assembly produces temporary member pages and their position maps\. We generate fingerprints for each page from its packed keys, scales, and member positions, then compare them with the fingerprints of live pages to identify potential matches\. A full comparison of the page contents and position maps confirms equality\. For each confirmed match, the bucket acquires a reference to the existing page; unmatched pages receive new storage\. Each bucket retains its own center records and references the resulting member pages\. This path still performs grouping, assembly, and content checking, but avoids storing another copy of each matching member page\.

### 5\.3Index Retention Policies and Storage Tradeoffs

The reuse mechanisms determine which index resources can be shared, while the retention policy determines how long they remain available\. We design two policies that differ in whether the prefix cache of the original KV pool retains bucket records and their associated reordered index resources after active requests finish or allows them to be reclaimed\. Both policies support page\-level sharing and, with a valid prefix\-to\-index association, complete bucket reuse\.

*Request\-scoped retention\.*Active requests hold bucket records until their GPU operations complete\. Once the last active holder releases a record, the record and any index resources no longer held elsewhere can be reclaimed, even if the matching prefix remains cached in the original KV pool\. This keeps the live index working set tied to active requests and frees capacity for new buckets rather than retaining indices for inactive prefixes\. A new request that matches a cached prefix in the original KV pool can reuse its compatible bucket record while that record remains held\. Once the record has been reclaimed, however, the same prefix match requires index reconstruction\. Repeated requests can therefore incur repeated grouping, center construction, and page matching\.

*Prefix\-cache retention\.*The prefix cache of the original KV pool holds the bucket records associated with compatible cached prefixes\. After a request completes, the cache retains the centers, reordered member pages, and position maps for subsequent requests\. This extends complete bucket reuse beyond the active request lifetime, allowing a valid hit to skip construction while both the original KV prefix and its index remain cached\. Evicting that prefix from the original KV pool releases the cache’s references to its bucket records\. Reclamation waits until all remaining holders release their references and outstanding GPU accesses complete\. This longer reuse window comes at the cost of retaining index resources for inactive prefixes\. Under a fixed GPU memory budget, this storage competes with original KV entries, active indices, and execution workspaces\.

The choice therefore depends on prefix reuse in the original KV pool and available capacity\. Request\-scoped retention limits inactive index residency but may require repeated construction; prefix\-cache retention preserves more reusable work but can reduce the capacity available to other requests\. A separate index\-cache budget can limit index residency while preserving cached prefixes in the original KV pool, with missing indices rebuilt on subsequent prefix hits\.

## 6Experiments and Results

We evaluate LRSA’s downstream task performance and inference efficiency\. We further analyze how index organization affects retrieval quality and how kernel optimizations and asynchronous index maintenance contribute to execution efficiency\.

### 6\.1Setup

*Models, datasets, and baselines\.*We evaluate task quality with Qwen3\-4B\-Instruct\-2507\([Yang et al\., 2025](https://arxiv.org/html/2611.27233#bib.bib13)\)and Hunyuan\-7B\-Instruct\-0124 on representative datasets: NarrativeQA\([Kociský et al\., 2017](https://arxiv.org/html/2611.27233#bib.bib21)\), MuSiQue\([Trivedi et al\., 2021](https://arxiv.org/html/2611.27233#bib.bib14)\), HotpotQA\([Yang et al\., 2018](https://arxiv.org/html/2611.27233#bib.bib22)\), TriviaQA\([Joshi et al\., 2017](https://arxiv.org/html/2611.27233#bib.bib20)\), TREC\([Li and Roth, 2002](https://arxiv.org/html/2611.27233#bib.bib15)\), 2WikiMQA\([Ho et al\., 2020](https://arxiv.org/html/2611.27233#bib.bib16)\), DuReader\([He et al\., 2017](https://arxiv.org/html/2611.27233#bib.bib17)\), LSHT, QMSum\([Zhong et al\., 2021](https://arxiv.org/html/2611.27233#bib.bib18)\), and Qasper\([Dasigi et al\., 2021](https://arxiv.org/html/2611.27233#bib.bib19)\)\. These tasks cover document question answering, multi\-hop reasoning, few\-shot classification, and summarization\. We report each task’s official score on a scale from zero to one hundred, together with the unweighted mean across tasks\. We compare against dense attention, which attends to all causally visible positions, and DSA\([DeepSeek\-AI, 2025](https://arxiv.org/html/2611.27233#bib.bib1)\), which exhaustively scores all causally visible keys and selects the exact Top\-KKpositions\. Under the same indexing function and selection budget, DSA maximizes the sum of selected\-key scores, providing an optimal reference for the key\-selection objective\. We evaluate how closely LRSA approaches this reference while reducing retrieval cost\. DSA and LRSA use a matching final selection budget of 2048 tokens for task\-quality evaluation and budgets of 2048, 1024, and 512 tokens for the end\-to\-end comparisons\.

*Implementation details\.*We run our experiments on NVIDIA H20 GPUs\. The end\-to\-end implementation runs in SGLang, stores model weights and original KV entries in BF16, and gathers selected KV entries for attention computation with FlashAttention\-3\. By default, the bucket capacity isB=1024B=1024\. Within each bucket, capacity\-balanced grouping based on cosine similarity placesCgrp=8C\_\{\\mathrm\{grp\}\}=8keys in each group\. Each page containsNgrp=8N\_\{\\mathrm\{grp\}\}=8complete groups, giving a page capacity ofCpage=64C\_\{\\mathrm\{page\}\}=64members\. A group center is the mean of its members’ unnormalized indexing keys; both keys and centers are stored in FP8 with FP32 scales\. Coarse retrieval scores each page by the maximum score of its group centers\. We set the reference page budgetKpageK\_\{\\mathrm\{page\}\}to the number of pages needed to achieve a mean all\-position attention\-mass recall \(AMR\) of 95% across all queries\. AMR is defined in Section[6\.5](https://arxiv.org/html/2611.27233#S6.SS5)\. Refinement applies the original scoring function to the retrieved page members and candidates fromS=64S=64sink positions, a sliding window ofW=512W=512indexing positions, and the visible unindexed suffix, then selects the final Top\-KKpositions\. These settings remain fixed unless explicitly varied in the corresponding experiment\.

### 6\.2Performance on Downstream Tasks

Table 1:Performance of dense attention, DSA, and LRSA across ten downstream tasks\. DSA and LRSA use the same final selection budget of 2048 tokens\.TaskQwen3\-4B\-Instruct\-2507Hunyuan\-7B\-Instruct\-0124DenseDSALRSADenseDSALRSANarrativeQA27\.4527\.9427\.2622\.9822\.6423\.17MuSiQue25\.4022\.7223\.2329\.9128\.9528\.72HotpotQA58\.9557\.0657\.5451\.3853\.3153\.38TriviaQA85\.2384\.4784\.2779\.8779\.7879\.42TREC74\.0074\.5074\.5063\.5062\.5062\.002WikiMQA43\.5344\.4244\.3045\.5946\.6146\.20DuReader26\.6426\.5426\.5831\.2731\.2731\.50LSHT43\.5047\.0046\.0027\.1626\.3726\.25QMSum22\.3722\.7522\.5223\.6724\.3924\.26Qasper44\.8643\.7244\.1844\.2943\.4543\.59Average45\.1945\.1145\.0441\.9641\.9341\.85We evaluate whether LRSA preserves downstream task performance when approximating DSA’s optimal selection under the indexing objective\. DSA exhaustively scores all causally visible keys and returns the exact Top\-K positions at the specified budget\. LRSA narrows the historical candidate set through page selection, then applies the same scoring function to the retrieved members and fixed candidates during refinement\. Comparing the two at the same final budget therefore measures how closely LRSA’s approximate retrieval preserves the downstream task performance obtained with exhaustive selection\.

Table[1](https://arxiv.org/html/2611.27233#S6.T1)shows that LRSA closely matches DSA’s average performance on both models at a final selection budget of 2048 tokens\. The absolute difference in the ten\-task average is at most 0\.08 points on a hundred\-point scale\. On Qwen3\-4B\-Instruct\-2507, LRSA scores 45\.04 compared with DSA’s 45\.11, a difference of 0\.07 points\. On Hunyuan\-7B\-Instruct\-0124, LRSA scores 41\.85 compared with DSA’s 41\.93, a difference of 0\.08 points\. These results indicate that LRSA’s page\-based retrieval closely preserves the average downstream performance obtained with exhaustive key selection\.

### 6\.3Impact of Kernel Fusion and Candidate Sharing

We examine how kernel fusion and candidate sharing reduce the cost of index construction and candidate preparation\. We measure partitioning latency under different fusion schedules and copying latency with and without shared fixed\-candidate storage, evaluating the optimizations in Sections[4\.2](https://arxiv.org/html/2611.27233#S4.SS2)and[4\.3](https://arxiv.org/html/2611.27233#S4.SS3)\.

Figure 2:Latency of recursive partitioning and fixed\-candidate copying\. \(a\) Partitioning latency for three fusion schedules as group size varies, with the total number of members per round held fixed\. \(b\) Candidate\-copying latency as chunk size varies, comparing per\-query copies with a shared copy\. Labels in \(b\) show the speedup from sharing\. Panel \(a\) uses a logarithmic latency axis; panel \(b\) uses a linear axis starting at zero\.*Group\-size\-dependent fusion\.*We compare three schedules for index partitioning: no fusion, full fusion, and our size\-aware fusion\. Our schedule selectively fuses stages for large groups and fuses the entire round for small groups\. We vary the group sizeNNwhile holding the total number of members processed per round fixed, allowing us to compare the schedules at the same workload\.

Figure[2](https://arxiv.org/html/2611.27233#S6.F2)\(a\) shows that the benefit of fusion depends on group size\. AtN=1024N=1024, full fusion takes 195\.06 microseconds, compared with 14\.61 microseconds without fusion and 12\.59 microseconds with our size\-aware schedule\. AtN=128N=128, the corresponding latencies are 11\.81, 9\.56, and 7\.51 microseconds\. For smaller groups \(N≤64N\\leq 64\), full fusion becomes faster than unfused execution\. Our schedule uses full fusion for these groups, and its latency closely matches the fully fused baseline\. AtN=16N=16, it reduces latency from 9\.16 microseconds without fusion to 2\.38 microseconds\. Across all measured group sizes, our schedule achieves a speedup of1\.16×1\.16\\timesto3\.85×3\.85\\timesover no fusion\. These results support fusing the entire round for small groups while using selective fusion for larger groups\.

*Shared fixed\-candidate copying\.*We compare copying fixed candidates separately for each query with preparing their union once for the entire chunk\. We vary chunk size from 16 to 1024 queries\. Figure[2](https://arxiv.org/html/2611.27233#S6.F2)\(b\) shows that per\-query copying latency rises from 2\.963 to 33\.916 microseconds, whereas shared copying latency increases only from 2\.492 to 3\.370 microseconds\. The resulting speedup increases from1\.19×1\.19\\timesto10\.06×10\.06\\times, reaching3\.08×3\.08\\timesat 256 queries and4\.52×4\.52\\timesat 512 queries\. This growing advantage comes from reusing keys in the overlapping sink and tail ranges of neighboring queries\. A shared copy serves more queries as the chunk grows, avoiding repeated transfers and limiting the increase in copying latency\.

### 6\.4Efficiency of Long\-Context Inference

We evaluate how LRSA’s retrieval design affects the cost of selecting keys, computing attention, and executing the full model across context lengths from 64K to 1024K tokens\. For key selection, we report LRSA’s speedup over DSA\. For attention computation, we include both key selection and sparse attention and compare DSA and LRSA with full attention\. For each comparison, speedup is the ratio of the reference method’s execution time to that of the evaluated method\.

Figure 3:Efficiency of key selection and attention across context lengths\. \(a\) Key\-selection speedup of LRSA over DSA\. \(b\) Speedups of DSA and LRSA over full attention; both sparse methods include key selection and attention computation\. Labels above LRSA bars give its speedup over the reference in each panel\. Dashed lines mark equal execution time \(1×1\\times\)\.Table 2:End\-to\-end speedup of LRSA over DSA across context lengths and final selection budgets\.ContextlengthSelection budget2048102451264K1\.144×1\.144\\times1\.130×1\.130\\times1\.125×1\.125\\times128K1\.249×1\.249\\times1\.333×1\.333\\times1\.329×1\.329\\times256K1\.667×1\.667\\times1\.702×1\.702\\times1\.738×1\.738\\times512K1\.638×1\.638\\times1\.762×1\.762\\times1\.755×1\.755\\times1024K1\.865×1\.865\\times1\.957×1\.957\\times1\.984×1\.984\\timesFigure[3](https://arxiv.org/html/2611.27233#S6.F3)\(a\) shows that LRSA achieves key\-selection speedups over DSA of1\.72×1\.72\\timesat 64K and4\.70×4\.70\\timesat 1024K\. DSA scores the full visible context, whereas LRSA uses page\-level retrieval to restrict fine\-grained scoring to selected historical members and fixed candidates\. This smaller search space becomes increasingly beneficial as the context grows\. When both selection and sparse attention are included, LRSA achieves speedups over full attention of3\.77×3\.77\\timesat 64K and35\.60×35\.60\\timesat 1024K; the corresponding DSA speedups are3\.25×3\.25\\timesand12\.70×12\.70\\times\(Figure[3](https://arxiv.org/html/2611.27233#S6.F3)\(b\)\)\. These results show that LRSA’s selection gains remain evident when the subsequent sparse attention computation is included\.

To examine how these gains translate to full\-model inference, we also compare DSA and LRSA over the same range of context lengths, using matching final selection budgets of 2048, 1024, and 512 tokens\. The end\-to\-end measurement includes model execution together with index construction and incremental maintenance, candidate preparation, position handling, scheduling gaps, and synchronization\. The resulting speedup therefore reflects the net benefit of LRSA within full\-model execution, with index\-management costs included\.

Table[2](https://arxiv.org/html/2611.27233#S6.T2)shows that LRSA is faster than DSA across all evaluated context lengths and selection budgets\. At 64K, the speedup ranges from1\.125×1\.125\\timesto1\.144×1\.144\\timesacross the three budgets\. It reaches1\.25×1\.25\\timesto1\.33×1\.33\\timesat 128K and1\.67×1\.67\\timesto1\.74×1\.74\\timesat 256K\. At 512K and 1024K, the ranges are1\.64×1\.64\\timesto1\.76×1\.76\\timesand1\.86×1\.86\\timesto1\.98×1\.98\\times, respectively\. LRSA thus retains an end\-to\-end advantage over DSA after accounting for index maintenance, with the largest gains observed at the longest evaluated context\.

### 6\.5Ablation Studies

We ablate the main choices in LRSA’s index organization: bucket capacity, group capacity, page representation, page\-score aggregation, and directional grouping\. For each comparison in Figure[4](https://arxiv.org/html/2611.27233#S6.F4), we change one setting while holding the queries, fixed candidates, page capacity, and selection budgets constant\. Figure[5](https://arxiv.org/html/2611.27233#S6.F5)further compares directional and temporal grouping at matched page budgets and over a budget sweep\.

Figure 4:Ablations of index organization across five context lengths\. The top row reports all\-position AMR and the bottom row historical AMR\. Panels \(a, d\) vary bucket capacity, and panels \(b, e\) vary group capacity\. In these panels, colors denote context lengths and vertical dashed lines mark the default capacities\. Panels \(c, f\) compare the default with two variants: one mean center per page and mean aggregation of group scores\. Each variant changes only the corresponding design choice\. Page capacity and selection budgets are held fixed within each comparison\. Points report mean AMR\.*Attention\-mass recall\.*To make differences in retrieval quality more apparent, we use attention\-mass recall \(AMR\), which measures how much reference attention mass is preserved by the selected positions\. Weighting each recovered position by its attention contribution makes AMR sensitive to the importance of the keys retained by each index design\. Let𝒟q\\mathcal\{D\}\_\{q\}and𝒱q\\mathcal\{V\}\_\{q\}be the original token positions selected by DSA and LRSA for queryqq, and letaq​h​ia\_\{qhi\}be the reference attention weight at positioniifor headhh, obtained by normalizing the attention logits over𝒟q\\mathcal\{D\}\_\{q\}with softmax\. We define

AMRq​h=∑i∈𝒟q∩𝒱qaq​h​i,AMRq​hhist=∑i∈ℋq∩𝒱qaq​h​i∑i∈ℋqaq​h​i,\\operatorname\{AMR\}\_\{qh\}=\\sum\_\{i\\in\\mathcal\{D\}\_\{q\}\\cap\\mathcal\{V\}\_\{q\}\}a\_\{qhi\},\\qquad\\operatorname\{AMR\}^\{\\mathrm\{hist\}\}\_\{qh\}=\\frac\{\\sum\_\{i\\in\\mathcal\{H\}\_\{q\}\\cap\\mathcal\{V\}\_\{q\}\}a\_\{qhi\}\}\{\\sum\_\{i\\in\\mathcal\{H\}\_\{q\}\}a\_\{qhi\}\},\(20\)whereℋq\\mathcal\{H\}\_\{q\}is the subset of𝒟q\\mathcal\{D\}\_\{q\}outside the sink and sliding\-window ranges\. All\-position AMR measures the fraction of DSA’s selected attention mass retained by LRSA\. Historical AMR excludes the contribution of the shared sink and sliding\-window positions, making differences among index designs more apparent without dilution by these fixed candidates\.

Figure 5:Ablation of directional grouping using temporal grouping as the control\. The left and right columns report all\-position and historical AMR, respectively\. Panels \(a, b\) compare the two methods at matched reference page budgets, with colors distinguishing the methods\. Panels \(c, d\) show the trade\-off between AMR and selection latency as the page budget varies; colors denote context lengths, and each point corresponds to one page\-budget setting\. In all panels, solid lines with circles indicate directional grouping, and dashed lines with squares indicate temporal grouping\.*Bucket capacity\.*Figure[4](https://arxiv.org/html/2611.27233#S6.F4)\(a, d\) shows that enlarging the bucket initially improves recall, but the benefit does not increase monotonically with capacity\. IncreasingBBfrom 1024 to 2048 improves historical AMR at all five lengths by 0\.11 to 0\.85 percentage points\. A further increase to 4096 lowers historical AMR at 64K from 95\.75% to 95\.09%, while raising it at 128K from 94\.85% to 95\.09%\. Across lengths,B=2048B=2048achieves a mean historical AMR of 94\.83%, compared with 94\.65% forB=4096B=4096\. These results suggest that a broader grouping scope can improve retrieval, but the benefit depends on context length and does not necessarily increase with bucket capacity\.

*Representative granularity\.*Figure[4](https://arxiv.org/html/2611.27233#S6.F4)\(b, e\) shows that finer groups improve recall while page capacity remains fixed\. ReducingCgrpC\_\{\\mathrm\{grp\}\}from 8 to 4 yields historical AMR gains of 0\.32 to 1\.23 percentage points across the five lengths\. Conversely, settingCgrp=64C\_\{\\mathrm\{grp\}\}=64, so that one center represents the entire page, lowers historical AMR by 1\.13 points at 64K and 3\.93 points at 1024K relative to the default\. To isolate representative granularity from page membership, the single\-center variant in Figure[4](https://arxiv.org/html/2611.27233#S6.F4)\(c, f\) keeps the default member pages and replaces each page’s group centers with one mean center\. This variant yields the same AMR asCgrp=64C\_\{\\mathrm\{grp\}\}=64at all five lengths because further partitioning within a page changes its group centers without changing its members\. Both comparisons support retaining fine\-grained group centers to capture relevant subsets of a page\.

*Page\-score aggregation\.*Replacing max aggregation with mean aggregation retains the same groups and centers but reduces historical AMR at every length \(Figure[4](https://arxiv.org/html/2611.27233#S6.F4)\(c, f\)\)\. The reduction grows from 1\.14 percentage points at 64K to 4\.19 points at 1024K\. This variant differs from the single\-center variant: it averages the group scores rather than their key vectors\. Although the two produce similar AMR in these experiments, both fall below the default\. The results support ranking a page by its strongest group response, so that a relevant group’s score is not diluted by less relevant groups on the same page\.

*Directional versus temporal grouping\.*We compare directional grouping with temporal grouping, which groups consecutive keys in their original sequence order\. The two methods use the same bucket, group, and page capacities, page\-scoring rule, fixed candidates, and final selection budgets\. We evaluate both on identical queries and historical prefixes, first at matched page budgets and then across a page\-budget sweep\.

At the reference page budgets, directional grouping improves all\-position AMR by 2\.84 to 4\.30 percentage points and historical AMR by 4\.58 to 6\.12 points across the five lengths \(Figure[5](https://arxiv.org/html/2611.27233#S6.F5)\(a, b\)\)\. These are aggregate gains; individual comparisons can still show a decrease in historical AMR\. The budget sweep complements this comparison by showing how retrieval quality changes with selection latency \(Figure[5](https://arxiv.org/html/2611.27233#S6.F5)\(c, d\)\)\. At 1024K, directional grouping with twice the reference page budget achieves 98\.078% historical AMR in 3\.1131 ms\. Temporal grouping with four times the budget reaches 97\.383% in 4\.8908 ms\. At these measured operating points, directional grouping retains more attention mass with a smaller page budget and a selection speedup of1\.57×1\.57\\times\.

### 6\.6Evaluating Overlap in Index Maintenance

We evaluate how much index\-maintenance overhead can be hidden by model execution between consecutive chunks\. Keeping the model computation fixed, we compare execution without index maintenance, with serial maintenance, and with asynchronous maintenance at a single layer\. We also measure index construction in isolation to assess its cost relative to the available execution window\. We set bucket capacity equal to chunk size and evaluate capacities of 256, 512, 1024, 2048, and 4096 across context lengths from 8K to 256K tokens\.

Figure 6:Overlap between index maintenance and model execution\. Colors and marker shapes identify five bucket capacities\. \(a\) Model\-only execution window\. \(b\) Isolated index\-construction time\. \(c\) Execution\-time difference relative to the model\-only baseline\. In \(c\), dashed lines with open markers indicate serial maintenance, while solid lines with filled markers indicate overlap\. All points show median measurements\. The vertical axis is logarithmic in \(a\) and linear in \(b, c\)\.We time the interval from the completion of attention at the monitored layer in one chunk to the start of attention at that layer in the next chunk, including any wait for index publication\. This givesTwindowT\_\{\\mathrm\{window\}\}for model\-only execution,TserialT\_\{\\mathrm\{serial\}\}with serial maintenance, andToverlapT\_\{\\mathrm\{overlap\}\}with asynchronous maintenance\. The isolated construction timeTbuildT\_\{\\mathrm\{build\}\}measures the same index update without concurrent model computation\. For each repeatrr, we compute the execution\-time difference from the model\-only baseline as

Δ​Tm\(r\)=Tm\(r\)−Twindow\(r\),m∈\{serial,overlap\}\.\\Delta T\_\{m\}^\{\(r\)\}=T\_\{m\}^\{\(r\)\}\-T\_\{\\mathrm\{window\}\}^\{\(r\)\},\\qquad m\\in\\\{\\mathrm\{serial\},\\mathrm\{overlap\}\\\}\.\(21\)Differences are computed for each repeat before taking the median\. Context lengths refer to the chunk that consumes the updated index\.

Figure[6](https://arxiv.org/html/2611.27233#S6.F6)\(a, b\) shows that the measured model execution windows substantially exceed isolated construction times across all five bucket capacities\. Median window durations range from 37\.793 to 4413\.542 ms, whereas isolated construction takes 1\.498 to 2\.778 ms\. Because bucket capacity and chunk size are equal in this experiment, larger buckets also yield longer model\-execution windows\. These windows provide an opportunity to overlap construction with model computation\. Figure[6](https://arxiv.org/html/2611.27233#S6.F6)\(c\) shows the median execution\-time difference relative to the model\-only baseline\. Across configurations, this difference ranges from 0\.674 to 2\.277 ms for serial maintenance and from \-0\.378 to 0\.199 ms with overlap\. Median waiting time for index publication at the next chunk ranges from 2\.6 to 3\.5 microseconds, indicating that the updated index is available with little waiting at the point of use\.

## 7Conclusion and Future Work

We presented LongCat Recall Sparse Attention, which represents historical keys using the centers of capacity\-balanced directional groups, retrieves members by page, and maintains the index incrementally through time buckets\. Capacity constraints align complete groups with member\-page boundaries, allowing fine\-grained representatives to guide regular page access\. Fixed page capacities make the historical refinement workload predictable under a given page budget, while temporal buckets allow new keys to be indexed without regrouping existing history\. Kernel fusion during index construction and shared candidate storage reduce kernel launches and repeated data transfers, respectively\. Integration with SGLang extends the design to asynchronous updates, prefix\-based reuse, and index retention, connecting query\-time retrieval with index maintenance and resource management\.

Our current retrieval hierarchy uses two stages: center\-based page selection followed by member\-level refinement\. A deeper hierarchy could further narrow the search, but adding levels does not necessarily improve efficiency\. At progressively coarser levels, fewer representatives remain to be evaluated, so another level offers a smaller absolute reduction in scoring work while still introducing its own scoring and Top\-KKselection operations\. These additional costs can offset the savings from further narrowing the search\. An important direction for future work is therefore to design scoring and Top\-KKkernels that reduce the overhead of traversing multiple levels, with cross\-level fusion as one possible approach\. Such kernels could make deeper retrieval hierarchies more effective at reducing search cost for longer contexts\.

## References

- Baiet al\.\(2026\)Y\. Bai, Q\. Dong, T\. Jiang, X\. Lv, Z\. Du, A\. Zeng, J\. Tang, and J\. LiIndexCache: accelerating sparse attention via cross\-layer index reuse\.ArXivabs/2603\.12201\.Cited by:[§1](https://arxiv.org/html/2611.27233#S1.p2.1),[§2\.1](https://arxiv.org/html/2611.27233#S2.SS1.p4.1)\.
- Dasigiet al\.\(2021\)P\. Dasigi, K\. Lo, I\. Beltagy, A\. Cohan, N\. A\. Smith, and M\. GardnerA dataset of information\-seeking questions and answers anchored in research papers\.ArXivabs/2105\.03011\.Cited by:[§6\.1](https://arxiv.org/html/2611.27233#S6.SS1.p1.1)\.
- DeepSeek\-AI \(2025\)DeepSeek\-AIDeepSeek\-v3\.2: pushing the frontier of open large language models\.ArXivabs/2512\.02556\.Cited by:[§1](https://arxiv.org/html/2611.27233#S1.p1.1),[§2\.1](https://arxiv.org/html/2611.27233#S2.SS1.p1.1),[§6\.1](https://arxiv.org/html/2611.27233#S6.SS1.p1.1)\.
- Fuet al\.\(2026\)Y\. Fu, J\. Chang, Y\. Li, R\. Zhao, B\. Long, M\. M\. Kamani, S\. Jain, R\. Raman, T\. Safavi, S\. Gupta, P\. A\. Fashi, M\. Lee, J\. Demouth, and B\. RouhaniSPIN: shadow predictive indexer for sparse attention\.Cited by:[§2\.1](https://arxiv.org/html/2611.27233#S2.SS1.p3.1)\.
- Heet al\.\(2017\)W\. He, K\. Liu, J\. Liu, Y\. Lyu, S\. Zhao, X\. Xiao, Y\. Liu, Y\. Wang, H\. Wu, Q\. She, X\. Liu, T\. Wu, and H\. WangDuReader: a chinese machine reading comprehension dataset from real\-world applications\.pp\. 37–46\.Cited by:[§6\.1](https://arxiv.org/html/2611.27233#S6.SS1.p1.1)\.
- Hoet al\.\(2020\)X\. Ho, A\. D\. Nguyen, S\. Sugawara, and A\. AizawaConstructing a multi\-hop qa dataset for comprehensive evaluation of reasoning steps\.ArXivabs/2011\.01060\.Cited by:[§6\.1](https://arxiv.org/html/2611.27233#S6.SS1.p1.1)\.
- Jainet al\.\(2026\)S\. Jain, S\. Pampana, S\. Agarwal, Y\. Marathe, B\. Gopireddy, A\. M\. Parvathy, and S\. IdgunjiMLIPS: multi\-layer indexer pool sharing\.Cited by:[§2\.1](https://arxiv.org/html/2611.27233#S2.SS1.p4.1)\.
- Joshiet al\.\(2017\)M\. Joshi, E\. Choi, D\. S\. Weld, and L\. ZettlemoyerTriviaQA: a large scale distantly supervised challenge dataset for reading comprehension\.ArXivabs/1705\.03551\.Cited by:[§6\.1](https://arxiv.org/html/2611.27233#S6.SS1.p1.1)\.
- Kociskýet al\.\(2017\)T\. Kociský, J\. Schwarz, P\. Blunsom, C\. Dyer, K\. Hermann, G\. Melis, and E\. GrefenstetteThe narrativeqa reading comprehension challenge\.Transactions of the Association for Computational Linguistics6,pp\. 317–328\.Cited by:[§6\.1](https://arxiv.org/html/2611.27233#S6.SS1.p1.1)\.
- Li and Roth \(2002\)X\. Li and D\. RothLearning question classifiers\.pp\. 1–7\.Cited by:[§6\.1](https://arxiv.org/html/2611.27233#S6.SS1.p1.1)\.
- Liuet al\.\(2024\)G\. Liu, C\. Li, J\. Zhao, C\. Zhang, and M\. GuoClusterKV: manipulating llm kv cache in semantic space for recallable compression\.2025 62nd ACM/IEEE Design Automation Conference \(DAC\),pp\. 1–7\.Cited by:[§1](https://arxiv.org/html/2611.27233#S1.p3.1),[§2\.1](https://arxiv.org/html/2611.27233#S2.SS1.p7.1)\.
- Meng and Fang \(2026\)F\. Meng and T\. FangDoSA: dots sparse attention\.Cited by:[§2\.1](https://arxiv.org/html/2611.27233#S2.SS1.p5.1)\.
- Parket al\.\(2023\)J\. Park, J\. O’Brien, C\. Cai, M\. Morris, P\. Liang, and M\. S\. BernsteinGenerative agents: interactive simulacra of human behavior\.Proceedings of the 36th Annual ACM Symposium on User Interface Software and Technology\.Cited by:[§1](https://arxiv.org/html/2611.27233#S1.p1.1)\.
- Songet al\.\(2026\)J\. Song, Y\. Kim, and J\. KimJoint subspace sparse attention for efficient long\-context decoding\.Cited by:[§2\.1](https://arxiv.org/html/2611.27233#S2.SS1.p5.1)\.
- Tianet al\.\(2026\)Z\. Tian, K\. Liu, Z\. Yang, Y\. Su, Q\. Dang, Y\. Sha, K\. Deng, D\. Yu, Y\. Ma, J\. Li, and M\. ZhangPrism attention: proposal\-refined index sharing mechanism for efficient llms inference\.Cited by:[§2\.1](https://arxiv.org/html/2611.27233#S2.SS1.p4.1)\.
- Trivediet al\.\(2021\)H\. Trivedi, N\. Balasubramanian, T\. Khot, and A\. Sabharwal♫ MuSiQue: multihop questions via single\-hop question composition\.Transactions of the Association for Computational Linguistics10,pp\. 539–554\.Cited by:[§6\.1](https://arxiv.org/html/2611.27233#S6.SS1.p1.1)\.
- Wuet al\.\(2021\)J\. Wu, L\. Ouyang, D\. M\. Ziegler, N\. Stiennon, R\. Lowe, J\. Leike, and P\. F\. ChristianoRecursively summarizing books with human feedback\.ArXivabs/2109\.10862\.Cited by:[§1](https://arxiv.org/html/2611.27233#S1.p1.1)\.
- Xuet al\.\(2026\)Y\. Xu, F\. Meng, F\. Jiang, Y\. Wang, R\. Zhou, Z\. Wang, J\. Wu, Z\. Pan, X\. Tang, W\. Pei, T\. Liu, D\. Yin, X\. Sun, and M\. ZhangHISA: efficient hierarchical indexing for fine\-grained sparse attention\.ArXivabs/2603\.28458\.Cited by:[§1](https://arxiv.org/html/2611.27233#S1.p2.1),[§2\.1](https://arxiv.org/html/2611.27233#S2.SS1.p3.1)\.
- Yanget al\.\(2025\)A\. Yang, A\. Li, B\. Yang, B\. Zhang, B\. Hui, B\. Zheng, B\. Yu, C\. Gao, C\. Huang, C\. Lv, C\. Zheng, D\. Liu, F\. Zhou, F\. Huang, F\. Hu, H\. Ge, H\. Wei, H\. Lin, J\. Tang, J\. Yang, J\. Tu, J\. Zhang, J\. Yang, J\. Yang, J\. Zhou, J\. Zhou, J\. Lin, K\. Dang, K\. Bao, K\. Yang, L\. Yu, L\. Deng, M\. Li, M\. Xue, M\. Li, P\. Zhang, P\. Wang, Q\. Zhu, R\. Men, R\. Gao, S\. Liu, S\. Luo, T\. Li, T\. Tang, W\. Yin, X\. Ren, X\. Wang, X\. Zhang, X\. Ren, Y\. Fan, Y\. Su, Y\. Zhang, Y\. Zhang, Y\. Wan, Y\. Liu, Z\. Wang, Z\. Cui, Z\. Zhang, Z\. Zhou, and Z\. QiuQwen3 technical report\.Cited by:[§6\.1](https://arxiv.org/html/2611.27233#S6.SS1.p1.1)\.
- Yanget al\.\(2018\)Z\. Yang, P\. Qi, S\. Zhang, Y\. Bengio, W\. W\. Cohen, R\. Salakhutdinov, and C\. D\. ManningHotpotQA: a dataset for diverse, explainable multi\-hop question answering\.ArXivabs/1809\.09600\.Cited by:[§6\.1](https://arxiv.org/html/2611.27233#S6.SS1.p1.1)\.
- Yinet al\.\(2026\)Z\. Yin, J\. Gao, P\. Yin, J\. Li, and G\. CongLiteTopK: exploiting the curse of dimensionality for a fused indexer\-topk kernel in long\-context sparse attention\.ArXivabs/2607\.11976\.Cited by:[§1](https://arxiv.org/html/2611.27233#S1.p2.1),[§2\.1](https://arxiv.org/html/2611.27233#S2.SS1.p5.1)\.
- Zanet al\.\(2026\)W\. Zan, J\. Zhang, J\. Tan, H\. Liu, C\. Wang, X\. Li, D\. Ma, G\. Wu, Y\. Lu, F\. Li, Y\. Sun, P\. Pei, Y\. Xie, and X\. CaiLongCat sparse attention: taming the lightning via streaming\-aware hierarchical cross\-layer indexing\.Cited by:[§1](https://arxiv.org/html/2611.27233#S1.p2.1),[§2\.1](https://arxiv.org/html/2611.27233#S2.SS1.p5.1)\.
- Zhanget al\.\(2023\)F\. Zhang, B\. Chen, Y\. Zhang, J\. Keung, J\. Liu, D\. Zan, Y\. Mao, J\. Lou, and W\. ChenRepoCoder: repository\-level code completion through iterative retrieval and generation\.pp\. 2471–2484\.Cited by:[§1](https://arxiv.org/html/2611.27233#S1.p1.1)\.
- Zhonget al\.\(2021\)M\. Zhong, D\. Yin, T\. Yu, A\. Zaidi, M\. Mutuma, R\. Jha, A\. Awadallah, A\. Celikyilmaz, Y\. Liu, X\. Qiu, and D\. R\. RadevQMSum: a new benchmark for query\-based multi\-domain meeting summarization\.pp\. 5905–5921\.Cited by:[§6\.1](https://arxiv.org/html/2611.27233#S6.SS1.p1.1)\.
- Zhouet al\.\(2026\)R\. Zhou, F\. Meng, Y\. Xu, T\. Liu, G\. Lu, M\. Zhang, and W\. PeiMISA: mixture of indexer sparse attention for long\-context llm inference\.ArXivabs/2605\.07363\.Cited by:[§2\.1](https://arxiv.org/html/2611.27233#S2.SS1.p3.1)\.

相似文章

面向超长上下文的新型稀疏注意力方法

Reddit r/LocalLLaMA

团队发布了 Latent Sparse Attention(LSA,潜在稀疏注意力)这一开放研究成果,实现了亚二次复杂度的注意力机制,在超长上下文中达到与全注意力相当的准确率,使稀疏注意力最高提速 22.7 倍,全注意力最高提速 72.4 倍。

LongAct:利用内在激活模式进行长上下文强化学习

Hugging Face Daily Papers

LongAct 提出了一种显著性引导的稀疏更新策略,通过选择性更新与查询和键向量中高幅值激活相关的权重来改进 LLMs 的长上下文推理能力,在 LongBench v2 上实现了约 8% 的提升。