0% found this document useful (0 votes)
31 views4 pages

L-BFGS Algorithm Overview

The document discusses the Limited-Memory BFGS (L-BFGS) algorithm, which is designed for large-scale optimization problems by approximating the inverse Hessian matrix using a limited number of vectors from recent iterations. It explains the trade-offs involved, such as reduced memory and computation at the cost of potentially losing local superlinear convergence. The document also outlines the implementation details of L-BFGS, including a two-loop recursion for efficiently computing the required matrix-vector products.

Uploaded by

Enoch C
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
31 views4 pages

L-BFGS Algorithm Overview

The document discusses the Limited-Memory BFGS (L-BFGS) algorithm, which is designed for large-scale optimization problems by approximating the inverse Hessian matrix using a limited number of vectors from recent iterations. It explains the trade-offs involved, such as reduced memory and computation at the cost of potentially losing local superlinear convergence. The document also outlines the implementation details of L-BFGS, including a two-loop recursion for efficiently computing the required matrix-vector products.

Uploaded by

Enoch C
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

UW-Madison CS/ISyE/Math/Stat 726 Spring 2023

Lecture 23: Limited-Memory BFGS (L-BFGS)

Yudong Chen

1 Basic ideas
Newton and quasi-Newton methods enjoy fast convergence (small number of iterations), but for
large-scale problems each iteration may be too costly.
For example, recall the quasi-Newton method xk+1 = xk − αk Hk ∇ f ( xk ) with BFGS update:

Hk = Vk⊤−1 Hk−1 Vk−1 + ρk−1 sk−1 s⊤


k −1 , (1)

where
1
ρk = , Vk = I − ρk yk s⊤
k ,
s⊤
k yk
s k = x k +1 − x k , y k = ∇ f ( x k +1 ) − ∇ f ( x k ),

and the stepsize αk satisfies WWC. The matrices Bk and Hk constructed by BFGS are often dense,
even when the true Hessian is sparse. In general, BFGS requires Θ(d2 ) computation per iteration
and Θ(d2 ) memory. For large d, Θ(d2 ) may be too much.
Idea of L-BFGS: instead of storing the full matrix Hk (approximation of ∇2 f ( xk )−1 ), construct
and represent Hk implicitly using a small number of vectors {si , yi } for the last few iterations.
Intuition: we do not expect the current Hessian to depend too much on “old” vectors si , yi (old
iterates xi and their gradients.)
Tradeoff: we reduce memory and computation to O(d), but we may lose local superlinear
convergence—we can only guarantee linear convergence in general.

2 L-BFGS
Recall and expand the BFGS update:

BFGS: Hk =Vk⊤−1 Hk−1 Vk−1 + ρk−1 sk−1 s⊤


k −1
=Vk⊤−1 Vk⊤−2 Hk−2 Vk−2 Vk−1 + ρk−2 Vk−2 sk−2 s⊤ ⊤
k −2 Vk −1 + ρk −1 sk −1 sk −1
 
= Vk⊤−1 Vk⊤−2 · · · Vk⊤−m Hk−m (Vk−m Vk−m+1 · · · Vk−1 )
 
+ ρk−m Vk⊤−1 · · · Vk⊤−m+1 sk−m s⊤ k −m (Vk −m+1 · · · Vk −1 )
 
+ ρk−m+1 Vk⊤−1 · · · Vk⊤−m+2 sk−m+1 s⊤ k −m+1 (Vk −m+2 · · · Vk −1 )

+···
+ ρk−2 Vk⊤−1 sk−2 s⊤
k −2 Vk −1
+ ρ k −1 s k −1 s ⊤
k −1 .

1
UW-Madison CS/ISyE/Math/Stat 726 Spring 2023

In L-BFGS, we replace Hk−m (a dense d × d matrix) with some sparse matrix Hk0 , e.g., a diagonal
matrix. Thus, Hk can be constructed using the most recent m ≪ d pairs {si , yi }ik=−k1−m . That is,
 
L-BFGS: Hk = Vk⊤−1 Vk⊤−2 · · · Vk⊤−m Hk0 (Vk−m Vk−m+1 · · · Vk−1 )
 
+ ρk−m Vk⊤−1 · · · Vk⊤−m+1 sk−m s⊤ k −m (Vk −m+1 · · · Vk −1 )
 
+ ρk−m+1 Vk⊤−1 · · · Vk⊤−m+2 sk−m+1 s⊤ k −m+1 (Vk −m+2 · · · Vk −1 )

+···
+ ρ k −1 s k −1 s ⊤
k −1 .

In fact, we only need the d-dimensional vector Hk ∇ f ( xk ) to update xk+1 = xk − αk Hk ∇ f ( xk ).


Therefore, we do not even need to compute or store the matrix Hk explicitly. Instead, we only
store the vectors {si , yi }ik=−k1−m , from which Hk ∇ f ( xk ) can be computed using only vector-vector
multiplications, thanks to tricks like ( aa⊤ + bb⊤ ) g = a( a⊤ g) + b(b⊤ g).

This leads to a two-loop recursion implementation for computing Hk ∇ f ( xk ), stated in Algo-


rithm 1.

Algorithm 1 L-BFGS two-loop recursion


set q = ∇ f ( xk ) want to compute Hk · ∇ f ( xk )
for i = k − 1, k − 2, . . . , k = m do:
αi ← ρi si⊤ q  
q ← q − αi yi // RHS= q − ρi si⊤ qyi = I − ρi yi si⊤ q
| {z }
Vi
r= Hk0 q
for i = k − m to k − 1:
β ← ρi yi⊤ r  
r ← r + si ( αi − β ) // RHS = r + ρi αi − ρi yi⊤ rsi = I − ρi si yi⊤ r + ρi αi
| {z }
Vi⊤
return r // which equals Hk ∇ f ( xk )

(Exercise) The total number of multiplications is at most 4md + nnz( Hk0 ) = O (md) .
In practice:

• We often take m to be a small constant independent of d, e.g., 3 ≤ m ≤ 20.


s⊤
k −1 y k −1
• A popular choice for Hk0 is Hk0 = γk I, where γk = y⊤
. This choice appears to be quite
k −1 y k −1
1 z⊤ 2
k ∇ f ( xk )zk
effective in practice. (Optional) is an approximation of , which is the size of the
γk ∥ z k ∥2
1/2
true Hessian along the direction zk ≈ ∇2 f ( xk )

sk ; see Section 6.1 in Nocedal-Wright.

The complete L-BFGS algorithm is given in Algorithm 2. As discussed in Lecture 21, it is important
that αk satisfies both the sufficient decrease and curvature conditions in Wolfe.

2
UW-Madison CS/ISyE/Math/Stat 726 Spring 2023

Algorithm 2 L-BFGS
input: x0 ∈ Rd (initial point), m > 0 (memory budget), ϵ > 0 (convergence criterion)
k←0
repeat:

• Choose Hk0

• pk ← − Hk ∇ f ( xk ), where Hk ∇ f ( xk ) is computed using Algorithm 1

• xk+1 ← xk + αk pk , where αk satisfies Wolfe Conditions

• if k > m:

– discard {sk−m , yk−m } from storage

• Compute and store sk ← xk+1 − xk and yk = ∇ f ( xk+1 ) − ∇ f ( xk )

• k ← k+1

until ∥∇ f ( xk ∥ ≤ ϵ

Some numerical results taken from Nocedal-Wright:

3 Relationship with nonlinear conjugate gradient methods


In Lecture 13 we mentioned several ways of generalizing CG to non-quadratic functions (a.k.a. non-
lienar CG), including Dai-Yuan, Fletcher-Rieves and Polak-Ribiere. The last one has a variant

3
UW-Madison CS/ISyE/Math/Stat 726 Spring 2023

called Hestenes-Stiefel, which uses the search direction


!
∇ f ( x k +1 ) ⊤ y k sk y⊤
k
p k +1 = −∇ f ( xk+1 ) + pk = − I− ⊤ ∇ f ( x k +1 ), (2)
y⊤k pk yk sk
| {z }
=: Ĥk+1

where we recall that yk = ∇ f ( xk+1 ) − ∇ f ( xk ) and sk = xk+1 − xk .


The matrix Ĥk+1 is neither symmetric nor p.d. If we try to symmetrize Ĥk+1 by taking Ĥk⊤+1 Ĥk+1 ,
we end up with a matrix that does not satisfy the secant equation and is singular.
A symmetric p.d. matrix that satisfies the secant equation is

sk s⊤
Hk+1 = Ĥk+1 Ĥk⊤+1 + k
y⊤
k ks
! !
sk y⊤ yk s⊤ sk s⊤
= I− ⊤k I I− ⊤k + k
yk sk yk sk y⊤
k ks
= BFGS update (1) applied to Hk = I

Therefore, computing Hk+1 as above for the search direction pk+1 = − Hk+1 ∇ f ( xk+1 ) can be
viewed as “memoryless” BFGS, i.e., L-BFGS with m = 1 and Hk0 = I.
Suppose we combine memoryless BFGS and exact line search:

αk = argmin f ( xk + αpk ).
α ∈R

For all k , the stepsize αk satisfies


D E
0 = ⟨∇ f ( xk + αk pk ), pk ⟩ = ∇ f ( xk+1 ), α−
k
1
s k ,

hence s⊤
k ∇ f ( xk +1 ) = 0. It follows that

pk+1 = − Hk+1 ∇ f ( xk+1 )


" ! ! #
sk y⊤ y k s ⊤ s k s ⊤
=− I− ⊤k I − ⊤ k + ⊤ k ∇ f ( x k +1 )
yk sk yk sk yk sk
y⊤
k ∇ f ( x k +1 )
= −∇ f ( xk+1 ) + sk s⊤
k ∇ f ( x k +1 ) = 0
y⊤
k sk
y⊤
k ∇ f ( x k +1 )
= −∇ f ( xk+1 ) + pk , sk = αk pk
y⊤
k pk

which is the same as Hestenes-Stiefel CG update (2).

Common questions

Powered by AI

The two-loop recursion in the L-BFGS implementation plays a crucial role in efficiently computing the product Hk∇f(xk) without explicitly forming the matrix Hk. This recursion utilizes a series of vector-vector multiplications and computations involving stored pairs {si, yi}, allowing for updates with O(md) complexity, much lower than constructing and inverting a full Hessian matrix. This method is memory efficient and exploits the structure of updates to significantly reduce computational overhead while still approximating the behavior of Newton’s method .

The primary tradeoff in the L-BFGS method is between memory/computation efficiency and local convergence speed. L-BFGS reduces the memory and computation requirements to O(d), which is a significant advantage when dealing with large-scale problems, as the full BFGS method requires Θ(d^2) memory and computation per iteration due to dense matrices . However, this efficiency comes at the cost of losing local superlinear convergence; L-BFGS generally guarantees only linear convergence . Despite this tradeoff, the benefits of reduced memory and computation demands are crucial for handling large problems effectively.

The parameter m determines the number of past update pairs {si, yi} stored and used in the L-BFGS method for approximating the inverse Hessian. A larger m increases the memory requirement and provides potentially better approximations, sometimes improving convergence speed or stability. Conversely, a smaller m reduces memory use and computation. Optimal performance often involves selecting m based on problem size, with common choices being a small constant like 3 to 20, ensuring efficient memory usage while maintaining enough information about recent gradient changes for effective updates .

The Wolfe Conditions consist of the sufficient decrease condition (ensuring the step length yields a substantial decrease in the function value) and the curvature condition (ensuring the search direction is a descent direction). For L-BFGS, these conditions are critical for calculating the step size αk in each iteration as they ensure that each step moves toward reducing the function value while maintaining sufficient descent, thereby facilitating efficient convergence despite the limited memory approximation of the Hessian. Using these conditions helps balance stability and performance in finding the minima .

L-BFGS ensures computational efficiency in approximating the inverse Hessian by avoiding direct computation or storage of dense matrices. Instead, it relies on storing only a limited number of past gradient and position differences (e.g., {si, yi} pairs), which are used in vector-vector operations to implicitly construct the Hessian approximation. The basic algorithmic approach involves a two-loop recursion that computes Hk∇f(xk) using these stored vectors, allowing for an approximation of the inverse Hessian product necessary to update the current position without forming the entire matrix, which is efficient in terms of both memory and computation .

The L-BFGS method may lose its local superlinear convergence property when the memory parameter m is too small relative to the problem size, limiting the available information from past iterations to accurately approximate the Hessian. Despite this, linear convergence is often adequate for large-scale problems because it provides sufficient reduction in function values while keeping memory and computational requirements manageable, which is crucial when dealing with very large d that makes full Hessian approaches impractical due to high computational costs and memory usage .

Memoryless BFGS can be seen as a specific case of L-BFGS where the memory parameter m is set to 1, and the initial matrix H0_k is taken as the identity matrix . In the context of an exact line search, the search direction for both memoryless BFGS and the Hestenes-Stiefel variant of the nonlinear conjugate gradient method becomes p_(k+1) = -∇f(x_(k+1)), which follows directly due to the line search satisfying the orthogonality condition ⟨∇f(xk+1), sk⟩ = 0, thus simplifying the update to align with the CG direction updates .

The choice of the initial matrix H0_k influences the L-BFGS algorithm by affecting the approximation of the inverse Hessian during optimization. A common choice for H0_k is to use a diagonal matrix γkI, where γk = s⊤_(k-1)y_(k-1) / y⊤_(k-1)y_(k-1). This selection provides a scaling that approximates the size of the true Hessian along a given direction. It has been found to be effective in practice, as it balances the tradeoff between achieving reasonable initial gradient approximations and maintaining memory efficiency .

The BFGS method constructs a dense Hessian approximation requiring Θ(d^2) memory and computation per iteration, leading to significant overhead for large-scale problems . In contrast, L-BFGS maintains only a limited number of past gradient information vectors to implicitly construct the Hessian approximation, significantly reducing both memory utilization and computational cost to O(d) per iteration. This structural difference allows L-BFGS to efficiently handle large datasets by focusing on recent gradient updates, which drastically lowers the memory footprint and computation time, making it feasible for problems where BFGS would be prohibitive .

The choice of the line search parameter αk in the context of L-BFGS is critical for affecting both convergence speed and stability. Selecting αk via methods that satisfy the Wolfe Conditions ensures a suitable balance between these factors, as it allows the method to make adequate progress toward the minimum while avoiding overly aggressive or insufficiently small step sizes that could destabilize convergence or slow it down significantly. Proper tuning of αk helps the algorithm navigate the landscape of large-scale optimization problems effectively, maintaining desirable convergence rates and avoiding potential pitfalls like oscillations or slowdowns .

You might also like