<?xml-model href='http://www.tei-c.org/release/xml/tei/custom/schema/relaxng/tei_all.rng' schematypens='http://relaxng.org/ns/structure/1.0'?><TEI xmlns="http://www.tei-c.org/ns/1.0">
	<teiHeader>
		<fileDesc>
			<titleStmt><title level='a'>SpENCNN: Orchestrating Encoding and Sparsity for Fast Homomorphically Encrypted Neural Network Inference</title></titleStmt>
			<publicationStmt>
				<publisher>Proceedings of the 40th International Conference on Machine Learning, PMLR</publisher>
				<date>07/03/2023</date>
			</publicationStmt>
			<sourceDesc>
				<bibl> 
					<idno type="par_id">10519133</idno>
					<idno type="doi"></idno>
					
					<author>Ran Ran</author><author>Xinwei Luo</author><author>Wei Wang</author><author>Tao Liu</author><author>Gang Quan</author><author>Xiaolin Xu</author><author>Caiwen Ding</author><author>Wujie Wen</author>
				</bibl>
			</sourceDesc>
		</fileDesc>
		<profileDesc>
			<abstract><ab><![CDATA[Homomorphic Encryption (HE) is a promising technology to protect clients’ data privacy for Machine Learning as a Service (MLaaS) on public clouds. However, HE operations can be orders of magnitude slower than their counterparts for plaintexts and thus result in prohibitively high inference latency, seriously hindering the practicality of HE. In this paper, we propose a HE-based fast neural network (NN) inference framework–SpENCNN built upon the co-design of HE operation-aware model sparsity and the single-instruction-multiple-data (SIMD)-friendly data packing, to improve NN inference latency. In particular, we first develop an encryption-aware HE-group convolution technique that can partition channels among different groups based on the data size and ciphertext size, and then encode them into the same ciphertext by novel group-interleaved encoding, so as to dramatically reduce the number of bottlenecked operations in HE convolution. We further tailor a HE-friendly sub-block weight pruning to reduce the costly HE-based convolution operation. Our experiments show that SpENCNN can achieve overall speedups of 8.37×, 12.11×, 19.26×, and 1.87× for LeNet, VGG-5, HEFNet, and ResNet-20 respectively, with negligible accuracy loss. Our code is publicly available at https://github.com/ranran0523/SPECNN.]]></ab></abstract>
		</profileDesc>
	</teiHeader>
	<text><body xmlns="http://www.tei-c.org/ns/1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xlink="http://www.w3.org/1999/xlink">
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="1.">Introduction</head><p>For the past decade, we have witnessed the tremendous progress of machine learning and the great success achieved in practical applications. Convolution Neural Network (CNN) <ref type="bibr">(Alex et al., 2014)</ref> models, for example, have been widely used for many cognitive tasks such as medical imaging, face and human action recognition. Meanwhile, there is a growing interest in deploying machine learning on cloud as a service (MLaaS) <ref type="bibr">(Varghese &amp; Buyya, 2018;</ref><ref type="bibr">Marston et al., 2011)</ref>. While cloud computing has been well recognized as an attractive solution, especially for computation-intensive scenarios such as the MLaaS, outsourcing sensitive data and data processing to the cloud service provider can pose a severe threat to the client's privacy.</p><p>Homomorphic Encryption (HE) <ref type="bibr">(Rivest et al., 1978)</ref> is a promising technology for protecting clients' privacy when deploying MLaaS on the cloud. HE allows computations to be performed on encrypted inputs. The decrypted output matches the corresponding results computed from the original inputs. Thus, a client can encrypt the sensitive data locally and send the encrypted ciphertexts to the cloud. The encrypted results sent from the cloud can be correctly decrypted using the secret key held by the client. While HE helps maintain the confidentiality of the computation process on the cloud effectively, one major problem is the excessive computational cost associated with the HE operations over the encrypted data (e.g. HE multiplication, addition, rotation). In fact, HE operations can be several (i.e., three to seven) orders of magnitude slower than the corresponding operations on plaintexts <ref type="bibr">(Jung et al., 2021)</ref>, becoming the bottleneck that hinders the popularity of MLaaS.</p><p>One of the most effective approaches (e.g. <ref type="bibr">Gilad-Bachrach et al. (2016)</ref>; <ref type="bibr">Brutzkus et al. (2019)</ref>; <ref type="bibr">Dathathri et al. (2019)</ref>; <ref type="bibr">Kim et al. (2022)</ref>; <ref type="bibr">Lee et al. (2022a)</ref>) to reduce the HE computational cost is to take advantage of the single-instructionmultiple-data (SIMD) capability, supported by HE schemes, e.g. Cheon-Kim-Kim-Song (CKKS) <ref type="bibr">(Cheon et al., 2017)</ref> and Brakerski/Fan-Vercauteren (BFV). <ref type="bibr">Smart &amp; Vercauteren (2010)</ref> packs multiple data elements into different "slots" in the same ciphertext and thus computations for data elements at the same slot of two encoded messages can be performed in parallel. The challenge is how to pack data based on the characteristics of the applications so that computation can be conducted effectively in a SIMD manner. In particular, the problem rises when the computation needs to be performed on data elements at different slots of the messages. To re-arrange the location of each individual data element in an encrypted message is out of the question due to its large overhead. A more reasonable solution is to employ the HE-rotation<ref type="foot">foot_0</ref> operation that can move the data element cyclically in the same message. However, HE-rotation has a high latency cost due to the required permutation and keyswitching operation, compared with other HE-operations such as the HE multiplication of a ciphertext with a plaintext (HE-PMult) and HE addition of two ciphertexts (HE-Add), as shown in Figure <ref type="figure">1</ref>(a). Therefore, how to judiciously encode the inputs and perform the SIMD operations plays a key role in reducing the HE computation complexity.</p><p>In this paper, we study the problem of how to improve the HE-based inference latency when deploying a privacypreserving machine learning (PPML) platform based on CNNs on the cloud. In particular, this work focuses on reducing HE operations involved in convolution layers based on the fact that such layers often dominate the computation workload in CNN inference. While there exist other studies in this regard, e.g. optimizing the costly bootstrapping operation <ref type="bibr">(Lee et al., 2022a;</ref><ref type="bibr">b)</ref>, this work is orthogonal to these studies and represents another important aspect for accelerating the HE-based inference. <ref type="foot">2</ref>Assuming the client inputs (e.g., images) are encrypted as the ciphertexts and associated CNN model parameters are encoded as plaintext messages, the major HE computations in CNN inference are therefore HE-PMult, HE-Add, and HE-rotation operations. Traditional neural network optimization techniques such as sparsification and pruning <ref type="bibr">(Han et al., 2015b;</ref><ref type="bibr">Wen et al., 2016;</ref><ref type="bibr">Frankle &amp; Carbin;</ref><ref type="bibr">Liu et al.;</ref><ref type="bibr">Li et al., 2019)</ref> help to reduce the computation and memory overhead to speedup CNN inference in the plaintext domain. However, this does not hold in the HE-based inference. In fact, they achieve very limited or even no improvement compared to dense models in their encrypted counterpart, as we shall show in Section 2.3. Because simply extending the design principles of existing sparsity solutions without considering the special SIMD-friendly data packing requirements for the encrypted inference, can reduce neither the huge volume of expensive HE operations nor the much-increased memory footprint for computing activation ciphertexts in each layer. As an example, they are unable to principally reduce the more expensive HE rotation involved frequently in the multi-channel convolution computation. Note that the computation overhead of an HE rotation can be over 43&#215; of that for a HE-Pmult or a HE-Add operation, as shown in Figure <ref type="figure">1</ref>(a), To this end, we develop a HE-based CNN inference framework, i.e., SpENCNN, with the goal of effectively exploiting the SIMD feature of the HE scheme to improve the CNN inference latency. In particular, we develop two techniques to reduce the HE computational cost. First, we develop HE-group convolution and associated group-interleaved encoding to optimize channel locations on ciphertexts based on the number of convolutional groups and ciphertext size, thus significantly reducing the number of costly HE-rotations. Second, we further optimize the model architecture by pruning and training the weights in the sub-blocks iteratively with the goal to minimize HE-rotations and accuracy loss. To comprehensively evaluate the efficiency of SpENCNN, we have conducted experiments on the following two settings using the state-of-the-art leveled HE-CKKS and the MNIST and CIFAR-10 datasets: 1) CKKS-based PPML for CNN models with no need of bootstrapping; 2) CKKS based PPML for deeper models with the support of the-state-ofthe-art bootstrapping solution <ref type="bibr">(Lee et al., 2022a)</ref>. For the former, SpENCNN can achieve overall speedups of 8.37&#215;, 12.11&#215; and 19.26&#215;, for LeNet, VGG-5 and HEFNet, respectively, with negligible accuracy loss. For the latter, while bootstrapping contributes significantly to the overall inference latency in ResNet-20, SpENCNN still offers 1.87&#215; speedup while preserving the accuracy by reducing the HE rotations. To our best knowledge, this is the first work that builds an optimizing framework for CNN model architecture from the aspect of co-design of structural sparsity and data packing in HE to benefit HE-based PPML inference.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="2.">Preliminary</head></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="2.1.">CKKS Homomorphic Encryption</head><p>Homomorphic Encryption (HE) allows computations to be performed on encrypted data without decryption. Among various HE schemes, the CKKS <ref type="bibr">(Cheon et al., 2017)</ref> is widely adopted in the encrypted neural network inference because of supporting the fixed-point real number arithmetic and potentially avoiding the prohibitively expensive bootstrapping. The CKKS-based HE operations mainly consist of ciphertext addition HE-Add (ct 1 + ct 2 ), ciphertext multiplication HE-Cmult (ct 1 &#215; ct 2 ), scalar multiplication HE-Pmult (pt 1 &#215; ct 2 ), ciphertext roation HE-rotation Rot(ct, k), etc. For MLaaS that only encrypts clients' data, HE-Add, HE-Pmult and HE-rotation often dominate the computations of an encrypted inference. Among these three operations, HE-rotation costs much longer latency than the other two, e.g. &#8764; 43&#215; as our profiling result in Figure <ref type="figure">1</ref> (a) shows, due to the complex automorphism operation and a key-switching operation. The detailed calculation process of HE-rotation can be described as:</p><p>where the evaluation key (evk k rot ) is a public key with a larger modulus P Q, and P is greater than Q. Assume ct = (c(X i ), a(X i )) represents a ciphertext before rotation, then the automorphism (c(X ik ) and a(X ik )) maps each polynomial coefficient index i to output polynomial coefficient index ik mod N , where N is the polynomial degree. The second term on the right side of Equation 1 represents the key-switching operation to ensure the final ciphertext can be still decrypted by the same secret key. It is very expensive and could take over 90% of all operations in practice <ref type="bibr">(Samardzic et al., 2022)</ref>.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="2.2.">Threat Model</head><p>We assume the cloud-based machine learning service, of which a trained convolutional neural network (CNN) model with plaintext weights, is hosted in a cloud server. A client could upload one's private and sensitive data to the public cloud for obtaining an online inference result. The cloud server is semi-honest (e.g., honest but curious). To ensure the confidentiality of clients' data against such a cloud server, the client utilizes HE to encrypt the data and then send it to the cloud for performing encrypted inference without decrypting the data or accessing the private key. Finally, the client can decrypt the returned encrypted inference results from the cloud using a private key. In this work, we focus on encrypting the client's data, and others like model parameters, are assumed as plaintext.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="2.3.">Motivation Example</head><p>To identify the computation bottleneck in HE inference, we analyze the computation pattern of the convolutional layer, which often dominates CNN inference's memory and computational overheads, in the encryption process. Here the input and output activation feature maps are encrypted as ciphertext, while the convolutional kernels are assumed as plaintext. We also assume the state-of-the-art ciphertext encoding-row-major <ref type="bibr">(Dathathri et al., 2019;</ref><ref type="bibr">Kim et al., 2022</ref>) is adopted here. This allows efficient multi-channel ciphertext packing to take advantage of the CPU's SIMD architecture for fast HE inference. Figure <ref type="figure">1 (d)</ref> shows the typical HE convolution process of a convolution layer which consists of 2-input/output channels with 3 &#215; 3 kernels. To compute a ciphertext output feature map, two types of ciphertext rotations need to be performed sequentially. First, inner-rotation rotates each input channel's ciphertext feature map 8 times (or K 2 -1, here kernel size K = 3). Each rotated version will need to be multiplied with its corresponding weight plaintext, and then such results will be summed up to obtain an intermediate ciphertext from each input channel, which will further be concatenated as a whole ciphertext (e.g. Ch1 and Ch2 as ct1). Second, outer-rotation rotates the concatenated ciphertext multiple times (in this simple example, 1 time because of packing 2 output channels as a ciphertext). Finally, all ciphertext output feature maps can be obtained in parallel by the summation of these rotated copies. Apparently, compared to non-encrypted convolution, HE convolution significantly escalates the memory and computation overheads. Moreover, since the latency of HE-rotation can be much higher than other operations due to complex automorphism and key switching operations (see our profiling result in Figure <ref type="figure">1</ref>(a) 63ms for HE-Rot v.s. 1.5ms for HE-Pmult, detailed setting in Sec. 4.1), and the multi-channel convolutions in deep CNNs would involve a huge volume of HE-rotation<ref type="foot">foot_3</ref> . As a result, the long-latency HE-rotation quickly becomes a bottleneck of the encrypted inference. is to reduce the number of rotations by zeroing out (or pruning) the plaintext weights. As Figure <ref type="figure">1</ref>(c) shows, if any weight plaintext-pt(k i ) contains all zero values, then the corresponding ciphertext rotation-Rot(ct 1 , k) and its associated multiplication and summation can be safely eliminated. Since existing pruning techniques have been proven to be effective in reducing the computation and memory overhead to speedup the non-encrypted inference without accuracy drop, we apply two representative pruning methodsnon-structured pruning <ref type="bibr">(Han et al., 2015a</ref>) (zeros appear randomly in a kernel, see Figure <ref type="figure">1</ref> (c)-B, 75% sparsity) and structured pruning <ref type="bibr">(Wen et al., 2016)</ref> (structured zeros in a kernel, see filter pruning and channel pruning in Figure <ref type="figure">1</ref> (c)-C and D, 50% sparsity). For HE operations in an example convolutional layer with 64 input/output channels, feature map size 32 &#215; 32 and kernel size 3 &#215; 3, as Figure <ref type="figure">1</ref> (d) shows, the existing pruning achieves very marginal or even no reduction of the HE-rotation latency which dominates the convolution computation. In the worst case, it even cannot remove any HE-rotation despite the high model sparsity, e.g. the non-structured pruning with 75% sparsity ratio.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head>One straightforward solution to accelerating HE inference</head><p>The underlying reason is two-fold: 1) pruning is unable to address the outer-rotation since computing an output ciphertext by convolution needs to sum all channels' feature maps belonging to the same ciphertext if using the state-of-the-art ciphertext encoding (see Figure <ref type="figure">3</ref> (a)); 2) existing pruning techniques are designed for non-encrypted inference, and the special channel-wise ciphertext operations involved in HE convolution are ignored. This prompts the need to jointly optimize ciphertext encoding and encryption-aware model sparsity to accelerate HE inference.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="3.">The SpENCNN Framework</head><p>In this section, we present the technical details of the SpENCNN framework. Figure <ref type="figure">2</ref> depicts an overview of the SpENCNN framework, of which its input is an initial CNN model and the output is a tailored CNN model suitable for fast HE inference. To achieve this, it requires two processing stages: (1) HE-group Convolution, which is designed to reduce the outer-rotations caused by multi-channel encoded ciphertext <ref type="bibr">(Kim et al., 2022;</ref><ref type="bibr">Lee et al., 2022a)</ref>. In particular, we design an adjustable method and determine a theoretically optimal group number G base based on the size of the ciphertext and data packed in the CKKS HE scheme, to ensure that all outer-rotations can be eliminated while keeping model accuracy.</p><p>(2) Sub-block Pruning, which is further proposed to reduce the number of inner-rotations. However, this is non-trivial. We observe that to reduce as many inner-rotations as possible, we must precisely identify and completely prune selected sub-blocks. This, unfortunately, results in a considerable accuracy drop. To address the challenge, we develop a set of sub-steps which include identifying sub-blocks, pruning sub-blocks, updating the remaining sub-blocks, and retraining for accuracy recovery.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="3.1.">HE-Group Convolution</head><p>Two intuitions. Our proposed HE-group convolution is based on two intuitions. We observe that the number of required outer-rotations for a ciphertext is Rot outer = N /2&#215;(h&#215;w) pad -1, where N is the polynomial degree defined in the cryptographic parameters. h and w are the height and width of the input feature map. pad rounds a number to the next power of two. Each ciphertext generated by the outer-rotation further requires a set of inner-rotations.</p><p>The number of inner-rotations is</p><p>where k is the convolutional kernel size. Apparently, increasing the number of outer-rotation-Rot outer by just 1 can bring an extra Rot inner = K 2 -1 inner-rotations. This gives us the first intuition-reducing the number of outer-rotations will fundamentally reduce the computational overhead.</p><p>The reason behind the outer-rotation is that multiple channels on the same ciphertext are involved in the same multichannel convolution. In our study, we find that convolution (e.g., depthwise convolution <ref type="bibr">(Howard et al., 2017)</ref>) can be also performed individually within each single channel. We also find that the group convolution technique <ref type="bibr">(Krizhevsky et al., 2012;</ref><ref type="bibr">Zhang et al., 2018;</ref><ref type="bibr">Ioannou et al., 2017)</ref> can reduce the number of channels involved in each group. This gives us the second intuition-reducing the number of channels in the same group can eliminate the outer-rotation.</p><p>Based on these intuitions, we propose the HE-group convolution. Given the group number G, the upper bound of the number of channels in the same group can be &#8968;( N /2&#8226;(h&#8226;w) pad ) &#215; 1 /G&#8969;. Then the relationship between Rot outer and G can be further expressed as Rot outer = &#8968;( N /2&#8226;(h&#8226;w) pad ) &#215; 1 /G&#8969; -1. Accordingly, we can go through the power of 2 numbers of G from 1 to the optimal value G base = N /2&#8226;(h&#8226;w) pad to cancel the Rot outer with negligible model accuracy loss in our design. Theoretically, this optimized value indicates zero outer-rotations when G reaches the upper bound.</p><p>Group-interleaved encoding. However, we find that the traditional ciphertext encoding format is not compatible when we implement our grouping idea. This is because the row-major format is mainly designed to perform convolution in the SIMD manner without considering the channel positions on the ciphertext. To address this issue, we propose a group-interleaved encoding format-the channel data from different groups are placed on the same ciphertext in an interleaved manner. This new encoding facilitates fast HE-group convolution without involving any outer-rotation.</p><p>Figure <ref type="figure">3</ref> shows an example of proposed HE-group convolution and group-interleaved encoding. We assume that two ciphertexts contain 4 channels of data, and each ciphertext ct i contains 2 channels. As shown in Figure <ref type="figure">3</ref> (a)-left, in general HE convolution, each ct i has to perform 1 outerrotation to cover the 2 different channels, i.e., {ch1, ch2} and {ch2, ch1} for ct 1 . Convolution will be performed individually on each outer-rotated case for all ciphertexts. The encrypted output channels {out 1 , out 2 }, {out 3 , out 4 } can be generated after a summation.</p><p>For our HE group convolution, as Figure <ref type="figure">3</ref> (a)-right shows, sibling channels {ch1, ch2} and {ch3, ch4} from the same ct i are in different convolution groups, which are encoded by our group-interleaved format, i.e., {ch1, ch3} in ct 1 and {ch2, ch4} in ct 2 . Now, the outer rotation is eliminated because each ct i can perform 2 groups of convolution individually without rotating the channels. The encrypted output channels after summation, i.e., {out 1 , out 3 }, {out 2 , out 4 }, are naturally group-interleaved and can be immediately sent to next HE-group convolution. Figure <ref type="figure">3</ref> (b) further shows the generalized group-interleaved encoding, in which a ciphertext can encrypt M channels using the adjustable group number G, with constraints G &#8804; M and M |G = 0.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="3.2.">Sub-block Pruning</head><p>We design the sub-block pruning to further remove the remaining inner-rotations after the HE-group convolution.</p><p>Our idea is to prune (zero out) a whole set of weights corresponding to specific inner-rotations, so that the computational overhead of these inner-rotations can be further reduced. In HE-convolution, an inner-rotated ciphertext will be multiplied with the weights at the same position, namely "sub-block", from all relevant kernels. Therefore, our design tends to cut out the same sparse pattern on these sub-blocks for all relevant kernels of the same ciphertext. As the example in Figure <ref type="figure">4</ref> (a) shows, the 4 kernels of ct 1 share the same sparse pattern, thus eliminating 6 inner-rotations.</p><p>To obtain the desired sparse pattern, we propose sub-block pruning. The more sub-blocks p i being pruned, the fewer inner-rotations needed. On the other hand, pruning more sub-blocks will lead to more accuracy drop. It is an optimization problem, in which, we need to minimize the total number of sub-blocks while maintaining the prediction accuracy concurrently:</p><p>where</p><p>We aim to find the sub-blocks with the minimum weight importance to the model at each iteration and prune, then, retrain the model for a few epochs to recover the accuracy. However, the sizes of sub-blocks are different. To measure the weight importance of each sub-block in a fair way, we define the weight importance metric as an average L 2 norm ||wp i || dim(wp i ) . As described in the following Algorithm 1, at each iteration, we prune the sub-blocks with the least weight importance. The iterative algorithm would stop when the model accuracy is lower than the initial accuracy.</p><p>The proposed sub-block pruning can be also extended to the FC layer. Given a N -element ct = {x 1..N }, the weight matrix of an FC layer can be reshaped as a M &#215; N &#215; N tensor { &#8407; W } (zero padding if needed). To multiply an N &#215; N matrix, we can multiply the diagonal N elements (as plaintext) with each copy of ct for total N times (including N -1 rotated copies and an original ct) according to the diagonalwise matrix multiplication with ct <ref type="bibr">(Halevi &amp; Shoup, 2014)</ref>. To illustrate this, we provide a toy example in Figure <ref type="figure">4 (b)</ref>. Assuming we have ct = {b 1..4 } and a 4 &#215; 4 weight matrix. Without sub-block pruning, the ciphertext ct needs to rotate 3 times to perform the weight matrix (plaintext)-ciphertext multiplication. However, by applying sub-block pruning and removing two diagonal sub-blocks (indicated by the white blocks in the figure), we can save 2 rotations. The final computation can be expressed as pt &#215; ct + pt 1 &#215; Rot(ct, 1), where pt represents the central diagonal weights, and pt 1 represents the remaining weights.</p><p>Algorithm 1 Sub-blocks Iterative Pruning 1: Input: CNN model:f (x; (W, P )), 2: Remark: x-Data, W-Weights, P-HE blocks 3: Output: HE-friendly model:f (x; (W &#8242; , P &#8242; )) 4: P &#8242; = P = i pi &#8226; Ii 5: While Accuracy loss &#8804; 0 :</p><p>prune weights in pi from current P 9:</p><p>update P &#8242; 10:</p><p>retrain model with P &#8242; and update W &#8242; 11: end While 12: Return f (x; (W &#8242; , P &#8242; ))</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="4.">Evaluation</head></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="4.1.">Experiment Setup</head><p>Setup. We conduct our experiments on a workstation equipped with an AMD Ryzen Threadripper 3975WX CPU, an NVIDIA RTX 3090 GPU, and 256GB of RAM. To evaluate our proposed SpENCNN, we select four baseline CNN models that are typically adopted in HE inference performance evaluation and implement them using PyTorch on GPU. This includes the LeNet-like for MNIST (2016), the VGG-5 <ref type="bibr">(Rathi et al., 2020)</ref>, the HE-friendly Net (HEFNet), and the ResNet-20 <ref type="bibr">(Idelbayev)</ref> for CIFAR10. The first three models and the fourth model are used for evaluating the cases without with bootstrapping, respectively. The following Table <ref type="table">2</ref> contains the detailed convolutional kernel size, weight matrix size, and number of channels. These three baseline models have different properties. The LeNetlike model is a tiny model designed for simple classification tasks so that the channel number and weight matrix size are small and have the least number of layers. The VGG-5 model has much more weight in FC layers and the max number of layers. The HEFNet contains the most convolutional layers and the widest channel size. The ResNet-20 architecture is consistent with the published version <ref type="bibr">(He et al., 2016)</ref>.</p><p>We adopt the Stochastic Gradient Descent (SGD) optimizer with a mini-batch size of 64 on MNIST and 128 on CI-FAR10, a momentum of 0.9, and weight decay of e -4 to train each selected model for 100 epochs. The initial learning rate is set to 0.01 with a decay factor of 5e -4 . For average pooling or convolution with stride &gt; 1, we use the same implementation as CHET <ref type="bibr">(Dathathri et al., 2019)</ref> for the first three models and <ref type="bibr">(Lee et al., 2022a)</ref> for the ResNet-20. Since the non-linear activation function like ReLU cannot be evaluated in HE, we replace ReLU with the adaptive quadratic polynomial function f (x) = ax 2 +bx+c following the recent work <ref type="bibr">(Peng et al., 2022)</ref>, where a, b, c are trainable parameters to maintain the model accuracy. Table <ref type="table">1</ref> lists the specifications of these models and the corresponding accuracy. In particular, the test accuracies for LeNet-like-MINST, VGG-5-CIFAR10, HEFNet-CIFAR10, ResNet-20-CIFAR10, are 98.95%, 84.06%, 83.67%, and 91.52%, respectively. Besides, we find that without retraining, the models would suffer from a considerable accuracy drop after pruning, while with retraining, the models can reach accuracy comparable to their published versions.</p><p>Hence, we prune one block in each iteration and then perform 5 epochs of fine-tuning to recover model accuracy.</p><p>We use Microsoft SEAL library v3.4.5 (SEAL) to implement the RNS variant of CKKS <ref type="bibr">(Cheon et al., 2019)</ref> based HE inference for these networks. Table <ref type="table">1</ref> also lists the key parameters used in our RNS-CKKS encryption, including the polynomial degree N , the total modulus in bit-length Q, the scale factor in bit-length P and special modulus in bitlength q to maintain the HE evaluation accuracy, and total multiplication level. These parameters guarantee a security level of 104 bits for LeNet-like and VGG-5, 128 bits for HEFNet, and 153 bits for ResNet-20, which are sufficient to tolerate the known attack proposed by <ref type="bibr">(Albrecht et al., 2015)</ref>. For ResNet-20, the bootstrapping time is calibrated by the data provided by <ref type="bibr">(Lee et al., 2022a)</ref> under a similar execution environment. As we replace the ReLU with degree-2 polynomials, the ResNet-20 model in this work has a lower level consumption than the original one in <ref type="bibr">(Lee et al., 2022a)</ref>, which reduces the latency of non-optimized ResNet-20 from 2275s to 647s.</p><p>Methodology. We first perform an ablation study to evaluate each individual technique's effectiveness and then compare the whole SpENCNN framework with the state-of-the-art methods. We adopt the average inference latency (in seconds) as the major metric. An image set containing 20 different samples is used to measure and report the latency for these models. A lower latency indicates better performance.</p><p>In addition, we measure the left homomorphic operation count (HOC, in %), sparsity (in %), and accuracy (in %) of the tailored models. The lower HOC and lower sparsity while offering higher accuracy are desired on all models.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="4.2.">Results</head></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="4.2.1.">EVALUATION ON HE-GROUP CONVOLUTION</head><p>Table <ref type="table">3</ref> lists our evaluation results for the HE-group convolution. We apply the HE group convolution alone (in ablation) to each baseline model and evaluate its effectiveness and scalability. In particular, we go through the number of groups from its default value (i.e., 1-baseline) until it exceeds its G base according to our design in Section 3.1 (i.e., the highlighted 4, 8, and 8 for LeNet-like, VGG-5, and HEFNet, respectively). The G base for ResNet-20 should be 16, but we could not set the group number to G base due to prominent accuracy loss. Therefore, we select a moderate group number for ResNet-20 with desirable accuracy for comparison. For detailed analysis, we break down HOC into "Rot" (HE-rotation) and "Others" (other operations including HE-Pmult and HE-add).</p><p>Our HE-group convolution can be scaled to any convolutional model. As the number of groups increases, it can effectively reduce the number of HOC and maintain the accuracy, thus reducing the latency of HE inference and improving the performance. As listed in Table <ref type="table">3</ref>, the number of HE-rotation is reduced from 100% to 27.27%, 85.45%, 11.95%, and 27.11% on LeNet-like, VGG-5, HEFNet, and ResNet-20, respectively.</p><p>Once G base is reached, the number of HE-rotation does not decrease further despite increasing the number of groups. This is because the outer-rotation is completely eliminated in HE-group convolution after the group number reaches G base . We also find that HE group convolution can reduce other HOC such as HE-Pmult and HE-add even after exceeding G base . This also contributes to latency improvement.</p><p>For example, the HE-group convolution is particularly effective on our HEFNet (i.e., &#8764; 88% and &#8764; 86% reduction for HE-rotation and others, respectively). This is because it has the largest volume of convolution layers among the selected models. Such a dramatic reduction in HOC further shortens the inference latency from 24.11s to 3.27s, which represents a 7.37&#215; speedup. In contrast, the HE group convolution is the least effective in VGG-5, as it contains three large FC layers (size of 8192&#215;4096), which cannot be substantially optimized using HE group convolution alone. There are more than 85% of HE-rotations and 80% of other operations that cannot be eliminated. And this number saturates as a lower bound after reaching the G base , resulting in a limited speedup of 1.19&#215;. For ResNet-20, the HE-group convolution can also effectively reduce a large number of HE operations because of the huge volume of convolutional layers. However, due to its long bootstrapping time of 275s, it only achieves a speedup of 1.65&#215;.</p><p>We also observe that model accuracy slightly decreases as the number of groups increases. This is due to the fact that fewer channels are involved in the HE-group convolution compared to the general convolution (see Figure <ref type="figure">3</ref>). Fortunately, our design is adjustable, allowing a trade-off between accuracy and the optimized number of convolution groups.</p><p>For an optimized group number, the accuracy loss can be marginal (i.e., 0%, 1.1%, 1.2%, and 1.31% on LeNet-like, VGG-5, HEFNet, and ResNet-20, respectively).</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="4.2.2.">EVALUATION ON SUB-BLOCK PRUNING</head><p>We also evaluate the sub-block pruning alone (in ablation) and compare its effectiveness against the representative pruning methods that are widely used in non-encrypted inference, such as Non-structural prune (NS-prune) <ref type="bibr">(Han et al., 2015a)</ref>, and Structural-prune (S-prune) <ref type="bibr">(Wen et al., 2016)</ref>. Table <ref type="table">4</ref> reports the results. Here we do not report the accuracy but the sparsity ratio and latency since all models maintain the original accuracy after applying pruning methods.</p><p>Our sub-block pruning can effectively improve the HE inference performance on all baseline models (i.e., the speedup Our sub-block pruning method performs the best (i.e., &#8764; 16% HOC) on VGG-5 because it effectively eliminates the inner-rotations caused by the large number of redundant weights in the FC layers. Together with the previous results (see Table <ref type="table">3</ref>), sub-block pruning can be a good complement to the HE-group convolution that performs weakly on the FC layers. We also note that our sub-block pruning method on LeNet-like (i.e., 35.21% Rot left) slightly outperforms HEFNet (i.e., 41.88% Rot left). This is because the larger convolutional kernel (i.e., 5 &#215; 5) in LeNet-like offer more space to optimize the inner-rotations using our method. For ResNet-20, the speedup is limited due to the bootstrapping overhead. However, the sub-block prune is still effective for reducing HE operations because of the increased number of convolutional layers.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="4.2.3.">COMPARE WITH SOTA SOLUTIONS</head><p>We compare our method with the state-of-the-art HE-prune method-Hunter <ref type="bibr">(Cai et al., 2022)</ref>. The comparison results are presented in Table <ref type="table">5</ref>. In this evaluation, we combine the HE-group convolution and sub-block pruning and use the proposed G base as the group number (i.e., highlighted data). For a fair comparison, pruning is controlled to ensure that our method and Hunter have the same level of accuracy (i.e., error&#8804; &#177;0.04%) on all baseline models. We can see from Table <ref type="table">5</ref>, our method outperforms the state-of-the-art significantly in terms of HOC, sparsity, and latency, across all baseline models. For example, our method eliminates 96% HE-rotations on HEFNet, achieving a 19.26&#215; speedup.</p><p>In contrast, the Hunter-optimized model still has 51% HErotations left behind and achieves only 2.22&#215; speedup compared to the un-pruned baseline. This is our method is designed eliminate both outer and HE-rotations by synthetically applying the HE-group convolution and sub-block pruning, while the state-of-the-art is solely built upon the fixed structure pruning. Besides, we prune 608 out of 921, 15431 out of 18139, 3412 out of 5083, and 3381 out of 6331 blocks for LeNet-like, VGG-5, HEFNet, and ResNet-20 respectively, which exhibits a similar trend to the reported sparsity ratio in Table <ref type="table">5</ref>. For illustration purpose, we also plot some examples of encrypted inferencefriendly sparsity patterns of kernels of LeNet-like as shown in Figure <ref type="figure">5</ref>. The weights after optimization are presented in a binary representation. In each convolutional group, it contains 64 weight kernels with size 5 &#215; 5. Here kernels associated with the same ciphertext, though belonging to different convolutional groups, exhibit the same sparse pattern (x direction). On the other hand, for kernels within the same convolutional group but across different cts, their sparse patterns are different (y direction). When considering deeper networks requiring bootstrapping, we further compare our method with the SOTA <ref type="bibr">(Lee et al., 2022a)</ref> under a similar setting, the baseline latency is improved from 647s to 475s, well demonstrating the effectiveness of our method in accelerating deeper networks. </p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="5.">Related Work</head><p>CryptoNets <ref type="bibr">(Gilad-Bachrach et al., 2016)</ref> is an initial attempt to realize HE inference. After that, many subsequent works are proposed to improve the HE-inference latency from different aspects. Faster-CryptoNets <ref type="bibr">(Chou et al., 2018)</ref> combines weight pruning and quantization to obtain a sparse polynomial representation to speed up the PMult operation, which achieves 6.38&#215; latency reduction. LoLa <ref type="bibr">(Brutzkus et al., 2019)</ref>   <ref type="formula">2022</ref>) further refine the row-major coding format to reduce inference latency by packing independent channels in one ciphertext and then performing multi-channel convolution on such packed ciphertexts. However, in these works, the packed channels associated with a ciphertext are still from the same convolution group as that of traditional non-encrypted convolution. As a result, ciphertext outer-rotations cannot be avoided because these channels still need to be added together via outer-rotations to obtain an output channel in encrypted convolution. <ref type="bibr">Lou &amp; Jiang (2021)</ref> propose a neural architecture search (NAS) based method to reduce the number of convolutional layers and then save the encryption parameters to speed up the HE-inference. <ref type="bibr">Kim et al. (2022)</ref>; <ref type="bibr">Lee et al. (2022a)</ref> use a multiplexed packing technique to exploit empty slots caused by average pooling or strided convolution and reduce the use of ciphertexts for acceleration. This work is orthogonal to these methods and can be integrated with them to further improve the latency. Hunter <ref type="bibr">(Cai et al., 2022)</ref> attempts to structurally prune the weights to accelerate the HE-inference in the MPC setting. HE-PEx <ref type="bibr">(Aharoni et al., 2022)</ref> leverage tile tensor and prune weights by tile sparsity in FC layers. It reduces memory overhead and latency by 60% on the tested autoencoder models in a non-client-aided setting. Different from them, SpENCNN is the first to orchestrate the ciphertext encoding and model sparsity design for HE inference acceleration in a non-client-aided setting, significantly outperforming these works.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="6.">Acknowledgement</head><p>We thank all anonymous reviewers for their constructive comments and suggestions on this work. This work is partially supported by the National Science Foundation (NSF) under Grants No. CNS-2153690, CNS-2247891, CNS-2247892 and CNS-2247893.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="7.">Conclusion</head><p>In this paper, we propose a fast HE-based encrypted inference framework-SpENCNN, which builds upon two novel encryption operation-aware techniques-HE-group convolution and sub-block weight pruning. Experimental results show that our solution can speed up the privacy-preserving inference by 8.37&#215;, 12.11&#215;, 19.26&#215;, and 1.87&#215; on LeNetlike, VGG-5, HEFNet, and ResNet-20, respectively, greatly outperforming the state-of-the-art solutions. In the future, we would like to combine our method with a specific hardware accelerator design to further reduce the total latency and make this solution practical.</p></div><note xmlns="http://www.tei-c.org/ns/1.0" place="foot" n="1" xml:id="foot_0"><p>E.g., Rot(ct, k) transforms an encryption of (v0, ..., v N/2-1 ) into an encryption of (v k , ..., v N/2-1 , v0, ..., v k-1 ).</p></note>
			<note xmlns="http://www.tei-c.org/ns/1.0" place="foot" n="2" xml:id="foot_1"><p>We show the efficiency of our work to speedup PPML in the presence of costly bootstrapping in Section 4.</p></note>
			<note xmlns="http://www.tei-c.org/ns/1.0" place="foot" xml:id="foot_2"><p>------------------</p></note>
			<note xmlns="http://www.tei-c.org/ns/1.0" place="foot" n="3" xml:id="foot_3"><p>The matrix-vector multiplications in fully-connected layers also require a substantial amount of HE-rotation.</p></note>
		</body>
		</text>
</TEI>
