TL;DR
This paper introduces "PowerSoftmax," a novel HE-friendly self-attention mechanism that allows for the first time the training and secure inference of billion-parameter Large Language Models (LLMs) over encrypted data. This breakthrough significantly advances privacy-preserving AI by enabling complex reasoning and in-context learning capabilities in LLMs without compromising data confidentiality.
What Problem Does This Paper Address?
Modern privacy-preserving AI techniques, particularly those using Homomorphic Encryption (HE), face a fundamental challenge: HE operations are restricted to polynomial computations. This is a major hurdle for complex models like Large Language Models (LLMs), which heavily rely on non-polynomial functions such as Softmax in their self-attention mechanisms. Previous attempts to adapt LLMs for HE either used high-degree polynomial approximations, leading to inefficiency, or simplified components before training, potentially sacrificing performance or introducing scalability issues. The authors aim to bridge this gap by developing an HE-compatible self-attention mechanism that retains the core functionality of standard attention while being amenable to efficient polynomial representation for secure inference.
Methods
The core innovation is the PowerSoftmax function, a polynomial approximation of the standard Softmax. Instead of the exponential function in Softmax, PowerSoftmax uses a power function ($x^p$, where $p$ is a positive even integer). This change makes the function more amenable to polynomial approximation required by HE.
To address practical challenges:
- -Lipschitz Division: To handle the potential for division by zero in the PowerSoftmax denominator, they introduce a small epsilon ($\epsilon$) to bound the denominator away from zero, making the division operation -Lipschitz continuous and easier to approximate.
- Stable Variant for Training: To prevent numerical instability (overflow/underflow) during training, they propose a stable variant that scales the input to PowerSoftmax by a constant, similar to how log-sum-exp is used for standard Softmax.
- Length-Agnostic Approximation: For inference, they introduce a length-agnostic approximation for the division operation, leveraging the fact that sequence length is not a secret. This avoids complex approximations for long sequences.
- Approximation Strategy: The paper outlines a three-stage process: architectural modification (replacing Softmax with PowerSoftmax), range minimization (using a loss function to keep model activations within HE-friendly bounds), and polynomial replacement (approximating remaining non-polynomial operations).
Datasets
The authors used several datasets for training and evaluation:
- Pile: Used for continual pre-training of GPT models.
- WikiText-103: Used for training and evaluating RoBERTa models and for analyzing the impact of the 'p' parameter.
- Text-8: Used for training and evaluating models.
- Tiny-ImageNet, CIFAR-100, CIFAR-10: Used for vision tasks to demonstrate the generality of their approach.
- GLUE benchmark (SST-2, QNLI, MNLI): Used for evaluating RoBERTa models.
- OpenWebText: Used for continual pre-training of RoBERTa models.
Key Insights and Ideas
- PowerSoftmax as a Viable Alternative: The core insight is that a simple power function can effectively mimic the behavior of the exponential function in Softmax for attention mechanisms, making it HE-compatible without significant performance degradation.
- Training Stability is Key: The development of a "stable variant" for PowerSoftmax was crucial. Without it, training large models with the HE-friendly attention would be unstable, highlighting the practical challenges of adapting complex models for HE.
- Inference vs. Training Optimizations: The paper cleverly separates optimizations for training (stability) from those for inference (length-agnostic division), allowing for efficient and accurate secure inference.
- Scaling to Billion Parameters: This work demonstrates that HE-based secure inference is no longer limited to small models. The ability to train and deploy billion-parameter LLMs over encrypted data is a significant leap forward.
- Comparable Performance: Surprisingly, the HE-friendly attention mechanism achieves performance comparable to standard Softmax, even on complex tasks like reasoning and in-context learning, which were previously out of reach for HE-based LLMs.
Key Results
- First Billion-Parameter Polynomial LLMs: The paper presents the first polynomial LLMs with over a billion parameters (up to 1.4B) capable of secure inference over HE.
- Comparable Performance: The PowerSoftmax models achieve performance comparable to standard transformers on various NLP benchmarks (e.g., Lambada, PIQA, ARC) and even demonstrate reasoning and in-context learning capabilities. For instance, on ARC-Challenge, their 1.4B model achieved 0.265 (Poly) vs. 0.272 (Orig) in zero-shot.
- Efficiency Gains: The proposed HE-friendly attention significantly reduces computational cost for secure inference. Compared to prior methods like Nexus and a square strategy, their method offers speedups of up to 20x and 9.7x, respectively.
- Latency Breakdown: The paper provides a detailed latency breakdown for HE computations, which is crucial for future optimization efforts.
- RoBERTa Performance: A polynomial variant of RoBERTa showed only a minor degradation (approx. 1%) on GLUE tasks compared to the original model.
Limitations and Future Work
- Full Generative Evaluation: The authors acknowledge that a full evaluation of the auto-regressive generative abilities of their models in both sequential decoding over plain and encrypted environments has not yet been conducted.
- Latency Reduction: While significant improvements are shown, further work is planned to explore techniques to reduce the model's latency when operating on encrypted data.
- Parameter 'p' Tuning: The paper analyzes the impact of the 'p' parameter in PowerSoftmax, finding that 4 < p < 8 generally yields the best results. However, the optimal 'p' might vary across tasks and architectures.
- Approximation Trade-offs: While PowerSoftmax is more HE-friendly, it's still an approximation. The paper notes that Softmax generally achieves slightly better final results, though PowerSoftmax converges faster.
Summary updated