TL;DR
SecureRouter introduces the first end-to-end encrypted routing framework for secure Transformer inference using Secure Multi-Party Computation (MPC). By dynamically directing encrypted inputs to the most efficient model within an MPC-optimized pool, it achieves up to a 1.95× speedup with negligible accuracy loss while maintaining complete data and model confidentiality.
What Problem Does This Paper Address?
Privacy-preserving machine learning using Secure Multi-Party Computation (MPC) allows cloud servers to perform inference on encrypted data without ever decrypting it. This is vital for sensitive domains like medicine and finance. However, MPC is notoriously slow—especially for Transformers, where non-linear operations like Softmax and GeLU account for over 77% of secure inference runtime.
Current secure inference systems rely on a single, fixed-size model for all inputs. This means an easy, straightforward query goes through the exact same computationally expensive pipeline as a highly complex one. While plaintext AI applications frequently use "model routing" (sending easy queries to small models and hard queries to large ones) to save costs, this approach fails in encrypted settings. Standard routers require full visibility of the plaintext data, and their cost metrics (like FLOPs) do not align with MPC, where costs are dominated by cryptographic communication rounds and non-linear operations rather than raw parameter counts.
Methods
SecureRouter bridges this gap by introducing a unified encrypted pipeline divided into an offline training phase and an online inference phase:
- Offline Co-Design: The authors train an MPC-cost-aware router alongside a heterogeneous pool of models (e.g., BERT-Tiny, BERT-Base, BERT-Large). To make the discrete routing decisions differentiable during training, they leverage the Gumbel-Softmax trick. The training is guided by a composite loss function combining task accuracy ($L_{task}$), a load-balancing loss ($L_{balance}$) to prevent the router from always picking the same model, and a novel MPC-Cost-Aware Loss ($L_{cost}$) derived from empirical MPC execution times rather than plaintext FLOPs.
- Online Inference Protocol: During inference, the client secret-shares their input embeddings across two non-colluding servers (a 2-Party Computation setting). The servers compute the routing decision directly on the encrypted shares using a secure two-layer neural network and a secure
argmaxprotocol. Once the optimal model index is determined in an encrypted format, the servers use Oblivious Transfer (OT) to retrieve the corresponding model parameters from the pool without revealing to the servers which model was selected.
Datasets
The framework was evaluated using the standard GLUE (General Language Understanding Evaluation) benchmark, which includes the following tasks:
- MNLI, QQP, QNLI, SST-2, RTE (evaluated via accuracy or F1 score)
- CoLA (evaluated via Matthews correlation coefficient)
- STS-B (evaluated via Pearson and Spearman correlations)
- MRPC (evaluated via F1 score)
No new datasets or benchmarks were introduced in this paper.
Key Insights and Ideas
- FLOPs $\neq$ MPC Cost: Traditional routing frameworks optimize for parameter counts or FLOPs. SecureRouter’s core insight is that an effective encrypted router must be trained on a cost model built explicitly around cryptographic communication overhead and non-linear operation costs.
- Confidential Routing Decisions: The framework proves that you can dynamically route queries to different models without the server ever knowing which model was chosen or what the input data looked like, breaking the rigid "one-size-fits-all" paradigm of prior secure inference.
- Negligible Memory Overhead: Instead of keeping all models active in memory simultaneously, the routing mechanism maintains a memory profile close to the smallest expert in the pool until the specific larger model parameters are obliviously fetched.
Key Results
SecureRouter was implemented using the Crypten framework and evaluated against state-of-the-art secure inference baselines like SecFormer:
- Significant Speedups: SecureRouter achieved up to a 1.95× lower inference latency on the QQP dataset and 1.73× on SST-2. Across the entire GLUE benchmark, it delivered an average speedup of 1.53× relative to a fine-tuned BERT-Large baseline.
- High Accuracy Retention: The latency reductions came with virtually no accuracy penalty. For instance, on the massive MNLI dataset, SecureRouter slightly outperformed the baseline (86.73% vs 86.64%), and on QQP it maintained a near-identical score (88.05% vs 88.08%).
- Resource Efficiency: The router itself introduces minimal system overhead. In a 2-PC environment, it consumes just 39.12 MB of memory—a marginal 3% increase over a standalone BERT-Tiny model (38.00 MB)—while successfully avoiding the massive 3114.00 MB footprint of BERT-Large for simpler queries.
Limitations and Future Work
- Threat Model Constraints: The system operates under a standard semi-honest (honest-but-curious) threat model. Extending this framework to malicious threat models, where adversarial servers might actively alter data or protocols, remains an open challenge.
- Task-Specific Sensitivity: On tasks requiring extreme syntactic and grammatical precision (such as CoLA), SecureRouter experienced a slight performance dip (59.10 vs 63.35), indicating that the router may occasionally over-optimize for speed on highly complex linguistic structures.
- Scaling to Autoregressive LLMs: The current evaluation focuses on encoder-only models (BERT variants). Scaling this encrypted routing paradigm to massive autoregressive decoder models (like GPT or LLaMA) will introduce substantial new communication challenges during the Oblivious Transfer phase.
Summary updated