arXiv:2512.22195cs.DCcs.AI2025-12中稿 · publication in ICD…被引 1

用闪存预存大模型推理的键值对,省电省时

MatKV: Trading Compute for Flash Storage in LLM Inference

  • 把RAG的键值对预先存到闪存,避免每次推理都用GPU计算
  • 相比纯GPU计算,推理耗时和功耗减半,问答准确率几乎不变
  • 支持低配显卡运行,还能并行加载与解码,提升效率

我们观察到生成式AI中推理成本已超过训练,且检索增强生成(RAG)日益普及。处理长输入时,RAG的预填充阶段计算键值向量(KVs)能耗高、耗时长,即使使用高端GPU也如此。为此,我们提出MatKV:将RAG对象(如文档)的键值对预先计算并存储在廉价、快速、低功耗的闪存中,推理时直接复用,避免昂贵且低效的GPU重算。实验基于Hugging Face Transformers库,在主流GPU与闪存固态硬盘上验证,相比全在GPU上计算KVs,MatKV使RAG任务的推理时间与功耗均降低50%,问答准确率无明显下降。此外,MatKV支持两项优化:其一,GPU可同时解码与加载下一实例的材料化KVs,降低等待延迟;其二,因解码速度对显卡性能不敏感,低配GPU在加载材料化KVs后也可高效解码,显著提升硬件适配性。这些结果表明,MatKV能大幅降低大规模生成式AI应用的成本、功耗与硬件门槛。

原文摘要 · Abstract (English)

We observe two major trends in LLM-based generative AI: (1) inference is becoming the dominant factor in terms of cost and power consumption, surpassing training, and (2) retrieval augmented generation (RAG) is becoming prevalent. When processing long inputs in RAG, the prefill phase of computing the key-value vectors of input text is energy-intensive and time-consuming even with high-end GPUs. Thus, it is crucial to make the prefill phase in RAG inference efficient. To address this issue, we propose MatKV, a scheme that precomputes the key-value vectors (KVs) of RAG objects (e.g., documents), materializes them in inexpensive but fast and power-efficient flash storage, and reuses them at inference time instead of recomputing the KVs using costly and power-inefficient GPU. Experimental results using Hugging Face's Transformers library across state-of-the-art GPUs and flash memory SSDs confirm that, compared to full KV computation on GPUs, MatKV reduces both inference time and power consumption by half for RAG workloads, without severely impacting accuracy in the question-answering task. Furthermore, we demonstrate that MatKV enables additional optimizations in two ways. First, a GPU can decode text while simultaneously loading the materialized KVs for the next instance, reducing load latency. Second, since decoding speed is less sensitive to GPU performance than KV computation, low-end GPUs can be leveraged for decoding without significantly compromising speed once the materialized KVs are loaded into GPU memory. These findings underscore MatKV's potential to make large-scale generative AI applications more cost-effective, power-efficient, and accessible across a wider range of tasks and hardware environments.

大模型推理闪存优化RAG节能

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