CipherPrune: Efficient and Scalable Private Transformer Inference

Yancheng Zhang, Jiaqi Xue, Mengxin Zheng, Mimi Xie, Mingzhe Zhang, Lei Jiang, Qian Lou

Introduction

As Transformer-based models become ubiquitous in digital services, the demand for "Transformer-as-a-Service" (TaaS) has grown exponentially. However, this trend introduces significant privacy risks, as users must often share sensitive data—such as medical records or private communications—with cloud servers. While cryptographic solutions like Homomorphic Encryption (HE) and Multi-Party Computation (MPC) allow for processing data in its encrypted state, they are notoriously slow and resource-intensive.

CipherPrune is a novel framework designed to overcome these bottlenecks. By progressively pruning redundant input tokens and simplifying mathematical approximations for less critical data, CipherPrune accelerates private Transformer inference by up to 10.6× while maintaining high accuracy and cryptographic security.

The Challenge of Private Inference

In a typical private inference setup, a client sends encrypted data to a server, which processes it using a combination of HE for linear operations and MPC for non-linear activations like SoftMax and GELU.

Overview of private Transformer inference challenges and the CipherPrune framework.

Two primary issues hinder the scalability of this approach:

  1. Quadratic Complexity: Transformers suffer from quadratic computational growth relative to input length. Doubling the number of tokens quadruples the workload.
  2. Expensive Approximations: Non-linear functions are approximated using high-degree polynomials in the encrypted domain, which are computationally expensive to evaluate for every token in a sequence.

The CipherPrune Framework

CipherPrune introduces a three-pronged strategy to address these efficiency and scalability hurdles:

1. Encrypted Token Pruning ($\Pi_{prune}$)

CipherPrune adaptively identifies and removes "redundant" tokens layer-by-layer. Not every word in a sentence is essential for the model to capture the underlying meaning. By removing these tokens, the framework reduces the total workload for subsequent layers. To maintain privacy, CipherPrune utilizes a Secure Swap protocol based on Oblivious Transfer (OT), ensuring the server never learns which specific tokens were removed, thus protecting the user's data patterns.

2. Encrypted Polynomial Reduction

For tokens that are not critical enough for full-precision processing but not redundant enough to prune entirely, CipherPrune applies lower-degree polynomial approximations for activations. This targeted simplification significantly reduces compute time compared to using high-degree polynomials for the entire sequence.

3. Protocol-Aware Network Optimization

To find the optimal balance between speed and accuracy, the authors developed a gradient-based search algorithm. During an offline fine-tuning phase, the model uses "soft masks" to learn exactly how much pruning or simplification can occur at each layer without compromising the final output accuracy.

Key Insights: Progressive and Input-Specific Pruning

A core innovation of CipherPrune is its progressive approach. Rather than pruning a fixed percentage of tokens at the start, the framework removes tokens incrementally across layers. This allows the model to make more informed decisions about token importance as information flows deeper into the network.

Progressive token pruning across Transformer layers.

Furthermore, the framework is input-specific. Simple sentences may undergo aggressive pruning, while complex or nuanced inputs retain more tokens to ensure accuracy. This dynamic adjustment optimizes the utility-accuracy trade-off for every unique request.

Evaluation and Results

The researchers evaluated CipherPrune using GPT2-Base and various BERT models across four standard GLUE benchmark tasks (MNLI, QNLI, SST-2, and MRPC). The results demonstrate a significant leap in performance over previous state-of-the-art methods like BOLT:

  • Speed: CipherPrune is 6.1× faster for 128-token inputs and 10.6× faster for 512-token inputs.
  • Communication Efficiency: The framework reduces the massive data transfer overhead typical of cryptographic protocols by 2.3× to 40.4×.
  • Accuracy: These efficiency gains come with a marginal accuracy drop, often less than 0.5%.
  • Scalability: Unlike prior methods where runtime explodes with input length, CipherPrune’s runtime scales much more linearly, making long-form private inference practically feasible.

Conclusion and Future Work

CipherPrune represents a major step toward making private AI services viable for real-world use. While the current framework operates under a semi-honest security model and discloses the total number of pruned tokens, it provides a robust foundation for secure, scalable TaaS. Future work may involve extending the framework to 3-party (3PC) setups and addressing malicious security models to further harden the system against adversarial actors.

Summary updated

BibTeX
@inproceedings{zhang2025cipherprune,
  author = {Yancheng Zhang and Jiaqi Xue and Mengxin Zheng and Mimi Xie and Mingzhe Zhang and Lei Jiang and Qian Lou},
  title = {{CipherPrune: Efficient and Scalable Private Transformer Inference}},
  booktitle = {International Conference on Learning Representations},
  year = {2025},
  url = {https://openreview.net/forum?id=mUMvr33FTu},
}
Figure