让多个LLM并行推理,共享注意力缓存加速复杂任务求解。
Hogwild! Inference: Parallel LLM Generation via Concurrent Attention
- 多个LLM实例共用动态更新的注意力缓存,实现即时信息共享。
- 无需微调,现有推理模型即可通过共享缓存提升并行效率。
- 利用旋转位置编码避免重复计算,适合需要长推理的任务。
大型语言模型(LLMs)通过高级推理、长文本生成和工具使用等能力,能够应对日益复杂的任务,但这些任务通常涉及长时间的推理计算。受人类协作启发,我们提出一种新的并行推理方法:让多个相同模型实例并行运行,通过一个不断更新的注意力缓存同步记忆,并自主决定协作策略。该方法无需额外微调,即可在现代推理型LLM中直接使用共享键值缓存。我们实现了名为Hogwild! Inference的并行推理引擎,利用旋转位置编码(RoPE)避免重复计算,显著提升硬件利用率。实验表明,该方法能有效加速复杂任务的推理过程。
原文摘要 · Abstract (English)
Large Language Models (LLMs) have demonstrated the ability to tackle increasingly complex tasks through advanced reasoning, long-form content generation, and tool use. Solving these tasks often involves long inference-time computations. In human problem solving, a common strategy to expedite work is collaboration: by dividing the problem into sub-tasks, exploring different strategies concurrently, etc. Recent research has shown that LLMs can also operate in parallel by implementing explicit cooperation frameworks, such as voting mechanisms or the explicit creation of independent sub-tasks that can be executed in parallel. However, each of these frameworks may not be suitable for all types of tasks, which can hinder their applicability. In this work, we propose a different design approach: we run LLM "workers" in parallel , allowing them to synchronize via a concurrently-updated attention cache and prompt these workers to decide how best to collaborate. Our approach allows the LLM instances to come up with their own collaboration strategy for the problem at hand, all the while "seeing" each other's memory in the concurrent KV cache. We implement this approach via Hogwild! Inference: a parallel LLM inference engine where multiple instances of the same LLM run in parallel with the same attention cache, with "instant" access to each other's memory. Hogwild! Inference takes advantage of Rotary Position Embeddings (RoPE) to avoid recomputation while improving parallel hardware utilization. We find that modern reasoning-capable LLMs can perform inference with shared Key-Value cache out of the box, without additional fine-tuning.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。