Paper 2025/2250

Nimbus: Secure and Efficient Two-Party Inference for Transformers

Zhengyi Li, Shanghai Jiao Tong University
Kang Yang, State Key Laboratory of Cryptology
Jin Tan, Ant Group
Wen-jie Lu, Ant Group
Haoqi Wu, Ant Group
Xiao Wang, Northwestern University
Yu Yu, Shanghai Jiao Tong University, Shanghai Qizhi Institute
Derun Zhao, Ant Group
Yancheng Zheng, Ant Group
Minyi Guo, Shanghai Jiao Tong University, Shanghai Qizhi Institute
Jingwen Leng, Shanghai Jiao Tong University, Shanghai Qizhi Institute
Abstract

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.

Metadata
Available format(s)
PDF
Category
Cryptographic protocols
Publication info
Published elsewhere. Neurips 2024
Keywords
secure multi-party computationhomomorphic encryptionTransformerLLMSecure Inference
Contact author(s)
hobbit @ sjtu edu cn
yangk @ sklc org
History
2025-12-18: revised
2025-12-15: received
See all versions
Short URL
https://ia.cr/2025/2250
License
Creative Commons Attribution
CC BY

BibTeX

@misc{cryptoeprint:2025/2250,
      author = {Zhengyi Li and Kang Yang and Jin Tan and Wen-jie Lu and Haoqi Wu and Xiao Wang and Yu Yu and Derun Zhao and Yancheng Zheng and Minyi Guo and Jingwen Leng},
      title = {Nimbus: Secure and Efficient Two-Party Inference for Transformers},
      howpublished = {Cryptology {ePrint} Archive, Paper 2025/2250},
      year = {2025},
      url = {https://eprint.iacr.org/2025/2250}
}
Note: In order to protect the privacy of readers, eprint.iacr.org does not use cookies or embedded third party content.