Selective Network Linearization for Efficient Private Inference

Minsu Cho, Ameya Joshi, Brandon Reagen, Siddharth Garg, Chinmay Hegde

TL;DR

Selective Network Linearization (SNL) is a new gradient-based algorithm that significantly speeds up private inference by strategically replacing expensive ReLU activations with simple linear identity functions. By optimizing the placement of non-linearities, SNL achieves a new state-of-the-art Pareto frontier, offering up to 4.25% higher accuracy or 2.2× lower latency compared to previous methods on standard benchmarks.

What Problem Does This Paper Address?

Machine learning models are increasingly deployed in the cloud, but sharing sensitive data (like medical records) with a service provider raises massive privacy concerns. Private Inference (PI) aims to solve this by using cryptographic techniques like Secure Multi-Party Computation (MPC) and Homomorphic Encryption (HE) to perform model evaluations without either party seeing the other's data or model weights.

However, PI has a massive performance bottleneck. In standard "plaintext" inference, speed is limited by the number of floating-point operations (FLOPs). In PI, linear operations (like convolutions) can be pre-processed and made relatively fast. The real killer is the ReLU activation function. Because ReLUs are non-linear, they require expensive cryptographic protocols called Garbled Circuits, which dominate the total runtime (often accounting for over 90% of latency). To make PI practical, we need neural networks that use as few ReLUs as possible without sacrificing too much accuracy.

Methods

The authors propose Selective Network Linearization (SNL), a highly automated, gradient-based approach to finding the best ReLUs to keep.

Instead of manually choosing which layers to "thin out," they replace every ReLU in a pre-trained network with a parametric ReLU (pReLU). They introduce a trainable binary mask $c$ for every single neuron. The output of a layer becomes a weighted combination:

$$a = c \cdot \sigma(z) + (1 - c) \cdot z$$

If $c=1$, the neuron acts as a standard ReLU ($\sigma(z)$). If $c=0$, it becomes a simple identity function ($z$), effectively "linearizing" that part of the network.

Visual representation of SNL vs. Pruning and the pReLU mechanism

To solve this, they use a four-step optimization process:

  1. Start with a pre-trained network.
  2. Relax and Regularize: They allow $c$ to be continuous and add an $\ell_1$ penalty (Lasso) to the loss function. This encourages the network to set as many $c$ values to zero as possible.
  3. Binarize: Once the desired "ReLU budget" is reached, they round $c$ values to exactly 0 or 1.
  4. Fine-tune: They freeze the linearized structure and fine-tune the remaining weights to recover accuracy.

Key Insights and Ideas

  • Linearization $\neq$ Pruning: Unlike standard network pruning, which removes entire neurons or weights to save FLOPs, linearization keeps the weights but removes the non-linearity. This preserves the network's capacity to perform linear transformations while drastically reducing cryptographic overhead.
  • Earlier Layers are More "Linearizable": SNL automatically discovers that ReLUs in the early layers of a network are less critical for accuracy than those in later layers. The algorithm aggressively linearizes the first few layers while preserving ReLUs near the output.
  • The "No Free Lunch" Theorem: The authors provide theoretical proof that linearization reduces a network's "memorization capacity." Specifically, for "contractive" networks (where layers get narrower, typical in classification), they prove that linearizing earlier layers is mathematically better for preserving capacity than linearizing later ones.

Key Results

SNL consistently outperforms existing state-of-the-art methods like DeepReDuce, SAFENet, and CryptoNAS across the entire accuracy-latency spectrum.

  • CIFAR-100: At a budget of 50K ReLUs, SNL achieves ~74% accuracy, while previous best methods were below 70%. Alternatively, to reach 70% accuracy, SNL requires less than half the latency of the previous state-of-the-art.
  • Tiny-ImageNet: SNL achieved 63.39% accuracy with only 200K ReLUs. For comparison, the previous best method needed 400K ReLUs to reach a lower accuracy of 61.65%.
  • Pareto Dominance: The SNL curve stays strictly above and to the left of all competing methods, representing a superior trade-off between speed and performance.
Pareto frontiers for CIFAR-10, CIFAR-100, and Tiny-ImageNet

Limitations and Future Work

While SNL is a major step forward, the authors note a few areas for improvement:

  • Holistic Costs: The current work focuses primarily on reducing online runtime. A more complete approach would also consider the offline pre-processing costs associated with different network structures.
  • Alternative Activations: The study focuses on replacing ReLUs with identity functions. Future work could explore replacing them with other low-cost non-linearities, like low-degree polynomials.
  • Theoretical Scope: The current "no free lunch" theorems are proven for dense feed-forward networks; extending these proofs to complex convolutional architectures with residual connections remains an open challenge.

Summary updated

BibTeX
@inproceedings{cho2022selective,
  author = {Minsu Cho and Ameya Joshi and Brandon Reagen and Siddharth Garg and Chinmay Hegde},
  title = {{Selective Network Linearization for Efficient Private Inference}},
  booktitle = {International Conference on Machine Learning},
  year = {2022},
  url = {https://openreview.net/forum?id=5QMT-1Znme1},
}
Figure