TL;DR
PUMA is a secure inference framework that allows large Transformer models to be evaluated using Secure Multi-Party Computation (MPC) without leaking user prompts or model weights. By designing highly accurate, MPC-friendly approximations for non-linear functions like GeLU and softmax, PUMA achieves a $2\times$ speedup over previous state-of-the-art methods, maintains plaintext-level accuracy without requiring model retraining, and enables the first-ever MPC evaluation of a 7-billion parameter model (LLaMA-7B).
What Problem Does This Paper Address?
Deploying Large Language Models (LLMs) via Deep Learning as a Service (DLaaS) creates a privacy paradox. Users must send private prompts to service providers (risking data leaks), or providers must ship proprietary model weights to users (risking intellectual property theft).
Secure Multi-Party Computation (MPC) offers a solution by splitting data and weights into encrypted "secret shares" distributed across multiple computing parties. However, standard MPC struggles with Transformers due to three main bottlenecks:
- High Inference Cost: Non-linear activation functions like GeLU and softmax require expensive mathematical operations (like exponentiation and division) that are incredibly slow to compute securely.
- The Retraining Requirement: Prior works substituted these complex functions with simpler ones (like ReLU or quadratics) to save time, but this degrades model accuracy and forces expensive, data-intensive model retraining.
- Incompatible Architectures: Many frameworks alter the underlying Transformer architecture or omit critical components like LayerNorm, making it impossible to directly load off-the-shelf pre-trained models (e.g., from Hugging Face).
PUMA tackles these challenges head-on to deliver fast, accurate, and end-to-end secure Transformer inference without retraining.
Methods
PUMA is built on a 3-party, 2-out-of-3 replicated secret sharing scheme. Its core innovations lie in how it handles the expensive non-linear layers of the Transformer architecture:
- Piece-wise Polynomial GeLU: The authors observed that GeLU is essentially linear outside the narrow interval of $[-4, 3]$. Instead of computing the exact function using costly MPC exponentiations, PUMA uses low-degree polynomial approximations only within this active interval, drastically reducing computation and communication overhead.
- Optimized Softmax: To compute softmax securely and stably, PUMA introduces a tiny positive offset ($\epsilon$) to ensure all inputs to the exponential function are negative. This allows the use of a highly efficient Taylor series approximation with simple clipping. Furthermore, it transforms $n$ expensive secure divisions into a single reciprocal operation followed by $n$ multiplications.
- Faithful Embedding and LayerNorm: Unlike previous frameworks that skipped or modified these layers, PUMA implements them natively in MPC. For LayerNorm, it computes the inverse square root ($\sigma^{-1/2}$) directly and broadcasts it, avoiding sequential square-root and reciprocal protocols.
Datasets
The authors evaluated PUMA across several standard NLP benchmarks using popular pre-trained models:
- GLUE Benchmark (CoLA, RTE, QNLI): Used to evaluate the accuracy of BERT-Base, RoBERTa-Base, and BERT-Large models.
- Wikitext-103 V1: Used to evaluate the perplexity of GPT2-Base, GPT2-Medium, and GPT2-Large models.
- LLaMA-7B Evaluation: Tested using a practical prompt-response task ("What is the largest animal?") to demonstrate feasibility on massive scale models.
Key Insights and Ideas
- Exploiting Asymptotic Linearity: The "aha moment" for GeLU is realizing that you don't need a complex global approximation. Because the function flattens out into linear behavior on both ends, a simple piece-wise polynomial fit over a tiny window is more than enough to preserve accuracy.
- Negative-Only Exponentiation: Forcing operands to be negative in the softmax layer allows the framework to safely clip values and use a truncated Taylor series, avoiding the catastrophic overflow/underflow issues typical of fixed-point MPC math.
- Zero-Shot Compatibility is Crucial: By strictly adhering to the exact mathematical formulations of standard Transformer layers (rather than substituting LayerNorm with BatchNorm, for example), PUMA can ingest plaintext weights directly from repositories like Hugging Face. This eliminates the deployment barrier of fine-tuning under MPC.
Key Results
PUMA demonstrates a remarkable balance of speed and precision, matching the accuracy of plaintext models while outperforming existing secure frameworks.
Precision Match
As shown in the GLUE benchmark results, PUMA's accuracy closely tracks the plaintext CPU baseline, with an accuracy difference of less than 0.011 across all datasets.
Inference Speedups
PUMA consistently achieves a $\sim 2\times$ speedup and improved communication efficiency over MPCFORMER across both BERT and GPT2 model families.
For BERT models processing a sentence of length 128: Table 3: Costs of BERT models
For GPT2 models generating 1 token: Table 4: Costs of GPT2 models
Scaling to LLaMA-7B
Most notably, PUMA successfully evaluates LLaMA-7B under MPC for the first time in literature. Given an input sentence of 8 tokens, it takes approximately 200 seconds (around 5 minutes) to securely generate a token, proving that MPC for billion-parameter models is entering the realm of feasibility.
Limitations and Future Work
While PUMA represents a massive leap forward, the absolute latency for large models remains high. Taking 5 minutes to generate a single token with LLaMA-7B is still too slow for interactive, real-time user applications. The communication overhead (gigabytes of data transferred per token) also poses a challenge for standard internet connections.
The authors point to combining PUMA with model quantization (e.g., 4-bit or 8-bit weights) and hardware-accelerated MPC primitives as the most promising paths forward to bring secure LLM inference down to seconds.
Summary updated