arXivDaily arXiv每日学术速递 周一至周五更新
arXiv周末暂无论文更新,休息一下吧,周末愉快~~
arXiv 2410.11184cs.CR
收藏

快速且精确的同态Softmax求值

Fast and Accurate Homomorphic Softmax Evaluation

Wonhee Cho, Guillaume Hanrot, Taeseong Kim, Minje Park, Damien Stehlé

AI总结:

本文提出一种基于“归一化与平方”策略的快速精确同态Softmax求值算法,在固定输入范围下实现O(log n)乘法深度复杂度,支持大维度向量并行计算,精度高且速度提升2.5至8倍。

摘要:

同态加密是为机器学习即服务构建安全且保护隐私的解决方案的主要方案之一。这推动了为人工智能的主要构建模块(通常是各类神经网络架构的组件)开发同态算法。在这些组件中,我们关注Softmax函数,其定义为$\mathrm{SM}(\mathbf{x}) = \left(\exp(x_i) / \sum_{j=1}^n \exp(x_j) \right)_{1\le i\le n}$。由于其多变量性质以及$\exp(x_i)$的取值范围非常大,该函数被认为是最难进行同态求值的函数之一。现有的同态算法仍然受限,尤其是在大维度情况下,而大型语言模型(LLM)等重要应用需要对大维向量计算Softmax。在计算的乘法深度(同态算法成本的合适度量)方面,对于固定范围的输入,我们的算法实现了$O(\log n)$的复杂度,其中$n$是Softmax的维度。我们的算法特别适用于必须同时计算多个Softmax的情况,例如在LLM场景中。在这种情况下,假设所有Softmax调用都被打包到$m$个密文中,在固定范围下,每个密文的渐近摊销乘法深度成本为$O(1 + m/N)$,其中$N$为同态环度。我们算法的主要成分是“归一化与平方”策略,该策略将大范围上的指数计算与归一化交替进行,将两者都分解为更稳定、成本更低的较小步骤。与现有技术相比,我们的实验表明,在实践中,该算法具有良好的精度,并且与现有技术解决方案相比,获得了2.5到8倍的增益。

英文摘要:

Homomorphic encryption is one of the main solutions for building secure and privacy-preserving solutions for Machine Learning as a Service. This motivates the development of homomorphic algorithms for the main building blocks of AI, typically for the components of the various types of neural networks architectures. Among those components, we focus on the Softmax function, defined by $\mathrm{SM}(\mathbf{x}) = \left(\exp(x_i) / \sum_{j=1}^n \exp(x_j) \right)_{1\le i\le n}$. This function is deemed to be one of the most difficult to evaluate homomorphically, because of its multivariate nature and of the very large range of values for $\exp(x_i)$. The available homomorphic algorithms remain restricted, especially in large dimensions, while important applications such as Large Language Models (LLM) require computing Softmax over large dimensional vectors. In terms of multiplicative depth of the computation (a suitable measure of cost for homomorphic algorithms), our algorithm achieves $O(\log n)$ complexity for a fixed range of inputs, where $n$ is the Softmax dimension. Our algorithm is especially adapted to the situation where we must compute many Softmax at the same time, for instance, in the LLM situation. In that case, assuming that all Softmax calls are packed into $m$ ciphtertexts, the asymptotic amortized multiplicative depth cost per ciphertext is, again over a fixed range, $O(1 + m/N)$ for $N$ the homomorphic ring degree. The main ingredient of our algorithms is a normalize-and-square strategy, which interlaces the exponential computation over a large range and normalization, decomposing both in stabler and cheaper smaller steps. Comparing ourselves to the state of the art, our experiments show, in practice, a good accuracy and a gain of a factor 2.5 to 8 compared to state of the art solutions.

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

↑