Skip to main content
QUICK REVIEW

[Paper Review] PUMA: Secure Inference of LLaMA-7B in Five Minutes

Ye Dong, Wenjie Lu|arXiv (Cornell University)|Jul 24, 2023
Cryptography and Data SecurityComputer Science11 citations
TL;DR

Puma enables secure MPC-based inference of LLaMA-7B, achieving roughly 5 minutes per token and matching plaintext accuracy without retraining, by introducing efficient GeLU/softmax approximations and end-to-end secure embedding and LayerNorm.

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, and 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 $2 imes$ faster than the state-of-the-art framework MPCFORMER(ICLR 2023) and has similar accuracy as plaintext models without fine-tuning (which the previous works failed to achieve). PUMA can even 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.

Motivation & Objective

  • Motivate privacy-preserving inference for large Transformer models without retraining.
  • Develop fast, accurate MPC-based protocols for non-linear layers in Transformers.
  • Provide end-to-end secure embedding and LayerNorm that align with plaintext Transformer workflows.
  • Demonstrate scalability to large models (LLaMA-7B) and compatibility with pretrained models from common sources.

Proposed method

  • Design new polynomial-based approximations for GeLU and softmax tailored to MPC efficiency.
  • Implement end-to-end secure Embedding and LayerNorm compatible with plaintext Transformer architectures.
  • Use 2-out-of-3 replicated secret sharing with established MPC primitives for linear and non-linear operations.
  • Optimize softmax via negative-exponent Taylor-style expansion and reduced divisions to cut communication/computation.
  • Enable secure loading and execution of pretrained Transformer weights without retraining.
  • Provide serialization-adjusted infrastructure to handle large secret-shared structures for big models.

Experimental results

Research questions

  • RQ1Can secure MPC-based inference achieve plaintext-level accuracy on large Transformer models without retraining?
  • RQ2What approximations and protocol designs yield practical secure inference speedups for non-linear Transformer components (GeLU, softmax, LayerNorm, Embedding)?
  • RQ3Is end-to-end secure Embedding and LayerNorm feasible without altering plaintext model workflows?
  • RQ4How does Puma scale to very large models like LLaMA-7B under MPC compared to prior work (MPCFormer)?

Key findings

  • Puma achieves accuracies matching plaintext models within small margins (differences not exceeding 0.011 on GLUE tasks and 0.02 perplexity on GPT-2 variants).
  • Puma is about 2x faster than MPCFormer while delivering similar or better accuracy across evaluated models and tasks.
  • Secure LLaMA-7B inference is demonstrated in five minutes per token under MPC with measured costs for inputs/outputs.
  • End-to-end secure embedding and LayerNorm enable loading pretrained Transformer weights without retraining, preserving compatibility with plaintext models.
  • Puma exhibits favorable scalability for larger models, with greater relative speedups for GPT-2 family models in the reported experiments.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.