[Paper Review] MPCFormer: fast, performant and private Transformer inference with MPC
MPCFormer enables fast, private, and high-performing Transformer inference using Secure Multi-Party Computation (MPC) by combining MPC-friendly function approximations with knowledge distillation. It achieves up to 5.9× speedup over BERT_BASE and BERT_LARGE while maintaining 97% of BERT_BASE's performance on GLUE, with minimal accuracy loss across diverse models and datasets.
Enabling private inference is crucial for many cloud inference services that are based on Transformer models. However, existing private inference solutions can increase the inference latency by more than 60x or significantly compromise the inference quality. In this paper, we design the framework MPCFORMER as a practical solution, using Secure Multi-Party Computation (MPC) and Knowledge Distillation (KD). Through extensive evaluations, we show that MPCFORMER significantly speeds up Transformer inference in MPC settings while achieving similar ML performance to the input model. On the IMDb dataset, it achieves similar performance to BERTBASE, while being 5.3x faster. On the GLUE benchmark, it achieves 97% performance of BERTBASE with a 2.2x speedup. MPCFORMER remains effective with different trained Transformer weights such as ROBERTABASE and larger models including BERTLarge. Code is available at https://github.com/MccRee177/MPCFormer.
Motivation & Objective
- Address the critical challenge of high latency in private Transformer inference using MPC, which currently slows down inference by over 60×.
- Overcome performance degradation caused by MPC-friendly approximations that disrupt training and require large downstream datasets.
- Enable practical deployment of private inference services for large-scale Transformer models without sacrificing model accuracy.
- Design a framework that is compatible with various pre-trained models (e.g., BERT_BASE, RoBERTa_BASE, BERT_LARGE) and MPC-friendly approximations.
- Achieve both low inference latency and high machine learning performance in MPC settings through efficient knowledge distillation.
Proposed method
- Replace bottleneck functions in a pre-trained Transformer with MPC-friendly approximations (e.g., Quad+2ReLU, a new fast Softmax approximation) to accelerate MPC inference.
- Apply knowledge distillation (KD) to transfer knowledge from the original teacher model to the approximated student model using intermediate hidden representations.
- Use the teacher model’s logits and intermediate features as supervision signals during student training, enabling effective distillation even on small downstream datasets.
- Train the student model using a combination of distillation loss and standard cross-entropy loss, with fine-tuned hyperparameters for embedding and attention layers.
- Deploy the distilled student model on an MPC engine (e.g., CrypTen) for end-to-end private inference.
- Optimize the distillation process with data-efficient training strategies, reducing reliance on large downstream datasets.
Experimental results
Research questions
- RQ1Can MPC-friendly approximations be effectively applied to Transformers without causing significant performance degradation in private inference?
- RQ2To what extent can knowledge distillation mitigate performance loss when training approximated Transformers under MPC constraints?
- RQ3How does MPCFormer scale across different model sizes, including BERT_LARGE, and how does it compare to baselines without distillation?
- RQ4What is the minimal amount of downstream data required to achieve high performance with distillation in MPC settings?
- RQ5Does initializing the student model with weights from the teacher model improve training stability and final performance, especially on small datasets?
Key findings
- On the IMDb dataset, MPCFormer achieves 95.0% accuracy with BERT_BASE and a 5.3× speedup, while maintaining performance comparable to the original model.
- For BERT_LARGE on IMDb, MPCFormer achieves 94.5% accuracy with a 5.9× speedup, significantly outperforming baselines without distillation.
- On the GLUE benchmark, MPCFormer achieves 97% of BERT_BASE’s average score (84.6 vs. 85.3) with a 2.2× speedup, demonstrating strong generalization.
- MPCFormer maintains high performance across different pre-trained models, including RoBERTa_BASE, showing compatibility with diverse architectures.
- Knowledge distillation enables effective training on small datasets: as little as 2% of medium datasets (e.g., QNLI) and 5% of small datasets (e.g., MRPC) suffice for high performance.
- Initializing the student model with the teacher’s weights leads to better performance than random initialization, especially on smaller downstream datasets.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.