跨模型KV缓存迁移:线性映射实现预填充复用

Cross-Model KV Cache Transfer in LLM Families: A Closed-Form Linear Mapping for Prefill Reuse

精选理由

同系列模型切换总得重新预填充?这篇用线性映射传KV缓存,能省2.7到25倍时间,四对组合还保住九成以上准确率。

AI 摘要

论文提出跨模型KV缓存迁移,让同系列不同尺寸模型切换时直接复用源模型的KV缓存,省去接收方从头预填充。在Qwen3 14B到32B上,单个源层能解释目标键56%的方差、值的32%,多个源层提升到79%和65%。方法用闭式岭回归映射器,基于500条FineWeb-Edu序列(每条1024 token)拟合,并在映射前剥离RoPE以保持位置无关。在三个模型族的六对组合中,四对保留了73%到98%的独立预填充准确率,两对退化严重,用非线性MLP最多挽回37个百分点HellaSwag;映射器比重新预填充快2.7到25倍。

原文 · arXiv cs.LG

Cross-Model KV Cache Transfer in LLM Families: A Closed-Form Linear Mapping for Prefill Reuse

Production deployments often swap between different-sized models in a family for cost-quality cascading, mid-conversation switching, and routing, and each swap forces the receiver to repay the prefill from scratch. We propose cross-model KV cache transfer, where the receiver reuses the source's KV cache, skipping prefill. We find that cross-model KV has substantial linear structure across matched-KV pairs, where source and target share KV head count and per-head dimension. On Qwen3 14B->32B, one source layer explains 56% of variance in the target's keys and 32% in values, rising to 79% and 65% with multiple source layers. Building on this, we design a closed-form ridge mapper that operates per head and proceeds in three steps. First, for each target layer we select the top-k most predictive source layers and concatenate their KV as input. Second, we strip RoPE from the keys before mapping, so the fit is position-free and reusable across context lengths. Third, we fit ridge regression on a small calibration set of 500 FineWeb-Edu sequences of 1,024 tokens each. Surprisingly, across six pairs in three families, this linear mapper retains 73-98% of the receiver's standalone-prefill accuracy on four pairs, while two degrade sharply. A nonlinear MLP recovers up to +37 pp HellaSwag retention on the failures. The mapper runs 2.7-25x faster than re-prefill and remains stable across multi-turn handoff, making cross-model KV cache transfer practical.