多代理大模型中,共享缓存降低内存开销,提升推理效率。
LRAgent: Efficient KV Cache Sharing for Multi-LoRA LLM Agents
- 将缓存分解为共享基础部分和适配器依赖部分,按需共享与压缩存储。
- 在多个代理任务上实现接近全共享缓存的吞吐量和首字延迟。
- 适合需要高效运行多个轻量化适配器的智能体系统开发者。
多大模型代理系统中角色专业化通常通过多LoRA实现,各代理共享预训练主干网络,仅通过轻量级适配器区分。尽管共享主干权重,每个代理仍独立构建并存储相同长序列、工具增强轨迹的KV缓存,造成显著内存与计算开销。现有缓存共享方法大多忽略此多LoRA场景。我们观察到,代理间缓存差异主要源于适配器输出,而共享预训练主干的激活高度相似。基于此,提出LRAgent,一种面向多LoRA代理的缓存共享框架。它将缓存分解为由预训练权重生成的共享基础部分和由LoRA权重生成的适配器依赖部分。LRAgent通过跨代理共享基础部分,并以低秩形式存储适配器部分,降低内存开销;同时通过共享低秩缓存(基于共享-A多LoRA架构),避免重复计算已处理上下文,减少计算开销。为高效运行时重建适配器贡献,引入Flash-LoRA-Attention核,重排注意力计算顺序,避免将低秩缓存展开至全维度。LRAgent在多个代理问答基准测试中,实现接近全共享缓存的吞吐量与首字延迟,同时保持接近非共享缓存基线的准确性。
原文摘要 · Abstract (English)
Role specialization in multi-LLM agent systems is often realized via multi-LoRA, where agents share a pretrained backbone and differ only by lightweight adapters. Despite sharing base model weights, each agent independently builds and stores its own KV cache for the same long, tool-augmented trajectories, incurring substantial memory and compute overhead. Existing KV cache sharing methods largely overlook this multi-LoRA setting. We observe that, cache differences across agents are dominated by adapter outputs, while activations from the shared pretrained backbone remain highly similar. Based on this observation, we propose LRAgent, a KV cache sharing framework for multi-LoRA agents. It decomposes the cache into two components, a shared base component derived from pretrained weights and an adapter-dependent component derived from LoRA weights. LRAgent reduces memory overhead by sharing the base component across agents and storing the adapter component in its inherent low-rank form. It also reduces computational overhead by sharing the low-rank cache, enabled by a shared-A multi-LoRA architecture. This avoids redundant computations for contexts that have already been processed by other agents. To efficiently reconstruct adapter contributions at runtime, we introduce Flash-LoRA-Attention, a kernel that reorders attention computation to avoid materializing the low-rank cache to full dimension. LRAgent achieves throughput and time-to-first-token latency close to fully shared caching, while preserving accuracy near the non-shared caching baseline across agentic question-answering benchmarks.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。