NVIDIA新研究:KV缓存可在模型间迁移,跳过预填充提速最高25倍
NVIDIA researchers did it again!
做LLM推理优化的同学必看,这是首个免训练的跨模型KV缓存迁移方案,直接解决模型切换时缓存失效的痛点,赶紧读论文验证一下效果。
NVIDIA researchers did it again!
NVIDIA 的研究人员又做到了!
They found a way to make KV cache transferable between models.
他们找到了一种让 KV 缓存可以在模型之间转移的方法。
The target model skips prefill entirely, and the conversion runs 2.7 to 25x faster than processing the context again.
目标模型完全跳过预填充,转换速度比重新处理上下文快 2.7 到 25 倍。
Let's understand why this is so important today.
让我们理解为什么这在今天如此重要。
LLM APIs are stateless, so every turn sends the entire conversation back to the model. The model reads all of it again before writing a single new token, and all of it is billed as input.
LLM API 是无状态的,因此每一轮都会将整个对话发送回模型。模型在写出一个新 token 之前会重新读取所有内容,并且所有内容都按输入计费。
Prompt caching allows Anthropic and other providers to hold the KV cache for a stable prefix and bill a hit at roughly 10% of the base input rate, because the compute was already done once.
提示缓存允许 Anthropic 和其他提供商为稳定的前缀保留 KV 缓存,并以大约基础输入费率 10% 的价格计费命中,因为计算已经完成过一次。
The 90% reduction is one of the largest lever in LLM serving, which is why so much production work goes into keeping prefixes byte-stable.
减少 90% 是 LLM 服务中最大的杠杆之一,这就是为什么这么多生产工作致力于保持前缀字节稳定。
But the cache only works on the model that produced it. Keys and values are produced from that model's weights, so no other model can read them.
但缓存只对产生它的模型有效。键和值是由该模型的权重产生的,因此没有其他模型可以读取它们。
In pratice, the constraint shows up in LLM routing. If the traffic is shifted to a different model for cost/capability reasons, the accumulated KV cache becomes invalid.
在实践中,这种限制在 LLM 路由中显现出来。如果由于成本或能力原因将流量转移到不同的模型,累积的 KV 缓存将变得无效。
As a result, the accumulated context has to be processed from scratch, and it's billed at full rate.
因此,累积的上下文必须从头开始处理,并按全价计费。
NVIDIA's recent paper treats this as a representation problem.
NVIDIA 最近的论文将此视为一个表示问题。
Prefill's only output is the KV cache, so to move KV between models, we need to convert one model's cache into the format the other expects.
预填充的唯一输出是 KV 缓存,因此要在模型之间移动 KV,我们需要将一个模型的缓存转换为另一个模型期望的格式。
They first checked whether the conversion has any structure worth exploiting.
他们首先检查了转换是否具有任何值得利用的结构。
They found that moving from Qwen3 14B to 32B, a plain linear regression from a single source layer reconstructed 56% of the variance in the target model's keys.
他们发现,从 Qwen3 14B 迁移到 32B,从单个源层进行的简单线性回归重建了目标模型键中 56% 的方差。
The two models obviously may have different layer counts, so there is no natural one-to-one pairing between them.
这两个模型显然可能具有不同的层数,因此它们之间没有自然的一对一配对。
For each target layer they rank every source layer by how well it predicts that layer, then feed the top eight in together, which takes the reconstruction to 79%.
对于每个目标层,他们根据每个源层预测该层的能力对其进行排名,然后将前八名一起输入,这将重建率提高到 79%。
The mapper itself has three parts:
映射器本身由三部分组成:
> Each target layer and head gets its own independent linear map, solved in one closed-form step rather than by gradient descent.
> 每个目标层和头都有自己的独立线性映射,通过一步闭式求解而不是梯度下降来求解。
> The cross-layer selection described above is the second part, and their ablation shows it carries the most weight of the three.
> 上述跨层选择是第二部分,他们的消融研究表明它在三部分中权重最大。
> Keys also carry a position-dependent rotation from RoPE. They strip that rotation, fit the map in position-free space, then re-apply the target model's rotation at inference.
> 键还带有来自 RoPE 的与位置相关的旋转。他们剥离该旋转,在无位置空间中拟合映射,然后在推理时重新应用目标模型的旋转。
Across six pairs from Qwen3, Llama 3.1 and Ministral 3, four retain 73 to 98% of the receiving model's standalone accuracy, and the conversion runs 3-25x faster than processing the context again.
在Qwen3、Llama 3.1和Ministral 3的六对模型中,有四对保留了接收模型独立准确率的73%至98%,且转换速度比重新处理上下文快3-25倍。
Prior work on cross-model KV reuse exists, but it either trains a neural adapter per pair or requires both models to be architecturally identical.
先前已有跨模型KV重用的研究,但要么需要为每对模型训练神经适配器,要么要求两个模型架构完全相同。
This is probably the first version that is closed-form and training-free, so a lot of it is still open research.
这可能是第一个闭式且无需训练的版本,因此很多方面仍是开放研究。
Every pair tested belongs to one family, so it works on Qwen to Qwen and Llama to Llama.
测试的每一对都属于同一家族,因此适用于Qwen到Qwen、Llama到Llama。
Cross-family transfer is listed as future work.
跨家族迁移被列为未来工作。
All six pairs mentioned above also happen to share KV head count and per-head dimension across scales. Mismatched head configurations are currently untested.
上述六对模型恰好共享KV头数和每头维度,尽管规模不同。头配置不匹配的情况目前尚未测试。
The researchers scoped this to dense full-attention only, so sliding-window and attention-recurrent hybrids still need work.
研究人员仅将范围限定为密集全注意力,因此滑动窗口和注意力循环混合体仍需研究。
Here's the paper: https://arxiv.org/abs/2608.03893
论文链接:https://arxiv.org/abs/2608.03893
Plenty of work is yet to be done. Still, the constraint being solved is genuine.
还有很多工作要做。不过,所解决的约束是真实存在的。
Every model swap currently invalidates the full KV that was already paid for, and this is the first result showing that work might be recoverable without training anything extra.
目前每次模型切换都会使已支付的完整KV失效,而这是首个表明无需额外训练即可恢复这些工作的成果。
That said, all of this only matters because of what the KV cache is doing in the first place.
话虽如此,这一切之所以重要,首先是因为KV缓存的作用。
I wrote a first-principles breakdown of it, covering why the model stores keys and values at all, why the cache grows with every token, and what generation speed looks like with and without it.
我写了一篇从基本原理出发的分析,涵盖模型为何存储键和值、缓存为何随每个词元增长,以及有和没有缓存时的生成速度。
Read it below.
请在下方阅读。
更进一步:量化金融体系
看懂新闻只是起点——沿量化金融路径,把它变成能交付的工程能力