TL;DR
Private Transformer inference using secure multi-party computation (MPC) is notoriously slow due to the heavy communication required for non-linear operations like GeLU and Softmax. This paper introduces Comet, a plug-in method that unifies these non-linear functions into a single inverse square root operation and solves it using a novel, communication-free "double approximation" technique. Comet slashes communication costs by up to 3.9× and speeds up inference by up to 3.5× with virtually no loss in model accuracy.
What Problem Does This Paper Address?
Cloud-based Transformer models (like ChatGPT) raise serious privacy concerns: users do not want to expose confidential prompts to service providers, and providers want to protect their proprietary model weights. Secure Multi-Party Computation (MPC) offers a solution by allowing private inference where neither party reveals their underlying data.
However, while linear operations (like matrix multiplications) can be executed relatively efficiently under MPC, non-linear functions (GeLU, Softmax, LayerNorm) require complex, hybrid cryptographic protocols. These functions create an overwhelming communication bottleneck, often accounting for over 80% of the total inference runtime. This bottleneck is primarily caused by the heavy communication needed to find a good initial guess before running iterative mathematical solvers.
Methods
Comet tackles this bottleneck through three main innovations:
- Unifying Non-Linear Functions: The authors replace GeLU and Softmax with mathematically smoothed alternatives using the Smoothed Maximum Unit (SMU) and ReLU. This clever substitution unifies all major non-linear operations in the Transformer architecture into a single core function: the inverse square root ($1/\sqrt{x}$).
- Double Approximation: To compute the inverse square root iteratively (via the Newton-Raphson method), standard MPC frameworks use communication-heavy Look-Up Tables (LUTs) to find a starting guess. Comet eliminates this communication entirely by exploiting the bit-level structure of IEEE 754 floating-point representations directly on secret shares, turning a distributed communication problem into local computation.
- Share Flooding: For the double approximation to converge without revealing private data, the exponents of the two parties' secret shares must be close. Comet introduces a "share flooding" technique that adds a large, secure random mask to drown out differences, ensuring numerical stability and local convergence without leaking information.
Datasets
The authors evaluated Comet using the GLUE (General Language Understanding Evaluation) benchmark, specifically focusing on a diverse subset of tasks:
- RTE (Recognizing Textual Entailment)
- MRPC (Microsoft Research Paraphrase Corpus)
- STS-B (Semantic Textual Similarity Benchmark)
- SST-2 (Stanford Sentiment Treebank)
- CoLA (Corpus of Linguistic Acceptability)
Key Insights and Ideas
- The Power of Unification: Instead of designing separate, complex cryptographic protocols for every distinct non-linear function (e.g., exponentials for Softmax, error functions for GeLU), transforming them into a single mathematical primitive drastically simplifies the optimization landscape.
- Exploiting Hardware Standards for Crypto: By looking at how floating-point numbers are actually stored in hardware (the IEEE 754 format), the authors found a way to approximate logarithms and square roots locally on secret shares, bypassing the need to pass messages back and forth.
- Activation Values are Naturally Well-Behaved: The success of the "share flooding" technique relies on the insight that Transformer activation values naturally cluster tightly around zero due to standard normalization layers (LayerNorm) and embedding techniques. This predictability allows the flooding mechanism to safely bound the numerical ranges.
Key Results
- Massive Efficiency Gains: Compared to the state-of-the-art LUT-based framework Iron, Comet achieved up to a 3.9× reduction in communication cost and up to a 3.5× runtime speedup.
- Framework Agnostic: When integrated with CrypTen, Comet delivered a 2.5× overall end-to-end speedup and reduced communication by 2× to 3× across various non-linear functions.
- Negligible Accuracy Loss: Across the GLUE benchmark tasks on BERT-base and RoBERTa-base, the unified model preserved competitive performance, experiencing less than 1% accuracy loss compared to the unmodified baseline models.
Limitations and Future Work
While Comet significantly optimizes the non-linear bottlenecks of private inference, the paper focuses primarily on encoder-based architectures (BERT and RoBERTa). Extending this approach to massive, autoregressive decoder-only large language models (LLMs) like GPT-4 or LLaMA—where generation happens token-by-token and scales differently—remains an open area for exploration. Additionally, the current implementation operates under a semi-honest threat model; adapting it to withstand fully malicious adversaries would require additional cryptographic overhead.
Summary updated