AsdaKV: Attention-Overlap Driven Semantic KV Retrieval for Long-Context LLMs

Tianming Yan, Kun Yang, Tingwang You, Kui RenNeurIPS 2026

TL;DR

When large language models read massive documents, their short-term memory—the KV cache—balloons until it chokes GPU memory. Instead of permanently throwing away old memories or guessing what to fetch using rigid rules like punctuation or fixed page sizes, AsdaKV watches where the model actually pays attention. When the model’s focus drifts to new parts of the text, AsdaKV seamlessly swaps the right memories in from CPU storage in the background, keeping accuracy remarkably close to full-memory baselines without stalling generation.

What Problem Does This Paper Address?

As LLMs tackle million-token contexts, storing the Key-Value (KV) states for every past token becomes a massive GPU memory and bandwidth bottleneck. Imagine trying to write a book while keeping every single reference page spread out on a tiny desk.

You have two choices. Eviction methods simply throw old pages into the shredder to save desk space—fast, but catastrophic if you need a shredded detail ten paragraphs later. Retrieval methods keep the full archive in a nearby filing cabinet (CPU memory) and only pull relevant pages onto the desk (GPU active cache).

Figure 2: Overview of retrieval-based KV-cache management.

The catch with retrieval is knowing what to group together and when to make a trip to the filing cabinet. Existing methods chop text into fixed-size blocks, split by sentences, or use proxy signals like comparing query vector similarities. Yet these external heuristics frequently misalign with how the LLM’s internal dependencies actually evolve, either missing subtle topic shifts or wasting time fetching data too often.

Methods

AsdaKV replaces external heuristics with an intrinsic, model-driven signal: attention-overlap drift.

Figure 3: Overview of AsdaKV. AsdaKV first constructs semantic windows and window anchors during prefill, then detects semantic drift during decoding and recalls missing KV pages from CPU memory to the GPU active cache for attention computation.
  1. Semantic Windows & Lightweight Anchors (Prefill): Instead of arbitrary chunks, AsdaKV groups contiguous physical memory pages into variable-length "semantic windows" based on where the model's final prefill queries attend. Full KV states are offloaded to CPU memory, while each window is summarized on the GPU by a tiny "anchor" vector (the average of its page-level mean keys).
  2. Attention-Overlap Drift Detection (Decode): As the model generates tokens, AsdaKV scores the GPU-resident anchors against the current query to see which top-$K_w$ windows the model wants. It measures the Jaccard overlap between the newly desired windows and the previously active ones. High overlap means the context is stable; a sharp drop below an offline-calibrated threshold signals "semantic drift" and triggers a cache refresh.
  3. Adaptive Stride: Checking for drift at every single token is wasteful when a thought is flowing smoothly. When overlap is high, AsdaKV dynamically widens its "stride," skipping checks for up to 4 steps, and snaps back to step-by-step monitoring as soon as drift occurs.
  4. Deferred KV Recall: Fetching pages over PCIe from CPU to GPU is slow. When drift is detected, AsdaKV doesn't freeze generation. It finishes the current token's math using the existing GPU cache while asynchronously loading the new pages in the background for the next token.

Datasets

AsdaKV requires no model training (only lightweight offline threshold calibration on held-out traces, including an ablation with C4). The authors evaluate it across existing benchmarks covering two regimes:

  • Long-input understanding: LongBench (16 tasks across QA, summarization, few-shot, synthetic, and code), Needle-in-a-Haystack (NIAH), and RULER.
  • Long-output reasoning: MATH500 (evaluating extended chain-of-thought generation up to 12,800 tokens).

No new datasets are introduced.

Key Insights and Ideas

  • Vector similarity can lie about context shifts: Comparing consecutive query or key vectors via cosine similarity—a popular trigger in prior work—can theoretically approach 1.0 even while the actual top-$k$ historical tokens receiving attention become completely disjoint! Measuring the overlap of realized attention supports directly certifies that retrieval error stays bounded.
Figure 1: Motivation for attention-overlap retrieval. (a) Attention distributions from different layers; brighter colors indicate larger attention weights. (b) Retrieval-error curves computed from decoding traces. For each decoding step, we evaluate the active cache selected by fixed-page, query similarity, key similarity, attention-overlap refresh, and an oracle top-k attention-support reference, then plot the resulting retrieval error over time.
  • Punctuation buys you a "free" transfer step: Why doesn't Deferred Recall hurt accuracy if it delays updating the cache by one step? The authors noticed that sharp attention drops usually happen right on transition tokens—like periods or sentence boundaries—where attention is briefly unsettled anyway. Stable focus only crystallizes on the following token, giving the system a natural one-step grace period to hide CPU-to-GPU memory transfers!
  • Decoupling logic from physics: Grouping variable-length semantic windows logically while transferring fixed-size pages physically gives you the best of both worlds: coherent meaning for the LLM, and clean, fragmentation-free memory management for the hardware.

Key Results

Tested across Llama-3.1 (8B & 70B), Qwen3-8B, Mistral-7B, and DeepSeek-R1-Distill-Llama-8B:

  • Long-Input Accuracy: Under a tight 1,024-token GPU budget on LongBench (Llama-3.1-8B), AsdaKV achieves an average score of 48.08, beating SOTA retrieval baselines like FreeKV (47.64) and ShadowKV (47.34), and retaining 99.13% of FullKV accuracy (48.50).
  • Long-Output Reasoning: On MATH500, AsdaKV matches or beats all compressed baselines, hitting 93.2% on Qwen3-8B (vs. 94.4% FullKV) and 78.0% on DeepSeek-R1-8B (vs. 79.8% FullKV).
  • Efficiency: Deferred recall slashes average per-layer decode latency nearly in half—from 2.26 ms to 1.21 ms—on Qwen3-8B (A100). Across 32K to 128K context lengths, AsdaKV achieves higher raw throughput than Quest, InfiniGen, and FreeKV, though prefill window preparation adds minor time-to-first-token (TTFT) overhead.

Limitations and Future Work

  • Theory-Practice Gap: The authors' mathematical error bounds assume step-by-step token-level checks against the last refresh, whereas the practical system uses sparse window-level checks and a one-step recall delay. Bridging this theoretical gap is left for future work.
  • Architecture & System Scope: The current codebase targets Grouped-Query Attention (GQA) models and lags behind ShadowKV in large-batch, long-input throughput on H200 GPUs. Future directions include adapting AsdaKV to Multi-head Latent Attention (MLA) and Multi-Query Attention (MQA), optimizing batched CPU-GPU transfers, and integrating the framework directly into production engines like vLLM.

Summary updated

Abstract

Long-context inference with large language models is bottlenecked by the linear growth of the KV cache. Existing eviction-based methods reduce memory overhead by irreversibly discarding historical states, while retrieval-based methods preserve the full context but rely on retrieval units defined by tokens, fixed pages, or proxy signals including query-key similarity, clustering, and linguistic rules. Such externally defined units often misalign with the model's actual contextual dependencies during generation. We propose AsdaKV, an adaptive semantic drift-aware KV cache retrieval framework that defines semantic continuity directly from the model's inherent attention behavior. AsdaKV detects semantic drift by measuring the overlap between high-attention historical regions across decoding steps: stable overlap indicates that the active cache still covers the relevant contextual evidence, whereas a sharp overlap drop triggers cache refresh. Guided by this drift signal, AsdaKV organizes historical KV states into variable-length semantic windows, offloads full window KV states to CPU memory, and maintains only lightweight window anchors plus a fixed-budget active KV cache on GPU. During decoding, the current query retrieves relevant windows via anchor matching, while adaptive-stride drift detection and deferred page recall reduce redundant detection, retrieval, and KV reloading overhead. Extensive experiments across diverse tasks and model families demonstrate that under the same KV budget, AsdaKV achieves higher accuracy than state-of-the-art KV retrieval methods, maintains comparable decoding efficiency in long-input settings, and further outperforms existing retrieval systems for long-output generation.
BibTeX
@inproceedings{yan2026asdakv,
  author = {Tianming Yan and Kun Yang and Tingwang You and Kui Ren},
  title = {{AsdaKV: Attention-Overlap Driven Semantic KV Retrieval for Long-Context LLMs}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2026},
  url = {https://openreview.net/forum?id=njapeOwRUM},
}
Figure