SparseX: Efficient Segment-Level KV Cache Sharing for Interleaved LLM Serving

Quqing Zhang, Kai Chen, Ning Liao, Zehao Lin, Bo Tang, Feiyu Xiong, Zhiyu Li, Xiaoxing WangarXiv 2026

TL;DR

SparseX is a training-free, model-agnostic framework that enables large language models (LLMs) to share and reuse KV caches at the segment level, even when text is arbitrarily shuffled or interleaved. By using the queries of newly inserted text ("Sparse-Q") to dynamically pinpoint and recompute only the most context-critical tokens, SparseX slashes Time-to-First-Token (TTFT) during long-context serving while maintaining near-perfect generation accuracy.

What Problem Does This Paper Address?

In long-context LLM applications, the "prefill" stage—where the model processes the input prompt and builds the Key-Value (KV) cache—is a massive computational bottleneck. While standard engines use "Prefix Caching" to reuse the KV cache of identical prompt prefixes, real-world workloads are rarely that clean.

In multi-round chat, retrieval-augmented generation (RAG), and multi-agent workflows, repeated text blocks (like document snippets or agent histories) are frequently shuffled, re-ordered, or interleaved with new user queries. Because self-attention mechanisms couple a token's representation with its surrounding context and absolute position, simply copying a cached KV block from a different position introduces severe representation errors. Existing workarounds either rely on rigid prompt structures, introduce slow auxiliary models to predict token importance, or sacrifice generation quality.

Comparison of how different KV cache reuse methods handle complex interleaved inputs.

Methods

SparseX transforms arbitrary-position KV cache reuse into a highly efficient sparse-recomputation problem through four core techniques:

  1. RoPE Alignment: To fix positional encoding mismatches when a cached segment is migrated to a new position, SparseX applies an incremental rotation matrix directly in the cache domain, avoiding the need to un-rotate or re-project the base vectors.
  2. Sparse-Q Driven Token Selection: Instead of using an external model to guess which tokens need recomputation, SparseX leverages the queries ($Q$) generated by the newly introduced text segments. This naturally occurring "Sparse-Q" pattern is used to calculate attention weights against all keys, acting as a built-in runtime signal to select the top-$k$ most important tokens requiring correction.
  3. Overflow Approximation: To account for local relative-position attention (the "slash" pattern) without full key projection, SparseX expands the recomputation range outward by one block at the boundaries of non-reused segments.
  4. Full+Sparse Hybrid Attention: The framework implements a layer-specific threshold. Early layers retain full attention to establish a stable token-importance signal, while later layers switch entirely to sparse recomputation for the selected tokens.

The authors integrated this method into vLLM (SparseX-vLLM), introducing Frozen Blocks for stable RAG database cache residency and Virtual Blocks to track user chat histories with zero additional memory overhead.

Datasets

The authors evaluated SparseX across three complex serving scenarios using several prominent benchmarks:

  • Multi-Round Chat: Evaluated using LOCOMO (long-term conversational memory) and LongMemEval (long-context memory retrieval).
  • Long-Context Standard Benchmarks: Evaluated using RULER, specifically focusing on challenging subtasks like Multi-Query Needle-in-a-Haystack (MQ-NIAH), Variable Tracking (VT), Common Words Extraction (CWE), and Frequent Words Extraction (FWE).
  • Multi-Agent Systems: Evaluated using the MASLab platform across frameworks like AutoGen and MAD, covering diverse reasoning domains including MATH, GSM-Hard, GPQA (scientific reasoning), MMLU-Pro, MedQA, and MedMCQA.

Key Insights and Ideas

  • The "Sparse-Q" Advantage: In interleaved prompts, new text segments must be fully computed anyway. SparseX realizes that the queries from these new segments provide a highly accurate, context-dependent map of which historical tokens matter most for the current generation step, eliminating the need for separate preprocessing or auxiliary models.
  • Attention Scores Trump Cache Deviation: Prior methods (like CacheBlend) select tokens based on how much their KV cache deviates from the original projection in early layers. The authors demonstrated that this signal is highly unstable and sensitive to prompt layout. In contrast, last-query attention scores provide a robust, stable needle-localization signal regardless of where the query cue is placed.
  • Phased Information Processing: LLMs process information in distinct stages: early layers handle structural formatting (punctuation, local layout), middle layers localize relevant regions, and later layers process semantic details. Consequently, full attention is only necessary for the first 10% to 20% of layers to capture an accurate token-importance contour before safely switching to sparse recomputation.
Top-token distribution based on last-query attention scores, showing a stable needle-localization signal early in the network.

Key Results

  • Massive Speedups (TTFT): When serving Qwen3-30B-A3B on the LOCOMO dataset, SparseX reduced the TTFT from 7.32 seconds (full recompute) to just 0.67 seconds. On LongMemEval, it dropped the prefill latency from 15.58 seconds to 2.13 seconds.
  • Near-Lossless Accuracy: On the rigorous RULER benchmark, naive cache reuse causes accuracy to plummet (e.g., dropping to 0.69 on Qwen3-8B). SparseX with hybrid attention achieved an average score of 0.94 (matching full recomputation's 0.96). On Qwen3-32B, it achieved 0.98, effectively matching the quality ceiling of full recomputation (0.97).
  • Robust Multi-Agent Performance: Integrated into AutoGen and MAD frameworks, SparseX maintained competitive task accuracy across massive, multi-turn collaborative workflows while bypassing redundant forward passes on shared intermediate agent outputs.

Limitations and Future Work

While SparseX delivers impressive efficiency gains, the authors noted a few areas for ongoing development:

  • Static Budgets: The top-$k$ recomputation ratio is currently governed by a fixed threshold; implementing finer-grained, adaptive recomputation ratios based on runtime context could optimize the compute-quality trade-off further.
  • Architectural Support: The current implementation is optimized for specific mainstream attention backends and decoder-only LLMs; expanding native support to a wider variety of model architectures is an open direction.
  • Distributed Serving: Future work will explore joint optimization strategies that combine SparseX with cross-node KV cache storage and advanced distributed scheduling policies for large-scale cluster deployments.

Summary updated

BibTeX
@misc{zhang2026sparsex,
  author = {Quqing Zhang and Kai Chen and Ning Liao and Zehao Lin and Bo Tang and Feiyu Xiong and Zhiyu Li and Xiaoxing Wang},
  title = {{SparseX: Efficient Segment-Level KV Cache Sharing for Interleaved LLM Serving}},
  year = {2026},
  eprint = {2606.01751},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2606.01751},
}
Figure