DoWG Unleashed: An Efficient Universal Parameter-Free Gradient Descent Method
Ahmed Khaled, Konstantin Mishchenko, Chi Jin
Introduction
We study the fundamental optimization problem
As models become larger and more complex, the cost and environmental impact of training have rapidly grown as well (Sharir et al., 2020; Patterson et al., 2021). Therefore, it is vital that we develop more efficient and effective methods of solving machine learning optimization tasks. One of the chief challenges in applying gradient-based methods is that they often require tuning one or more stepsize parameters (Goodfellow et al., 2016), and the choice of stepsize can significantly influence a method’s convergence speed as well as the quality of the obtained solutions, especially in deep learning (Wilson et al., 2017).
The cost and impact of hyperparameter tuning on the optimization process have led to significant research activity in designing parameter-free and adaptive optimization methods in recent years, see e.g. (Orabona and Cutkosky, 2020; Carmon and Hinder, 2022) and the references therein.
We say an algorithm is universal if it adapts to many different problem geometries or regularity conditions on the function (Nesterov, 2014; Levy et al., 2018; Grimmer, 2022). In this work, we focus on two regularity conditions: (a) Lipschitz and (b) smooth. Lipschitz functions have a bounded rate of change, that is, there exists some such that for all we have . The Lipschitz property is beneficial for the convergence of gradient-based optimization algorithms. They converge even faster on smooth functions, which have continuous derivatives; that is, there exists some such that for all we have . Smoothness leads to faster convergence of gradient-based methods than the Lipschitz property. Universality is a highly desirable property because in practice the same optimization algorithms are often used for both smooth and nonsmooth optimization (e.g. optimizing both ReLU and smooth networks).
The main question of our work is as follows:
Can we design a universal, parameter-free gradient descent method for (OPT)?
Existing universal variants of gradient descent either rely on line search (Nesterov, 2014; Grimmer, 2022), bisection subroutines (Carmon and Hinder, 2022), or are not parameter-free (Hazan and Kakade, 2019; Levy et al., 2018; Kavis et al., 2019). Line search algorithms are theoretically strong, achieving the optimal convergence rates in both the nonsmooth and smooth settings with only an extra log factor. Through an elegant application of bisection search, Carmon and Hinder (2022) design a parameter-free method whose convergence is only double-logarithmically worse than gradient descent with known problem parameters. However, this method requires resets, i.e. restarting the optimization process many times, which can be very expensive in practice. Therefore, we seek a universal, parameter-free gradient descent method for (OPT) with no search subroutines.
Our contributions. We provide a new algorithm that meets the above requirements. Our main contribution is a new universal, parameter-free gradient descent method with no search subroutines. Building upon the recently proposed Distance-over-Gradients (DoG) algorithm (Ivgi et al., 2023), we develop a new method, DoWG (Algorithm 1), that uses a different stepsize with adaptively weighted gradients. We show that DoWG automatically matches the performance of gradient descent on (OPT) up to logarithmic factors with no stepsize tuning at all. This holds in both the nonsmooth setting (Theorem 3) and the smooth setting (Theorem 4). Finally, we show that DoWG is competitive on real machine learning tasks (see Section 4).
Related Work
There is a lot of work on adaptive and parameter-free approaches for optimization. We summarize the main properties of the algorithms we compare against in Table 1. We enumerate some of the major approaches below:
Polyak stepsize. When is known, the Polyak stepsize (Polyak, 1987) is a theoretically-grounded, adaptive, and universal method (Hazan and Kakade, 2019). When is not known, Hazan and Kakade (2019) show that an adaptive re-estimation procedure can recover the optimal convergence rate up to a log factor when is Lipschitz. Loizou et al. (2021) study the Polyak stepsize in stochastic non-convex optimization. Orvieto et al. (2022) show that a variant of the Polyak stepsize with decreasing stepsizes can recover the convergence rate of gradient descent, provided the stepsize is initialized properly. Unfortunately, this initialization requirement makes the method not parameter-free.
The doubling trick. The simplest way to make an algorithm parameter-free is the doubling-trick. For example, for gradient descent for -smooth and convex optimization, the stepsize results in the convergence rate of
where . We may therefore start with a small estimate of the smoothness constant , run gradient descent for steps, and return the average point. We restart and repeat this for times, and return the point with the minimum function value. So long as , we will return a point with loss satisfying eq. 1 at the cost of only an additional logarithmic factor. This trick and similar variants of it appear in the literature on prediction with expert advice and online learning (Cesa-Bianchi et al., 1997; Cesa-Bianchi and Lugosi, 2006; Hazan and Megiddo, 2007). It is not even needed to estimate in some cases, as the restarting can be done adaptively (Streeter and McMahan, 2012). In practice, however, the performance of doubling trick suffers from restarting the optimization process and throwing away useful that could be used to guide the algorithm.
Parameter-free methods. Throughout this paper, we use the term “parameter-free algorithms” to describe optimization algorithms that do not have any tuning parameters. We specifically consider only the deterministic setting with a compact domain. As mentioned before, Carmon and Hinder (2022) develop an elegant parameter-free and adaptive method based on bisection search. Bisection search, similar to grid search, throws away the progress of several optimization runs and restarts, which may hinder their practical performance. Ivgi et al. (2023); Defazio and Mishchenko (2023) recently developed variants of gradient descent that are parameter-free when is Lipschitz. However, D-Adaptation (Defazio and Mishchenko, 2023) has no known guarantee under smoothness, while DoG (Ivgi et al., 2023) was only recently (after the initial release of this paper) shown to adapt to smoothness. We compare against the convergence guarantees of DoG in Section 3.2. For smooth functions, Malitsky and Mishchenko (2020) develop AdGD, a method that efficiently estimates the smoothness parameter on-the-fly from the training trajectory. AdGD is parameter-free and matches the convergence of gradient descent but has no known guarantees for certain classes of Lipschitz functions. A proximal extension of this method has been proposed by Latafat et al. (2023).
Parameter-free methods in online learning. In the online learning literature, the term “parameter-free algorithms” was originally used to describe another class of algorithms that adapt to the unknown distance to the optimal solution (but can still have other tuning parameters such as Lipschitz constant). When the Lipschitz parameter is known, approaches from online convex optimization such as coin betting (Orabona and Pál, 2016), exponentiated gradient (Streeter and McMahan, 2012; Orabona, 2013), and others (McMahan and Orabona, 2014; Orabona and Cutkosky, 2020; Orabona and Pál, 2021; Orabona and Tommasi, 2017) yield rates that match gradient descent up to logarithmic factors. Knowledge of the Lipschitz constant can be removed either by using careful restarting schemes (Mhammedi et al., 2019; Mhammedi and Koolen, 2020), or adaptive clipping on top of coin betting (Cutkosky, 2019). For optimization in the deterministic setting, it is later clarified that, by leveraging the normalization techniques developed in (Levy, 2017), the aforementioned online learning algorithms can be used without knowing other tuning parameters (i.e., achieve “parameter-free” in the sense of this paper) for optimizing both Lipschitz functions (Orabona and Pál, 2021) and smooth functions (Orabona, 2023). Concretely, as shown in Orabona (2023) (which appears after the initial release of this paper), combining algorithms in Streeter and McMahan (2012); Orabona and Pál (2016) with normalization techniques (Levy, 2017) yields new algorithms that are also search-free, parameter-free (in the sense of this paper), and universal. However, these algorithms are rather different from DoWG in algorithmic style: these algorithms only use normalized gradients while DoWG does use the magnitudes of the gradients; DoWG falls in the category of gradient descent algorithms with adaptive learning rate, while these algorithms do not.
Line search. As mentioned before, line-search-based algorithms are universal and theoretically grounded (Nesterov, 2014) but are often expensive in practice (Malitsky and Mishchenko, 2020).
AdaGrad family of methods. Li and Orabona (2019) study a variant of the AdaGrad stepsizes in the stochastic convex and non-convex optimization and show convergence when the stepsize is tuned to depend on the smoothness constant. Levy et al. (2018) show that when the stepsize is tuned properly to the diameter of the domain in the constrained convex case, AdaGrad-Norm adapts to smoothness. Ene et al. (2021) extend this to AdaGrad and other algorithms, and also to variational inequalities. Ward et al. (2019); Traoré and Pauwels (2021) show the convergence of AdaGrad-Norm for any stepsize for non-convex (resp. convex) optimization, but in the worst case the dependence on the smoothness constant is worse than gradient descent. Liu et al. (2022) show that AdaGrad-Norm converges in the unconstrained setting when is quasi-convex, but their guarantee is worse than gradient descent. We remark that all AdaGrad-style algorithms mentioned above require tuning stepsizes, and are thus not parameter-free.
Alternative justifications for normalization. There are other justifications for why adaptive methods work outside of universality. Zhang et al. (2020a) study a generalized smoothness condition and show that in this setting tuned clipped gradient descent can outperform gradient descent. Because the effective stepsize used in clipped gradient descent is only a constant factor away from the effective stepsize in normalized gradient descent, (Zhang et al., 2020a), also show that this improvement holds for NGD. Zhang et al. (2020b) observe that gradient clipping and normalization methods outperform SGD when the stochastic gradient noise distribution is heavy-tailed. However, Kunstner et al. (2023) later observe that adaptive methods still do well even when the effect of the noise is limited.
Algorithms and theory
In this section we first review the different forms of adaptivity in gradient descent and normalized gradient descent, and then introduce our proposed algorithm DoWG. The roadmap for the rest of the paper is as follows: we first review the convergence of gradient descent in the Lipschitz and smooth settings, and highlight the problem of divergence under stepsize misspecification, and how normalization fixes that. Then, we introduce our main new algorithm, DoWG, and give our main theoretical guarantees for the algorithm. Finally, we evaluate the performance of DoWG on practical machine learning problems.
We start our investigation with the standard Gradient Descent (GD) algorithm:
Suppose that is convex with minimizer . Let . Let be the initial distance to the optimum. Denote by the average iterate returned by GD. Then:
(Bubeck, 2015) If is -Lipschitz, the average iterate satisfies for any stepsize :
(Nesterov, 2018) If is -smooth, then for all the average iterate satisfies
Minimizing eq. 2 over gives with . We have several remarks to make about this rate for gradient descent. First, the optimal stepsize depends on both the distance to the optimum and the Lipschitz constant , and in fact, this rate is in general optimal (Nesterov, 2018, Theorem 3.2.1). Moreover, if we misspecify or while tuning , this does not in general result in divergence but may result in a slower rate of convergence. On the other hand, for the smooth setting the optimal stepsize is for which . Unfortunately, to obtain this rate we have to estimate the smoothness constant in order to choose a stepsize , and this dependence is hard: if we overshoot the upper bound , the iterations of gradient descent can diverge very quickly, as shown by Figure 1. Therefore, GD with a constant stepsize cannot be universal: we have to set the stepsize differently for smooth and nonsmooth objectives.
Normalized Gradient Descent (NGD) (Shor, 2012) consists of iterates of the form
Under the same conditions as Theorem 1, the iterations generated by generated by (NGD) satisfy after steps satisfy:
(Nesterov, 2018) If is -Lipschitz, the minimal function suboptimality satisfies
where .
(Levy, 2017; Grimmer, 2019) If is -Lipschitz, the minimal function suboptimality satisfies
Tuning eq. 4 in gives , and the stepsize is also optimal for eq. 5. This gives a convergence rate of when is Lipschitz and when is smooth. Observe that NGD matches the dependence of gradient descent on and without any knowledge of it. Furthermore that, unlike GD where the optimal stepsize is in the smooth setting and in the nonsmooth setting. The optimal stepsize for NGD is the same in both cases. Therefore, NGD is universal: the same method with the same stepsize adapts to nonsmooth and smooth objectives. Moreover, misspecification of the stepsize in NGD does not result in divergence, but just slower convergence. Another interesting property is that we only get a guarantee on the best iterate: this might be because NGD is non-monotonic, as Figure 2 (a) shows.
Theorem 2 offers an alternative, global, and less explicit explanation of this phenomenon: NGD matches the optimal gradient descent rate, and in order to do so it must drive the effective stepsize to be large. Specifically, suppose that we use the optimal stepsize , and call the best iterate returned by NGD . Then satisfies and therefore by smoothness
2 DoWG
We saw in the last section that NGD adapts to both the Lipschitz constant and the smoothness , but we have to choose to vary with the distance to the optimum . In this section, we develop a novel algorithm that adaptively estimates the distance to the optimum, and attains the optimal convergence rate of gradient descent for constrained convex and smooth optimization up to a logarithmic factor. Our algorithm builds upon the recently proposed Distance over Gradients (DoG) algorithm developed by Ivgi et al. (2023). We call the new method DoWG (Distance over Weighted Gradients), and we describe it as Algorithm 1 below.
DoWG uses the same idea of estimating the distance from the optimum by using the distance from the initial point as a surrogate, but instead of using the square root of the running gradient sum as the normalization, DoWG uses the square root of the weighted gradient sum . Observe that because the estimated distances are monotonically increasing, later gradients have a larger impact on than earlier ones compared to . Therefore, we may expect this to aid the method in adapting to the local properties of the problem once far away from the initialization . We note that using a weighted sum of gradients is not new: AcceleGrad (Levy et al., 2018) uses time-varying polynomial weights and Adam (Kingma and Ba, 2015) uses exponentially decreasing weights. The difference is that DoWG chooses the weights adaptively based on the running distance from the initial point. This use of distance-based weighted averaging is new, and we are not aware of any previous methods that estimate the running gradient sum in this manner.
Nonsmooth analysis. The next theorem shows that DoWG adapts to the Lipschitz constant and the diameter of the set if the function is nonsmooth but -Lipschitz. We use the notation following (Ivgi et al., 2023).
(DoWG, Lipschitz ). Suppose that the function is convex, -Lipschitz, and has a minimizer . Suppose that the domain is a closed convex set of (unknown) diameter . Let . Then the output of Algorithm 1 satisfies for some
where is a weighted average of the iterates returned by the algorithm.
Discussion of convergence rate. DoWG matches the optimal rate of tuned GD and tuned NGD up to an extra logarithmic factor. We note that the recently proposed algorithms DoG (Ivgi et al., 2023) and D-Adaptation (Defazio and Mishchenko, 2023) achieve a similar rate in this setting.
Comparison with DoG. As we discussed before, DoWG uses an adaptively weighted sum of gradients for normalization compared to the simple sum used by DoG. In addition, DoG uses the stepsize , whereas the DoWG stepsize is pointwise larger: since is monotonically increasing in we have
Of course, the pointwise comparison may not reflect the practical performance of the algorithms, since after the first iteration the sequence of iterates generated by the two algorithms can be very different. We observe in practice that DoWG is in general more aggressive, and uses larger stepsizes than both DoG and D-Adaptation (see Section 4).
Smooth analysis. Our next theorem shows that DoWG adapts to the smoothness constant and the diameter of the set .
(DoWG, Smooth ). Suppose that the function is -smooth, convex, and has a minimizer . Suppose that the domain is a closed convex set of diameter . Let . Then the output of Algorithm 1 satisfies for some
where is a weighted average of the iterates returned by the algorithm.
The proof of this theorem and all subsequent results is relegated to the supplementary material. We note that the proof of Theorem 4 uses the same trick used to show the adaptivity of NGD to smoothness: we use the fact that for all applied to a carefully-chosen weighted sum of gradients.
Comparison with GD/NGD. Both well-tuned gradient descent and normalized gradient descent achieve the convergence rate where for the constrained convex minimization problem. Theorem 4 shows that DoWG essentially attains the same rate up to the difference between and and an extra logarithmic factor. In the worst case, if we initialize far from the optimum, we have and hence the difference is not significant. We note that DoG (Ivgi et al., 2023) suffers from a similar dependence on the diameter of , and can diverge in the unconstrained setting, where is not compact. This can be alleviated by making the stepsize smaller by a polylogarithmic factor. A similar reduction of the stepsize also works for DoWG, and we provide the proof in Section 7 in the supplementary.
Comparison with DoG. After the initial version of this paper, Ivgi et al. (2023) reported a convergence guarantee for the unweighted average returned by DoG. In particular, Proposition 3 in their work gives the rate
where , and where in the second step we used the bound and . This rate is the same as that achieved by the weighted average of the DoWG iterates up to an extra logarithmic factor . We note that DoG also has a guarantee in the stochastic setting, provided the gradients are bounded locally with a known constant, while in this work we have focused exclusively on the deterministic setting.
Edge of Stability. Like NGD, DoWG also tends to increase the stepsize and train at the edge of stability. The intuition from NGD carries over: in order to preserve the convergence rate of GD, DoWG tends to drive the stepsize larger. However, once it overshoots, the gradients quickly diverge, forcing the stepsize back down. Figure 3 shows the performance of DoWG and its stepsize on the same regularized linear regression problem as in Figure 2. Comparing the two figures, we observe that DoWG is also non-monotonic and trains close to the edge of stability, but its stepsize oscillates less than NGD’s effective stepsize.
Universality. Theorems 4 and 3 together show that DoWG is universal, i.e. it almost recovers the convergence of gradient descent with tuned stepsizes in both the smooth and nonsmooth settings. As the optimal stepsize for gradient descent can differ significantly between the two settings, we believe that achieving both rates simultaneously without any parameter-tuning or search procedures is a significant strength of DoWG.
Comparison with other universal methods. Nesterov (2014) developed a universal method for convex optimization based on a modified line search that is almost parameter-free, requiring only a small initial estimate of the smoothness or Lipschitz constants. Grimmer (2022) later extended the analysis of Nesterov’s method to minimizing finite-sums. Levy et al. (2018) showed that properly-tuned AdaGrad-Norm and an accelerated variant of it are universal. However, neither AdaGrad-Norm nor its accelerated variant is parameter-free. Hazan and Kakade (2019) show that the Polyak stepsize is universal, provided is known. Kavis et al. (2019) also develop a universal method, UniXGrad, but it requires estimating the distance to the optimum . Carmon and Hinder (2022) also develop a universal method that is almost-optimal using bisection search. However, their method requires an initial stepsize to satisfy , though we can get around this requirement by choosing to be very small, only paying a penalty. In contrast, the only initialization DoWG requires is choosing . This can be done by choosing for any two .
Experimental results
We compare DoWG to DoG, L-DoG from Ivgi et al. (2023), for all of which we also report performance of the polynomially-averaged iterate with power 8 as recommended by Ivgi et al. (2023). We also add comparison against Adam (Kingma and Ba, 2015) with cosine annealing and the standard step size . All methods are used with batch size 256 with no weight decay on a single RTX3090 GPU. We plot the results in Figure 4 with the results averaged over 8 random seeds. We train the VGG11 (Simonyan and Zisserman, 2015) and ResNet-50 (He et al., 2016) neural network architectures on CIFAR10 (Krizhevsky, 2009) using PyTorch (Paszke et al., 2019), and implementhttps://github.com/rka97/dowg DoWG on top of the DoG codehttps://github.com/formll/dog. Unsurprisingly, DoWG’s estimates of the step size are larger than that of DoG and D-Adapt-norm, which also makes it less stable on ResNet-50. While the last iterate of DoWG gives worse test accuracy than Adam, the average iterate of DoWG often performs better.
Finally, we note that while both neural networks tested are generally nonsmooth, recent work shows local smoothness can significantly influence and be influenced by a method’s trajectory (Cohen et al., 2022; Pan and Li, 2022). We believe this adaptivity to smoothness might explain the empirical difference between DoWG and DoG, but leave a rigorous discussion of adaptivity to local smoothness to future work.
References
Supplementary material
In this section we collect different results that are algorithm-independent, the first is a consequence of smoothness:
Because is lower bounded by we thus have
Rearranging gives . ∎
The next two results are helpful algebraic identities that will be useful for the proof of DoWG.
[Ivgi et al., 2023, Lemma 4]. Let be a nondecreasing sequence of nonnegative numbers. Then
This is [Ivgi et al., 2023, Lemma 4]. We include the proof for completeness:
([Ivgi et al., 2023, Lemma 3], similar to [Defazio and Mishchenko, 2023, Lemma 11]). Let be a positive increasing sequence. Then
where .
This is [Ivgi et al., 2023, Lemma 3]. We include the proof for completeness: Define and . Then,
Rearranging and using gives
Proofs for DoWG
This section collects proofs for DoWG. First, we give the following lemma, which holds under convexity alone (regardless of whether is smooth or Lipschitz).
Suppose that is convex and has minimizer . For the iterations generated by Algorithm 1, we have
This proof follows the proof of DoG [Ivgi et al., 2023, Lemma 1], itself a modification of the standard proof for adaptive cumulative gradient normalization methods [Gupta et al., 2017] incorporating insights from [Carmon and Hinder, 2022]. We specifically modify the proof to handle the weighting scheme we use in DoWG. By the nonexpansivity of the projection we have
Rearranging and dividing by we get
Multiplying both sides by we get
Summing up as varies from to we get
We shall now bound each of the terms (A) and (B). We have
where eq. 8 holds by definition of the DoWG stepsize , eq. 9 holds by telescoping, eq. 10 holds because and hence , and by definition. Equation 11 just follows by telescoping. Finally observe that for some , and . Then by the triangle inequality and that the sequence is monotonically nondecreasing we have
Therefore . This explains eq. 12.
where eq. 13 is by Lemma 1. Plugging eqs. 12 and 14 in eq. 7 gives
We now prove the convergence of DoWG under smoothness. In particular, we shall use Fact 1 and the DoWG design to bound the weighted cumulative error by its square root multiplied by a problem-dependent constant. We note that a similar trick is used in the analysis of AdaGrad-Norm [Levy et al., 2018], in reductions from online convex optimization to stochastic smooth optimization [Orabona and Cutkosky, 2020], and in the method of [Carmon and Hinder, 2022]. However, in all the mentioned cases, the unweighted error is bounded by its square root. Here, DoWG’s design allows us to bound the weighted errors instead.
We start with Lemma 3. Let . By eq. 6 we have
Using this to lower bound the left-hand side of eq. 15 gives
If for some then the statement of the theorem is trivial. Otherwise, we can divide both sides by the latter square root to get
Dividing both sides by we get
By Lemma 2 applied to the sequence we have that for some
Because has diameter we have and therefore
If then and we use this in eqs. 19 and 18 to get
Observe that because has diameter at most we have , therefore
If , then . Let . Using smoothness and this fact we have
Observe and has diameter , hence and we get
Thus in both cases we have that , this completes our proof. ∎
2 Nonsmooth case
We now give the proof of DoWG’s convergence when is Lipschitz.
We start with Lemma 3. Let . By eq. 6 we have
Using this to lower bound the left-hand side of eq. 20 gives
We have by the fact that is -Lipschitz that for all . Therefore,
Taking square roots and plugging into eq. 21 gives
Dividing both sides by we get
By Lemma 2 applied to the sequence we have that for some
Because we further have
If : then . We can use this in eq. 22 alongside eq. 23 and the fact that to get
Because the diameter of is bounded by we have and , using this and convexity we get
If : then
Because is -Lipschitz then and because has diameter we have . Using this and eq. 24 in eq. 25 gives
Now because we have and hence
In both cases, we have that , and this completes our proof. ∎
Unconstrained domain extension
In this section we consider the case where the domain set is unbounded, and we seek dependence only on . We use the same technique for handling the unconstrained problem as [Ivgi et al., 2023] in this section and consider DoWG iterates with the reduced stepsizes
We prove that with this stepsize, the iterates do not venture far from the initialization. The proof follows [Ivgi et al., 2023].
(Stability). For the iterates following the stepsize scheme given by (26) we have and provided that .
Summing up as varies from to and using [Ivgi et al., 2023, Lemma 6]
Therefore we have . Now suppose for the sake of induction that , then applying the last equation we get . Taking square roots gives . By the triangle inequality we then get
Squaring both sides gives . This completes our induction and we have for all . Finally, observe that
It follows that for all . Finally, we have . This completes our proof. ∎
Therefore the iterates stay bounded. The rest of the proof then follows Theorems 4 and 3 and is omitted for simplicity.. In both cases it gives the same results with instead of , up to extra constants and polylogarithmic factors.