arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2411.15707cs.CRcs.AI
收藏

Nimbus:面向 Transformer 的安全高效两方推理

Nimbus: Secure and Efficient Two-Party Inference for Transformers

Shanghai Jiao Tong University(上海交通大学);State Key Laboratory of Cryptology(密码学国家重点实验室);Ant Group(蚂蚁集团);Northwestern University(西北大学);Shanghai Qizhi Institute(上海期智研究院)

Zhengyi Li, Kang Yang, Jin Tan, Wen-jie Lu, Haoqi Wu, Xiao Wang, Yu Yu, Derun Zhao, Yancheng Zheng, Minyi Guo, Jingwen Leng

AI总结:

本文提出面向 Transformer 的两方推理框架 Nimbus,通过外积编码优化矩阵乘法,并利用输入分布对 GELU 和 Softmax 进行低次多项式逼近,在保持低精度损失的同时显著提升推理性能。

摘要:

Transformer 模型因其在机器学习任务中的强大能力而受到广泛关注。其大规模部署引发了人们对推理过程中敏感信息可能泄露的担忧。然而,现有基于安全两方计算(2PC)的方法在应用于 Transformer 时,在效率上存在两方面局限:(1)线性层中资源密集型的矩阵乘法;(2)复杂的非线性激活函数,如 $\mathsf{GELU}$ 和 $\mathsf{Softmax}$。本文提出了一个面向 Transformer 模型的新型两方推理框架 $\mathsf{Nimbus}$。针对线性层,我们提出了一种新的 2PC 范式以及一种基于外积思想的编码方法,用于安全计算矩阵乘法,与最先进(SOTA)协议相比,实现了 $2.9\times \sim 12.5\times$ 的性能提升。针对非线性层,通过对输入分布利用的新观察,我们提出了一种对 $\mathsf{GELU}$ 和 $\mathsf{Softmax}$ 进行低次多项式逼近的方法,将 SOTA 多项式逼近的性能提升了 $2.9\times \sim 4.0\times$,与无隐私保护的非 2PC 推理相比,我们方法的平均精度损失为 0.08\\%。与 SOTA 两方推理相比,$\mathsf{Nimbus}$ 在不同网络设置下将 \bert{} 推理的端到端性能提升了 $2.7\times \sim 4.7\times$。

英文摘要:

Transformer models have gained significant attention due to their power in machine learning tasks. Their extensive deployment has raised concerns about the potential leakage of sensitive information during inference. However, when being applied to Transformers, existing approaches based on secure two-party computation (2PC) bring about efficiency limitations in two folds: (1) resource-intensive matrix multiplications in linear layers, and (2) complex non-linear activation functions like $\mathsf{GELU}$ and $\mathsf{Softmax}$. This work presents a new two-party inference framework $\mathsf{Nimbus}$ for Transformer models. For the linear layer, we propose a new 2PC paradigm along with an encoding approach to securely compute matrix multiplications based on an outer-product insight, which achieves $2.9\times \sim 12.5\times$ performance improvements compared to the state-of-the-art (SOTA) protocol. For the non-linear layer, through a new observation of utilizing the input distribution, we propose an approach of low-degree polynomial approximation for $\mathsf{GELU}$ and $\mathsf{Softmax}$, which improves the performance of the SOTA polynomial approximation by $2.9\times \sim 4.0\times$, where the average accuracy loss of our approach is 0.08\% compared to the non-2PC inference without privacy. Compared with the SOTA two-party inference, $\mathsf{Nimbus}$ improves the end-to-end performance of \bert{} inference by $2.7\times \sim 4.7\times$ across different network settings.

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

↑