arXivDaily arXiv每日学术速递 周一至周五更新
感恩节,周五至周末无更新,大家顺遂。周一再来吧
arXiv 2602.11470cs.CR
收藏

Cachemir: 生成式大语言模型的全同态加密推理与KV缓存

Cachemir: Fully Homomorphic Encrypted Inference of Generative Large Language Model with KV Cache

Columbia University(哥伦比亚大学);Peking University(北京大学);Virginia Tech(弗吉尼亚理工大学)

Ye Yu, Yifan Zhou, Yi Chen, Pedro Soto, Wenjie Xiong, Meng Li

AI总结:

Cachemir通过整合KV缓存优化同态加密推理,实现高效生成式大语言模型推理。

摘要:

生成式大语言模型(LLMs)已经革新了多个领域。现代LLMs主要依赖于自回归解码策略,该策略按顺序生成输出标记,并使用键值缓存(KV缓存)以避免重复计算。然而,LLMs的广泛部署引发了严重的隐私问题,因为用户将各种类型的数据输入模型,这促使开发基于全同态加密(FHE)的安全推理框架。现有基于FHE的框架的主要限制是无法有效整合KV缓存,导致自回归解码的延迟过高。在本文中,我们提出了Cachemir,一种KV缓存加速的同态加密LLM推理机制,以克服这一限制。Cachemir有三个关键技术贡献:1)一组新的HE打包算法,专门设计以利用KV缓存的计算优势;2)一种交错复制打包算法,用于高效计算由KV缓存在Transformer线性层中使用的向量-矩阵乘法;3)一种增强的启动策略,考虑KV缓存以最小化启动成本。我们证明,Cachemir在CPU上比MOAI(ICML'25)快48.83倍,在CCS'25上的THOR快67.16倍,并且在GPU上生成Llama-3-8B的输出标记时间不到100秒。

英文摘要:

Generative large language models (LLMs) have revolutionized multiple domains. Modern LLMs predominantly rely on an autoregressive decoding strategy, which generates output tokens sequentially and employs a key-value cache (KV cache) to avoid redundant computation. However, the widespread deployment of LLMs has raised serious privacy concerns, as users are feeding all types of data into the model, motivating the development of secure inference frameworks based on fully homomorphic encryption (FHE). A major limitation of existing FHE-based frameworks is their inability to effectively integrate the KV cache, resulting in prohibitively high latency for autoregressive decoding. In this paper, we propose Cachemir, a KV Cache Accelerated Homomorphic Encrypted LLM Inference Regime to overcome this limitation. Cachemir comprises three key technical contributions: 1) a set of novel HE packing algorithms specifically designed to leverage the computational advantages of the KV cache; 2) an interleaved replicated packing algorithm to efficiently compute the vector-matrix multiplications that result from using the KV cache in Transformer linear layers; and 3) an augmented bootstrapping placement strategy that accounts for the KV cache to minimize bootstrapping cost. We demonstrate that Cachemir achieves $48.83\times$ and $67.16\times$ speedup over MOAI (ICML'25) and THOR (CCS'25) respectively on CPU and consumes less than 100 seconds on GPU to generate an output token for Llama-3-8B.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑