PReCache:通过低秩预计算和中性重建实现多LoRA代理的高效KV缓存共享

·

研究论文 · 2026/09/29

多LoRA智能体系统通过共享骨干模型实现高效的角色专业化,但每个智能体重复处理不断增长的共享轨迹并构建自己的KV缓存,导致长时任务中的内存和计算冗余。现有KV缓存共享方法减少了重复预填充,但要么需要额外训练或架构约束,要么保留大量模型计算。此外,直接缓存重用会使当前智能体依赖前一个智能体适配器生成的缓存状态,削弱其自身LoRA编码的角色特定行为。我们提出PReCache,一种无需训练的KV缓存共享框架,包含PreLRShared和ReBaseShared两种设计,共享使用预训练权重计算的基础缓存,并预计算紧凑的智能体特定低秩(LR)缓存。为消除重复预填充,PreLRShared在首次处理共享上下文时预计算每个智能体的LR缓存,使当前智能体无需重新处理前序智能体已处理的上下文即可使用自己的LR缓存。为提高共享准确性,ReBaseShared从无适配器的隐藏状态重建共享基础缓存,减少前序智能体适配表示造成的剩余误差。为最小化重建成本,我们提出两种推理方案,分别针对单流推理和并发服务,在每轮智能体后执行相同重建或与其执行并行。在多个模型和智能体基准上,PreLRShared相比无KV缓存共享的推理实现了高达3.1倍的TTFT加速和2.3倍的每请求吞吐量提升。ReBaseShared在评估的缓存共享方法中整体上最好地保持了准确性,相对于无缓存共享推理平均仅下降1.1分。

该论文提出了一种无需训练的KV缓存共享方法,显著提升了多LoRA智能体系统的推理效率,同时保持了角色特定行为,具有较高的实用价值和创新性。

Multi-LoRA agent systems enable efficient role specialization by sharing a common backbone model. However, each agent repeatedly processes the growing shared trajectory and constructs its own KV cache, introducing substantial memory and computation redundancy in long-horizon tasks. Existing KV cache sharing methods reduce this repeated prefill, but they either require additional training or architectural constraints or retain substantial model computation. Moreover, direct cache reuse causes the current agent to rely on cache states generated by the previous agent's adapter, weakening the role-specific behavior encoded by its own LoRA. We present PReCache, a training-free KV cache sharing framework with two designs, namely PreLRShared and ReBaseShared, that share the base cache computed using the pretrained weights and precompute a compact agent-specific low-rank (LR) cache. To remove repeated prefill, PreLRShared precomputes each agent's LR cache when the shared context is first processed, allowing the current agent to use its own LR cache without reprocessing context processed by previous agents. To improve sharing accuracy, ReBaseShared reconstructs the shared base cache from adapter-free hidden states, reducing the remaining error caused by the previous agent's adapted representation. To minimize its reconstruction cost, we propose two inference schemes tailored to single-stream inference and concurrent serving, performing the same reconstruction after each agent's turn or alongside its execution, respectively. Across multiple models and agent benchmarks, PreLRShared achieves up to a 3.1x TTFT speedup and a 2.3x improvement in per-request throughput over inference without KV cache sharing. ReBaseShared best preserves accuracy overall among the evaluated cache-sharing methods, with an average drop of only 1.1 points relative to inference without cache sharing.

阅读原文

参与讨论