Large-Scale Methods for Distributionally Robust Optimization
Daniel Levy, Yair Carmon, John C. Duchi, Aaron Sidford
Introduction
The growing role of machine learning in high-stakes decision-making raises the need to train reliable models that perform robustly across subpopulations and environments . Distributionally robust optimization (DRO) shows promise as a way to address this challenge, with recent interest in both the machine learning community and in operations research . Yet while DRO has had substantial impact in operations research, a lack of scalable optimization methods has hindered its adoption in common machine learning practice.
Finally, the penalized objective replaces the hard constraint (3) with regularization,
We develop sampling-based algorithms for each of the objectives (2)–(4). In Table 1 we summarize their complexities and compare them to previous work. Each entry of the table shows the number of (sub)gradient evaluations to obtain a point with optimality gap ; for reference, recall that for ERM the stochastic subgradient method requires order evaluations, independent of and . We discuss related work further in Section 1.1 after outlining our approach.
We establish that is a useful surrogate for by proving uniform bounds on the error . For CVaR (2) we prove a bound scaling as and extend it to other objectives, including (3), via the Kusuoka representation . Notably, for the penalty version of the objective (4) we prove a stronger bound scaling as .
This analysis implies that, for large enough mini-batch size , an -minimizer of is also an -minimizer of . Further, for CVaR and the penalized objective, we show that the variance of the gradient estimator decreases as , and we use Nesterov acceleration to decrease the required number of (stochastic) gradient steps.
To obtain algorithms with improved oracle complexities, in Section 4 we present a theoretically more efficient multi-level Monte Carlo (MLMC) gradient estimator which is a slight modification of the general technique of Blanchet and Glynn . The resulting estimator is unbiased for but requires only a logarithmic number of samples in in expectation. (In contrast, the above-mentioned mini-batch estimator requires samples). For CVaR and penalty we control the second moment of the gradient estimator, resulting in complexity bounds scaling with . In Section 5 we prove that these rates are worst-case optimal up to logarithmic factors.
Unfortunately, direct application of the MLMC estimator for the -constrained objective (3) demonstrably fails to achieve a second moment bound. Instead, in Section 6 we optimize its Lagrange dual—the penalty—with respect to and Lagrange multiplier . Using a doubling scheme on the domain, we obtain a complexity guarantee scaling as .
We conclude the paper in Section 8 with some remarks and directions for future research.
Distributionally robust optimization grows from the robust optimization literature in operations research , and the fundamental uncertainty about the data distribution at test time makes its application to machine learning natural. Experiments in the papers show promising results for CVaR (2) and -constrained (3) DRO, while other works highlight the importance of incorporating additional constraints into the uncertainty set definition . Below, we review the prior art on solving these DRO problems at scale.
Similar dual formulations exist for both the constrained and penalized objectives (3) and (4), and dual SGM provides similar guarantees to CVaR for the penalized objective (4). For the constrained problem (3), the additional Lagrange multiplier associated with the constraint induce a so-called “perspective transform” , making the method unstable. Indeed, Namkoong and Duchi report that it fails to converge in practice and instead propose a stochastic primal-dual method with convergence rate . Their guarantee is optimal in the weak regularization regime where , but is worse than the full-batch method in the setting where . Hashimoto et al. propose a different scheme alternating between ERM on and line search over a Lagrange multiplier, but do not provide complexity bounds. Duchi and Namkoong prove that for a sample of size the empirical objective converges to uniformly in ; substituting into the full-batch complexity bound implies a rate of . This guarantee is independent of , but features an undesirable dependence on . Ghosh et al. use the mini-batch gradient estimator and gradually increase the batch size to as optimization progresses; they do not provide convergence rate bounds. We establish concrete rates for fixed batch sizes independent of .
Preliminaries
We collect notation, establish a few assumptions, and provide the most important definitions for the remainder of the paper in this section.
Most of our bounds do not require Assumptions A1 and A2. Moreover, in Appendix B.2 we argue that these assumptions are frequently not restrictive.
Then, for convex with , a constraint radius , and penalty the general form of the objectives we consider is
The form (5) allows us to redefine the objectives (2)–(4) for general (nonuniform and with infinite support):
constraint. corresponds to and .
penalty. corresponds to and .
Additionally, define the following smoothed version of the CVaR objective, which we use in Section 3.
In Appendix A we present additional standard formulations and useful properties of these objectives.
denote the loss with respect to the empirical distribution on . Averaging the robust objective over random batches of size , we define the surrogate objective
Mini-batch gradient estimators
In this section, we develop and analyze stochastic subgradient methods using the subgradients of the mini-batch loss (6). That is, we estimate by sampling a mini-batch and computing
To show that the mini-batch gradient estimator is nevertheless effective for minimizing , we proceed in three steps. First, in Section 3.1 we prove uniform bounds on the bias that tend to zero with . Second, in Section 3.2 we complement them with variance bounds on . Finally, Section 3.3 puts the pieces together: we apply the SGM guarantees to bound the complexity of minimizing to accuracy , using Nesterov acceleration to exploit our variance bounds, and choose the mini-batch size large enough to guarantee (via our bias bounds) that the resulting solution is also an minimizer of the original objective .
where the bound (11) holds under Assumption A1.
To show that for every loss of the form (5), we use Lagrange duality to write
Showing the bound (10) requires a fairly different argument. Our proof uses the dual representation of as a minimum of an expected risk over a Lagrange multiplier imposing the constraint that in (6) sums to (or that in (5) integrates to ). Using convexity with respect to we relate the value of the risk at (the minimizer for sample ) to (the population minimizer), which on expectation are and , respectively. We then apply Cauchy-Schwartz and bound the variance of with the Efron-Stein inequality to obtain a bias bound. ∎
2 Variance analysis
With the bias bounds in Proposition 5 established, we analyze the variance of the stochastic gradient estimators . More specifically, we prove that the variance of the mini-batch gradient estimator decreases as for penalty-type robust objectives (with ) for which the maximizing has bounded divergence from , which we call “-bounded objectives” (see Section A.4). Noting that (with as a special case) and are -bounded yields the following.
(Note that the variance bound on is independent of and therefore holds also for where ).
3 Complexity guarantees
We also consider Nesterov’s accelerated gradient method . For , a fixed step-size and a sequence , we iterate
We now state the rates of convergence of the iterations (12) and (13) following the analysis in , with a small variation where the stochastic gradient estimates are unbiased for a uniform approximation of the true objective with additive error . We provide a short proof in Appendix B.4.
Since our gradient estimator has norm bounded by , SGM allows us to find an -minimizer of in steps. Therefore, choosing large enough in accordance to Proposition 1 guarantees that we find an -minimizer of . The accelerated scheme (13) admits convergence guarantees that scale with the gradient estimator variance instead of its second moment, allowing us to leverage Proposition 2 to reduce to the order of . The accelerated guarantees require the loss to have order -Lipschitz gradients—fortunately, this holds for and .
Let Assumption A1 hold. For all , and are -Lipschitz in , and for all .
See proof in Appendix A.1.6. Thus, to minimize we instead minimize and choose to satisfy the smoothness requirement while incurring order approximation error. For with we get sufficient smoothness for free.We can also handle the case by adding a KL-divergence term to for .
For , we have nT\lesssim\frac{(GR)^{2}}{\alpha\epsilon^{2}}\left(1+\min\Big{\{}\frac{\alpha G_{\textup{icdf}}\sqrt{\log\frac{1}{\alpha}+\nu}}{GR},\frac{B^{2}\sqrt{\log\frac{1}{\alpha}+\nu}}{GR\epsilon},\frac{B^{2}}{\epsilon^{2}}\Big{\}}\right).
For with , we have nT\lesssim\frac{(GR)^{2}B}{\lambda\epsilon^{2}}\left(1+\min\Big{\{}\frac{B}{GR}\sqrt{\frac{\epsilon(1+\nu)}{\lambda}},\frac{B}{\epsilon}\Big{\}}\right).
For , we have .
For any loss of the from (5), we have .
The smoothness parameter only appears in rates resulting from Nesterov acceleration. Even there, appears in lower-order terms in since . We also note that the final rate holds even when the uncertainty set is the entire simplex; therefore, when it is possible to approximately minimize the maximum loss in sublinear time. Theorem 1 achieves the claimed rates of convergence in Table 1 in certain settings. In particular, it recovers the rates for and (the first and last column of the table) when , , and . In the next section, we show how to attain the claimed optimal rates for and without conditions, returning to address the rates for the constrained objective in Section 6.
Multi-level Monte Carlo (MLMC) gradient estimators
In the previous section, we optimized the mini-batch surrogate to the risk , using Proposition 1 to guarantee the surrogate’s fidelity for sufficiently large . The increasing (linear) complexity of computing the estimator as grows limits the (theoretical) efficiency of the method. To that end, in this section we revisit a multi-level Monte Carlo (MLMC) gradient estimator of Blanchet and Glynn to form an unbiased approximation to whose sample complexity is logarithmic in . We provide new bounds on the variance of this MLMC estimator, leading immediately to improved (and, as we shall see, optimal) efficiency estimates for stochastic gradient methods using it.
For a given minimum sample size parameter , we define , the MLMC estimator of , via
Our estimator differs from the proposal in two aspects: the distribution of and the option to set . As we further discuss in Appendix C.3, the former difference is crucial for our setting, while the latter is pratically and theoretically helpful yet not crucial. The following properties of the MLMC estimator are key to our analysis (see Appendix C.1 for proofs).
The estimator with parameters satisfies
For all , the multi-level Monte Carlo estimator with parameters and satisfies
Further paralleling Proposition 2, we obtain similar bounds on the MLMC estimates of and (in addition to their gradients), and demonstrate that similar bounds fail to hold for (Proposition 7 in Appendix C.1). Therefore, directly using the MLMC estimator on cannot provide guarantees for minimizing ; instead, in Section 6 we develop a doubling scheme that minimizes the dual objective jointly over and . This scheme relies on MLMC estimators for both the gradient and the derivative of with respect to .
Proposition 4 guarantees that the second moment of our gradient estimators remain bounded by a quantity that depends logarithmically on . For these estimators, Proposition 3 thus directly provides complexity guarantees to minimize and . We also provide a high probability bound on the total complexity of the algorithm using a one-sided Bernstein concentration bound. We state the guarantee below and present a short proof in Appendix C.2.
The same conclusion holds when replacing with and with .
Lower bounds
The remaining technical contribution in the paper is to revisit the constrained objective (3), which is resistant to many of the techniques we have thus far developed. In this section, we leverage duality relationships to approximate the constrained objective (3) via its penalized counterpart (4), . We adjust notation to make the dependence of on explicit, and defer all proofs to Appendix E.
Our starting point is the recognition that, by duality (cf. [59, Sec. 3.2]),
for any distribution . For , we may thus consider the approximation
By restricting to an appropriate range, we can then approximate by its truncated version, as the next lemma shows.
Our strategy is therefore to jointly minimize over both and (rather than ), using the approximation guarantee in Lemma 1 to argue that the restriction of will have limited effect on the quality of the resulting solution. We iterate the projected stochastic gradient method with the multi-level Monte Carlo (MLMC) gradient estimator (16) via
If we can bound the moments of the MLMC-approximated gradients , we can then leverage standard stochastic gradient analyses to prove convergence. We use the following bound.
Therefore, we may find an approximate minimizer with complexity roughly :
Directly substituting and results in a guarantee scaling as , which is worse than the mini-batch rate of . To improve on this, we divide into sub-intervals satisfying . We then perform the stochastic gradient method (17) on each of these intervals in turn, yielding estimates that are each -suboptimal for the approximate objective . Using the bounded ratio , this requires complexity roughly , giving the following theorem.
Theorem 4 provides a rigorous guarantee on the complexity of minimizing with a fixed constraint by optimizing the parameter of . In practice, we usually have no prior knowledge of , so it will often make sense to directly tune according to validation criteria rather than a target . We also note that Duchi and Namkoong prove a lower bound of order , which is smaller than our rate. Establishing the optimal rate for this problem remains an open question.
Experiments
We test our theoretical predictions with experiments on two datasets. Our main focus is measuring how the total work in solving the DRO problems depends on different gradient estimators. In particular, we quantify the tradeoffs in choosing the mini-batch size in the estimator of Section 3 and the effect of using the MLMC technique of Section 4. To ensure that we operate in practically meaningful settings, our experiments involve heterogeneous data, and we tune the DRO objective to improve the generalization performance of ERM on the hardest subpopulation. We provide a full account of experiments in Appendix F and summarize them below.
Figure 1 plots the training objective as optimization progresses. In Appendix F.4 we provide expanded figures that also report the robust generalization performance. We find that the benefits of DRO manifest mainly when the metric of interest is continuous (e.g., log loss) as opposed to the 0-1 loss.
Our analysis in Section 3.1 bounds the suboptimality of solutions resulting from using a mini-batch estimators with batch size , showing it must vanish as increases. Figure 1 shows that smaller batch sizes indeed converge to suboptimal solutions, and that their suboptimality becomes negligible very quickly: essentially every batch size larger than provides fairly small bias (with the exception of in the digits experiment). The effect of bias is particularly weak for , consistent with its superior theoretical guarantees. We note, however, that the suboptimality we see in practice is far smaller than the worst-case bounds in Proposition 1. We investigate this in Appendix F.5, where we show that the bias is in fact consistent with our theory, but the minimizers of and are more similar than expected a priori.
While the MLMC estimator does not suffer from a bias floor (by design), it is also much slower to converge. This may appear confusing, since the MLMC convergence guarantees are optimal (for and ) while the mini-batch estimator achieves the optimal rate only under certain assumptions. Recall, however, that these assumptions are smoothness of the loss (which holds in our experiments) and—for CVaR—sufficiently rapid decay of the bias floor, which we verify empirically.
For batch sizes in the range 50–5K, the traces in Figure 1 look remarkably similar. This is consistent with our theoretical analysis for and , which shows that the variance decreases linearly with the batch size and we may therefore (with Nesterov acceleration) increase the step size proportionally and expect the total work to remain constant. As theory predicts, this learning rate increase is only possible up to a certain batch size (roughly 5K in our experiments), after which larger batches become less efficient. Indeed, to reach within 2% of the optimal value, the full-batch method requires 27–36 more work than batch sizes 50–5K for ImageNet, and 9–16 more work for the digits experiment (see Table 5 and 6 for a precise breakdown of the number of epochs required per algorithm for each robust objective).
We also repeat our experiments with the dual SGM and prima-dual methods mentioned in Table 1 and compare them with them our proposed method; see Appendix F.6 for details.
Conclusion
This work provides rigorous convergence guarantees for solving large-scale convex -divergence DRO problems with stochastic gradient methods, laying out a foundation for their use in practice; we conclude it by highlighting two directions for further research.
First, while our work resolves the optimal theoretical convergence rates for CVaR and penalty objectives, the corresponding result for constraint remains open. In particular, there is a gap between our upper and the lower bound of Duchi and Namkoong . Moreover, combining the uniform convergence results in Duchi and Namkoong with a cutting plane method gives complexity guarantees scaling a roughly as , so the rate can only be optimal in high-dimensional settings.
The authors would like to thank Hongseok Namkoong for discussions and insights, as well as Nimit Sohoni for comments on an earlier draft. DL, YC and JCD were supported by the NSF under CAREER Award CCF-1553086 and HDR 1934578 (the Stanford Data Science Collaboratory) and Office of Naval Research YIP Award N00014-19-2288. YC was supported by the Stanford Graduate Fellowship. AS is supported by a Microsoft Research Faculty Fellowship, NSF CAREER Award CCF-1844855, NSF Grant CCF-1955039, a PayPal research gift, and a Sloan Research Fellowship.
References
Appendix
In this section we collect several basic results which we use in subsequent derivations in the paper: Section A.1 gives several additional characterization of the robust objective , Section A.2 briefly discusses the computation of and its costs, Section A.3 gives a short derivation of the complexity guarantees for “dual SGM” in Table 1, and Section A.4 introduces the notion of losses contained in a divergence ball. Finally, Section A.5 lists a few standard probabilistic bounds.
Here we give several equivalent characterizations of the robust objective
For uniform on (which we abbreviate ), we write
We can convert the maximization over in Eq. (20) (or in (18)) with minimization over Lagrange multipliers for the constraint that sums to 1 and the -divergence constraint, yielding
where the expectation is over , i.e. the distribution from which we observe samples. On a finite sample we have
For pure-constraint objectives (with ), simplifies to
For pure-penalty objective (with ) the Lagrange multiplier is unnecessary and we have
Note that is an expectation (i.e., an empirical risk) which means that to minimize we can, in principle, apply ERM jointly on and , as we further discuss in Section A.3.
Finally, we note that any attaining the supremum in (18) is of the form
where and are optimal Lagrange multipliers in (22) and is a subderivative of . For this specializes to
We note that this last expression is a direct consequence of (20), since is the set of measures never exceeding . On a finite sample this gives the closed-form expression
In words, is a sum of a CVaR (at level ), a conditional variance regularization term and an outage probability regularization term. This expression simplifies considerably when is sufficiently large. Specifically, we have,
That is, for sufficiently large the objective is simply the empirical risk with variance regularization (see also ).
An expression for follows via (29)
Similarly, for a sample of size and a maximizing , we have
Therefore, if is Lipschitz w.r.t. in the 1-norm then is Lipschitz as well. This is indeed the case and .
Since entropy is 1-strongly-convex w.r.t. the 1-norm, for we have that the penalty is -strongly-convex w.r.t. the 1-norm and therefore [56, Lemma 2]
establishing that is also -Lipschitz.
A.2 Computational cost
Since we are interested in large-scale application, we assume that and therefore the time to compute the objective and its gradient is .
For simplicity and stability, our code implements the computation of using bisection over for each of and .
A.3 Stochastic gradient method on the dual objective
Here we discuss the convergence guarantees for a simple stochastic gradient method using the dual expression (22) for in order to minimize it over . While several works consider such methods (see Section 1.1), we could not find direct reference for their runtime guarantees, and we therefore briefly derive it below.
Focusing on objectives with (as in (25)), and writing and for step sizes, we write the iterations on and the Lagrange multiplier as
Where are drawn iid from .
Let . For CVaR and a suitable choice of the average iterate satisfies
Similarly, for penalty we have
By Proposition 3, the expected sub-optimality of is , where (respectively ) is an upper bound on the second moment of (respectively ). For we have , and . For we have , and . The result follows from substituting . ∎
A number of our results hold for general subclass of the objective (18) with the following property.
The three objectives we focus on are -bounded.
The objectives and are -bounded with constants , and , respectively.
That is --bounded is obvious from definition. For we have
A.5 General results
We conclude this section of the appendix by stating three general results that aid our analysis. First, we give a lemma stating that a binomial random variable with parameters and has a constant probability of being at least below its mean.
Second, we state the Efron-Stein inequality in vector form, which follows from applying the standard scalar bound element-wise.
Third, we give a general lemma on the variance of sampling without replacement, which we specialize to the simplex for later use.
Let and let be a random subset of of size . Then
Let us denote . We have
Appendix B Proofs from Section 3
This section completes the proof and discussion of the results in Section 3. First, in Section B.1, we prove the bias bounds in Proposition 1 and argue their tightness in the worst case. Section B.2 provides additional discussion of the smoothness and Lipschitz inverse-cdf assumptions sometimes used in this section. Then, in Section B.3 we bound the variance of the mini-batch estimators for -bounded penalty objectives and their gradient, obtaining Proposition 2 as a corollary. We also argue that similar bounds do not hold for the constraint objective. In Section B.4 we review the standard convergence guarantees for stochastic gradients iterations with and without Nesterov acceleration, and in Section B.5 we combine all these ingredients to prove Theorem 1.
We first show that the bound holds for any loss of the form (18) and then proceed to show each of the bounds (8)–(11). We remark here that the bound (9) actually holds for any --bounded objective (Definition 1).
where the inequality follows from exchanging the expectation and the infimum.
where is the density function of the Beta random variable of parameters . Substituting back, we have
Recalling Eq. (27) for , and recalling that for all by assumption, we bound the bias as
To conclude, it suffices to bound the tail probability of the Beta random variables. We have [see, e.g., 50, Ex. 5 in Sec. 4.6]
and the multiplicative Chernoff bound [40, Theorem 4.3] gives
Substituting into (40) and using when gives the final bound
We start with the expression (20) specialized for the ,
The restriction of to non-increasing functions is “free” since is non-decreasing. Our strategy is to relate to CVaR and then apply the corresponding bias bounds (8)—this type of transformation is closely related to the Kusuoka representation of coherent risk measures . Specifically, note that
Therefore, for any integration by parts gives
Taking a supremum over , we conclude that
It remains to bound the quantity , which we do via the the Cauchy-Schwarz inequality and the definition of , which gives
for all , giving the required bound.
The bound (42) hold for any loss (18) and not just . Moreover, the final bound using Cauchy-Schwarz is equally valid for any --bounded uncertainty set. In particular, consider the Cressie-Read uncertainty sets corresponding to -norm the constraint . For they satisfy and our bias bounds holds (using Hölder’s inequality instead of Cauchy-Schwarz removes the logarithmic factor). For Hölder’s inequality gives bounds decaying as .
Starting with CVaR, we return to the expression (38) for the bias and note that
holds for all , because when we have that and so we increase the LHS by replacing with an under-estimate, while for we have due to (39) and we increase the LHS be replacing it with an with an over-estimate. Substituting into (38) and calculating gives
Above, uses the fact that is a convex combination of densities to deduce that
and is the unique solution to . Convexity of w.r.t. gives us
To handle the second variance we use the Efron-Stein inequality (Lemma 5). Let be uniformly distributed on , and define
Combining (47), (45) and (44) gives the result for .
In the edge case that , Eq. (A.1.4) gives us that
We note that in this case may easily form an unbiased estimator of by using the standard unbiased variance estimator. ∎
As before, we treat each case separately.
where the final bound follows from the Berry-Esseen theorem (see Lemma 4).
The divergence between two Bernoulli random variables is
Therefore, for any , the element in that maximizes is with . Set and note that the function satisfies and for all . Therefore, we have
for all , with equality at . In particular, setting implies and for a sample with we have . Therefore
where follows from the CVaR case and for the final equality we substitute the definition of .
with equality at . Taking and and for a sample letting , we have
by Berry-Esseen and Chernoff, and the result follows by substituting . ∎
B.2 Discussion of additional assumptions
The guarantees for the accelerated gradient iterations (13), detailed in Appendix B.4, require the objective function be smooth, i.e., have Lipschitz gradient. However, the degree of smoothness need not be high: as Nesterov and subsequent work observed, even if is order Lipschitz, acceleration allows finding an accurate solution in roughly steps (a quadratic improvement over the SGM rate), as long as the gradient variance is itself of order ; the accelerated rates in Theorem 1 stem from this fact.
B.3 Proofs of variance bounds
We give a more general statement of the variance bound using the notion of --bounded objectives (Definition 1); Proposition 2 follows immediately from Claim 4.
If in addition and is strictly convex, we have
We first show the bound on the objective variance. By the the Efron-Stein inequality (see Lemma 5), we have
Next, to show the bound on the gradient variance we invoke Efron-Stein elementwise to obtain
By the expression (34) for we have
The remainder of the proof is identical to that of the objective variance bound, except with replacing . ∎
(Note that we may assume without loss of generality that , so that , since for we already have a standard lower bound on the variance). We set the loss values to be
The source of high variance in this construction is that, for a sample , the maximizing behaves very differently when for some and when for all . In the former case, we show that puts significant mass on samples with , so for some . In the latter case, we show that with constant probability places mass only on samples with , and so . Since either scenario occurs with constant probability, the variance bound follows.
We bound conditional on each event in turn.
To bound the gradient under event , assume that without loss of generality that is the unique sample with that value. We consider separately the cases and . In the former, we clearly have . In the latter case, we recall Eq. (33) showing that is of the form
Assuming that , we have that the total weight under of samples with gradient is
which implies . We conclude that
B.4 Convergence rates of stochastic gradient methods
We state below the classical convergence rates for standard and accelerated stochastic gradient methods, under a somewhat non-standard assumption that the stochastic gradient estimates are unbiased for a uniform approximation of the objective function with additive error .
gives us the rates (14) and (15) but for rather than . That is, it guarantees that SGM finds such that
To remove the bars, we use to write
B.5 Proofs of complexity bounds
To prove each bound in the theorem we choose large enough via one of the bounds in Proposition 1 and then choose to guarantee -accurate solution via Proposition 3. For a (potentially random) point and robust risk , we define the shorthand
We summarize our choices of and for different robust objectives, under different assumptions in Table 3. In the statement of the theorem, we sometimes upper bound by for readability, and state the tighter rates here.
In that case, setting guarantees that the bias is smaller than and setting yields that .
being -smooth, the final iterate of the sequence (13) achieves
To make sure that the second and third terms are smaller than , we set . To guarantee small bias, we set ; the resulting complexity is
We once again set , and choosing yields the result.
and setting and yields the fist rate.
First, noting that guarantees that . Furthermore, we simplify the variance term since . We thus set and choose . This yields the final result
This case is straightforward—without any bound on the variance in the worst-case, we turn to the basic SGM guarantee (14); we have
We set and . We then have
The sequence of iterates (12) yield error
and setting concludes the proof of the theorem. ∎
Appendix C Proofs of Section 4
We now provide additional discussion of the multilevel Monte Carlo estimator for general functions , whose form we restate here for convenience
Section C.1 provides upper bounds on the moments of for estimating , , and their gradients, proving Claim 2 and Proposition 4. In that section we also prove that similar second moment bounds do not always hold for . In Section C.2 we prove the complexity guarantees in Theorem 2, and we conclude in Section C.3 with a comparison of some of our design choices to the original proposal of Blanchet and Glynn .
For any function , the estimator with parameters satisfies
We have the following bound on the second moment of the estimator,
Let be an objective of the form (18) with and strictly convex . If is --bounded, we have that for all , the multi-level Monte Carlo estimator with parameters and satisfies
where is due to Lemma 6 and follows from the assumption that is --bounded. Substituting into (56), we have
This concludes the argument for the gradient.
Finally, we know that is optimal for and so
where follows from Lemma 6 and the --boundedness of . Substituting into (56) yields the desired bound on . ∎
Having established the gradient estimator upper bounds for pure-penalty objectives, we demonstrate that similar bounds do not extend to the case of constraint.
We reuse the construction and notation in the proof of Proposition 6 and so do not repeat it. For a sample , we consider the event where for all and there are at least samples with value 1. We argue in the proof of Proposition 6 (Eq. (52)) that under this event we have
We also consider the event that there is exactly one sample with value 2 and less the samples with value 1. As per the proof of Proposition 6 (Eq. (53)) we have
Moreover, by the arguments in the proof of Proposition 6, we have
Therefore, since , we have
Since the number of SGM iterations must be proportional to the second moment of the gradient estimator, Proposition 7 tells us that in the worst case we might have to set , in which case we might as well use a mini-batch estimator with batch size and run SGM steps.
C.2 Proof of complexity bounds
The convergence guarantee of Proposition 3 and the second moment bound of Proposition 4 directly give that iterates of the form (12) with the MLMC gradient estimator guarantees a regret smaller than for , and . However, since the multilevel estimator randomizes the batch size, it remains to show that the number of samples concentrates below the claimed bound. Let be the batch size at time , and note that
Therefore, since are iid, a one-sided Bernstein bound [66, Prop. 2.14] implies that
Solving in for the RHS to be equal to yields . We replace and by their values and conclude the proof. ∎
C.3 Comparison with Blanchet and Glynn [7]
There are two differences between our MLMC estimator and the proposal of Blanchet and Glynn . First, we take to be a truncated random variable while they suggest without truncation—as we further discuss below, this modification is crucial for ensuring a useful second moment bound in our setting. The second difference is that we allow for a minimum sample size as opposed to in . This modification is somewhat less important, as suffices for optimal gradient complexity, but choosing slightly larger is helpful in practice and can provably reduce the sequential depth of SGM by logarithmic factors.
Appendix D Lower bound proofs
This section proves our lower bounds, which we restate for ease of reference.
Since our proofs for CVaR and penalty are quite different, we present them separately in Theorems 3a and 3b, respectively.
To prove the CVaR lower bound we use the following standard Le Cam reduction from stochastic optimization to hypothesis testing.
[17, Chapter 5] Let be a set of distributions and and define
Armed with Lemma 7, we state and prove the lower bound for CVaR.
Let us first assume that . For , and we consider the distributions such that for we have
It therefore suffices to compute . A quick calculation yields
We thus have a closed-form expression for the CVaR objective: for we have
which clearly attains its minimum at where it has value . Choosing such that
gives and
which attains its minimum at where it has value . We therefore have that
where that last transition used and .
and the result follows from substituting . When the result follows from the standard lower bound for stochastic convex optimization (e.g. [17, Thm. 5.2.10]). ∎
Computation of for the CVaR lower bound construction (57) shows that the argument does not easily transfer to the penalized- objective because—as opposed to constrained- and CVaR—it is not positive homogeneous in .
We construct the hard instance for based on the standard hard instance for non-stochastic convex optimization, whose properties are as follows.
In other words, any “dimension-free” algorithm needs to interact times with the deterministic oracle to obtain an -suboptimal point. With this result, we prove our lower bound for optimizing .
for independent of and .
(If the result follows from the standard lower bound for convex optimization). Expressing the resulting objective with the dual form (29) gives
since . We get that minimizing is equivalent to optimizing .
Appendix E Doubling schemes proofs
We now complete the proofs of the claims in Section 6.
When in addition we have then clearly . Otherwise, if we may write
Recall the definition (55) of the MLMC estimator of a general and the expression (56) for its second moment. Suppose that , where is a constant. Then
We apply this observation to \widehat{\mathcal{M}}\big{[}\tfrac{\partial}{\partial\lambda}\mathcal{L}_{\chi^{2}\textup{-pen}}^{\lambda}(x;\cdot)+\rho\big{]} by noting that
By exactly the same argument that proves the gradient second moment bound in Proposition 4’. The result then follows by substituting into (60). ∎
We take to guarantee bias below by Proposition 1, and we take to guarantee that
Let be the average of the iterates in (17). By appropriate choice of and we guarantee (via Proposition 3) that
By Lemma 3, finding an approximate solution in the interval requires
gradient computations, where we have used , , and . Summing over (and applying a union bound) gives the claimed guarantee. Since the minimizer of over and is equivalent is identical to its minimizer in one of the intervals for , the result follows from Lemma 1. ∎
Appendix F Experiments
In this section we give a detailed description of our experiments. We begin with a description of the problems we study (Section F.1) followed by our hyperparameter settings (Section F.2) and brief remarks about our PyTorch implementation (Section F.3). Then, in Sections F.4 and F.5 we present and discuss our results in detail, including speed-up factors over full-batch optimization, a study of the generalization impacts of the DRO objective, and direct empirical evaluation of the bias which we bound in Proposition 1.
The ImageNet dataset comprises of training images and test images with different classes. We featurize the dataset using a pre-trained ResNet-50 (trained on ImageNet itself with an ERM objective). We use those features as the input to a linear classifier, with regularized multi-class logarithmic loss as in the previous experiment. As the robust generalization metric, we report the average loss and accuracy on the 10 classes with highest test loss.
F.2 Hyperparameter tuning
We tune our stepsizes with a coarse-to-fine strategy. More precisely, for each stepsize in , we perform a single run of the experiment, and pick the best two stepsizes in terms of the final training value. For these two stepsizes, we evaluate and select the stepsize that gives the best value of the training loss. For this final stepsize, we repeat the experiments with different seeds (affecting weight initialization and mini batch samples but not the dataset structure) and report the minimum and maximum across seeds at each iteration. We select all the stepsizes in our experiments using this strategy, except for batch size in ImageNet where we extrapolated the stepsize from other batch sizes. Table 4 summarizes our step size choices—for batch sizes up to 5K we see a clear linear relationship between the batch size and optimal step size.
F.3 PyTorch Integration
Figure 2 illustrates our integration of DRO into PyTorch. Users simply define the robust loss they wish to use (in the example with ) and feed the loss for the examples in the batch to the robust layer. While our current implementation only supports the robust objectives we analyze—namely, CVaR, KL-regularized CVaR, constrained- and penalized-—it is easy to extend to other choices of and .
F.4 Experiment results
We complement the training curves in Figure 1 with comparisons of robust generalization metrics and training efficiency. In Figures 3 and 4 we show the training curves of Figure 1 along with two “robust” generalization metrics and two “average” performance metrics. For Digits, we consider the loss and accuracy on the worst sub-group—typically the typed digit 9—as the robust generalization metrics. For ImageNet, we look at the average loss (resp. accuracy) on the 10 labels with highest loss (resp. lowest accuracy). In each figure we also show the values achieved by ERM with two different regularization strengths chosen to optimize either loss or accuracy on the worst-subgroup. In Tables 5 and 6 we compare the number of epochs the various algorithms require to reach a training loss within 2% of the minimal value found across all runs. To achieve such convergence with the full batch method we run it for much longer: 30K epochs for Digits and 1K epochs for ImageNet.
F.5 Discussion
We now take a closer look at the curves presented in Figures 3 and 4. We first note that, in the context of machine learning, one does not wish to reach the minimum of the training objective but rather find a model that achieves good generalization performance. From that perspective, we observe that mini-batch methods achieve their best generalization performance in a shorter time than necessary to converge on the training objective, e.g., less than 50 epochs for CVaR on Digits when the training objective always requires more than 115 epochs.
In the case of Digits, we observe that DRO achieves a better trade-off than ERM in all settings. More precisely, DRO achieves better worst sub-group loss and accuracy than either of the ERM runs with no visible degradation in average accuracy and slightly worse average loss. We observe a similar trend in the case of ImageNet, albeit with a more visible degradation in average loss and accuracy.
We note that in the Digits experiment batch size has generalization performance more similar to ERM. This is an expected by-product of the bias inherent in small batch size, as in the edge case , the mini-batch method degenerates to ERM.
Hu et al. observe that applying DRO objectives of the form (18) directly on the 0-1 loss amounts to a simple monotonic transformation of the average accuracy, and is therefore equivalent to minimizing average accuracy. Thus, in as far as the logarithmic loss is a surrogate to the 0-1 loss (which is arguably the case in near realizable-settings), DRO might not provide improvements in robust accuracy. This is consistent with the observations in our experiments, where we see only small effects on the accuracy in the Digits experiments (which is close to realizable), and a somewhat more pronounced but still modest effect on ImageNet (which is not quite realizable, as the training accuracy is below 90%). Nevertheless, these observation do not preclude DRO from improvement the subpopulation test loss itself, as we see in our experiments: for Digits DRO provides between between 17.5% and 27% reduction in worst subgroup loss compared to ERM, and for ImageNet the reduction is a more modest 5.6% and 9%. While the common practice in machine learning is to view accuracy as the more important performance metric, logarithmic loss is also operationally meaningful, as it measures the calibration of the model predictions. Thus, DRO is potentially helpful in situations where robust precise uncertainty estimates are important.
We remark that approaches that explicitly target the subgroups on which we measure the generalization [e.g., 54] will likely perform better than DRO. However, in contrast to these methods DRO is agnostic to the subgroup definition—except that we use a subgroup validation set in order to tune its uncertainty set size—and therefore requires less data annotation.
As Figure 1 and Tables 5 and 6 indicate, mini-batch methods converge significantly faster than full-batch. We also see that, while theoretically optimal, MLMC methods are slower to converge. Furthermore, the bias is empirically much smaller than what the theory predicts and setting the batch size as small as 50 guarantees negligible bias; we investigate this further below. As the theory predicts, the MLMC method (for corresponding values of ) effectively counteracts this bias, and is able to converge to the optimal value even when is 10.
We also note that the effect of batch size on the depth of the algorithm (number of iterations) is remarkably consistent with the theoretical prediction of the variance-based analysis in Section 3: for smaller batch sizes the number of steps is roughly inversely proportional to the batch size, and the total amount of work is constant. The best stepsize also grows linearly with the batch size (see Table 4). As batch sizes grow, the best stepsize plateaus and the number of steps required for convergence also stops decreasing with the batch size, making the total work become larger.
Figure 1 shows that even for small batch sizes—where the guarantees of Proposition 1 are essentially vacuous—stochastic gradient steps with the mini-batch gradient estimator find solutions very close to optimal. There could be two explanations for this finding: (a) and are actually much closer to each other than the theory predicts, or (b) and are far apart as expected, but still their minimizers are close.
To test hypothesis (a), we examine the loss values at the last iterate of our Digits and ImageNet experiments with mini-batch size 10. For each objective, we estimate for various values of by averaging 50K evaluations of , and use it to compute an estimate of the bias . For CVaR it is fact possible to compute in closed form via (28); we do that for the Digits experiment. Scaling the computation to ImageNet is nontrivial, so there we use an empirical estimate instead. In Figure 5 we plot the bias estimate against the mini-batch size . We see that hypothesis (a) is false: for both ImageNet and Digits, the difference is quite large at small , as our upper bounds and matching lower bounds in the Bernoulli case would suggest. We also see that the bias decays as in all cases except for constraint in Digits; this is again consistent with our theory as we expect the inverse-cdf assumption to be relevant in practice and particularly for CVaR where it only needs to hold around the quantile. We conclude that despite the significant bias at small batch size , approximate minimizers of are also approximate minimizers of . This is possibly due to the fact that the bias is nearly constant as a function of . We leave further study of this hypothesis to future work.
F.6 Comparison with alternative optimization methods
We complement the worst-case complexity comparison in Table 1 by repeating our experiments with two alternative optimization methods: dual SGM and primal-dual methods.
Recall the dual SGM method we describe and analyze in Section A.3. The complexity guarantees of dual SGM depend quadratically on the size of the uncertainty set—scaling with for CVaR and with for the penalized version of the objective. In contrast, our theory predicts that the method we propose have an optimal linear dependence on the size of the uncertainty set. Here we empirically test this prediction on the Digits experiment. To do so, we compare the performance of our proposed mini-batch method with dual SGM for uncertainty sets of increasing size. For CVaR we consider
For each uncertainty set size, we jointly tune the stepsizes and over the following grids
We choose a coarser grid for as we noticed that the value of had a marginal influence on the final performance. For both the mini-batch algorithm and dual SGM, we pick the batch size We follow the same averaging scheme and momentum as in our previous experiments.
We plot the results of the experiment in Figure 6. As the theory predicts, when the size of the uncertainty set grows, dual SGM performs significantly worse than batch methods. Conversely, as expected, for small uncertainty sets dual SGM performs on par with the mini-batch method. We empirically observe that the performance of dual SGM depends only weakly on the choice of . As a result, dual SGM is not much more difficult to tune than the mini-batch method.
We now turn to primal-dual methods, whose complexity guarantees scale as but are linear in , and are therefore expected to become less efficient as the size of the training set grows. To test this prediction, we repeat our Digits and ImageNet experiments (with K and M, respectively) using these alternative methods for the contrained- and CVaR objectives. We then compare their performance to that of gradient methods with our mini-batch estimator.
i.e., a Euclidean projection of the unconstrained gradient step on to the uncertainty set. For the CVaR problem, the step is of the form
The step is essentially the same as in , while the CvaR step is different from the proposal by Curi et al. . Nevertheless, local norms regret analysis readily shows that with appropriate and the step (62) allows us to find -optimal solutions within iterations, similarly to the guarantee that Curi et al. show for a computationally intractable determinantal point process scheme. They also propose a tractable approximation for this scheme, but do not prove that it converges to the solution of the CVaR problem.
For every training task we jointly tune the parameters and . We tune over the values , and for (similarly to our previous experiments) and we tune over the values and for . The best-performing values of are for Digits/CVaR; for Digits/; for ImageNet/CVaR; and for ImageNet/. We use batch size throughout.
For the larger-scale ImageNet experiment, the primal-only method significantly outperforms the primal-dual method. This is consistent with the above discussion, since here the number of misclassified training examples is large (more than 100K).
Finally, we remark that tuning the primal-dual method is considerably more difficult than tuning the primal-only method. In addition to having two learning rates to search over, using an overly large value for typically causes the algorithm to converge to a suboptimal point rather than diverge. Therefore, the common procedure of decreasing the learning rate until divergence no longer occurs will fail for the primal-dual method.