扩展基于FHE的隐私保护机器学习:LLama-3-8B的更高吞吐量和更长输入
Scaling up FHE-based Privacy-Preserving ML: Higher Throughput, Longer Inputs for LLama-3-8B
AI总结:
针对FHE-based LLM推理中输入长度扩展性差和非线性层评估受异常值影响的问题,采用令牌预置、正交旋转和稀疏密文多项式求值方法,结合快速同态线性代数技术,实现128加密令牌推理加速,并扩展至数千令牌的异构输入,在Llama-3-8B上取得显著性能提升。
摘要:
随着大型语言模型(LLM)变得无处不在,与推理相关的隐私问题日益突出。全同态加密(FHE)已成为非交互式机密LLM推理的主要密码学解决方案。然而,现有解决方案在输入令牌长度上扩展性差,主要关注小模型或小输入尺寸。它们还受到大的异常值影响,这强烈影响非线性层的评估,导致高昂的多项式逼近成本。我们从两个方向扩展基于FHE的LLM推理。首先,我们加速了128个加密令牌的基于FHE的推理。我们采用机器学习技术(令牌预置和正交旋转)来减轻异常值对非线性层FHE评估的影响。另外,我们设计了一种新颖的稀疏密文多项式求值方法,以加速我们的同态SoftMax实现。我们将这些与最近的快速同态线性代数技术相结合,实现了显著提高的效率。其次,我们将提示大小扩展到数千个令牌,适用于只有输入的最终部分敏感且加密的场景。处理此问题需要处理标准的明文-明文和密文-密文组件,以及针对新颖的明文-密文组件的宽同态计算。为了解决这个问题,我们设计了一种专用的同态线性代数算法,构建了一个浅层同态注意力电路,以最小化自举成本。基于这些要素,我们提出了一个基于CKKS的Llama-3-8B私有推理端到端实现。在8个NVIDIA RTX PRO 6000 GPU上,128个加密令牌的摘要生成需要20秒,生成每个令牌需要18秒(远超SOTA在更昂贵的H100 GPU上的295秒)。对于4096个令牌的异构输入(最后128个加密),摘要生成需要64秒,生成每个令牌需要22秒。
英文摘要:
As large language models (LLMs) become ubiquitous, privacy concerns pertaining to inference keep growing. Fully homomorphic encryption (FHE) has emerged as a primary cryptographic solution for non-interactive confidential LLM inference. However, existing solutions scale poorly with input token length, focusing on small models or input sizes. They also suffer from large outlier values, which strongly impact the evaluation of non-linear layers, leading to heavy polynomial approximation costs. We scale up FHE-based LLM inference in two directions. First, we accelerate FHE-based inference for 128 encrypted tokens. We adopt ML techniques (token prepending and orthogonal rotations) to mitigate outlier impacts on the FHE evaluation of non-linear layers. Separately, we devise a novel polynomial evaluation method for sparsely-packed ciphertexts to speed up our homomorphic SoftMax implementation. We combine these with recent fast homomorphic linear algebra techniques, achieving significantly improved efficiency. Second, we expand the prompt size up to thousands of tokens for contexts where only the final part of the input is sensitive and encrypted. Processing this requires handling standard plaintext-plaintext and ciphertext-ciphertext components, alongside a wide homomorphic computation for a novel plaintext-ciphertext component. To address this, we devise a dedicated homomorphic linear algebra algorithm, building a shallow homomorphic attention circuit that minimizes bootstrapping costs. Based on these ingredients, we present a CKKS-based end-to-end implementation of Llama-3-8B private inference. On 8 NVIDIA RTX PRO 6000 GPUs, 128 encrypted tokens take 20s for summarization and 18s/token for generation (vastly outperforming the SOTA 295s on costlier H100 GPUs). For a heterogeneous 4096-token input (last 128 encrypted), it takes 64s for summarization and 22s/token for generation.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。