Manuscript Offprint

arXiv:2611.01715

EarlySelectKV: Anticipatory KV Selection via Cross-Layer Query Proxies

Yuhao Liu, Yuehao Li, Linghe Zhang, Gaobin Huang, Junran Li, Hongchang Wang, Haifang Jian

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

Abstract

Query-conditioned sparse KV selection reduces long-context inference cost by attending to a subset of historical KV entries at each decoding step. Existing selectors must wait for the target-layer query before scoring candidates and generating indices, placing routing on the immediate pre-attention path. We introduce EARLYSELECTKV, a training-free transformation that uses proxy queries from earlier hidden states to precompute selected KV indices while retaining the real target-layer query for final attention. Tests with RocketKV, Quest, and Loki show no consistent pattern of quality degradation across the evaluated settings. In the primary RocketKV evaluation, ES-RocketKV differs by +0.018 points on LongBench, approximately -0.01 points on RULER, and +0.25 percentage points on representative NIAH/Passkey settings. In a TensorRT-LLM deployment with CPU-offloaded routing, ES-RocketKV improves end-to-end output throughput by up to 12.4% and reduces GPU-resident memory by 11.1% of the combined KV/K-summary pool. This makes routing timing an explicit optimization target alongside KV subset selection in sparse long-context decoding. 1^{1}

1 Introduction

Long-context inference in large language models requires substantial memory capacity and bandwidth to store and access historical key-value (KV) states (Kwon et al., 2023; Ribar et al., 2024). The KV cache grows linearly with context length, batch size, and model depth, making these costs especially relevant to long-input workloads such as

Figure

Figure 1: Conventional query-conditioned KV selection and EARLYSELECTKV. Conventional selectors wait for the target-layer query, so index generation remains on the immediate pre-attention path. EarlySelectKV derives a proxy query from preceding hidden states and precomputes KV indices in an earlier computation window.

long-document understanding and repository-level code completion (Bai et al., 2024; Liu et al., 2024).

A common strategy reduces the number of historical KV entries read by attention. Eviction and compression methods maintain a compact cache by retaining recent tokens, attention sinks, or tokens estimated to be important from prompt-time observations (Xiao et al., 2024; Zhang et al., 2023; Li et al., 2024). Dynamic sparse methods instead keep a candidate cache and select a small KV subset at each decoding step according to the current query. This query-conditioned interface adapts to changing evidence needs during generation, but the selected-token count alone does not determine its cost (Tang et al., 2024; Ribar et al., 2024; Singhania et al., 2024).

∗^{*}Corresponding author: jhf@semi.ac.cn.

1^{1}Code is available at https://github.com/sea-with-sakura/EarlySelectKV.

As shown in Figure 1, conventional query-conditioned selectors must obtain the target-layer query before scoring candidate pages or tokens, producing selected indices, and preparing the corresponding KV entries. The resulting serial routing dependency precedes sparse attention. Reducing the sparse budget lowers attention computation, but routing computation and metadata access remain exposed on the same critical path. Once attention is sparsified, deciding which KV entries to access can become a visible source of latency.

The optimization target is therefore not only which KV entries to keep, but also when their indices can be determined. Routing and value aggregation require different levels of query fidelity. Attention over the selected KV states needs the exact target-layer query, whereas routing only needs to preserve the relative preference among candidates.

We propose EarlySelectKV, a training-free transformation for query-conditioned sparse KV selectors. It advances index generation without changing sparse attention: the proxy query is used only for routing, while the real query still performs attention over the original selected KV states. We integrate EarlySelectKV with representative query-conditioned sparse KV selectors, including RocketKV, Quest, and Loki, demonstrating its plug-and-play applicability across different routing designs. Rather than redesigning the selector, EarlySelectKV advances the availability of selected KV indices, making query-conditioned sparsity more amenable to system-level scheduling.

As a representative case, ES-RocketKV matches RocketKV on LongBench (+0.018 points), Needle-in-a-Haystack (+0.25 percentage points), and RULER (-0.01 points), indicating negligible accuracy degradation. This parity makes the selected indices a reliable scheduling signal. In a deployment with CPU-offloaded routing, the early availability of selected indices allows routing and metadata preparation to be staged before the target attention step, reducing exposed stalls on the GPU attention path and lowering GPU-resident auxiliary state.

Our contributions are summarized as follows:

  • We propose EarlySelectKV, a training-free framework for anticipatory KV-cache selection. It uses query anchors from preceding hidden states to reduce routing overhead on the critical path of dynamic sparse decoding.

  • EarlySelectKV provides a selector-preserving

Figure

Figure 2: Theoretical routing overhead under sparse attention budgets. We analyze a single Llama-3.1-8B layer with an 8K KV cache and vary the selected-token budget. As the budget decreases, sparse attention becomes cheaper, and routing accounts for a larger fraction of the remaining attention-side computation.

interface for query-conditioned routing. It retains the original candidate construction and scoring rules while supporting anchor choices with different lookahead windows and query-projection approximations.

  • Experiments on LongBench, Needle-in-a-Haystack, and RULER show that EarlySelectKV maintains task performance and selection fidelity while reducing the visible routing overhead of exact-query routing.

References (18)