Source-linked AI summary
ATTUNER: Recomputation-Free KV Cache Reuse via Query-Side Adaptation
Xinghao Chen, Junnan Dong, Cai Ke, Chak Tou Leong, Haocheng Sun, Keyu Chen, Siyu An, Ruizhi Qiao, Xing Sun, Wenjie Li, Xiaoyu Shen
TL;DR
LLM agents repeatedly load reusable artifacts, but re-encoding them is costly and PIC can lose quality relative to full-context prefill. ATTUNER adapts queries to read frozen artifact caches; across benchmarks, it improves over PIC, matches full-context quality, and offers speedups.
Problem
PIC reuses independently encoded artifact KV at arbitrary positions, but can lose quality relative to full-context prefill as agent workloads dynamically assemble context.
Source: §1 · p. 1Method
ATTUNER trains low-rank query-projection adapters by distilling full-prefill behavior into a PIC student, then deploys them without cache reconstruction or a teacher.
Source: §4 · p. 6Results
ATTUNER improves in-domain quality and out-of-domain generalization over PIC, matches full-context prefill quality, and provides up to 3.73× speedups.
Source: §1 · p. 3Takeaways & Limitations
Full-prefill attention routing recovers task quality with cached artifact KV unchanged, supporting query-side adaptation as a cache-reading path without cache reconstruction.
Source: §6 · pp. 10–11The evaluation treats skills, documents, and memories as separate task settings and does not examine requests combining all three artifact types.
Source: §D.2 · p. 28
Abstract
from arXiv · showhide
Large language model (LLM) agents repeatedly load reusable content, such as skills, documents, and memory entries, into the current context. Re-encoding this content for every request wastes computation. Position-independent caching (PIC) alleviates this by encoding each artifact independently and reusing its key-value (KV) states at arbitrary positions, but it incurs a quality loss relative to full-context prefill. Existing methods repair this loss by restoring global position IDs or recomputing selected tokens. In this work, we isolate the source of the loss, finding that the positional mismatch has minor effect, and independently cached artifacts retain faithful representations: reading a provided artifact stays largely accurate, and performance degrades only when the model must select among multiple artifacts. Moreover, replacing PIC's attention scores with full-prefill scores recovers performance with the cached KV unchanged, localizing the failure to the attention rather than KV recomputation. Motivated by this, we propose \textsc{Attuner}, a query-side adaptation method that learns to read a frozen artifact cache. \textsc{Attuner} inserts low-rank adapters into the query projections and is trained by distilling full-prefill distribution into the student. It trains fewer than 0.05\% of the model parameters and, at inference, requires neither cache recomputation nor a full-context reference. On Qwen3-4B and Qwen3-8B across seven benchmarks covering skills, documents, memory, and code, \textsc{Attuner} substantially outperforms prior PIC baselines in both in-domain and out-of-domain settings, matches full-context prefill quality while providing up to $3.73\times$ speedup.
1 Introduction
PIC supports reusable artifacts at dynamic positions, but its performance loss is concentrated in attention routing rather than cached representations. ATTUNER adapts queries to read frozen artifact caches, improving benchmark quality and efficiency over PIC.
1 Introduction
- Agent requests dynamically determine which artifacts to load, their order, and their positions, limiting conventional prefix caching and motivating position-independent caching.PIC independently encodes artifacts, but this can reduce performance relative to full prefill; existing repairs restore global positions or recompute selected tokens.Source: §1 · pp. 1–2
- PIC preserves readable artifact representations, but multi-artifact selection falters; replacing its attention scores with full-prefill scores recovers performance while cached KV stays unchanged.The positional mismatch has little impact on task performance.Source: §1 · p. 2
- ATTUNER learns to read frozen artifact caches by adapting query projections with low-rank adapters distilled from full-prefill behavior.At inference, it needs neither cache reconstruction nor a full-prefill reference.Source: §1 · p. 2
- The evaluation covers seven benchmarks on Qwen3-4B and Qwen3-8B, spanning skills, documents, and memory, with task quality and time to first token measured.Additional analyses examine training-data scale and attention outputs.Source: §1 · p. 2
- 5.13 and 7.77 points are average-score gains over PIC, with full-context-prefill-matching quality and up to 3.73× speedups.The gains span in-domain quality and out-of-domain generalization.Source: §1 · pp. 2–3
2 Background and Related Work
The section defines reusable artifacts and contrasts full-context prefill with position-independent caching. It surveys inference-time repair and learned approaches that change model behavior, cache representations, or their interfaces.
2 Background and Related Work
- An artifact is reusable context such as a skill, document, or memory; a request combines a prefix, artifacts, and a user query to generate a response.The response is sampled from the model conditioned on the assembled input.Source: §2 · p. 3
- Full prefill encodes artifacts under preceding request context, whereas PIC independently encodes and stores their KV states before assembling cached blocks at request time.Identical artifact text can therefore yield different KV states under Full and PIC.Source: §2 · p. 3
- Prior inference-time repairs either recompute selected context or adjust how independently encoded blocks are read, including CacheBlend, APE, CacheSlide, and AgentKVShift [28].Related work also addresses alignment, recomputation primitives, serving, and multi-agent or multimodal settings [30] [31] [34] [35].Source: §2 · p. 3
- Learning-based approaches adapt the model [38], learn alternative cache representations or interfaces [18], or distill full-context behavior into independently constructed caches [19].These methods primarily modify the backbone, cache construction, or the interface exposing reusable representations.Source: §2 · pp. 3–4
3 Understanding Quality Loss and Recovery in PIC
PIC’s performance loss persists when relevant artifacts are provided, and position alignment yields only marginal changes. Routing recovery with cached artifact values brings task performance close to Full.
3.1 Artifact Discovery and Evidence Utilization under PIC
- The analysis separates artifact discovery—selecting relevant candidates—from evidence utilization—reading and integrating information from selected artifacts.The evaluation compares Full and PIC on identical requests under matched generation settings.Source: §3.1 · p. 4
- With relevant artifacts retained, PIC deteriorates more sharply than Full as distractors increase; relevant-only settings show larger gaps on multi-artifact than single-artifact tasks.Figure 2 compares increasing distractor sets and relevant-only settings grouped by single- and multi-artifact tasks.Source: §3.1 · p. 4, Figure 2 · p. 4
- PIC-Pos, which aligns artifact positions while preserving independent cache construction, produces only marginal changes on multi-artifact tasks.Position alignment does not restore conditioning on preceding artifacts that occurs during full prefill.Source: §3.1 · p. 5
3.2 Attention Routing Enables Recovery with Cached Values
- Cached values remain relatively similar to Full, while attention allocation over artifact tokens differs substantially, especially in later layers; routing replacement brings outputs closer to Full.The routing oracle retains PIC’s cached artifact values while replacing attention weights with a Full reference for selected online tokens.Source: §3.2 · p. 5
- On MuSiQue, EM rises from 34.84 under PIC to 47.91 under the oracle (47.79 under Full); BigCodeBench pass@1 rises from 38.98 to 44.53 (43.63 under Full).At the final prompt token in the paired example, mean output cosine similarity increases from 0.898 to 0.984.Source: §3.2 · p. 6
4 ATTUNER: Learning to Read a Frozen Cache
ATTUNER adapts queries during online reading while reusing frozen artifact KV. It trains adapters through Full-context supervision of the PIC student’s output distributions.
Inference workflow
- The inference workflow prepares artifact KV once and reuses it unchanged while adapted queries operate during online prefill and decoding.Warm-cache TTFT includes KV loading and assembly, online prefill, and first-token selection, but excludes offline cache construction.Source: Figure 4 · p. 6, §4 · p. 6
Query Adaptation with Fixed Artifact KV
- ATTUNER adapts online query projections with low-rank updates while keeping cached artifact keys and values available for direct reuse.The frozen backbone and stored artifact KV remain unchanged; online states and newly produced KV evolve under the adapted computation.Source: §4 · p. 6
Learning from Full-Context Behavior
- A frozen Full-context teacher and PIC student receive identical inputs and response prefixes, and training distills the teacher’s output distributions into the student.Only query-adapter parameters are trained; at deployment, their updates are merged into the query projections, with no Full-context teacher required.Source: §4 · p. 6, Figure 5 · p. 7
5 Experiments
ATTUNER improves cached-context quality across in-domain and held-out tasks while preserving near-PIC latency. Analyses show recovery with more training data, improved attention-output alignment, and adaptation limited to a subset of layers.
5.1 Experimental Setup
- One shared adapter per model is trained on a balanced 12,000-example mixture, with full-context responses providing supervision; evaluation reports task quality and warm-cache TTFT.Baselines include Full, PIC, training-free repair methods, and training-based methods.Source: §5.1 · p. 7
5.2 Main Results
- ATTUNER’s in-domain TTFT is only 1.8% and 0.5% higher than PIC, retaining 1.79× and 2.45× speedups over Full on Qwen3-4B and Qwen3-8B.Figure 6 compares quality with speedup; shaded regions indicate lower quality and speed than ATTUNER.Source: Figure 6 · p. 8, §5.2 · p. 8
- ATTUNER improves over PIC on all five tasks for both model sizes, raising in-domain averages by 5.13 and 7.77 points and held-out averages by 3.02 and 3.51 points.The in-domain gaps to Full fall to 1.61 points on Qwen3-4B and 0.51 points on Qwen3-8B; recovery remains incomplete on some benchmarks.Source: §5.2 · p. 8, Table 2 · p. 9
5.3 Analysis
- With 8,192 training examples, MuSiQue reaches 61.15 F1, matching Full’s 61.01; BigCodeBench reaches 44.08 pass@1, approaching Full’s 44.53.Figure 7 shows substantial recovery even with limited training data, with gains as training coverage expands.Source: Figure 7 · p. 9, §5.3 · p. 9
- During teacher-forced answer positions, mean cosine similarity rises from 0.903 to 0.927 on MuSiQue and from 0.932 to 0.949 on BigCodeBench, though alignment deteriorates at the final layer.The analysis compares attention outputs before the output projection; these outputs are not directly supervised.Source: §5.3 · p. 9, Figure 8 · p. 10
- Adapting either half of Qwen3-4B’s layers yields 65.14 or 63.34 MuSiQue F1, versus 49.00 for PIC; the difference between layer windows is inconclusive.These results indicate substantial recovery is possible with updates confined to a subset of layers.Source: §5.3 · p. 10
- Across three in-domain tasks, adaptation gains average 5.13 points under PIC but 0.17 under Full, and its gain is larger under PIC on every task.Under Full, MuSiQue and PersonaMem-v2 improve while BigCodeBench and CHAMP decline.Source: §5.3 · p. 10
6 Conclusion
The conclusion presents ATTUNER as query-side adaptation for reading frozen artifact caches, with quality gains across in-domain and held-out tasks and near-PIC warm-cache latency. The surrounding statements identify scope boundaries, disclose AI assistance, and point to supporting experimental details.
6 Conclusion
- ATTUNER improves in-domain scores over PIC by 5.13 and 7.77 points on Qwen3-4B and Qwen3-8B, transfers to held-out tasks, and retains 1.79× and 2.45× in-domain speedups over Full.The conclusion describes query-side adaptation as learning to read the cache rather than rewriting it.Source: §6 · pp. 10–11
AI use statement
- Generative AI tools assisted with manuscript polishing, literature discovery, code development, and figure preparation, while the authors retain responsibility for the final text and scientific claims.Source: AI use statement · p. 11
Ethics statement
- The method does not address biases, privacy risks, or harmful outputs inherited from the underlying models and data; reusable-context applications should protect cached information and control access.Source: Ethics statement · p. 11
Reproducibility statement
- Appendix materials describe data, prompts, training and generation settings, diagnostic cohorts, and evaluation protocols; baseline configurations are detailed in Appendix C.Source: Reproducibility statement · p. 11, A Experimental Details · p. 16
A.1 Datasets and Splits
The appendix describes benchmark splits and how reusable artifacts are prepared from skills, documents, and memory messages. It also specifies warm-cache TTFT measurement and the prompt boundaries used to assemble cached and online content.
A.1 Datasets and Splits
- Evaluation covers seven benchmarks for Qwen3-4B and Qwen3-8B, with relevant artifacts supplied directly in the relevant-only setting and requests matched across methods.TheoremQA, LogicBench, MedCalc-Bench, CHAMP, and BigCodeBench use annotated skills; ToolQA is excluded because it reuses one skill across multi-step ReAct interactions.Source: §A.1 · p. 16
- BigCodeBench uses a skill-disjoint split of 70 training-side and 69 evaluation-side skill IDs, yielding 198 real training-side and 667 evaluation instances; 275 cross-partition instances are excluded.The main adapter mixture uses synthetic tasks from training-side skills, while the 198 real instances support validation and ablations.Source: §A.1 · p. 16
- MuSiQue supplies two- to four-document evidence contexts, while PersonaMem-v2 uses annotated related-conversation snippets as separate message artifacts rather than full conversation history.MuSiQue retains supporting documents in original order; PersonaMem-v2 retains all 5,000 requests and keeps the request-specific question online.Source: §A.1 · pp. 16–17
A.2 Evaluation Metrics and Efficiency Protocol
- Warm-cache TTFT starts with reusable KV resident in CPU RAM and includes transfer, cache assembly, online repair, uncached-token prefill, and first-token selection, but excludes model loading and cache construction.Median request-level timings are aggregated across datasets using the geometric mean; speedup is Full TTFT divided by method TTFT.Source: §A.2 · pp. 17–18
A.3 Prompt Construction and Artifact Boundaries
- Artifact spans are cached while instructions, separators, questions, and other text remain online; cached artifact KV is assembled in original prompt order and stays fixed during adapted inference.PersonaMem-v2 cached spans include complete historical messages and their chat-template boundaries.Source: §A.3 · p. 18
A.4 Training Data Construction
The training set combines 12,000 requests across document, memory, and synthetic skill-use tasks, with Full-context teacher supervision. The appendix also specifies generation and analysis protocols, including prefix-length limits and controlled cache-reading comparisons.
A.4 Training Data Construction
- 12,000 requests form a balanced mixture of MuSiQue, PersonaMem-v2, and synthetic BigCodeBench-style tasks.The synthetic tasks combine two to five training-side skills; generated tasks are not independently validated with unit tests.Source: §A.4 · p. 19
- Training and validation requests are disjoint, with PersonaMem-v2 additionally separated by persona and evaluation personas excluded from training.The validation cohorts are distinct from separately constructed diagnostic cohorts.Source: §A.4 · p. 19
- For each model, Full-context teacher responses supervise the PIC student through response-position distribution KL, with each request weighted equally.Prompt positions are not directly supervised; losses are averaged within responses and then across requests.Source: §A.4 · p. 19
- Some retained teacher-response prefixes are incomplete: all selected Qwen3-4B MuSiQue trajectories and most PersonaMem-v2 trajectories reach their length limits.The stated maximum retained prefix lengths are 1,024 tokens for BigCodeBench and 256 for PersonaMem-v2.Source: §A.4 · p. 19
A.5 Training and Generation Settings
- Query adapters target q_proj in every layer while base-model parameters remain frozen; evaluation uses greedy decoding with thinking disabled.The runtime merges the learned update into the query projection, and cache transfer is included in TTFT measurements while quality-run timings are not formal latency measurements.Source: §A.5 · p. 20
A.6 Analysis Settings
- Distractor tests add irrelevant skills or documents, while attention-output alignment compares Full, PIC, and ATTUNER on shared prompts and saved response prefixes.Alignment is measured per head before the output projection, with summaries averaged over positions, heads, examples, and layers.Source: §A.6 · p. 20
B Routing Recovery Case Studies
Across three selected routing case studies, restoring Full attention routing brings outputs close to Full while leaving artifact KV unchanged. The section also describes the reference and training-free baseline configurations used in the comparisons.
B Routing Recovery Case Studies
- With artifact KV unchanged, routing restoration raises mean output cosine similarity to at least 0.985 across the three examples.The examples are one each from CHAMP, BigCodeBench, and PersonaMem-v2; these visualized cases do not establish task-level recovery.Source: Table 8 · p. 21, B Routing Recovery Case Studies · p. 21, Figure 9 · p. 22
- The case-study comparison measures cached-value, artifact-attention, and output cosine similarities, with oracle outputs compared against Full at the final prompt token.The three examples include CHAMP, BigCodeBench, and PersonaMem-v2; similarities are measured before the output projection for attention and outputs.Source: B Routing Recovery Case Studies · p. 21, Figure 9 · p. 22
C Baseline Implementations
- Baseline comparisons use Qwen3 adaptations under a common evaluation protocol, and AgentKVShift is a paper-based reimplementation.The comparison concerns these implementations, not the original systems’ serving performance.Source: C Baseline Implementations · p. 23, Table 9 · p. 23
C.1 Reference Methods
- Full provides the reference; PIC independently encodes artifacts at local positions, while PIC-Pos encodes them at target positions without restoring cross-artifact conditioning.PIC-Pos requires target placement during cache construction, so it is a position control rather than a placement-independent cache-building strategy.Source: §C.1 · p. 23
C.2 Training-Free Baselines
- APE combines separately computed cached-context and online-token attention outputs; EPIC recomputes the first four eligible artifact tokens.The EPIC configuration rotates pre-RoPE cached keys to target positions during assembly and skips artifacts beginning at position zero.Source: §C.2 · pp. 23–24
- CacheBlend propagates selected positions after a value-difference check, whereas AgentKVShift [28] uses key and value probes to estimate corrections for remaining cached tokens.The reported Qwen3 CacheBlend adaptation uses a causal mask indexed by original query positions and retains the entire online suffix.Source: §C.2 · p. 24
C.3 Training-Based Baselines
KVLink and COMB are trained baselines with distinct cache-reading architectures, using the same 12,000 requests and Full-context teacher responses as ATTUNER. Their controlled training budget and efficiency measurements are specified separately from the original papers’ complete protocols.
C.3 Training-Based Baselines
- KVLink adds five learned link tokens per artifact and fine-tunes the backbone, requiring caches built with the trained model.Its block mask keeps ordinary artifact tokens in their causal blocks while link and online tokens can attend to preceding valid blocks.Source: §C.3 · p. 25, Table 10 · p. 25
- COMB [18] exposes independently encoded artifacts through added cross-attention modules, while retaining a frozen original backbone and embeddings.The Qwen3 port inserts nine cross-attention points and trains the new encoder and related components.Source: §C.3 · p. 25
- Both baselines use ATTUNER’s 12,000 requests and teacher responses but train with response-token cross-entropy; the controlled run lasts one epoch and 750 updates.Efficiency timing includes online transfer, cache assembly, and method-specific online computation or repair, but excludes offline construction and training.Source: §C.3 · p. 25
D.1 Alternative Repair Interventions
Controlled interventions show that restoring Full routing reduces output divergence while retaining cached artifact KV, whereas positional alignment alone does not ensure task recovery. The diagnostics motivate adapting cache reading and do not establish that artifact values are unimportant.
D.1 Alternative Repair Interventions
- 0.794 to 0.975: PIC-Pos raises mean key cosine similarity to Full, yet both PIC and PIC-Pos answer the CHAMP example incorrectly.Full answers correctly; target-position encoding does not restore the contextual conditioning omitted by independent encoding.Source: Figure 10 · p. 26, §D.1 · p. 26
- Interventions replace artifact K, V, both, routing, or attention outputs under matched prompts and saved Full-response prefixes.The output-divergence measure averages response-position KL within each request and then equally across requests; it is not free-generation task accuracy.Source: §D.1 · p. 27
- 87.5% on MuSiQue and 93.0% on BigCodeBench: full-routing restoration reduces mean output KL relative to PIC.KL reductions occur in 31/32 MuSiQue examples and all 32 BigCodeBench examples.Source: Table 11 · p. 27, §D.1 · p. 27, Figure 11 · p. 27
- Higher output similarity need not mean better behavior: under all-layer K replacement, 14/32 MuSiQue examples have higher answer-position output cosine but worse KL.Poor V-only replacement increases KL, so the diagnostics do not show that values are unimportant.Source: §D.1 · p. 27
D.2 Limitations and Future Directions
- The evaluation treats skills, documents, and memories as separate task settings; mixed-artifact requests and other attention architectures remain unexamined.The paper focuses on cache reading, not storage or transport, and does not optimize cache placement, eviction, or communication.Source: §D.2 · p. 28
E Detailed Results by Evaluation Domain
Tables 12 and 13 reproduce the in-domain and out-of-domain results separately, with scores, timings, aggregates, and rankings unchanged. The section also clarifies the domain split and illustrates how artifacts are presented in evaluation examples.
E Detailed Results by Evaluation Domain
- Tables 12 and 13 reproduce the corresponding portions of Table 2, with all scores, timings, aggregate values, and rankings unchanged.Table 12 covers in-domain tasks; Table 13 covers out-of-domain tasks.Source: E Detailed Results by Evaluation Domain · p. 29, Table 12 · p. 29, Table 13 · p. 30
- In-domain tasks are BigCodeBench (BCB), MuSiQue (MSQ), and PersonaMem-v2 (PMem); out-of-domain tasks are TheoremQA (TQA) and CHAMP (CHP).TheoremQA uses one artifact, while CHAMP includes both single- and multiple-artifact requests; domain status reflects training coverage, not artifact count.Source: E Detailed Results by Evaluation Domain · p. 29
- Table 12 reports BCB pass@1, MSQ F1, and PMem accuracy; Table 13 reports accuracy for both TQA and CHP.Both tables report median warm-cache TTFT, arithmetic-mean score and change from Full, geometric-mean TTFT, and speedup relative to Full.Source: Table 12 · p. 29, Table 13 · p. 30
F Dataset Examples
- Dataset examples show full skill, document, and memory contents as independently cached artifacts, while current questions and task instructions remain online.Reference answers, code, and tests are illustrative and are not added to evaluated prompts; only line wrapping and typographic punctuation are normalized.Source: F Dataset Examples · p. 31
F.1 BigCodeBench: Reusable Skills
The examples show independently cached skills, supporting documents, and conversation messages paired with online tasks or questions. They illustrate how each artifact type supplies information needed for its task.
F.1 BigCodeBench: Reusable Skills
- BigCodeBench pairs independently cached geopy and Folium skills: geopy computes pairwise distances from coordinate tuples, while Folium builds maps and markers.The task is evaluated with task-specific tests, rather than textual agreement with the reference implementation.Source: §F.1 · pp. 31, 33, 35
F.2 MuSiQue: Supporting Documents
- MuSiQue's example caches two supporting documents whose cross-document link identifies Steve Hillage's partner, Miquette Giraudy, as required by the answer.The original document indices and relative order are retained, while other candidate documents are excluded.Source: §F.2 · p. 36
F.3 PersonaMem-v2: Relevant Memory Messages
- PersonaMem-v2's two-message cache supports a multiple-choice reference: option C includes drum practice mentioned in the historical assistant message.The messages retain their order and the saved answer-option mapping.Source: §F.3 · p. 37