To cache or not to cache: understanding and mitigating security incompatibility in cross-model KV cache reuseTo Cache or Not to Cache: Understanding and Mitigating Safety Incompatibility in Cross-Model KV Cache Reuse
The authors use VReparo to correct reused values; average HarmBench ASR across four settings drops from 57.28% to 39.21%.
The paper does not define an adversarial attacker. The setting is prefix KV reuse between related models: the sender generates K/V, and the receiver decodes under full KV, K-only, V-only, or DroidSpeak. Deviation from the receiver's native safety behavior is called safety incompatibility. The paper states it does not construct adversarial caches.
- Reusing the sender's prefix KV across models can reduce the receiver's prefill, but existing work mainly looks at latency and generation quality. The authors want to quantify the deviation of such reuse from the receiver's native safety behavior, i.e., safety incompatibility.
- Compare full KV, K-only, and V-only, and use metrics such as SDV to measure deviation from native safety scores. VReparo fits an affine mapping per layer and per KV head offline, maps the reused values once before decoding, and does not change keys or model weights.
- In Table 2, across all eight pairs, the deviation of V-only from native ASR is greater than that of K-only. Across the four settings, VReparo reduces average HarmBench ASR from 57.28% to 39.21% and average StrongREJECT from 0.4215 to 0.2163.
- The conclusion notes the trade-off between benign refusal and answer quality. Mitigation experiments use two model pairs, full KV and DroidSpeak, with five fitting samples. The paper states it does not construct adversarial caches; timing excludes sender prefill and cache transfer.
- Evaluated models
- Qwen3-4B (Base)Qwen3-4B (Instruct)Qwen3-8B (Base)Qwen3-8B (Instruct)Llama-3.2-3B (Base)Llama-3.2-3B (Instruct)Llama-3-8B (Base)Llama-3-8B (Instruct)Gemma-2-2B (Base)Gemma-2-2B (Instruct)Mistral-7B-v0.3 (Base)Mistral-7B-v0.3 (Instruct)LoRI-D (Code)LoRI-D (Safety)
- Benchmarks
- HarmBenchStrongREJECTHotpotQAHEx-PHIXSTestOR-Bench2WikiMultihopQAMultiFieldQA-enLongBench-E
- Metrics
- HarmBench ASRStrongREJECT scoreΔSSDSISDVTTFTtoken-level F1OR-Bench full refusal
The researchers systematically evaluate the impact of cross-model KV cache reuse on the safety behavior of the receiving model and propose a repair method, VReparo, which reduces the average HarmBench attack success rate from 57.28% to 39.21% on two model pairs. They call the receiving model's deviation from its own native safety behavior safety incompatibility, finding that its direction and magnitude depend on the model pair and reuse configuration, and that value reuse causes larger shifts than key reuse across all tested model pairs. VReparo learns layer-wise, per-KV-head affine mappings offline to align reused sender value tensors to the receiver's native state before decoding. The paper reports that under full KV reuse and the current best selective reuse settings, the average StrongREJECT score drops from 0.4215 to 0.2163 while preserving an average TTFT reduction of 85.62%.
Paper analysis
What problem does this paper attempt to solve?
Cross-model reuse of the sender's KV makes the receiver deviate from native safety behavior.
When reusing KV generated by the sender across models, the receiver's safety behavior deviates from its native inference.
- Scenario: Service systems reuse KV of shared prefixes to reduce prefill. In cross-model reuse, the sender generates the prefix K/V and the receiver uses it directly. The authors argue these states enter subsequent attention, so this is not just a storage optimization. Figure 1 shows a case: native inference refuses, but after reuse it becomes a harmful answer.
- Existing gaps: Activated LoRA, DroidSpeak, etc., mainly evaluate generation quality and service performance. The authors state that quantizing or compressing the model's own KV can already change safety behavior; in cross-model reuse, the state comes from another model, and whether the receiver's native safety behavior is preserved is unclear.
- Observation: The authors call the deviation from the receiver's native safety behavior safety incompatibility. The direction can be more harmful or the opposite; the magnitude and direction depend on the model pair and on whether K, V, or both are reused. The authors state that, on the evaluated pairs, value reuse causes larger deviation than key reuse.
- Threat model:
- Target: relevant model pairs. A base provides cache to its instruction-tuned model; LoRI-D's Code and Safety variants reuse bidirectionally.
- Capability: the receiver reuses the sender's prefix K and/or V, with unselected components provided by the receiver. Diagnostic configurations are full KV, K-only, V-only.
- Non-adversarial: the paper states it does not construct adversarial caches, and experiments do not target deployed third-party services.
- Judgment: on the same prompt, compare the harmfulness score of the reused output with the receiver's native output.
- This paper's approach: characterize the phenomenon with safety score shift, worse, better, and absolute deviation, and propose VReparo: offline learning of layer-wise, KV-head-wise affine mappings that align reused values toward the receiver's native values before decoding.
What related research exists?
Related work mainly evaluates KV efficiency and generation quality, or addresses the safety impact of a model's own cache.
Service-side KV optimization
- vLLM (Kwon et al., 2023) manages and reuses KV cache for shared prefixes.
- Token retention includes H2O (Zhang et al., 2023) and SnapKV (Li et al., 2024); KIVI (Liu et al., 2024) does quantization; KVSharer (Yang et al., 2024) does cross-layer sharing.
Cross-model reuse
- Activated LoRA (Greenewald et al., 2025; Li et al., 2025) lets adapters reuse the base cache of tokens activated before.
- DroidSpeak (Liu et al., 2026) selectively recomputes some layers for a shared prefix and reuses the sender's KV for the rest.
- Other approaches include closed-form affine mapping (Heo et al., 2026), head-local mapping (Qu et al., 2026), reconstruction from compact semantic codes with selective patching (Ma et al., 2026a), and cache fusion across models (Fu et al., 2026). The authors state these works mainly target efficiency and generation quality.
Safety impact of one's own cache and mitigations
- The authors state that compression can affect safety-related capabilities (Liu et al., 2025), and jailbreaks can be weakened or strengthened depending on the compression interval (Ma et al., 2026b); low-bit KV quantization can reduce refusals while general utility remains largely stable (Xu et al., 2026).
- HijackKV (Zhang et al., 2026) exploits position-independent reuse to inject attacker-controlled context via caches associated with benign text. The authors state this paper does not construct adversarial caches.
- Existing mitigations include eviction that preserves instructions and reduces system prompt leakage (Chen et al., 2025), Safe-CAM's history-aware merging (Ma et al., 2026b), channel-wise reduction-guided quantization repair (Xu et al., 2026), and AnchorKV's refusal-aware token retention (Ni & Lao, 2026). The authors state these methods mainly handle transformations of the model's own cache.
Baselines and benchmarks
- Comparisons are receiver-native inference and uncorrected reuse; selective reuse uses DroidSpeak. Safety benchmarks are HarmBench and StrongREJECT.
The authors position this paper as: characterizing safety incompatibility across sender–receiver pairs and reuse configurations, and using VReparo to map reused values toward the receiver's native values while preserving the prefill savings from cross-model reuse.
How does the paper address this problem?
VReparo fits per-layer, per-head affine mappings offline and only corrects reused values before decoding.
The authors first measure the deviation of reuse from native safety scores, then apply offline correction to the value component, which deviates more. The mitigation method is named VReparo. The pipeline is shown in Figure 2.
Reuse configurations
- Prefill saves K and V at each layer; during decode, new tokens only append their own states. The cross-model configuration ρ=(UK, UV) specifies which layers reuse the sender's K or V, with the remaining components provided by the receiver.
- In the diagnostic experiments of Section 4, the sender cache and the receiver's native cache are independently generated from the same token sequence and then concatenated. K-only uses the sender's keys with the receiver's native values; V-only is the opposite; full KV takes both from the sender.
- Each configuration is initialized with the cache of the prompt prefix and processes the same boundary token. Without reuse, the receiver builds its own prefix cache.
- When evaluating VReparo, DroidSpeak is used: within selected receiver layer blocks, the shared prefix has KV recomputed from the sender's intermediate hidden states; other layers reuse the sender's KV, and the receiver then processes the suffix.
Definition of safety incompatibility
- The harmfulness evaluation σ(y, x) takes values from 0 to 1, with 0 being safe and higher values indicating greater risk. ΔS is the average of reuse score minus native score; SD and SI accumulate only the worse and better parts, respectively; SDV is the average of absolute differences, defined in equation (6).
- The authors note that SD and SI can cancel each other out, so a small |ΔS| does not imply compatibility. SDV of 0 means safety scores exactly match native on that prompt set.
- HarmBench judgments take values in {0, 1}, and StrongREJECT scores are in [0, 1]. For HarmBench, SD, SI, and SDV are the proportion of prompts where the label changes, and ΔS is the difference in ASR, in percentage points.
VReparo
- For a fixed sender, receiver, and ρ, an affine mapping is fitted offline on each layer and each KV head of the reused values, without updating either language model and without an online reference prefill per request. Keys, recomputed values, and model weights are unchanged.
- Fitting does not use task or safety labels. The same tokenized input is used to construct the cache under ρ and the receiver's native cache, collecting value pairs at matching positions. Closed-form ridge makes the mapped values close to native values and penalizes the matrix deviating from the identity; the bias is not penalized. A is a full matrix, λ is fixed across all model pairs and configurations, and the intercept is set to 1.
- Additionally, a scalar strength α⋆ is selected on behavioral data, in the range [0, 1], and fixed across requests for that (sender, receiver, ρ). Before decoding, each reused value is replaced with
v̂n=vρn+α⋆(A⋆vρn+b⋆−vρn)
This moves the reused value toward the fitted native value by α⋆. When α⋆ is 0, it is unchanged; when 1, the full mapping is used.
- For full KV, the mapping is applied to the sender's prompt values, then the boundary token is processed. DroidSpeak maps only the reused prefix values outside the recomputation layer blocks. The receiver then autoregressively decodes with original weights; newly produced values during decoding are not mapped, and no safety labels are needed at inference.
Fitting, calibration, and layer selection
- Each fit uses 32 HotpotQA and 32 HEx-PHI items, sampled over five random seeds. The appendix states that fitting does not use labels, but HEx-PHI inputs are not limited to benign text. When cache length does not exceed 128, all positions are used; otherwise, the first 128 positions are taken with step floor(L/128); DroidSpeak samples only on the reused shared prefix.
- α candidates are 0.1, 0.25, 0.5, 1, selected by string refusal rate on XSTest: relative to uncorrected reuse, refusal on unsafe prompts must increase; relative to native, refusal increase on safe prompts must not exceed 5 percentage points, and no more than 20 percentage points per safe subcategory. Maximize the increase in unsafe refusal, with ties broken by smaller α. XSTest has 250 safe prompts and 200 unsafe prompts.
- DroidSpeak's recomputation layer block is selected only by question-answering F1, not safety scores: on 50 HotpotQA items, compare 136 contiguous blocks of two layers each, and take the smallest budget reaching 95% of native F1. Both model pairs fix the block to zero-starting layers [0, 1].
What experiments did the paper conduct?
The authors report: across eight pairs, value deviation is larger; average ASR across four settings drops from 57.28% to 39.21%.
Experimental Setup
- Models: For characterization experiments, receivers are instruction-tuned Qwen3-4B, Qwen3-8B, Llama-3.2-3B, Llama-3-8B, Gemma-2-2B, Mistral-7B-v0.3, and senders are the corresponding bases. LoRI-D's Code and Safety share Meta-Llama-3-8B, evaluated bidirectionally. Mitigation experiments use only LoRI-D (Code→Safety) and Llama-3-8B (base→Instruct).
- Data: Characterization uses 159 HarmBench and 313 StrongREJECT directly harmful requests, without optimizing jailbreak prompts; only prompts passing validity checks in all compared conditions are kept, so n and native ASR differ across tables. Mitigation uses 127 HarmBench after removing the 32-item development subset and all 313 StrongREJECT, without that filtering.
- Comparisons and configurations: receiver-native inference, uncorrected reuse; selective reuse is DroidSpeak, with layers [0, 1] recomputed for both pairs. Section 4 additionally compares K-only and V-only.
- Metrics: HarmBench ASR; StrongREJECT average score (0–1); ΔS, SD, SI, SDV relative to native. QA is token-level F1. OR-Bench full refusal means refusing to assist without providing a substantive completion. TTFT is measured with resident sender cache; speedup is native TTFT divided by VReparo TTFT.
- Evaluation: HarmBench-Llama-2-13b-cls, BF16, looking at the first 512 tokens of the response, strict yes/no. StrongREJECT uses Gemma-2B with strongreject-15k-v1, looking at the last 512 tokens. OR-Bench has 200 items, 20 per category, judged by Qwen3-8B, with no human adjudication. Llama-3-8B full Reuse and corrected seeds 0 and 3 each have 1/200 items that cannot be scored.
- Implementation: FP16, no quantization, greedy; safety and refusal up to 512 tokens. VReparo safety numbers are averages over five fitting seeds; the authors state they report point estimates. Characterization experiments do not report the number of repetitions. The native implementations of full reuse and DroidSpeak differ, and saved native outputs are not always identical.
Main Results
HarmBench ASR for mitigation evaluation (Table 10; VReparo is the average of five runs; 127 items, without Section 4's validity filtering):
Swipe horizontally to read the table
Setting Native Reuse VReparo LoRI-D Full KV 29.13% 79.53% 64.09% LoRI-D DroidSpeak 29.13% 82.68% 60.47% Llama-3-8B Full KV 7.09% 34.65% 14.65% Llama-3-8B DroidSpeak 7.09% 32.28% 17.64% - The authors report in Table 3 that, across four settings and two benchmarks, VReparo's ΔS, SD, and SDV are all lower than uncorrected reuse. HarmBench SDV goes from 58.27% to 42.83%, 59.84% to 38.58%, 33.86% to 12.60%, and 26.77% to 13.39%.
- The abstract gives the average over these four settings: HarmBench ASR from 57.28% to 39.21%, StrongREJECT from 0.4215 to 0.2163. The authors state that absolute ASR and StrongREJECT average scores remain higher than Native; in Table 10, StrongREJECT average scores are 0.6431, 0.6353, 0.2505, 0.1569 for uncorrected, and 0.3966, 0.3916, 0.0373, 0.0398 for VReparo.
- OR-Bench full refusal: LoRI-D full from 4.0% to 12.6% (Native 11.0%), Llama-3-8B full at 25.3% (Native 10.0%). The authors state that XSTest constraints do not guarantee OR-Bench refusal rates match native. Across five seeds, two benchmarks, and four settings, SDV is lower than uncorrected reuse.
Characterization of Safety Incompatibility
Full KV, scores relative to native (Table 1; n in Table 5, HarmBench ΔS in percentage points, SDV in %):
Swipe horizontally to read the table
Model pair (S→R) nHB HB ΔS HB SDV SR ΔS SR SDV Qwen3-4B Base→Instruct 158/159 +10.13 16.46% +0.0495 0.0938 Qwen3-8B 132/159 -2.27 3.79% -0.0260 0.0414 Llama-3.2-3B 150/159 +8.67 18.00% +0.0781 0.1236 Llama-3-8B 157/159 +24.84 31.21% +0.2383 0.2391 Gemma-2-2B 158/159 +20.25 21.52% +0.1564 0.1589 Mistral-7B-v0.3 159/159 +9.43 24.53% +0.0882 0.2306 LoRI-D Code→Safety 135/159 +54.81 60.74% +0.5648 0.5790 LoRI-D Safety→Code 137/159 -44.53 51.82% -0.4512 0.4886 - The authors state that five of the six base/instruct pairs show increased harmfulness; Qwen3-8B decreases on both metrics but still has label changes. In Table 5, Gemma-2-2B's ASR goes from 1.27% to 21.52%, and Llama-3-8B from 6.37% to 31.21%.
- LoRI-D in Code→Safety has ASR from 25.93% to 80.74% and StrongREJECT average from 0.1093 to 0.6741 (Table 5, Table 6). In the reverse direction, ASR decreases, HarmBench SD is 3.65%, and 5 of 137 items change from judged safe to harmful. The authors state that a shared base does not guarantee safety compatibility.
- The authors' answer to RQ1: safety incompatibility appears in all evaluated pairs; SD and SI can coexist; when average harmfulness decreases, some answers still become more harmful.
Reused Components
- Table 2 keeps only prompts valid under Native, K-only, V-only, and full KV, with n from 121 to 158, so native ASR differs from Table 5. Across eight pairs, V-only's ASR difference relative to Native is larger than K-only; for six base/instruct pairs, V-only ASR is higher than K-only. Full KV ASR is lower than V-only for all eight pairs.
- Direction varies by model pair. Llama-3-8B (n=138) V-only ASR is 57.25%, a +51.45 percentage point difference relative to Native 5.80%; K-only is 18.12%. Qwen3-8B (n=129) V-only difference is +2.33 percentage points, and full KV difference is -2.33 percentage points.
- LoRI-D when Safety reuses Code: V-only ASR is 81.89%, full KV is 81.10%, K-only is 24.41% (Native 26.77%, n=127). In the reverse direction, V-only goes from 82.03% to 40.62%, K-only is 82.81% (n=128). The authors' answer to RQ2: on HarmBench, V-only ASR changes more than K-only; increase or decrease depends on the model pair and configuration.
Latency and QA Quality
- Table 4 uses a different fitting set, not the average of the five safety experiments; its XSTest-calibrated α is 1 for LoRI-D and 0.25 for Llama-3-8B. With resident sender cache, the authors state the average TTFT reduction across four settings is 85.62%. Speedups are 15.24×, 4.49×, 15.21×, 4.52×.
- The authors state that, relative to uncorrected reuse, the implementation-level TTFT overhead is about 34 ms (full KV) and about 97 ms (DroidSpeak), with per-token generation time essentially unchanged (about 51 ms/token in Table 4). Timing excludes sender prefill, cache transfer, tokenization, and distributed scheduling. The appendix states that the current DroidSpeak-plus-VReparo implementation includes two suffix prefills, and the overhead includes implementation cost.
- Five runs, 248 HotpotQA items: Llama-3-8B F1 under DroidSpeak goes from 43.43 to 43.42, and full reuse from 9.68 to 10.55, below native 47.91 (Section 6.2). The authors state that value mapping does not generally restore native QA quality.
Other Ablations and Analyses
- α (Table 11): LoRI-D is 1 in all five runs; Llama-3-8B full is 0.5 in all; its DroidSpeak is 0.5 in three runs and 0.25 in two.
- Same table: Llama-3-8B DroidSpeak at α=0.25 has HarmBench SDV of 16.54% and 17.32%, and the three runs at α=0.5 have 11.02%.
- Table 9: Llama-3-8B full KV HotpotQA F1 is Native 49.64, Reuse 9.64, VReparo 11.54 (149 items); DroidSpeak is 47.46, 43.43, 43.36 (248 items).
- The authors state that LoRI-D full KV is below uncorrected reuse on all three QA sets, with a 12.52% relative drop on 2WikiMultihopQA (F1 from 25.19 to 22.03, 200 items).
- The authors state that the 95% layer selection target does not guarantee evaluation quality: in Table 9, Llama-3-8B DroidSpeak retains only 91.52% of native HotpotQA F1 before mapping.
- Table 3: LoRI-D full HarmBench SI is 3.94% both before and after correction; for several settings, SI does not decrease along with SDV.
What are some points that can be further explored?
The conclusion states the trade-off between refusal and quality; the main text has no dedicated Limitations section.
Limitations and future directions noted by the authors
- The paper has no dedicated Limitations, Discussion, or Future Work sections. The Conclusion states: in the evaluated settings, VReparo improves safety compatibility and preserves the TTFT reduction, while there is a trade-off in benign refusal and answer quality.
- Appendix A.1 states: the retrospective annotation used to exclude invalid outputs was assisted by Codex, not an independent human audit; passing the validity check does not prove semantic validity or benign task quality.
Experimental coverage
- Characterization experiments cover six base/instruction-tuned pairs across four model families, plus LoRI-D Code/Safety in both directions (Section 4.2). Safety requests are 159 directly harmful requests from HarmBench and 313 from StrongREJECT, without optimizing jailbreak prompts (Appendix A.1).
- Mitigation evaluation covers LoRI-D (Code→Safety) and Llama-3-8B (base→Instruct), each with full KV and DroidSpeak; HarmBench has 127 items and StrongREJECT 313; fitting and α selection are repeated over five seeds (Section 6.1).
- Evaluation uses HarmBench-Llama-2-13b-cls (first 512 tokens of response) and Gemma-2B with strongreject-15k-v1 (last 512 tokens); 200 OR-Bench items are judged by Qwen3-8B (Appendix A.1, B.2).
- The paper states that the caches studied are produced by the relevant models, with no adversarial cache construction (Section 2). DroidSpeak's recomputation block is fixed to layers [0, 1] for both pairs (Appendix B.1).
- Timing is done on NVIDIA A40 with 50 HotpotQA items and five timing repetitions, excluding sender prefill, cache transfer, tokenization, and distributed scheduling (Section 6.2). Characterization experiments do not report the number of repetitions.
Summarize the main content of the paper
Reuse can change safety behavior in both directions; VReparo reduces deviation but still remains above native.
The authors study whether cross-model prefix KV reuse changes the receiver's safety behavior relative to its own native inference, and call this deviation safety incompatibility.
- Problem: The K/V generated by the sender is used by the receiver for subsequent attention. Existing cross-model reuse mainly looks at latency and generation quality; the authors also look at safety scores getting worse, getting better, and absolute deviation.
- Approach: In base-to-instruction-tuned, and LoRI-D Code/Safety bidirectional settings, compare full KV, K-only, and V-only. VReparo fits layer-wise, per-KV-head affine mappings offline for each sender, receiver, and configuration, and before decoding only modifies the reused values, not keys or weights.
- Characterization: In Table 5, Llama-3-8B full KV HarmBench ASR goes from 6.37% to 31.21% (157/159); Qwen3-8B goes from 6.82% to 4.55%, while still having label changes. LoRI-D in Code→Safety has ASR from 25.93% to 80.74%; in the reverse direction ASR decreases, with 5 of 137 still changing from safe to harmful.
- Components: Across the eight pairs in Table 2, V-only's difference from native ASR is greater than K-only's. Llama-3-8B V-only ASR is 57.25%, with a difference of +51.45 percentage points from Native.
- Mitigation: Across two model pairs, full KV and DroidSpeak in four settings, the five-run average HarmBench ASR mean goes from 57.28% to 39.21%, and StrongREJECT from 0.4215 to 0.2163, but still higher than each Native. Under the other mapping in Table 4 with a resident sender cache, the average TTFT reduction is 85.62%.
- Authors' conclusion: Reuse can shift the receiver's safety behavior in either direction, and reused values affect safety behavior more than keys. The authors state that VReparo improves safety compatibility and preserves the TTFT reduction, while having trade-offs in benign refusal and answer quality.