Abstract
Private Inference (PI) enables the execution of machine learning models on sensitive user data without compromising the privacy of the data or the proprietary nature of the model weights. However, Vision Transformers (ViTs), the current state-of-the-art in computer vision, face significant latency bottlenecks in PI due to their heavy reliance on nonlinear operations like GELU and Softmax, which are computationally expensive in Secure Multi-Party Computation (MPC). This paper introduces PriViT, a gradient-based algorithm designed to accelerate ViTs for private inference. By selectively replacing expensive nonlinearities with efficient polynomial approximations through a learnable switching mechanism, PriViT achieves up to a 6.6x speedup on standard benchmarks while maintaining competitive accuracy.
1. Introduction
As machine learning models are increasingly deployed in sensitive domains such as healthcare and finance, the need for Private Inference (PI) has become paramount. PI typically leverages Secure Multi-Party Computation (MPC) to ensure that a service provider learns nothing about the user's input, and the user learns nothing about the provider's model weights.
While linear operations (e.g., matrix multiplications) are relatively efficient in MPC, nonlinear functions are the primary bottleneck. Vision Transformers (ViTs) are particularly challenging in this context; a standard ViT-base model contains over 700,000 GELU activations and 4,000 Softmax operations. Previous optimization efforts have largely focused on Convolutional Neural Networks (CNNs), leaving the high-performance Transformer architecture unoptimized for private settings. PriViT addresses this gap by providing a systematic way to linearize ViTs without sacrificing performance.
2. The PriViT Methodology
PriViT introduces a "Taylorization" process that surgically identifies and replaces redundant nonlinearities with cheaper alternatives. The approach consists of four key components:
2.1 Switched Approximations
Rather than a blanket replacement of all nonlinearities, PriViT utilizes "switched" versions of standard operations:
- GELU: Blended with a linear identity function.
- Softmax: Blended with a "Squared Attention" block, a quadratic approximation that is significantly cheaper to compute within MPC protocols.
2.2 Learnable Switches and Sparsity
The model introduces binary switching variables ($c_i, s_i$) for every unit. During a specialized fine-tuning phase, the model learns to optimize both its weights and these switches simultaneously. To drive the model toward a more efficient architecture, an $\ell_1$-penalty is added to the loss function (similar to LASSO), incentivizing the model to "turn off" as many expensive nonlinearities as possible to meet a predefined latency budget.
2.3 Knowledge Distillation
To mitigate the accuracy loss associated with aggressive linearization, PriViT employs knowledge distillation. A standard, uncompressed ViT serves as a "teacher" model, guiding the training of the Taylorized "student" model to ensure it retains as much representational power as possible.
3. Experimental Results
The researchers evaluated PriViT on three standard image classification benchmarks: TinyImageNet, CIFAR-10, and CIFAR-100, using models initialized from ImageNet-21k pre-trained checkpoints.
3.1 Efficiency and Speedup
PriViT demonstrates a superior Pareto frontier compared to existing methods. On TinyImageNet, PriViT achieved a 6.6x speedup compared to the previous state-of-the-art (MPCViT) at a comparable accuracy level (~63%). This efficiency is driven by the discovery of massive redundancy: on CIFAR-100, PriViT successfully removed nearly 83% of GELUs and 97% of Softmax operations with less than a 0.5% drop in accuracy.
3.2 Architectural Insights
A key finding of the study is the "Early Bird" importance of nonlinearities. PriViT consistently retains nonlinearities in the earlier layers of the transformer while discarding them in deeper layers. This suggests that initial feature extraction requires complex mapping, whereas deeper layers can function effectively with simpler polynomial logic.
4. Discussion and Limitations
While PriViT significantly advances the state of private ViT inference, some challenges remain. Layer Normalization remains difficult to Taylorize without significant accuracy loss and was largely excluded from this study's optimization scope, representing a primary bottleneck for future research. Additionally, the training process for switching variables introduces higher GPU memory and time overhead compared to standard fine-tuning.
5. Conclusion
PriViT provides a practical, gradient-based framework for making Vision Transformers viable for private inference. By moving away from complex Neural Architecture Search (NAS) in favor of a top-down linearization strategy, PriViT offers an out-of-the-box solution for deploying high-performance transformers in privacy-sensitive environments. Future work will explore extending these techniques to other transformer variants, such as Swin Transformers, and applying them to Natural Language Processing (NLP) tasks.
Summary updated