NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

PUMA: Secure Inference of LLaMA-7B in Five Minutes

Ye Dong, Wen-jie Lu, Yancheng Zheng, Haoqi Wu, Derun Zhao, Jin Tan, Zhicong Huang, Cheng Hong, Tao Wei, Wenguang Chen · OpenReview

Abstract

With ChatGPT as a representative, tons of companies have began to provide services based on large Transformers models. However, using such a service inevitably leak users' prompts to the model provider. Previous studies have studied secure inference for Transformer models using secure multiparty computation (MPC), where model parameters and clients' prompts are kept secret. Despite this, these frameworks are still limited in terms of model performance, efficiency, and deployment. To address these limitations, we propose framework PUMA to enable fast and secure Transformer model inference. Our framework designs high quality approximations for expensive functions, such as GeLU and Softmax, which significantly reduce the cost of secure inference while preserving the model performance. Additionally, we design secure Embedding and LayerNorm procedures that faithfully implement the desired functionality without undermining the Transformer architecture. PUMA is about 2x faster than the state-of-the-art MPC framework MPCFORMER(ICLR 2023) and has similar accuracy as plaintext models without fine-tuning (which the previous works failed to achieve). One more thing, PUMA can evaluate LLaMA-7B in around 5 minutes to generate 1 token. To our best knowledge, this is the first time that a model with such a parameter size is able to be evaluated under MPC. PUMA has been open-sourced in the Github repository of SecretFlow-SPU.

Introduction

As Large Language Models (LLMs) become ubiquitous, they create a massive privacy paradox. Using a service like ChatGPT requires users to send private prompts to a provider, while providers are unwilling to release their proprietary model weights to users. Secure Multi-Party Computation (MPC) offers a solution where multiple parties can compute a function without any single party seeing the underlying data. However, applying MPC to Transformers has historically faced three major hurdles: high computational costs for non-linear functions, the need for expensive model retraining when using simplified approximations, and incomplete architecture support for layers like LayerNorm or Embedding.

Methodology

PUMA utilizes a three-party MPC setting (specifically 2-out-of-3 replicated secret sharing) and introduces several clever engineering and mathematical optimizations to overcome these hurdles:

  • Piece-wise Polynomial Approximations: Instead of using expensive exact functions or over-simplified ones like ReLU, PUMA uses piece-wise low-degree polynomials to approximate GeLU. This captures the function's behavior accurately enough that the model doesn't need to be retrained.
  • Softmax Optimizations: The authors optimized the Softmax function by using a Taylor series expansion specifically for negative operands and reducing the number of divisions from $n$ to just one reciprocal operation.
  • End-to-End Compatibility: PUMA provides secure implementations for Embedding and LayerNorm, allowing the framework to load standard plaintext weights (like those from LLaMA or BERT) and run them directly without modification.
  • Large-Scale Serialization: To handle the massive parameter size of LLaMA-7B, the communication layer was optimized to "chunk" data, overcoming the 2GB serialization limits found in standard libraries.

Experimental Evaluation

The researchers evaluated PUMA across a variety of standard NLP benchmarks to prove its precision and efficiency, including the GLUE benchmark (CoLA, RTE, and QNLI tasks) for BERT and RoBERTa models, and Wikitext-103 V1 for GPT-2 models. Most notably, PUMA was tested on LLaMA-7B to demonstrate the first-ever MPC-based inference of a 7-billion parameter model.

Key Results

PUMA achieves a significant breakthrough by maintaining the performance of pre-trained models without retraining. On the GLUE benchmark, PUMA’s accuracy is nearly identical to plaintext models (within a 0.011 margin), as shown in the comparison below.

Accuracy comparison between plaintext (CPU) and PUMA across various models and GLUE tasks.

In terms of efficiency, PUMA is consistently ~2x faster than MPCFORMER, the previous state-of-the-art. As detailed in the performance table, PUMA provides substantial improvements in both execution time and communication overhead across different GPT-2 model sizes.

Performance comparison (Time and Communication) between MPCFORMER and PUMA for GPT-2 models.

For the LLaMA-7B model, PUMA can generate one token in approximately 5 minutes. While not yet real-time, this represents a landmark achievement for secure computation on models of this scale.

Conclusion and Future Work

PUMA demonstrates that high-quality approximations can bridge the gap between secure inference and practical model performance. While latency remains a bottleneck for real-time applications, future work involving quantization (e.g., 8-bit or 4-bit weights) and hardware acceleration (GPUs/FPGAs) could further reduce the performance gap. Additionally, extending the framework from a semi-honest to a malicious threat model remains an important area for future research.

Summary updated

BibTeX
@misc{dong2023puma,
  author = {Ye Dong and Wen-jie Lu and Yancheng Zheng and Haoqi Wu and Derun Zhao and Jin Tan and Zhicong Huang and Cheng Hong and Tao Wei and Wenguang Chen},
  title = {{PUMA: Secure Inference of LLaMA-7B in Five Minutes}},
  year = {2023},
  eprint = {2307.12533},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2307.12533},
}
Figure