Fast and Private Inference of Deep Neural Networks by Co-designing
  Activation Functions
Machine Learning as a Service (MLaaS) is an increasingly popular design where
a company with abundant computing resources trains a deep neural network and
offers query access for tasks like image classification. The challenge with
this design is that MLaaS requires the client to reveal their potentially
sensitive queries to the company hosting the model. Multi-party computation
(MPC) protects the client's data by allowing encrypted inferences. However,
current approaches suffer from prohibitively large inference times. The
inference time bottleneck in MPC is the evaluation of non-linear layers such as
ReLU activation functions. Motivated by the success of previous work
co-designing machine learning and MPC, we develop an activation function
co-design. We replace all ReLUs with a polynomial approximation and evaluate
them with single-round MPC protocols, which give state-of-the-art inference
times in wide-area networks. Furthermore, to address the accuracy issues
previously encountered with polynomial activations, we propose a novel training
algorithm that gives accuracy competitive with plaintext models. Our evaluation
shows between $3$ and $110\times$ speedups in inference time on large models
with up to $23$ million parameters while maintaining competitive inference
accuracy.
Abdulrahman Diaa, Lucas Fenaux, Thomas Humphries, Marian Dietz, Faezeh Ebrahimianghazani, Bailey Kacsmar, Xinda Li, Nils Lukas, Rasoul Akhavan Mahdavi, Simon Oya, Ehsan Amjadian, Florian Kerschbaum
# Fast and Private Inference of Deep Neural Networks by Co-designing Activation Functions

###### Abstract

Machine Learning as a Service (MLaaS) is an increasingly popular design where a company with abundant computing resources trains a deep neural network and offers query access for tasks like image classification. The challenge with this design is that MLaaS requires the client to reveal their potentially sensitive queries to the company hosting the model. Multi-party computation (MPC) protects the client's data by allowing encrypted inferences. However, current approaches suffer prohibitively large inference times. The inference time bottleneck in MPC is the evaluation of non-linear layers such as ReLU activation functions. Motivated by the success of previous work co-designing machine learning and MPC aspects, we develop an activation function co-design. We replace all ReLUs with a polynomial approximation and evaluate them with single-round MPC protocols, which give state-of-the-art inference times in wide-area networks. Furthermore, to address the accuracy issues previously encountered with polynomial activations, we propose a novel training algorithm that gives accuracy competitive with plaintext models. Our evaluation shows between 4 and 90\(\times\) speedups in inference time on large models with up to 23 million parameters while maintaining competitive inference accuracy.

## 1 Introduction

The rapid development of increasingly capable machine learning (ML) models has resulted in significant demand for products like machine learning as a service (MLaaS). In this scenario, big tech companies with vast computing resources train large machine learning models and provide users with query access. The major pitfall with MLaaS is that it requires clients to submit potentially sensitive queries to an untrusted entity. A promising solution to this problem is to employ cryptography to ensure the queries and inferences are hidden from the model owner. Secure inference is an active field of research with many solutions and different threat models as summarized in a recent SoK [30]. The challenge is that despite recent advances, the inference times are still prohibitively large compared to plaintext inferences.

This work focuses on reducing the runtime of secure inference on image data, under realistic network conditions, while maintaining classification accuracy. We consider the two-party setting using multi-party computation (MPC), where the server holds the ML model, and the client holds the data to query the model. Recent state-of-the-art works in this space employ various co-design approaches to reduce the inference time [30]. For example, COINN co-designs ML models optimized for quantization with efficient MPC protocols tailored to the custom models [17]. COINN substantially compresses the model and makes numerous optimizations to the architecture to achieve fast inferences. Another example is GForce, which tailors the cryptography needed for ML to high-speed GPU hardware [29]. By offloading vast amounts of work to

Figure 1: Summary of the inference time in seconds vs. test accuracy for each state-of-the-art approach on the CIFAR-10 dataset in the WAN (100 ms roundtrip delay).
the pre-computation phase, they are able to achieve state-of-the-art runtime and accuracy in secure inference [29]. Similarly, CryptGPU [32] modifies the CrypTen framework [20] to run efficiently on the GPU and give state-of-the-art inference times in wide area networks. However, despite making major steps towards practical inference, none of these works remove a crucial bottleneck in secure inference: the non-linear layers.

It is well known that the non-linear layers are the bottleneck of secure inference [12, 13, 17, 27]. This is because secure computation on arithmetic shares is optimized for multiplications and additions, instead of non-linear layers such as ReLU activation functions or MaxPool layers. In order to compute these non-linear functions, expensive conversions between different types of MPC protocols are required. Specifically, in more realistic network settings with high latency, the inference time is substantially degraded due to each conversion taking many rounds of communication. This problem is particularly prevalent in deep neural networks (DNNs), where a non-linear activation separates each of the many linear layers.

This work addresses the non-linear layers by taking a co-design approach between the activation functions and MPC. We take the approach of replacing classic ReLU activation functions with a polynomial approximation to avoid conversions altogether. Previous work has considered this approach but with limited success [12]. We propose two modifications to make this approach practical. First, we develop and evaluate new single-round MPC protocols that give the fastest evaluation of polynomials to date. The challenge with using polynomials is they severely impact model accuracy [12, 17, 27]. Previous work could not successfully train DNNs with more than 11 layers due to exploding gradients [12]. Thus, our second contribution is tailoring the ML training process to ensure high accuracy and stable training using polynomials. Our approach utilizes a new type of regularization that focuses on keeping the input to each activation function within a small range. We achieve close to plaintext accuracy on models as deep as ResNet-110 [16] and as large as a ResNet-50 on ImageNet [10] (23 million parameters). The combination of these approaches yields a co-design with state-of-the-art inference times and the highest accuracy for polynomial models.

We compare our work with three solutions representing the state-of-the-art approaches in secure inference according to Ng and Chow [30]. We summarize our results in Figure 1. Combining the single-round MPC protocols with our activation regularization achieves significantly faster inference times than all other solutions. Specifically, our solution is faster than CryptGPU by 4\(\times\), GForce by 5\(\times\), and COINN by 18\(\times\) on average in wide area networks. Our approach also scales to large models on ImageNet with a 90\(\times\) speedup over COINN and a 3\(\times\) speedup over CryptGPU. Furthermore, our inference accuracy remains competitive with all other solutions. CryptGPU often gives slightly higher accuracy as it can evaluate any plaintext model (albeit slower than our work). Thus, the challenge for future work is to further close the ML accuracy gap between plain and polynomial models.

## 2 Background

### Multi Party Computation

Secure multi-party computation (MPC) allows a set of parties to jointly compute a function while keeping their inputs to the function private. We focus on a variant of MPC which performs operations over shares of the data [5]. We use \([[s]]=[[s]_{a},[s]_{b}]\) to denote that the value of \(s\) is shared among participants, where \([s]_{a}\) is the share held by party \(a\) and \([s]_{b}\) by party \(b\). Arithmetic MPC protocols utilize a linear secret sharing scheme, such as an additive secret sharing scheme to compute complex circuits using combinations of additions and multiplications. Given constants \(v_{1},v_{2},v_{3}\) and shares of values \([[x]],[[y]]\), one can locally compute

\[v_{1}[[x]]+v_{2}[[y]]+v_{3}=[[v_{1}\cdot x+v_{2}\cdot y+v_{3}]] \tag{1}\]

to obtain shares of the value \(v_{1}\cdot x+v_{2}\cdot y+v_{3}\). For multiplication, one can use Beaver's trick to multiply using a single round of communication between parties [4]. Specifically, we assume a triplet of random numbers \(a,b,c\) (called a Beaver triplet) was generated such that \(a\cdot b=c\) and secret shared among all parties ahead of time (typically in an offline pre-computation phase). Then the parties compute \([[x\cdot y]]\) by first locally computing \([[a+x]]=A\) and \([[b+y]]=B\) and reconstructing \(A\) and \(B\) so that both parties have them in plaintext. This reconstruction is the single round required. Using these values, the parties compute the result locally as \([[x\cdot y]]=A[[y]]+(-B)[[a]]+[[c]]\), using the linearity property in equation 1.

Arithmetic MPC protocols are limited to basic multiplications and additions. Thus, for computing non-linear operations such as comparisons, other techniques such as converting to binary secret shares or using Yao's garbled circuits are common [9]. A binary secret sharing scheme is an arithmetic scheme carried out bitwise in the ring \(\mathbb{Z}_{2}\). Specifically, the difference is that we first decompose \(x\) into its bits and have a separate arithmetic share of each bit. By maintaining this bitwise structure, operations such as XOR or bit shifts are trivial. We describe how to use a binary and arithmetic secret-sharing scheme together to compute non-linear functions in Section 3.3.

### Neural Network Inference

We consider DNN classifiers with domain \(\mathcal{X}\subseteq\mathbb{R}^{d}\) and range \(\mathcal{Y}\subseteq\mathbb{R}^{c}\). DNN classifiers consist of a sequence of layers, each performing either a linear or a non-linear operation. The ResNet [16] architecture we consider is composed of (i) convolutional, (ii) fully connected, (iii) pooling, (iv) batch normalization, and (v) ReLU layers. All layers are linear, except for \(\text{ReLU}(x)=\max(x,0)\) and max pooling (that can
be replaced with average pooling). To classify an input \(x\), a classifier \(h\), passes the input sequentially through each layer. Upon reaching the last layer, the prediction is obtained by taking \(\arg\max_{i\in\{1..c\}}h(x)_{i}\), where we call \(h\) the logit function for a classifier \(h:X\rightarrow\mathcal{Y}\). The output of the secure inference protocol for an encrypted input \(x\) is the encrypted output \(h(x)\) of the logit function.

## 3 Problem Setup and Motivation

### Problem Setup

We follow the same threat model as prior work for two-party secure inference [29, 20, 17, 20]. Specifically, we follow the two-party client-server model where the server has a machine learning model (a DNN) they have trained, and the client holds private data upon which they would like to make an inference. The server's input to the protocol is the weights of their trained model, which they do not want to leak to the client (due to intellectual property or protecting their MLaaS business [33]). The client has a private input (typically an image) they would like to classify using the model but do not want to leak this input or the prediction to the server. That is, the MPC function can be written as \(f(\text{image},\text{model})=(label,\emptyset)\). Following previous work [29, 20, 17, 20], we consider the semi-honest model, introduced by Goldreich [15, SS7.2.2], where adversaries do not deviate from the protocol but may gather information to infer private information. Also, in line with previous work, we assume the model architecture is known to both parties. This includes the dimensions and type of each layer and parameters such as field size used for inference. The mean and standard deviation of the training set are also known to both parties following CrypTen [20].

### Privacy During Model Training

We focus only on the inference phase of machine learning. However, the privacy of the training process and training data is an orthogonal but essential problem. We recommend that the data owner take appropriate steps to protect the privacy of the model, such as training using differential privacy [1] or rounding the output of the inference. Furthermore, during training, care should be taken to protect against threats such as model stealing, which can be launched using only the inference result [18]. To summarize, the model owner learns nothing other than the fact a query was made. We ensure only the inference is revealed to the client; however, ML attacks that only require black box query access [18] must be defended against during the training process.

### Motivating the Co-Design of Activation Functions

It has been well established in the literature that activation functions such as ReLU are the bottleneck in MPC-based secure inference, taking up to 93% of the inference time [12, 13, 27, 17]. The reason for this is that current approaches use different types of MPC protocols for a model's linear and non-linear layers [29, 20, 17, 19, 27]. The linear layers are typically computed using standard arithmetic secret-sharing protocols tailored for additions and multiplications. The non-linear layers are computed using garbled circuits or binary secret share-based protocols. The bottleneck in wide area networks is typically the conversions between these protocols as they require a large number of communication rounds. A typical DNN architecture has many linear layers, each followed by a non-linear layer resulting in a prohibitively large number of conversions.

Consider CrypTen, a PyTorch-based secure ML library, as a baseline approach [20]. CrypTen uses binary shares to evaluate boolean non-linear layers such as ReLUs and MaxPooling layers. Specifically, all linear layers are computed using standard multiplication and addition protocols over arithmetic shares. To compute \([[ReLU(x)]]\) at each layer, \([[x]]\) is first converted to binary shares using a carry look-ahead adder. Once in binary shares, CrypTen extracts the sign bit to compute \([[x>0]]\) (a local operation). The sign bit, \([[x>0]]\), is then converted back to arithmetic shares (trivial for a single bit) and multiplied with \([[x]]\) to get \([[ReLU(x)]]\). The problem with this approach is that each conversion takes \(O(log(L))\) communication rounds. Taking into account the additional round needed for multiplication, we observe nine communication rounds per ReLU in practice (under 64-bit precision). Recently, more sophisticated MPC protocols have been proposed that reduce the number of rounds needed for comparisons in arithmetic shares [6, 7] or reduce the cost of binary share conversions [11]. However, even if one were to implement these protocols in CrypTen, the number of rounds needed for non-linear layers would still outweigh the number needed for linear layers.

Motivated by this bottleneck, several works have focused on either reducing the number of ReLUs or replacing ReLUs altogether [12, 13, 27, 28, 19, 22]. One approach is to approximate each ReLU with a high degree polynomial [12, 22]. The advantage of using polynomials is that polynomials can be computed in arithmetic shares, thus removing the need for expensive conversions and improving the total inference time. A significant challenge with polynomials is maintaining model accuracy [12, 13, 17, 19, 27].

Thus, this work aims to provide a secure inference protocol with state-of-the-art inference time and accuracy in realistic networks with high latency. To do this, we take a co-design approach to balance accuracy and fast inference time. In Section 4, we develop MPC protocols that achieve the fastest
evaluation of polynomials to date, assuming a modified ML architecture. In Section 5, we tailor the ML training procedure to achieve high accuracy using this modified architecture.

## 4 Faster Evaluation of Polynomials

In this section, we evaluate the speed-up of replacing ReLU's with a naive polynomial approximation. We then develop our single-round protocols and show that they drastically reduce the activation function evaluation time in wide area networks.

### The Polynomial Advantage

To highlight the speed-up of polynomials over standard ReLUs, we first evaluate the runtime of a single layer with \(2^{15}\) ReLU activation functions in Figure 2. (See Section 6 for more implementation details.) First, we plot an unmodified version of CrypTen (using CryptGPU [32]) with the conversion to binary shares. Next, we replace the ReLU with a degree four polynomial fitted using least squares polynomial regression (see Section 5 for the details). We can see that using polynomials in off-the-shelf CrypTen is much faster across all network speeds than the default mixed arithmetic and binary protocol. This difference becomes more pronounced as we add more network delay or scale to deeper models with more ReLUs.

Despite the significant speed-up, naively computing a polynomial is still expensive in MPC with a non-trivial number of communication rounds. For example, Horner's method (an iterative approach to evaluating polynomials) uses \(O(n)\) communication rounds (where \(n\) is the degree of the polynomial). However, most MPC libraries (including CrypTen) use the square-and-multiply algorithm for exponentiation, followed by multiplying and summing the coefficients locally. The square-and-multiply algorithm requires \(O(log(n))\) multiplications (and thus rounds) in MPC. In practice, the default square and multiply implementation in CrypTen uses two rounds per ReLU for a degree four polynomial. To increase the advantage of using polynomial activation functions even further, we develop a new single-round protocol for evaluating polynomials in MPC.

### ESPN: Exponentiating Secret Shared Values using Pascal's triangle

We present our single-round, highly parallelizable protocol ESPN for computing high-degree polynomials. The fundamental idea is utilizing the binomial theorem (Pascal's triangle) to achieve faster exponentiation. We begin by describing our protocol for raising a number \([[x]]\) to the power \(k\), in MPC (see Algorithm 1 for an overview). Using the additive secret sharing scheme, the exponentiation corresponds to \((x_{a}+x_{b})^{k}\) where \(x_{a}\) represents the first party's share and \(x_{b}\) represents the second (such that \(x_{a}+x_{b}=x\)). The binomial theorem expands this expression as:

\[x^{k}=(x_{a}+x_{b})^{k}=\sum_{i=0}^{k}\binom{k}{i}x_{a}^{k-i}x_{b}^{i} \tag{2}\]

We observe that, for each \(i\) in the sum, party \(a\) can compute \(a_{i}=x_{a}^{k-i}\) without needing to communicate with party \(b\) (Alg. 1 line 4). Similarly, party \(b\) can compute \(x_{b}^{i}\) without communicating with party \(a\) (Alg. 1 line 5). Finally, \(\binom{k}{i}\) can be computed by any party (or pre-computed ahead of time). For simplicity, we assign the computation of \(\binom{k}{i}\) to party \(b\). Thus party \(b\) computes \(b_{i}=\binom{k}{i}x_{b}^{i}\).

Once each party has computed their respective vectors, we multiply \(a_{i}\cdot b_{i}\) for each \(i\) in parallel (Alg. 1 line 6). We carry out this multiplication using standard MPC protocols in one round. To use these multiplication protocols, each party must have a share of the input. We use a trivial additive secret sharing, where the other party inputs zero as their share to the protocol (Alg. 1 line 2). Finally, after the multiplication, the sum of the binomial theorem can be efficiently computed with no communication (Alg. 1 line 7).

Using our exponentiation protocol, we can now efficiently compute high-degree polynomials in a single round. The first step in evaluating a polynomial is to compute all needed exponents of the input (i.e. \(\{x^{k}|k\in[n]\}\) for a degree \(n\) polynomial) by calling Algorithm 1 in parallel. We note there will be a significant overlap in each party's local powers from the binomial theorem. Thus, a simple cache can improve performance significantly. Furthermore, the binomial coefficients \(\binom{k}{i}\), can also benefit from basic dynamic programming by reusing the

Figure 2: Benchmarking the secure evaluation of ReLU activation functions using various approaches. The \(x\)-axis is the network delay in ms and the \(y\)-axis is the mean runtime in seconds averaged over 20 runs with the shaded area representing the 95% confidence intervals.
previous result (\(k-1\)) to compute the next (\(k\)). After computing the exponents, the output of the polynomial can be computed by multiplying the coefficients (public values) and summing, all of which can be done locally.

In Figure 2, we plot this approach alongside the previous approaches to evaluate the runtime. ESPN incurs slightly more overhead in the LAN setting; however, it scales significantly better (the confidence intervals do not overlap) to wide area networks that can be expected in practice.

### Alternative Single Round Protocol: HoneyBadger

Like ESPN, Lu et al. give a single round protocol for exponentiation in MPC [26]. Despite focusing on a completely different problem (anonymous communication), they provide an MPC protocol of independent interest for exponentiation, which we also utilize in our work. They take a very different approach to our work that yields different trade-offs. Instead of the binomial theorem, their work utilizes the following factoring rule

\[x^{k}-r^{k}=(x-r)\sum_{i=0}^{k-1}x^{k-i-1}r^{i} \tag{3}\]

where \(r\) is a random secret-shared number derived during pre-computation. We assume each party has a share of \(x\) and a share of \(r^{i}\) for \(i\in\{1,\ldots,k\}\) before beginning the protocol (instead of the more common Beaver triplets). The first step in the protocol is to compute and reveal \(x-r\) (\(x\) blinded by \(r\)), which uses a single round. Once revealed, this value becomes a public constant \(C\). After some algebraic manipulation of (3), Lu et al. obtain a recursive formula for \(x^{i}r^{j}\) given below.

\[[[x^{k}r^{j}]]=[[r^{k+j}]]+C\sum_{i=0}^{k-1}[[x^{k-i-1}r^{i+j}]] \tag{4}\]

Using dynamic programming, the parties can then compute any power (\(x^{k}r^{0}\)) using only additions of previously computed terms and powers of \(r\). To compute polynomials using this protocol, we need to multiply the coefficients and sum the terms, precisely as we did in ESPN.

The advantage of Lu et al.'s protocol is that the communication is small (only the opening of \(x-r\)). The first disadvantage is that the protocol requires a modified pre-computation phase, which is as difficult to pre-compute securely as the original problem (it is exponentiation). On the contrary, our binomial protocol uses standard beaver triplets commonly found in MPC frameworks. There are well established protocols for efficiently computing these triplets, and the parties may already have them due to the popularity of Beaver's trick. The second disadvantage of Lu et al.'s solution is that, while the protocol requires very little communication, it is not locally parallelizable as each dynamic programming step depends on the previous one. In contrast, our entire protocol can be executed in parallel.

We also consider the runtime of using HoneyBadger to compute polynomial approximations of ReLUs in Figure 2. We emphasize this is a runtime-only evaluation. Without our training algorithm in Section 5, none of the polynomial-based solutions can attain usable accuracy. We find that ESPN and HoneyBadger perform similarly in practice, with HoneyBadger gaining a slight advantage in very low network delay. Due to the trade-offs and similarities, we will evaluate both approaches for the remainder of this work.

### Floating Point Considerations

We note that the exponentiation protocols we have discussed are designed for integers. Extending to floating point values is straightforward, but requires rescaling (a standard practice in fixed-point arithmetic). Furthermore, in both protocols (ESPN and HoneyBadger), we can only rescale once for each polynomial computation (since the majority of the computation is local). Thus, to ensure correctness, we must scale up each exponent by \(n+1-k\) where \(n\) is the degree of the polynomial and \(k\) is the exponent (Algorithm 1). This scaling up is a scalar multiplication by a public constant and thus incurs no additional rounds. At the end of the computation, we must then scale down by \(n\) for correctness. We use CrypTen's two-party truncation protocol that also incurs no additional rounds. However, there is a negligible chance of an incorrect result from this truncation protocol due to wrap-around in the ring. Specifically, the probability of an incorrect result when truncating \(x\) is \(\frac{x}{2^{L}}\) where \(2^{L}\) is the size of the ring [20]. This implies \(x\) must be small compared to the ring for this fast truncation protocol to be correct. We observe that \(x\) can also be very large while maintaining correctness due to symmetry. Following the proof of Mohassel and Zhang [28], we get that the probability of failure is \(max\{\frac{x}{2^{L}},\frac{2^{L}-x}{2^{L}}\}\). Since we upscale all terms by \(n+1-k\) we ensure \(x\) is sufficiently large and thus can take advantage of this fast truncation protocol with no additional rounds.

In addition to scaling, we must ensure that the polynomial computation does not overflow in the ring by choosing the correct precision. Consider using degree \(n\) polynomials fitted
to a range \([-\lambda,\lambda]\). If the global precision (size of the ring) is \(L\)-bit, then the working precision of each value must be \(p\)-bit where

\[\log\left[n\cdot\frac{1-\lambda^{n}}{1-\lambda}\right]+n\cdot p\leq L-1 \tag{5}\]

For our experiments, we use CrypTen, with \(L=64\)[20]. Assuming default values of \(n=4\) and \(\lambda=5\) we get that 10-bit is the maximum working precision. However, this is a pessimistic upper bound, and in practice, we find that 12-bit precision gives the best results.

## 5 PILLAR: Polynomial Activation Regularization

Our initial benchmark in Section 4 showed a significant speed-up when replacing ReLU functions with polynomials implemented using ESPN and HoneyBadger. However, a notable challenge neglected thus far is that replacing a ReLU with a polynomial can drastically reduce the accuracy of the model [12, 17]. This section discusses the causes of the accuracy degradation and describes our mitigation techniques. Finally, we give empirical results showcasing the high accuracy of our modified training procedures across various architectures and datasets.

### The Problem with Polynomial Activation Functions

Escaping Activations.The first step in replacing an activation function with a polynomial is to design a polynomial that approximates the original function as closely as possible. A common approach for this is the least-squares polynomial fitting. In this approach, a small discretized range is chosen to fit the polynomial on. A table of values is created for the function over all values in the range. This creates a system of equations for the polynomial coefficients that can be solved with least squares. The challenge with this approach is that, outside of this range, the polynomial no longer resembles the original activation function and often diverges rapidly. This leads to a problem called escaping activations, first identified by Garimella et al. [12]. If one naively swaps a ReLU for its polynomial approximation, with no additional modifications to the training, all weights will become infinite within a few training epochs. We give an example of this degradation in Figure 4. We can see that, without modifying the training procedure, a polynomial can completely destroy the accuracy.

To illustrate the problem more clearly, we conduct an experiment using a polynomial of degree four fitted on the range \([-5,5]\) (\(\lambda\)=5) as the activation function for a three-layer model on CIFAR-10 [21]. In Figure 4, we plot this polynomial activation function and the \(\ell_{\infty}\)-norm of the input and output to each activation function. We note that, with no modification (except replacing ReLUs with polynomials), the weights of this model become undefined within approximately three epochs of training. First, we note the divergent behaviour of the polynomial outside the fitted range. Second, we observe the effect of the divergence on the outputs of the activation function. Specifically, we wait until the model weights become undefined (NaN in Python) and then observe the behaviour leading up to the explosion. We can see that three steps before the model weights become undefined (NaN), the input values of each activation are out-of-range, but the outputs still behave similarly to a ReLU. However, in the next iteration (two steps before NaN), a single value in the first layer goes too far out of range. This causes a ripple effect for the other two layers, creating an extremely large output (approx \(-2000\)) in the final activation function. This large value creates a large gradient, and after another iteration of training, the values become so large that the gradients (and weights) become undefined (NaN). We find that training the model by minimizing the classification loss alone is not enough to keep the model in
range as the gradients explode before decreasing the loss.

Truncated Polynomial Coefficients.An additional challenge is that we will evaluate the fitted polynomial in a finite ring with limited precision. This significantly impacts the polynomial coefficients, which tend to be relatively small, especially for the higher-order terms. Specifically, these small coefficients can get truncated to zero in limited precision, which causes the polynomial to diverge even inside the fitted range. We give an example of this in Appendix B.

### Defining PILLAR

Our approach, which we call PILLAR, is the combination of the components we describe in this section. Activation function regularization is our primary approach for mitigating escaping activation functions. However, to scale to larger models, we find that the additional steps of clipping, regularization warm-up, and adding batch normalization are beneficial.

Quantization-Aware Polynomial Fitting.We begin by solving the problem of truncated polynomial coefficients. To address this, we fit the polynomial with the precision constraint in mind. We do this by using mixed integer non-linear programming. Let \(X\) be the set of all values between \([-\lambda,\lambda]\) in \(p\)-bit precision (the domain we want to fit on). First, we generate \(Y=ReLU(X)\cdot 2^{p}\), a table of values for a standard ReLU scaled up by the precision. Scaling the output of the ReLU allows us to work in the integer domain (similar to fixed point arithmetic). We then compute a matrix \(B\) where each column is the different powers of \(X\) used in a polynomial (\(B=[X^{0},X^{1},X^{2},\ldots]\)).

Next, we solve the system \(AB=Y\) for \(A\) using mixed integer linear programming with \(A\in[-2^{p}-1,2^{p}-1]\) to get the coefficients \(A\) that minimize the error between the polynomial \(AB\) and the ReLU values \(Y\). Finally, we scale the resulting coefficients down by \(2^{p}\). We note that \(A\in[-2^{p}-1,2^{p}-1]\) corresponds to coefficients being bounded by \([-1,1]\) after we scale down. We use 10 bits of precision for all polynomials motivated by our derivations in Section 4. As we observe in Appendix B, our quantized polynomial fitting addresses the problems of exploding activations within the range. However, the issue of going out-of-range requires additional treatment.

Activation Regularization.Following the observations of Section 5.1 and Garimella et al. [12], it is clear that minimizing the classification loss alone is not sufficient to prevent escaping activations. Garimella et al. proposed QuaIL, a method that trains one layer of the model at a time, focusing not on classification accuracy but the similarity of the layer to a standard ReLU model [12]. QuaIL showed much better accuracy than naive training but only scaled to models with at most 11 layers.

In our work, we address the cause of the problem directly by regularizing the input to each activation function during training. We add an exponential penalty to the loss function when the model inputs out-of-range values to the polynomial activation function. Let \(x\) be the input to the activation function, and \(\lambda_{reg}\) be the upper bound of the symmetric range \([-\lambda_{reg},\lambda_{reg}]\) in which we would like the input to be contained. Then, we define our penalty function as

\[p(x)=\left(\frac{x}{\lambda_{reg}}\right)^{\gamma} \tag{6}\]

where \(\gamma\) is a large even number (to handle negative values) determining the severity of the penalty. We find that values between six and ten work best in practice, with \(\gamma=10\) being the default in our experiments. This penalty function gives negligible penalties (less than 1) for \(|x|<\lambda_{reg}\) and rapidly grows (in the degree of \(\gamma\)) as \(|x|>\lambda_{reg}\).

We aggregate \(p(x)\) over \(I\), the set of inputs to all activation functions, by taking the average over each activation layer in the model. After aggregation, we scale the penalty using a regularization coefficient \(\beta\) and add it to the existing cross-entropy loss function of the model \(\ell_{c}\). Specifically, the modified loss function \(\ell^{\prime}\) is defined as:

\[\ell^{\prime}(\cdot)=\ell_{c}(\cdot)+\frac{\beta}{K}\sum_{x\in I}p(x) \tag{7}\]

where \(K\) is the number of activation layers in the model. This allows us to tune the importance of classification loss vs. the cost of going out-of-range.

Clipping.Although activation regularization teaches the model not to go out-of-range over time, the model still needs to avoid going to infinity during the early stages of training. Thus, during training, we apply a clipping function to the input of the activation function such that if any input goes out of range, it is truncated to the range's maximum (or minimum) value. This clipping function does not affect the penalty as it is applied after the penalty function has been computed. We emphasize that this clipping function is only used during training and is removed during inference. The intuition is that the model should learn not to go out-of-range during training and thus no longer requires this clipping function during inference. Additionally, we often find that setting the \(\lambda_{reg}\) of the penalty to be smaller than the range used for clipping and polynomial fitting can yield even better results as it gives room for going slightly out-of-range in the inference.

Regularization Warm-up.We find the minimum requirements for successfully training a model with polynomial activation functions are activation regularization and clipping. However, for larger models, the penalty term can be extremely large in the first few epochs (until the model learns to stay in range). In some cases, the loss can become infinite due
to our regularization penalty. To address this challenge, we adopt a regularization scheduler for the first four epochs that slowly increases both \(\gamma\) and \(\beta\) to the values used for the rest of the training. Empirically, the following schedule works well and avoids infinite loss. We let \(\gamma^{\prime}\in\{4,6,\dots,\gamma,\gamma,\dots\}\) and \(\beta^{\prime}\in\{\beta/100,\beta/50,\beta/10,\beta/5,\beta,\beta,\dots\}\).

BatchNorm Layers.Garimella et al. also investigated using normalization to help prevent the escaping activation functions [12]. They proposed a min-max normalization approach where each layer's minimum and maximum values are approximated using a weighted moving average of the true minimum and maximum. These values are frozen during inference. Garimella et al. observed that this approach alone was insufficient, as activations still escaped the range during inference. We observe this operation is similar to the batch norm layer commonly added to ML models. The main difference is that the mean and standard deviation of the batch are used to normalize the layer instead of the minimum and maximum values. By fixing the approximation of the mean and standard deviation during inference (following CrypTen [20]), this operation is very efficient in MPC. We study the effect of BatchNorm in Appendix A. We find that batch norm layers considerably improve the accuracy of PILLAR. This is an intuitive result as batch normalization helps to keep each layer's output bounded and thus reduces the work of our regularization function.

### Measuring PILLAR's Effectiveness

The Regularization Coefficient.To show the effect of our regularization and coefficient \(\beta\), we conduct an experiment using the same three-layer model on CIFAR-10 from Section 5.1. In Figure 5, the left \(y\)-axis gives the out-of-range ratio (OOR), defined as the ratio of activation function inputs that were not within the interval \([-5,5]\). The right \(y\)-axis is standard classification accuracy, and the \(x\)-axis varies the regularization coefficient \(\beta\). We observe that when the coefficient, \(\beta\), is small, the model goes out-of-range often and thus has poor accuracy. As we increase \(\beta\), the out-of-range ratio decreases, and accuracy increases. However, if we increase the coefficient too much, the accuracy decreases again.

End-to-end Accuracies.We evaluate PILLAR across a range of different models and architectures considered in related work [32, 17, 29]. We summarize the results in Table 1. All results are averaged over five random seeds, and we show the 95% confidence interval. The only exception is ResNet50 on ImageNet, where we only train a single model due to the size of the dataset. We defer to Section 6 for the details of the experimental setup. We note that these results are using PyTorch with no cryptography or quantization. We give a complete evaluation using MPC in Section 6 where quantization has an effect. Table 1 provides preliminary evidence that our polynomial training approach yields high accuracies competitive with state-of-the-art ReLU models across a range of models and datasets.

## 6 Evaluation of Co-Design

In this section, we provide an end-to-end comparison of our co-design against state-of-the-art solutions in secure inference. We determine the state-of-the-art works following a recent SoK by Ng and Chow [30]. Specifically, we consider three solutions on the Pareto front of latency and accuracy as determined by Ng and Chow. These works are COINN [17], GForce [29] and CrypTen (CryptGPU) [20, 32]. We will evaluate the metrics of latency (or runtime of a single sample) and encrypted accuracy. We begin with the experimental setup, then evaluate both metrics against each related work. Section 6.2 evaluates the ResNet-18 architecture, which gives our state-of-the-art performance. Section 6.3 evaluates the VGG-16 architecture, the only architecture GForce evaluates.

\begin{table}
\begin{tabular}{l l l} \hline \hline Dataset & Model & Accuracy \(\pm\) CI \\ \hline \multirow{4}{*}{Cifar10} & MiniONN & 88.1 \(\pm\) 0.26 \\  & VGG 16 & 90.8 \(\pm\) 0.11 \\  & ResNet18 & 93.4 \(\pm\) 0.14 \\  & ResNet110 & 91.4 \(\pm\) 0.18 \\ \hline \multirow{4}{*}{CIFAR-100} & VGG 16 & 66.3 \(\pm\) 0.22 \\  & ResNet32 & 67.8 \(\pm\) 0.32 \\  & ResNet18 & 74.9 \(\pm\) 0.14 \\ \hline ImageNet & ResNet50 & 77.7 \\ \hline \hline \end{tabular}
\end{table}
Table 1: Plain-text Accuracy of PILLAR (5 runs).

Figure 6: Summary of the inference time vs accuracy for each state-of-the-art approach on the CIFAR-100 dataset in the WAN (100 ms roundtrip delay).
Section 6.4 considers other ResNets and the MiniONN architecture following COINN. Finally, in Section 6.5, we evaluate ImageNet.

Results Summary.We plot a summary of the accuracy and inference time for CIFAR-100 in Figure 6. For both datasets (recall Figure 1 for CIFAR-10), we observe that our work always gives the solution with the fastest inference time by a statistically significant amount. In terms of accuracy our work is competitive with the state-of-the-art but CryptGPU is always the most accurate as it can infer unmodified plaintext models. We find that our solution is faster than CryptGPU by \(4\times\), GForce by \(5\times\), and COINN by \(18\times\) on average in wide area networks. Our accuracies are competitive with state-of-the-art and plaintext solutions and stay stable (no escaping activations) with models containing up to 110 layers and 23 million parameters.

### Experimental Setup

We develop an experimental setup that follows as closely as possible to the works we compare to [17, 32, 29]. We use CIFAR-10/100 [21] and ImageNet [10], the same common benchmark datasets as related work. Our model architectures include: MiniONN [24], VGG [31], and ResNets [16]. This covers models of depth 7 to 110 layers with the number of trainable parameters ranging from 0.2 to 23 million. See Appendix C for further details on architectures and datasets.

Implementation Details.We implement PILLAR using GEKKO's [3] mixed integer linear programming solver for the quantization-aware polynomial fitting. We then cache these polynomial coefficients and use them for all models and datasets. We train all our models using PyTorch and implement a custom activation function module for the polynomial approximations. We call this the PolyReLU layer and use it to replace all ReLU layers. This module takes the cached coefficients and computes the output of the polynomial approximation for forward passes. When training, we compute the regularization penalty by taking a snapshot of the inputs passed to the PolyReLU layers and computing our modified loss function from equation 7. After training, we export the model as an ONNX model which can be inputted to CrypTen.

We implement ESPN and HoneyBadger in the CrypTen interface. We add configuration parameters that allow the user to specify which type of activation function they would like from ReLU or PolyReLU. Similarly, the polynomial evaluation method is parametrized in the config file between ESPN, HoneyBadger, and the default CrypTen Polynomial Evaluation. We follow CrypTen's default trusted first party provider, which assumes a first party will generate and distribute all needed pre-computed values from Beaver triplets to binary shares, etc. To ensure we accurately measure the online phase of the inference, we move some additional operations to the pre-computation phase. Specifically, random-number generation in the Pseudo-Random-Zero-Sharing (PRZs) are fixed to zero to simulate being computed in the offline phase.

For ESPN, we implement the idea directly into CrypTen's polynomial evaluation module. As discussed in Section 4, we compute the powers for the last term in the polynomial first, and then reuse these powers for all lower-degree terms. For HoneyBadger, we modify the Trusted First-Party Provider to provide the additional sets of random numbers and exponents needed for their protocol. We then implement the idea directly into the polynomial module of ArithmeticSharedTensors. We use HoneyBadger's proposed dynamic programming method with the memory optimization technique of keeping only the current and previous iterations in memory.

When running our experiments on the GPU, we observed overflows not present in the CPU version of CrypTen. Upon inspection, we found that the default number of blocks (4) set in CryptGPU is not adequate for our use-case. Increasing this parameter to 5 fixed the overflow issue completely. All experiments are run on a machine with 32 CPU cores @ 3.7 GHz and 1 TB of RAM with two NVIDIA A100 with 80 GB of memory. We simulate network delay by calling the sleep function for the appropriate time whenever the client and server communicate. We simulate the LAN with 0.25 ms roundtrip delay and the WAN with 100 ms, following COINN [17]. All experiments (except ImageNet) are repeated over multiple random seeds, and we report the mean and 95% confidence interval as shaded areas.

Since COINN does not include source code, only executables, we use the numbers reported in the paper for their work. For all other works, we run our own benchmarks. To evaluate GForce we use their code unmodified. In order to use CryptGPU in practice, one must first train a model in PyTorch. For ImageNet, PyTorch provides pre-trained models that we can use. However, we will need to train a model for all other architectures and datasets. We simply use the same configurations as our PolyRelu models but with standard ReLUs. We include all source code to reproduce our results1.

Footnote 1: [https://github.com/LucasFenaux/PILLAR-ESPN](https://github.com/LucasFenaux/PILLAR-ESPN)

Hyperparameters.We introduce five new hyperparameters associated with our techniques: polynomial degree (\(n\)), polynomial approximation range (\(\lambda\)), polynomial regularization range (\(\lambda_{reg}\)), polynomial regularization coefficient (\(\beta\)), and polynomial regularization exponent (\(\gamma\)). We found that, for all models and datasets, a value of \(\gamma=10\) performs well as it introduces a strong enough incentive for PolyReLU inputs to stay in range while keeping penalization for values in range practically 0 (if an input \(x\) is within range, then \(\frac{x}{\lambda_{reg}}<1\Rightarrow(\frac{x}{\lambda_{reg})^{10}}\sim 0\)). We also found that a polynomial approximation range \(\lambda=5\) provides a good compromise between regularization (larger ranges require less regularization) and quantization (lower range values use less precision).
Similarly, we found the optimal quantization-aware polynomial degree (\(n\)) to be 4. This value provides a good trade-off between approximation quality while avoiding overflow by keeping the total precision less than 64-bits. We vary the polynomial regularization range (\(\lambda_{reg}\)) and polynomial regularization coefficient (\(\beta\)) per model and dataset, although we found \(\lambda_{reg}=4.8\) (slightly tighter than \(\lambda=5\)) and \(\beta=5\times 10^{-5}\) to be good default values. We use a precision of \(p=12\) as this allows us to work in CrypTen's 64-bit ring.

We used Stochastic Gradient Decent as the optimizer with a learning rate of 0.013 as the default. This includes a Cosine Annealing Learning Rate Scheduler with Linear Learning Rate Warmup of 5 epochs and decay 0.01. We use a weight decay of either \(10^{-4}\) or \(5\times 10^{-4}\) and a momentum of 0.9. We used a default batch size of 128 and set the default number of Epochs to 185. For some models we tuned the learning rate, number of epochs, and regularization coefficient to achieve a slightly higher accuracy. We detail hyperparameters in our source code repository.

### ResNet-18 Architecture

In this section, we use a ResNet-18 architecture as it is the architecture that yields the best inference time and accuracy over all CIFAR-10 and CIFAR-100 experiments. For this comparison we focus on CryptGPU, which has been shown to be a state-of-the-art solution [30]. CryptGPU (or CrypTen) [32] serves as a baseline in all our comparisons including those against GForce and COINN in Sections 6.3 and 6.4. Neither COINN nor GForce support the ResNet-18 architecture evaluated in this section.

Inference Time.We measure the inference time of a single input image over varying network delays. The results are given in Figure 7. We include the result for CIFAR-100 and omit the plot for CIFAR-10 as it displays similar trends. We observe that both PILLAR + HoneyBadger and PILLAR + ESPN outperform CryptGPU with statistical significance across all roundtrip delays (as the shaded area does not overlap). In the WAN (100 ms), this corresponds to a 4\(\times\) speedup over CryptGPU. Furthermore, we find HoneyBadger and ESPN perform similarly as observed in Section 4, with PILLAR + HoneyBadger having a slight advantage.

Accuracy.We measure the accuracy of the models on the testing set both in plain (using PyTorch) and encrypted (using CrypTen). We give the result in Table 2. First, we observe the plain and encrypted accuracies are very similar, indicating that quantization has a minor effect despite not considering this in training. We find that CryptGPU and PILLAR give similar accuracies, with CryptGPU performing slightly better, as is to be expected since they use unmodified activation functions. However, we argue this slight loss in accuracy is well justified by the significant decrease in inference time.

\begin{table}
\begin{tabular}{l l l l} \hline \hline Dataset & Technique & Plain Acc & Enc Acc \\ \hline \multirow{2}{*}{CIFAR-10} & PILLAR & 93.4 \(\pm\) 0.14 & 93.3 \(\pm\) 0.15 \\  & CryptGPU & 94.7 \(\pm\) 0.09 & 94.6 \(\pm\) 0.10 \\ \hline \multirow{2}{*}{CIFAR-100} & PILLAR & 74.9 \(\pm\) 0.14 & 74.4 \(\pm\) 0.21 \\  & CryptGPU & 76.6 \(\pm\) 0.07 & 76.6 \(\pm\) 0.13 \\ \hline \hline \end{tabular}
\end{table}
Table 2: ResNet-18 accuracy comparison (5 runs).

Figure 8: VGG-16 evaluation on CIFAR-100 (20 runs).

Figure 7: ResNet-18 evaluation on CIFAR-100 (20 runs).
### VGG-16 Architecture

In this section, we compare with GForce, the current state-of-the-art as shown by Ng and Chow [30]. GForce focused on a modified VGG-16 [31] architecture and compared it to all other works (including those using different architectures). For completeness, we evaluate the VGG-16 architecture using our techniques, and CryptGPU although we note that the ResNet-18 architecture outperforms VGG-16 in both inference time and accuracy. COINN [17] does not give results for VGG-16, so we exclude it from this section.

Inference Time.Since our work aims to reduce the rounds needed by binary non-linear layers, we replace the MaxPool layers in the VGG-16 with AvgPool for all solutions (including CryptGPU and GForce). We give the inference times over various delays in Figure 8. First, we note that GForce significantly outperforms all other solutions in the LAN. However, for more realistic high latency networks (>5ms roundtrip delay), we observe our solutions significantly outperform GForce (5\(\times\) speedup in WAN). Once again, our solutions outperform CryptGPU for all network delays.
We once again outperform CryptGPU in all evaluations2 with a 4\(\times\) speed up on average in the WAN.

Footnote 2: All of which are statistically significant except MiniONN in LAN where the confidence intervals overlap slightly.

Encrypted Accuracy.We give the results in Table 4. We observe that PILLAR is competitive with related work in all models, although we remark that, once again, our ResNet-18 models outperform all others. We also note that, while COINN does quantization-aware training, PILLAR does not and still only loses a small amount of accuracy in encryption vs. plaintext.

### Scaling to ImageNet

In this section, we evaluate the scalability of our approach on the ImageNet dataset using a ResNet-50 architecture with 23 million parameters. This architecture was previously too large for training with polynomial activation functions [12]. We compare our approach to COINN and CryptGPUand exclude GForce as they do not consider ImageNet.

Inference Time.We plot the inference time in Figure 10. We observe a significant reduction over COINN across all network delays with a 28\(\times\) reduction in the LAN (0.25 ms) and a 90\(\times\) reduction in the WAN (100 ms). Compared to CryptGPU we find that PILLAR + HoneyBadger is the fastest in all network delays by 3\(\times\) on average. PILLAR + ESPN is slightly slower in the LAN, but once again outperforms CryptGPU in the WAN.

Encrypted Accuracy.We present a summary of the accuracies in Table 5. We observe a much higher encrypted accuracy for PILLAR compared to COINN and thus, our solution is Pareto dominant. For CryptGPU, we use a pre-trained PyTorch model with state-of-the-art accuracy. Therefore, as expected, CryptGPU has an accuracy 3% higher than the model we trained from scratch. We note that with a higher degree polynomial, we were able to train a 79.2% polynomial model. However, this model is not possible to infer in the 64-bit field used by CrypTen (as higher degrees need more precision by equation 5). We discuss future directions to further improve this result in Section 7.

## 7 Discussion

Our experimental evaluation in Section 6 showed our algorithms significantly outperform all related work in inference time when the network latency is high. While state-of-the-art compared to other polynomial training approaches, PILLAR still incurs a minor accuracy degradation compared to standard models with ReLUs. We posit a few directions for future work to further close this gap between polynomials and ReLUs.

Quantization.Note that aside from our quantization-aware polynomial fitting described in Section 5, we have made no efforts to reduce the effects of quantization. COINN developed training algorithms to help the model be robust to the overflow and quantization present in MPC [17]. An interesting future work would be to combine the COINN methods with PILLAR to see if further accuracy gains are possible.

\begin{table}
\begin{tabular}{l l l l} \hline \hline Dataset/Model & Technique & Plain Acc & Enc Acc \\ \hline \multirow{2}{*}{CIFAR-10 / MiniONN} & PILLAR & 88.1 \(\pm\) 0.26 & 87.85 \(\pm\) 0.36 \\  & CryptGPU & 91.2 \(\pm\) 0.17 & 91.2 \(\pm\) 0.16 \\  & COINN & - & 87.6 \\ \hline \multirow{2}{*}{CIFAR-10 / ResNet-110} & PILLAR & 91.4 \(\pm\) 0.18 & 91.4 \(\pm\) 0.18 \\  & CryptGPU & 92.8 \(\pm\) 0.27 & 92.7 \(\pm\) 0.26 \\  & COINN & - & 93.4 \\ \hline \multirow{2}{*}{CIFAR-100 / ResNet-32} & PILLAR & 67.8 \(\pm\) 0.32 & 67.84 \(\pm\) 0.35 \\  & CryptGPU & 68.4 \(\pm\) 0.46 & 68.5 \(\pm\) 0.45 \\ \cline{1-1}  & COINN & - & 68.1 \\ \hline \hline \end{tabular}
\end{table}
Table 4: Accuracy comparison on the various architectures considered in COINN (5 runs).

Figure 10: ImageNet evaluation on ResNet-50 (20 runs).

\begin{table}
\begin{tabular}{l l l} \hline \hline Technique & Plain Acc & Enc Acc \\ \hline PILLAR & 77.7 & 77.5 \\ CryptGPU & 80.8 & 80.8 \\ COINN & - & 73.9 \\ \hline \hline \end{tabular}
\end{table}
Table 5: ImageNet accuracy comparison (1 run).
Precision.By using CrypTen as our backend, we were limited to a 64-bit ring for cryptographic operations. As discussed in Section 4, this precision determines the degree and range of polynomials we can use. Interesting future work is to increase this precision to enable higher-degree polynomials and study the performance-accuracy trade-off. Our initial results on ImageNet show that we can train up to a degree eight polynomial without suffering escaping activations. However, we could not increase the ring size to study the effect of higher degrees on inference time.

MaxPools.We recall that a MaxPool layer requires comparisons and, thus, expensive conversions to binary shares (like ReLUs). Therefore, we replaced all MaxPools with AvgPool layers. However, in some architectures, such as VGG-16 [31], we found that swapping MaxPool for AvgPool degraded accuracy by up to 6%. Finding an efficient MaxPool alternative for architectures like VGG is important for future work. However, since the ResNet models give high accuracy using AvgPool layers we did not pursue this issue further.

## 8 Related Work

This work focuses on achieving state-of-the-art run time and accuracy in two-party secure inference. We measure this objective by evaluating against the current state-of-the-art as determined by a recent SoK by Ng and Chow [30]. Namely, we compare to COINN [17], GForce [29] and CrypTen [20, 32] in Section 6 as they represent the Pareto front according to Ng and Chow [30]. Another potential candidate on the Pareto front is Falcon [23], with low latency and accuracy [23]. We did not evaluate Falcon as the accuracy drop was too significant (over 10% [30]). Furthermore, GForce is shown to outperform Falcon in both latency and accuracy, and we outperform GForce [29]. For a complete list of other works not on the Pareto front, we defer to Ng and Chow's work [30]. Notably, many works consider different threat models or use different approaches, such as homomorphic encryption. We leave extending our polynomial activation functions to these settings for future work. For the remainder of this section, we discuss works with a similar approach to ours that are not state-of-the-art or not evaluated by Ng and Chow [30].

Replacing or Reducing ReLU's.It has been established that the non-linear functions such as ReLU are the bottleneck for secure computation [12, 13, 27, 17]. Several works initially focused on reducing the number of ReLU activations, optimizing for the best trade-off between accuracy and runtime [13, 19]. A faster approach is to replace all ReLU's entirely using polynomial approximations [12]. In Section 5, we discussed the most recent work in this space, Sisyphus [12]. While making significant progress toward training models with polynomial activations, Sisyphus could not overcome the escaping activation problem for models with more than 11 layers. Before Sisyphus, there were a handful of works on smaller models that typically focus on partial replacement (some ReLU's remained) [27, 28, 14]. An interesting exception from Lee et al. used degree 29 polynomials in HE but suffered prohibitively high runtimes [22]. Our work is the first to make high-accuracy polynomial training feasible (without escaping activations) in deep neural networks.

A notable recent work is PolyKervNets [2]. Inspired by the computer vision literature, PolyKervNets remove the activation functions and instead exponentiate the output of each convolutional layer [2]. The problem with this approach is that, similar to polynomial activation functions, the exponents make the training unstable. Aremu and Nandakumar note that exploding gradients prevent their approach from scaling to ResNet models deeper than ResNet18 (using degree 2 polynomials). Furthermore, PolyKervNets only allow for a single fully connected layer which reduces the accuracy of the models. Conversely, PILLAR scales to deeper models such as ResNet110 and much higher degrees. Moreover, we achieve significantly better plaintext accuracy on ResNet-18 (93.4 vs 90.1 on CIFAR-10 and 74.9 vs 71.3 on CIFAR-100).

Polynomial Evaluation in MPC.Our work focuses on designing the activation functions with cryptography by using polynomials. However, the problem of computing polynomials in MPC is of independent interest and has also been studied in the literature. The state-of-the-art in this space is HoneyBadger, as discussed in Section 4. Other notable works include the initial inspiration for HoneyBadger from Damgard et al. [8]. This early approach conducts exponentiation by blinding and reconstructing the number to be exponentiated so the powers can be computed in plaintext [8]. Building off this idea, Polymath constructs a constant round protocol for evaluating polynomials focused on matrices [25]. However, HoneyBadger outperforms Polymath by reducing both the rounds and the number of reconstructions to one.

## 9 Conclusion

In this work, we co-designed the ML and MPC aspects of secure inference to remove the bottleneck of non-linear layers. PILLAR maintains a competitive inference accuracy while being significantly faster in wide area networks using novel single round MPC protocols (ESPN and HoneyBadger). Our state-of-the-art inference times motivate future work to further improve the ML accuracy of polynomial activations in DNNs.
## Acknowledgments

We gratefully acknowledge the support of the Natural Sciences and Engineering Research Council (NSERC) for grants RGPIN-05849, and IRC-537591, the Royal Bank of Canada, and Amazon Web Services Canada.

## Availability

We make all source code to reproduce our experiments available here: [https://github.com/LucasFenaux/PILLAR-ESPN](https://github.com/LucasFenaux/PILLAR-ESPN).
