Convex Optimization & Gradient Descent
Convergence guarantees, learning rate, momentum, Adam
You are training L2-regularized logistic regression. You are minimizing L(w) = Σ log(1 + exp(-y_i w^T x_i)) + λ‖w‖². This function is convex — every local minimum is the global minimum, gradient descent is guaranteed to converge, and convergence rates are provable. Now train a 5-layer neural network instead. L(w) is non-convex, has countless saddle points and local minima of varying quality, and has no convergence guarantee. The mathematical gulf between these two problems is the difference between a well-posed optimization problem and one that works empirically.
A convex set C: for any x, y in C and t ∈ [0,1], the point tx + (1-t)y is also in C. The line segment between any two points stays inside the set. A convex function satisfies f(tx + (1-t)y) ≤ tf(x) + (1-t)f(y) — the function lies below the chord connecting any two points. First-order condition: f is convex if and only if f(y) ≥ f(x) + ∇f(x)^T(y-x) for all x, y. The tangent plane is a global lower bound on the function. This is why gradient information is sufficient for global optimization of convex problems.
What convexity buys: every local minimum is also the global minimum — no need to worry about getting trapped in a worse optimum (note: this does not mean the global minimum is unique; only strict convexity gives that) — gradient descent convergence guaranteed with appropriate step size, and theoretical convergence rates: O(1/t) for gradient descent, O(1/t²) for Nesterov acceleration. If the function is strongly convex (its curvature is bounded below by some m > 0 everywhere, not merely ≥ 0), gradient descent does better still, converging geometrically — the error shrinks by a constant factor each step — rather than the slower O(1/t) that plain convexity alone guarantees. Convexity of the objective and constraints also makes strong duality plausible — the dual problem's optimal value matching the primal's — but that additionally requires a constraint qualification such as Slater's condition; convexity alone does not guarantee it.
Where that dual problem comes from: for a constrained problem min f(x) subject to g(x)=0, form the Lagrangian L(x,λ) = f(x) + λg(x). The constrained optimum satisfies stationarity, ∇ₓL = ∇f(x) + λ∇g(x) = 0, together with primal feasibility, g(x) = 0 — two conditions that pin down both x* and λ* at once. Geometrically this says ∇f is parallel to ∇g at the optimum: if it weren't, you could still move along the constraint surface g=0 and decrease f further. λ* also has a sensitivity interpretation — relax the constraint from g(x)=0 to g(x)=ε and the optimal value of f shifts by approximately −λ*ε, so λ* measures how hard the constraint is binding.
SVMs, logistic regression, lasso, ridge — all convex. Neural networks: not convex. But empirically, modern overparameterized networks rarely get trapped in bad local minima. In overparameterized regimes where the number of parameters exceeds the number of training examples, loss surfaces have many saddle points but almost all local minima are approximately globally optimal.
NOT this. Non-convex optimization is not practically hopeless. Modern neural network training is non-convex optimization that works reliably in practice because of a structural property of overparameterized loss surfaces: most critical points are saddle points, not local minima, and most local minima have similar loss values to the global minimum. The theory of why gradient descent on non-convex neural networks generalizes well is still being developed — but empirically, the non-convexity is not the obstacle it appears to be in theory.
Key points
- Verify whether your objective is convex before choosing an optimizer. For convex problems, SGD with a decaying learning rate is provably convergent to the global minimum. For non-convex problems, convergence is only guaranteed to a stationary point — a point where the gradient is zero, which could be a saddle point. This determines whether you should trust a single run or require multiple restarts.
- Trap: using gradient descent on an ill-conditioned convex problem without checking convergence. A function can be convex but have a condition number κ = λ_max/λ_min that is extremely large — meaning the loss surface is a narrow, elongated valley. Gradient descent zigzags across the valley rather than descending efficiently. The convergence rate is (κ-1)/(κ+1) per step. Use Adam or L-BFGS for ill-conditioned convex problems, not vanilla gradient descent.
- Diagnostic: if optimization is converging slowly on a problem you believe is convex, compute the condition number of the Hessian at your current point. If κ > 1000, the problem is ill-conditioned — standardize your features or add regularization. For logistic regression, feature scaling directly improves the condition number of the Hessian and can reduce the number of gradient steps needed by an order of magnitude.
Convexity guarantees that every local minimum is global — but it does not guarantee fast convergence. The condition number of the loss landscape determines convergence speed, and a highly convex but ill-conditioned problem can be slower to optimize than a well-conditioned non-convex one.
Recap
- Convex function lies below its chords; first-order: f(y) ≥ f(x) + ∇f(x)ᵀ(y−x) — tangent is a global lower bound.
- Convexity buys every local min being global (not necessarily unique) and guaranteed GD convergence, with provable rates; strong duality also needs a constraint qualification like Slater's, not convexity alone.
- Strongly convex → gradient descent converges geometrically; merely convex → only O(1/t).
- Lagrangian L(x,λ)=f(x)+λg(x): stationarity ∇f+λ∇g=0 plus feasibility g(x)=0 pin the optimum; λ measures sensitivity (Δf*≈−λε).
- Rates: O(1/t) for gradient descent, O(1/t²) for Nesterov acceleration.
- SVM / logistic / lasso / ridge are convex; neural nets are not — but overparam nets rarely hit bad local minima.
- Non-convex isn't hopeless: most critical points are saddles, and most local minima ≈ global in loss.
- Ill-conditioning, not non-convexity, is the real slowdown: GD zigzags at rate (κ−1)/(κ+1); standardise features.
- Slow on a convex problem? Compute the Hessian condition number — κ > 1000 means rescale or use Adam/L-BFGS.
Check your understanding
Q1. A function f is convex. You find a local minimum. Which two of the following are valid proofs that it is also a global minimum?
- A) By contradiction: if x* is a local minimum but not global, there exists y with f(y) < f(x*). For small enough λ ∈ (0,1), z = λy+(1−λ)x* lies arbitrarily close to x*. By convexity: f(z) ≤ λf(y)+(1−λ)f(x*) < f(x*). But z is inside the local minimum ball around x* (for small λ), contradicting x* being a local minimum. Therefore no such y exists: x* is global, since the same argument would apply to any candidate non-global local minimum.
- B) Suppose x* is a local minimum of convex f but not global — there exists y with f(y) < f(x*). Since x* is a local minimum, f(x*) ≤ f(z) for all z in a ball around x*. By convexity, for any λ ∈ (0,1): f(λy+(1−λ)x*) ≤ λf(y)+(1−λ)f(x*) < f(x*). As λ→0 this point lies inside the local-minimum ball — yet its value is strictly less than f(x*), contradicting local minimality. So no such y exists: x* is global.
- C) A local minimum of a convex function is global because convex functions have only one minimum by definition. A function is convex if and only if it has a unique minimiser — the existence of a local minimum proves both that the minimiser exists and that it is unique. The proof follows directly from the strict convexity of the sublevel sets, which forces every level set to be a single connected point at the minimum.
- D) Convexity implies the function has no local minima at all except at the global minimum, because any local minimum immediately satisfies the first-order condition ∇f(x*)=0, and for convex functions ∇f(x*)=0 is both necessary and sufficient for global minimality. Therefore finding any point where the gradient vanishes is equivalent to finding the global minimum, regardless of the function's higher-order behavior.
Q2. Gradient descent is given function f(x) = x⁴. The gradient is ∇f = 4x³. Starting from x₀=2.0 with learning rate α=0.1, what is x₁? Does gradient descent converge for this non-strongly-convex function?
- A) x₁ = x₀ − α·∇f(x₀) = 2.0 − 0.1·(4·8) = 2.0 − 3.2 = −1.2. Gradient descent converges for f(x)=x⁴, but slowly. f is convex (f''=12x²≥0) but not strongly convex (f''(0)=0). Strongly convex functions converge geometrically; without strong convexity the rate drops to O(1/t). Note x₁=−1.2 overshoots the minimum at x=0 and goes negative — the algorithm still converges, with initial oscillation, provided α is small enough.
- B) x₁ = x₀ − α·∇f(x₀) = 2.0 − 0.1·(4·4) = 2.0 − 1.6 = 0.4. Gradient descent does not converge for f(x)=x⁴ because the function is not strongly convex (the Hessian f''=12x² is zero at x=0). Without strong convexity, gradient descent oscillates around the minimum indefinitely with a fixed learning rate, regardless of how small α is chosen. A decaying learning rate α_t = α/√t is required for any convergence guarantee to hold.
- C) x₁ = 2.0 − 0.1·(2·2³) = 2.0 − 1.6 = 0.4. Gradient descent converges for any convex function with a bounded Hessian, regardless of strong convexity. Since f''(x) = 12x² ≤ 48 for x ∈ [0,2], the smoothness constant L=48 and learning rate 0.1 < 1/L=0.021 is too large — but the step still reduces f from 16 to 0.026, showing rapid convergence despite violating the standard step-size bound.
- D) x₁ = 2.0 − 0.1·(4·2³) = 2.0 − 3.2 = −1.2. Gradient descent diverges for f(x)=x⁴ because x⁴ is not strongly convex. The step overshoots to negative x, then the next gradient 4·(−1.2)³ = −6.9 pushes to x₂ = −1.2 − 0.1·(−6.9) = −0.51, then x₃ diverges further from the origin. Non-strongly-convex functions always cause gradient descent to diverge unless momentum is added to stabilize the trajectory.
Q3. Which two of the following correctly describe how a Lagrange multiplier λ solves the constrained optimisation problem: min f(x) subject to g(x)=0?
- A) A Lagrange multiplier λ is introduced to convert the constrained problem into the unconstrained Lagrangian L(x,λ) = f(x) + λ·g(x). At the constrained optimum, the stationarity condition ∇_x L = ∇f(x) + λ∇g(x) = 0 must hold together with primal feasibility g(x) = 0 — together these two equations pin down both x* and λ* simultaneously, without needing manual tuning.
- B) The Lagrange multiplier method converts the constrained problem to unconstrained via: find saddle points of L(x,λ) = f(x) + λ·g(x). Saddle points satisfy ∂L/∂x = 0 and ∂L/∂λ = 0. The second condition ∂L/∂λ = g(x) = 0 automatically enforces the constraint. This method works only when g is linear in x; for nonlinear constraints, KKT conditions with inequality constraints are required instead.
- C) The Lagrange multiplier λ has a sensitivity interpretation: if the constraint is relaxed from g(x)=0 to g(x)=ε, the optimal value of f changes by approximately −λε. Geometrically, at the optimum the gradient of f must be parallel to the gradient of g — otherwise moving along the constraint surface g=0 could still decrease f, contradicting optimality. λ is exactly the scaling factor that makes ∇f cancel −λ∇g at that point.
- D) A Lagrange multiplier replaces the constraint g(x)=0 with a barrier function B(x) = −μ·log(−g(x)), yielding an unconstrained problem min f(x) + B(x) that stays strictly feasible throughout the optimization. As μ→0, the barrier enforces the constraint in the limit. Lagrange multipliers are defined as the limiting values of μ at the optimum and measure the constraint's binding force on the objective.
Try it interactively
ML Systems Lab is a free interview-prep platform for ML engineers — work through the full interactive module, quizzes, and drills.
Open ML Systems Lab →