arXiv:2505.02922cs.LG2025-05中稿 · VLDB 2026被引 7

通过稀疏注意力优化长文本推理,显著提升速度且不损失精度。

RetroInfer: A Vector Storage Engine for Scalable Long-Context LLM Inference

  • 用三段式近似与聚类索引实现高效稀疏缓存检索
  • 在12万上下文长度下提速4.4倍,百万级上下文提速12.2倍
  • 适合需要高吞吐长文本生成的场景,如文档摘要、代码理解

当前大语言模型正不断扩展上下文窗口,但推理吞吐受限于日益增长的GPU内存与带宽需求。原因在于键值(KV)缓存随上下文长度线性增长,且注意力计算需迭代扫描。一种有前景的加速方法是利用注意力的固有稀疏性,将KV缓存卸载至CPU内存,仅检索对当前生成步骤重要的少量标记。然而,现有稀疏注意力方法难以在准确率与检索成本间取得平衡,主要因稀疏模式变化大且跨设备内存管理低效。我们提出RetroInfer,一个面向长上下文推理的向量存储引擎。它引入注意力感知的向量索引(wave index),通过三重注意力近似、精度约束估计与分段聚类,从根本上优化了准确率与检索开销的权衡。同时设计wave buffer,作为异构硬件间的缓冲管理器,智能分配计算与数据。我们在多种模型与工作负载上评估RetroInfer,结果显示:在12万上下文长度下,解码吞吐较全注意力提升4.4倍;在百万级上下文下,较稀疏注意力基线提升12.2倍,且保持全注意力级别的准确率。

原文摘要 · Abstract (English)

Recent large language models (LLMs) are rapidly extending their context windows, yet inference throughput lags due to increasing GPU memory and bandwidth demands. This is because the key-value (KV) cache, an intermediate structure storing token representations, grows linearly with context length and requires an iterative linear scan for attention computation. A promising direction to accelerate long-context inference is to exploit attention's inherent sparsity by offloading the KV cache to CPU memory and retrieving only a small subset of tokens important to the current generation step. However, prior sparse attention approaches struggle to balance accuracy and retrieval cost due to varying sparsity patterns and inefficient GPU-CPU memory management. We present RetroInfer, a vector storage engine that realizes a sparsity-based KV cache for long-context inference. RetroInfer introduces an Attention-aWare VEctor index (wave index), which fundamentally improves the tradeoff between attention accuracy and retrieval cost through tripartite attention approximation, accuracy-bound attention estimation, and segmented clustering. We also design the wave buffer, a GPU-CPU buffer manager that assigns computation and manages data across heterogeneous hardware. We evaluate RetroInfer across a range of models and workloads, demonstrating up to 4.4X decoding throughput over full attention at 120K context and up to 12.2X over sparse attention baselines at 1 million tokens -- all while preserving full-attention-level accuracy.

长上下文稀疏注意力推理优化向量存储

Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。