Manuscript Offprint

arXiv:2611.01735

CacheWeave: Learning to Recompute for Efficient Position-Independent KV Caching

Yueyang Pan, Qianchao Zhu, Yuliang Liu, Teng Ma, Sanidhya Kashyap

ABSTRACT

Position-independent caching reuses chunk KV caches across positions and requests. Independent encoding, however, omits cross-chunk interactions and can degrade accuracy. In our study, neither PIC training nor rule-based recomputation, alone or combined, consistently recovers full-prefill accuracy. Oracle-guided recomputation on PIC-trained models improves accuracy at the same budget, motivating better selection. We present CacheWeave, which adapts the full backbone to PIC, then freezes it and trains a model-native block selector on the adapted model's oracles. The selector uses compact cached chunk features and question hidden states without extracting backbone attention scores. It selects contiguous token blocks aligned with KV blocks to support efficient recomputation and limit copy-on-write amplification. Its runtime, CacheWeave-Serve, supports private and shared KV caches, keeps selection and recomputation on the GPU, and stages sliding-window KV for hybrid attention models. Across three models and four tasks, CacheWeave outperforms CacheBlend and ProphetKV by 7.2 and 3.5 percentage points on average at a 5% recomputation budget, with a mean relative accuracy loss of 1.6% to full prefill. With 32-token blocks, CacheWeave-Serve cuts single-request TTFT by up to 16.1× over full prefill and 1.7× over ProphetKV, and raises SLO goodput under load by up to 7.8×.

1 INTRODUCTION

LLM requests often reuse the same context in different combinations. Retrieval-augmented generation (RAG) draws documents from a shared corpus, while coding agents revisit source files and tool outputs as a task evolves (Yang et al., 2024; Wang et al., 2025; Fang et al., 2026; Lewis et al., 2020; Wu et al., 2024; Geng et al., 2026). Reusing the key-value (KV) states of these recurring chunks can avoid repeated prefill computation. Prefix caching exploits this opportunity when requests share an identical token prefix (Zheng et al., 2024; Kwon et al., 2023). However, a chunk's KV states generally depend on its preceding context. Prefix caching therefore recomputes a recurring chunk if its preceding context changes, even when the chunk's tokens are identical.

Position-independent caching (PIC) broadens reuse by encoding chunks independently and assembling their cached KV for each request (Gim et al., 2024; Lu et al., 2024; Hu et al., 2025). This avoids repeated chunk prefill but removes cross-chunk interactions from the cached representations, which can hurt tasks that combine evidence across

chunks. Existing remedies follow two approaches (Table 1). Training-free methods selectively recompute tokens using predefined criteria, such as KV deviation or question attention, without changing model weights (Yao et al., 2025; Wang et al., 2026). Training-aware methods instead adapt how the model constructs or consumes independent chunk caches, avoiding per-request chunk recomputation (Ma et al., 2025; Chen et al., 2026b; Xie et al., 2026).

Our study finds that neither PIC training nor selective recomputation consistently recovers the base model's full-prefill accuracy across the models and tasks we evaluate (Section 3). Applying ProphetKV or CacheBlend to PIC-trained models also yields inconsistent gains and can reduce multi-hop QA accuracy. Yet at the same 5% recomputation budget, oracle selectors on these models improve over ProphetKV by up to 9.7 percentage points. These oracles require information unavailable during normal PIC inference, but demonstrate room for better selection at a fixed budget. This motivates learning a selector from the adapted model's own oracles.

Better selection must also preserve PIC's serving advantage. Extracting the backbone's attention probabilities can require materializing matrices that fused attention kernels normally avoid storing (Dao et al., 2022). In our Qwen3-4B measurements at 16K context, ProphetKV's selection and 5% recomputation reduce warm PIC's speedup over full prefill from 14× to 3.1× (Section 3.4). Updates also affect

*Work done during internship at Xiaohongshu Inc. †Corresponding authors. ¹École Polytechnique Fédérale de Lausanne ²Independent Researcher. Correspondence to: Qianchao Zhu and Yuliang Liu.

Preprint.

Table 1. Comparison of PIC approaches. Restoration gives selected tokens access to preceding chunks; model-native selection is learned for the adapted model. Online cost is extra work beyond PIC: β\beta denotes the recomputed token fraction, probe an early-layer KV deviation pass, QQ pass question prefill with attention probabilities, and selector learned block scoring. Accuracy is relative to full prefill in our evaluation; Attuner, SemPIC, and block distillation are represented by our reader-only, writer-only, and full-model training variants.

FamilyMethodTrainingAttention restoreQuery-aware selectionModel-native selectionOnline costAccuracy
Training-free selective recomputeCacheBlend✕✓✕✕probe + β\betaLow
EPIC✕✓✕✕β\betaLow
ProphetKV✕✓✓✕Q pass + β\betaMedium
Training-aware PIC (partial)Attunerreader✕––noneLow
SemPICwriter✕––noneLow
Training-aware PIC (full)Block distillation✓✕––noneMedium
Native recomputeCacheWeave✓✓✓✓selector + β\betaHigh

memory sharing: in a block-based KV cache (Kwon et al., 2023), recomputing scattered tokens can require copying many shared blocks. A small token budget can therefore incur substantial execution and memory costs. Effective recomputation requires choosing both which states to update and how to execute and store those updates.

We present CacheWeave, which couples PIC adaptation with a learned, model-native recomputation selector. Using cached chunk features and question hidden states, the selector chooses contiguous token blocks aligned with the engine’s KV blocks, without extracting backbone attention probabilities (Section 4.1). We first fine-tune the full backbone under PIC by self-distillation on the base model’s full-prefill responses, then freeze it and train the selector on oracles computed from that adapted backbone (Section 4.2). For a fixed block size, one selector supports multiple recomputation budgets without retraining. Our runtime, CacheWeave-Serve, uses block alignment to bound copy-on-write amplification, supports private and shared GPU caches, and keeps selection and recomputation on the GPU. It also supports hybrid attention models by staging sliding-window KV layer by layer (Section 4.3).

We evaluate CacheWeave on three models from two families and four tasks covering multi-hop QA and retrieval (Section 5). At a 5% recomputation budget, CacheWeave outperforms CacheBlend and ProphetKV on the same PIC-trained models over all model-task pairs, gaining 7.2 and 3.5 points on average. Its relative accuracy loss to full prefill averages 1.6% and is at most 8.3%; its average lead over ProphetKV persists at every tested block size. At 24K material tokens, with 32-token blocks as recompute granularity and a 5% budget, CacheWeave-Serve achieves single-request time-to-first-token (TTFT) speedups of 13.9× over full prefill and 1.46× over ProphetKV on Qwen3-32B, and 16.1× over full prefill on Gemma4-12B. Under load, CacheWeave-Serve raises peak SLO goodput by up to 7.8×.

We make the following contributions:

  • A diagnosis of PIC accuracy and cost: either PIC training or rule-based recomputation stays far from full-prefill accuracy. Simple combination can still leave the gap wide. Oracle selections at the same budget do much better, and inefficient recomputation can consume a lot of PIC’s prefill speedup (Section 3).

  • A model-native selector and a two-stage recipe that trains it on the PIC-trained model’s own oracles, with no attention scores at inference and selector granularity aligned with KV block sizes (Section 4.1–4.2).

  • CacheWeave-Serve, a serving design providing private and shared GPU memory modes with an analysis of when sharing pays, efficient GPU-resident selection and recomputation, and support for hybrid sliding-window models (Section 4.3).

  • An evaluation on three models from two families and four tasks, demonstrating higher accuracy at matched recomputation budgets and substantial single-request TTFT reductions at long contexts (Section 5).

References (39)