Differentially Private SGD with Non-Smooth Losses
Puyu Wang, Yunwen Lei, Yiming Ying, Hai Zhang
Introduction
Stochastic gradient descent (SGD) algorithms are widely employed to train a wide range of machine learning (ML) models such as SVM, logistic regression, and deep neural networks. It is an iterative algorithm which replaces the true gradient on the entire training data by a randomized gradient estimated from a random subset (mini-batch) of the available data. As opposed to gradient descent algorithms, this reduces the computational burden at each iteration trading for a lower convergence rate . There is a large amount of work considering the optimization error (convergence analysis) of SGD and its variants in the linear case as well as the general setting of reproducing kernel Hilbert spaces .
At the same time, data collected often contain sensitive information such as individual records from schools and hospitals, financial records for fraud detection, online behavior from social media and genomic data from cancer diagnosis. Modern ML algorithms can explore the fine-grained information about data in order to make a perfect prediction which, however, can lead to privacy leakage . To a large extent, SGD algorithms have become the workhorse behind the remarkable progress of ML and AI. Therefore, it is of pivotal importance for developing privacy-preserving SGD algorithms to protect the privacy of the data. Differential privacy (DP) has emerged as a well-accepted mathematical definition of privacy which ensures that an attacker gets roughly the same information from the dataset regardless of whether an individual is present or not. Its related technologies have been adopted by Google , Apple , Microsoft and the US Census Bureau .
For a randomized algorithm (e.g., SGD) to solve the above ERM problem, let be the output of algorithm based on the dataset . Then, its statistical generalization performance is measured by the excess (population) risk, i.e., the discrepancy between the expected risk and the least possible one in , which is defined by
Our key idea to handle general Hölder smooth losses is to establish the approximate non-expansiveness of the gradient mapping, and the refined boundedness of the iterates of SGD algorithms when domain is unbounded. This allows us to show the uniform argument stability of the iterates of SGD algorithms with high probability w.r.t. the internal randomness of the algorithm (not w.r.t. the data ), and consequently estimate the generalization error of differentially private SGD with non-smooth losses.
Organization of the Paper. The rest of the paper is organized as follows. The formulation of SGD algorithms and the main results are given in Section 2. We provide the proofs in Section 3 and conclude the paper in Section 4.
Problem Formulation and Main Results
For a randomized learning algorithm , let denote the model produced by running over the training dataset . We say two datasets and are neighboring datasets, denoted by , if they differ by a single datum. We consider the following high-probabilistic version of the uniform argument stability (UAS), which is an extension of the UAS in expectation .
We say an algorithm has -UAS with probability at least () if
where
We will use UAS to study generalization bounds with high probability. In particular, the following lemma as a straightforward extension of Corollary 8 in establishes the relationship between UAS and generalization errors. The proof is given in the Appendix for completeness.
Then there exists a constant such that for any distribution over and any , there holds
Differential privacy is a de facto standard privacy measure for a randomized algorithm
We say a randomized algorithm satisfies -DP if, for any two neighboring datasets and and any event in the output space of , there holds
In particular, we call it satisfies -DP if .
Although the concept of -DP is widely used in privacy-preserving methods, its composition and subsampling amplification results are relatively loose, which are not suitable for iterative SGD algorithms. Based on the Rényi divergence, the work proposed Rényi differential privacy (RDP) as a relaxation of DP to achieve tighter analysis of composition and amplification mechanisms.
For , , a randomized mechanism satisfies -RDP, if, for all neighboring datasets and , we have
where and are the density of and , respectively.
As , RDP reduces to -DP, i.e., satisfies -DP if and only if D_{\infty}\big{(}\mathcal{A}(S)||\mathcal{A}(S^{\prime})\big{)}\leq\epsilon for any neighboring datasets and . Our analysis requires the introduction of several lemmas on useful properties of RDP listed below.
First, we introduce the privacy amplification of RDP by uniform subsampling, which is fundamental to establish privacy guarantees of noisy SGD algorithms. In general, a uniform subsampling scheme first draws a subset with size uniformly at random with a subsampling rate , and then applies a known randomized mechanism to the subset.
The following adaptive composition theorem of RDP establishes the privacy of a composition of several adaptive mechanisms in terms of that of individual mechanisms. We say a sequence of mechanisms are chosen adaptively if can be chosen based on the outputs of the previous mechanisms for any .
If a mechanism consists of a sequence of adaptive mechanisms with satisfying -RDP, , then satisfies -RDP.
Lemme 4 tells us that the derivation of the privacy guarantee for a composition mechanism is simple and direct. This is the underlying reason that we adopt RDP in our subsequent privacy analysis. The following lemma allows us to further convert RDP back to -DP.
If a randomized mechanism satisfies -RDP, then satisfies -DP for all .
The following lemma shows that a post-processing procedure always preserves privacy.
Let satisfy -RDP and be an arbitrary function. Then satisfies -RDP.
2 Main Results
We begin by stating the key result on the distance between two iterate trajectories produced by SGD on neighboring datasets. Let
where \Delta_{SGD}(\gamma)=\Big{(}e\big{(}c^{2}_{\alpha,2}T\eta^{\frac{2}{1-\alpha}}+4\big{(}M+L(C_{\alpha}T\eta)^{\frac{\alpha}{2}}\big{)}^{2}\eta^{2}\Big{(}1+\frac{T}{n}(1+c_{\gamma,T})\Big{)}\frac{T}{n}(1+c_{\gamma,T})\big{)}\Big{)}^{1/2}.
If with , then, for any , there holds
2.2 Differentially Private SGD with Output Perturbation
To examine the excess population risk , we use the following error decomposition:
where is the output of non-private SGD. The first term is due to the added noise , which can be estimated by the Chernoff bound for Gaussian random vectors. The second term is the generalization error of SGD, which can be handled by the stability analysis. The third term is an optimization error and can be controlled by standard techniques in optimization theory. Finally, the last term can be bounded by by Hoeffding inequality. The proof of Theorem 9 is given in Subsection 3.2.
Now, we turn our attention to the utility guarantee for the case with a bounded domain.
These together with Theorem 8 and Theorem 9 imply the privacy and utility guarantees in the above theorem. The detailed proof is given in Subsection 3.2.
The private SGD algorithm with output perturbation was studied in under both the Lipschitz continuity and the strong smoothness assumption, where the excess population risk for one-pass private SGD (i.e. the total iteration number ) with a bounded parameter domain was bounded by \mathcal{O}\big{(}(n\epsilon)^{-\frac{1}{2}}(d\log(1/\delta)^{\frac{1}{4}}\big{)}. As a comparison, we show that the same rate (up to a logarithmic factor) \mathcal{O}\big{(}(n\epsilon)^{-\frac{1}{2}}(d\log(1/\delta))^{\frac{1}{4}}\log^{\frac{1}{2}}(n/\delta)\big{)} can be achieved for general -Hölder smooth losses by taking Our results extend the output perturbation for private SGD algorithms to a more general class of non-smooth losses.
2.3 Differentially Private SGD with Gradient Perturbation
An alternative approach to achieve -DP is gradient perturbation, i.e., adding Gaussian noise to the stochastic gradient at each update. The detailed algorithm is described in Algorithm 2, whose privacy guarantee is established in the following theorem.
Other than the privacy guarantees, the DP-SGD-Gradient algorithm also enjoys utility guarantees as stated in the following theorem.
Our basic idea to prove Theorem 12 is to use the following error decomposition:
Similar to the proof of Theorem 9, the generalization error can be handled by the UAS bound, the optimization error can be estimated by standard techniques in optimization [[, e.g.]]Nem, and the last term can be bounded by the Hoeffding inequality. The detailed proof can be found in Subsection 3.3.
We now compare our results with the related work under a bounded domain assumption. The work established the optimal rate for the excess population risk of private SCO algorithm in either smooth case () or non-smooth case (). However, their algorithm has a large gradient complexity \mathcal{O}\Big{(}n^{4.5}\sqrt{\epsilon}+\frac{n^{6.5}\epsilon^{4.5}}{(d\log(\frac{1}{\delta}))^{2}}\Big{)}. The work proposed a private phased ERM algorithm for SCO, which can achieve the optimal excess population risk for non-smooth losses with a better gradient complexity of the order . The very recent work improved the gradient complexity to . As a comparison, we show that SGD with gradient complexity is able to achieve the optimal (up to logarithmic terms) excess population risk for general -Hölder smooth losses. Our results match the existing gradient complexity for both the smooth case in and the Lipschitz continuity case . An interesting observation is that our algorithm can achieve the optimal utility guarantee with the linear gradient complexity for , which shows that a relaxation of the strong smoothness from to does not bring any harm in both the generalization and computation complexity.
Now, we give a sufficient condition for the existence of in Theorem 11 under a specific parameter setting.
Let , and . If then there exists such that Algorithm 2 satisfies -DP.
Privacy parameters and together quantify the privacy risk. is often called the privacy budget controlling the degree of privacy leakage. A larger value of implies higher privacy risk. Therefore, the value of depends on how much privacy the user needs to protect. Theoretically, the value of is less than 1. However, in practice, to obtain the desired utility, a larger privacy budget, i.e., , is always acceptable . For instance, Apple uses a privacy budget for Safari Auto-play intent detection, and for Health typeshttps://www.apple.com/privacy/docs/Differential_Privacy_Overview.pdf. Parameter is the probability with which fails to bound the ratio between the two probabilities in the definition of differential privacy, i.e., the probability of privacy protection failure. For meaningful privacy guarantees, according to the value of should be much smaller than . In particular, we always choose . For DP-SGD-Gradient algorithm, another constant we should discuss is which depends on the choice of the number of iterations , size of training data , privacy parameters and . The appearance of this parameter is due to the use of subsampling result for RDP (see Lemma 3). The condition in Lemma 13 ensures the existence of such that Algorithm 2 satisfies DP. In practical applications, we search in for all that satisfy the RDP conditions in Theorem 11. Note that the closer the is to , the smaller the variance of the noise added to the algorithm in each iteration. Therefore, we choose the value that is closest to of all that meets the RDP conditions as the value of .
We end this section with a final remark on the challenges of proving DP for Algorithm 2 when is unbounded.
Proofs of Main Results
Before presenting the detailed proof, we first introduce some useful lemmas on the concentration behavior of random variables.
Let be a sub-Gaussian random variable with mean and sub-Gaussian parameter . Then, for any , we have, with probability at least 1-\exp\big{(}-t^{2}/(2v^{2})\big{)}, that .
Our stability analysis for unbounded domain requires the following lemma on the self-bounding property for Hölder smooth losses.
Finally, we consider the case . According to the self-bounding property and the convexity, we know
Therefore, for there holds
where the last inequality used Young’s inequality with Putting the above inequality into (5), we have
Taking a summation of the above inequality, we get
The desired result follows directly from (6), (7) and (8) for different values of ∎
With the above preparation, we are now ready to prove Theorem 7.
Case 1: If , Lemma 21 implies that
Case 2: If , it follows from the elementary inequality that
According to the definition of Hölder smoothness and Lemma 20, we know
Combining the above two cases and (9) together, we have
Since and , we further get
For any , with probability at least , there holds
Plug the above two inequalities back into (3.1), and let c_{\gamma,t}=\max\Big{\{}\sqrt{\frac{3\log(n/{\gamma})}{t/n}},\frac{3\log(n/{\gamma})}{t/n}\Big{\}}. Then, for any , with probability at least , we have
Let . Then we know and therefore
This together with the inequality c^{2}_{\alpha,t}\leq\big{(}M+L(C_{\alpha}t\eta)^{\frac{\alpha}{2}}\big{)}^{2} due to Lemma 20, we have, with probability at least , that
By taking a union bound of probabilities over , with probability at least , there holds
2 Proofs on Differentially Private SGD with Output Perturbation
We first prove Theorem 8 on the privacy guarantee of Algorithm 1.
Now, we turn to the utility guarantees of Algorithm 1. Recall that the excess population risk can be decomposed as follows ()
We now introduce three lemmas to control the first three terms on the right hand side of (12). The following lemma controls the error resulting from the added noise.
If with , then, with probability at least , we have
Further, by the convexity of a norm and Lemma 20, we know
Putting the above inequality and (14) back into (3.2) yields
(b) The proof for the unbounded domain case is similar to that of the bounded domain. Since for in this case, then
Plugging (16) and (14) back into (3.2) yield the result in part (b). ∎
In the following lemma, we use the stability of SGD to control the generalization error .
If with , then, with probability at least , we have
(a) Consider the unbounded domain case. Part (a) in Theorem 7 implies, with probability at least , that
Since , then we know (17) holds with probability at least . According to the result by (15) and Lemma 1 with together, we derive the following inequality with probability at least
where is a constant. The proof of part (a) is completed.
(b) For the case , the proof follows a similar argument as part (a). Indeed, part (b) in Theorem 7 implies, with probability at least , that
Note that in this case, then combining (18) and Lemma 1 with together, with probability at least , we have
where is a constant. This completes the proof of part (b). ∎
In the following lemma, we use techniques in optimization theory to control the optimization error .
If with , then, with probability at least , we have
Similarly, for any , we have
Now, combining Lemma 17 with (3.2) and noting , we get the following inequality with probability at least
According to Lemma 16, with probability at least , there holds
Since , Lemma 19 implies the following inequality for any
Rearranging the above inequality and using (21), we derive
Now, plugging (22), (23) and (3.2) back into (3.2), we derive
with probability at least , which completes the proof of part (a).
Now, we are in a position to prove the utility guarantee for DP-SGD-Output algorithm. First, we give the proof for the unbounded domain case (i.e. Theorem 9).
Combining part (a) in Lemmas 22, 23, 24 and (27) together, with probability at least , the population excess risk can be bounded as follows
Plugging \Delta_{\text{SGD}}(\delta/2)=\mathcal{O}\Big{(}\sqrt{T}\eta^{\frac{1}{1-\alpha}}+\frac{(T\eta)^{1+\frac{\alpha}{2}}\log(n/\delta)}{n}\Big{)} and back into (3.2), we have
Taking the derivative of w.r.t and setting it to , then we have \eta=n^{\frac{1}{3+\alpha}}/\big{(}T(\log(1/\gamma))^{\frac{1}{3+\alpha}}\big{)}. Putting this back into (3.2), we obtain
To achieve the best rate with a minimal computational cost, we choose the smallest such that , and . Hence, we set if , and else. Now, putting the choice of back into (3.2), we derive
Without loss of generality, we assume the first term of the above utility bound is less than 1. Therefore, with probability at least , there holds
Finally, we provide the proof of utility guarantee for the DP-SGD-Output algorithm when (i.e. Theorem 10).
The proof is similar to that of Theorem 9. Indeed, plugging part (b) in Lemmas 22, 23, 24 and (27) back into (12), with probability at least , the population excess risk can be bounded as follows
Consider the tradeoff between and . Taking the derivative of \big{(}\frac{T\log(n/\delta)\log(n)\log(1/\gamma)}{n}+\frac{T\sqrt{d\log(1/\delta)}\log(n/\delta)(\log(1/\gamma))^{1/4}}{n\epsilon}\big{)}\eta w.r.t and setting it to , we have \eta=1/\Big{(}T\max\Big{\{}\frac{\sqrt{\log(n/\delta)\log(n)\log(1/\gamma)}}{\sqrt{n}},\frac{\big{(}d\log(1/\delta)\big{)}^{1/4}\sqrt{\log(n/\delta)}(\log(1/\gamma))^{1/8}}{\sqrt{n\epsilon}}\Big{\}}\Big{)}. Then putting the value of back into (3.2), we obtain
Similarly, we choose the smallest such that . Hence, we set if , and else. Since , we have
It is reasonable to assume the first term is less than here. Therefore, with probability at least , there holds
3 Proofs on Differential Privacy of SGD with Gradient Perturbation
We now turn to the analysis for DP-SGD-Gradient algorithm (i.e. Algorithm 2) and provide the proofs for Theorems 11 and 12. We start with the proof of Theorem 11 on the privacy guarantee for Algorithm 2.
Lemma 3 with implies that satisfies \Big{(}\lambda,\frac{\lambda\beta\epsilon}{T\big{(}\frac{\log(1/\delta)}{(1-\beta)\epsilon}+1\big{)}}\Big{)}-RDP if the following conditions hold
Let . We obtain that satisfies -RDP. Then by the post-processing property of DP (see Lemma 6), we know also satisfies -RDP for any . Furthermore, according to the adaptive composition theorem of RDP (see Lemma 4), Algorithm 2 satisfies -RDP. Finally, by Lemma 5, the output of Algorithm 2 satisfies -DP as long as (32) and (33) hold. ∎
Now, we turn to the generalization analysis of Algorithm 2. First, we estimate the generalization error in (4).
where is a constant. The proof is completed. ∎
The following lemma gives an upper bound for the second term in (4).
To estimate the term , we decompose it as
In addition, Hoeffding inequality (see Lemma 16) implies, with probability at least , that
Therefore, with probability at least , there holds
Putting (35), (36) and (37) back into (34), we obtain, with probability at least , that
Now, we are ready to prove the utility theorem for DP-SGD-Gradient algorithm.
The Hoeffding inequality implies, with probability at least , that
Combining Lemma 25, Lemma 26 and the above inequality together, with probability at least , we obtain
To choose a suitable and such that the algorithm achieves the optimal rate, we consider the trade-off between and . We take the derivative of \frac{1}{T\eta}+\eta\big{(}\frac{Td\log(1/\delta)\sqrt{\log(1/\gamma)}}{n^{2}\epsilon^{2}}+\frac{T\log(n)\log(n/\gamma)\log(1/\gamma)}{n}\big{)} w.r.t and set it to , then we have \eta=1/T\cdot\max\big{\{}\frac{\sqrt{\log(n)\log(n/\gamma)\log(1/\gamma)}}{\sqrt{n}},\frac{\sqrt{d\log(1/\delta)}(\log(1/\gamma))^{\frac{1}{4}}}{n\epsilon}\big{\}}. Putting the value of back into (3.3), we obtain
In addition, if , then there holds
The above bound matches the optimal rate \mathcal{O}\big{(}\frac{\sqrt{d\log(1/\delta)}}{n\epsilon}+\frac{1}{\sqrt{n}}\big{)}. Furthermore, we want the algorithm to achieve the optimal rate with a low computational cost. Therefore, we set if , and else. The proof is completed.
Finally, we give the proof of Lemma 13 on the existence of for Algorithm 2 to be -DP.
We give sufficient conditions for the existence of such that RDP conditions (32) and (33) hold with and in Theorem 11. Condition (32) with and is equivalent to
If \big{(}1+\frac{7}{1.34n\epsilon}\big{)}^{2}<\frac{28(2\log(n)+\epsilon)}{1.34n\epsilon^{2}}, then for all . Then (32) holds for any . If \big{(}1+\frac{7}{1.34n\epsilon}\big{)}^{2}\geq\frac{28(2\log(n)+\epsilon)}{1.34n\epsilon^{2}}, then such that the above condition holds, where \beta_{1,2}=\frac{1}{2}\Big{(}\big{(}1+\frac{7}{1.34n\epsilon}\big{)}\mp\sqrt{\big{(}1+\frac{7}{1.34n\epsilon}\big{)}^{2}-\frac{28(2\log(n)+\epsilon)}{1.34n\epsilon^{2}}}\Big{)} are two roots of .
Now, we consider the second RDP condition. Plugging back into (33), we derive
To guarantee (40), it suffices that the following three inequalities hold
We set in the above three inequalities. Since , then (41) holds if . Eq. (42) reduces to . Moreover, (43) is equivalent to the following inequality
There exists at least one such that if , which can be ensured by the condition . Furthermore, for all , where \beta_{3,4}=\frac{1}{2}\Big{(}\big{(}1+\frac{7}{2n(n^{1/3}-1)\epsilon}\big{)}\mp\sqrt{\big{(}1+\frac{7}{2n(n^{1/3}-1)\epsilon}\big{)}^{2}-\frac{14(2\log(n)+\epsilon)}{n\big{(}n^{1/3}-1\big{)}\epsilon^{2}}}\Big{)} are two roots of . Finally, note that
Conditions (45) and (46) ensure the existence of at least one consistent such that (39), (41), (42), (43) and (44) hold, which imply that (32) and (33) hold. The proof is completed. ∎
Conclusion
Acknowledgement. This work was done while Puyu Wang was a visiting student at SUNY Albany. The corresponding author is Yiming Ying, whose work is supported by NSF grants IIS-1816227 and IIS-2008532. The work of Hai Zhang is supported by NSFC grant U1811461.