TL;DR
Many large problems reduce to a system of linear equations , solved by repeated steps rather than in one go. If is badly scaled, those steps crawl. Preconditioning multiplies the system by a cheap approximation of 's inverse, so the steps converge in far fewer rounds, and the answer does not change.
Builds on: Gradient Descent, Matrix Inverse, Positive Definite Matrix · Leads to: Conjugate Gradient, Condition Number
Where it's used
Finite-element and finite-difference simulations. Heat flow, structural loads and electric fields are discretised with the finite-difference method or finite elements into millions of unknowns. The resulting matrix is sparse and symmetric, and at this size an iterative solver is the practical way to solve it. Most production solvers of this kind use a preconditioner.
Least-squares fitting at scale. Large regression problems and Gauss–Newton steps in nonlinear fitting reduce to solving a system with a symmetric positive definite matrix. Preconditioners keep the solve time manageable when the data columns are of very different sizes.
Training neural networks. Adaptive optimisers such as Adam, which scale each parameter by a running estimate of its gradient size, are preconditioned gradient methods with a diagonal preconditioner. Scaling each parameter by its own typical step size is the same idea in a different setting.
How it works
Solve one equation with one unknown, , whose answer is . Use the simplest iterative rule, a plain form of gradient descent: start from a guess, measure how far off the equation is, and step the guess to reduce that error.
- Plain iteration with step 1. The update is . Start at . The first step gives . Check: , which is 6 too large.
- Next step. From , the update gives . The guesses are growing, not closing in on . The step is too big for this matrix. Check: is further from than is.
- Divide the step by a preconditioner. Pick , a cheap approximation to . The update becomes . Start at again. The first step gives . Check: the error is now , down from .
- Keep going. From : . From : . Check: the errors are , , , so each step multiplies the error by .
- Read the rule. The error shrinks by the factor . A preconditioner close to makes that factor close to 0.
flowchart LR A[Current guess x] --> B[Residual b minus A x] B --> C[Apply cheap inverse of M] C --> D[Update x] D --> A
The math
For a symmetric positive definite matrix , a preconditioner is a symmetric positive definite matrix such that in some sense, and such that solving with is cheap. Preconditioning replaces by the equivalent system .
Step 1 in symbols: the update
Let the residual be , which measures how far the current guess is from solving the equation. A preconditioned step with step size , which applies the inverse of , is
In the 1D example, , , and , which gives the update of step 3.
Step 2 in symbols: the error
Let , the difference from the true solution. Since ,
The matrix decides everything. In 1D, , which is step 4's factor.
Step 3 in symbols: the eigenvalues
The eigenvalues of are , and the condition number of the preconditioned problem is
This is the ratio of largest to smallest eigenvalue, the condition number. A large value means some directions are stretched much more than others, so the solver zig-zags. Choosing makes every error direction shrink by at least the factor per step. Thus the number of steps grows with , and a preconditioner that drives toward 1 makes the solver fast.
In practice the preconditioner is used inside the preconditioned conjugate gradient method, which needs only products with and solves with , never the inverse itself.
Worked examples
Solve , whose answer is , with and , then with .
- The rule is . Start at .
- With the first step is . The error is .
- With the second step is . The error is , larger than before, so this diverges.
- With the first step is . The error is .
- The second step is . The error is .
- The error factor is , and , so the error keeps shrinking.
Interpretation: the factor is , which has size below 1 only when . With , fails that test and passes it, so must be close enough to .
Try it: Solve with . Find the error factor and whether the method converges. Answer: , so the factor has size and the sign flips each step. It converges, with the error halving and alternating in sign.
Let , a diagonal matrix, and , whose exact solution is . The condition number is .
- Plain gradient descent uses step . Start at .
- The residual is . One step gives .
- The second coordinate is now exactly . The first coordinate has error .
- Each step multiplies the first error by . Reaching an error of requires , which takes steps.
- Now precondition with , which equals here. Then and .
- One step gives exactly.
Interpretation: the condition number 100 costs about 459 steps in the plain method and one step with the preconditioner.
Discretise a heat-flow problem on a line with the finite-difference method, using 100 interior points. The matrix is tridiagonal with 2 on the diagonal and beside it. Its condition number is about with .
- Compute .
- Square it: .
- Multiply by 4: .
- Divide by : . The condition number is about 4,130.
- Because every diagonal entry is 2, a diagonal preconditioner scales the matrix by a constant, so does not change.
- The usual conjugate gradient bound on the number of steps is proportional to the square root of , here times a logarithmic factor set by the accuracy wanted. A better preconditioner, such as incomplete Cholesky or multigrid, is needed for a large gain.
Interpretation: the condition number grows with the square of the grid size, so refining the grid makes plain solvers much slower.
Try it: Use the same formula with 50 interior points. Find the condition number and its square root. Answer: , and .
Common mistakes and tradeoffs
It is tempting to think the best preconditioner is , because it makes . In fact applying means solving a system with , which is the original problem. A good preconditioner is cheap to apply and still close enough to that is small.
It is tempting to think diagonal (Jacobi) preconditioning always helps. In fact it only helps when the diagonal entries differ in size, as in example 2. When they are all equal, as in example 3, scaling by the diagonal does nothing.
It is tempting to think preconditioning changes the answer. In fact the solution is the same. Only the path to it and the number of steps change, because the work per step rises with the cost of applying .
When to use it: large, sparse, symmetric positive definite systems where an iterative method converges slowly, and where a cheap preconditioner gives a large drop in .
When not to use it: small or dense systems, where a direct factorisation such as Cholesky is cheaper; and systems whose condition number is already close to 1.
Alternatives: direct factorisation such as Cholesky for small problems, multigrid for elliptic equations, and simpler iterative methods for well-conditioned matrices.
History
Magnus Hestenes and Eduard Stiefel described the conjugate gradient method in 1952 as a direct method that also worked as an iteration. For large sparse problems it was mostly ignored for two decades, because rounding errors seemed to destroy its exact-arithmetic guarantee. Interest returned in the 1970s, when people found that with a good preconditioner it converged quickly enough to be practical. In 1977 Jan Meijerink and Henk van der Vorst published an incomplete Cholesky preconditioner that is still a standard choice for sparse symmetric problems.
Recap
- A preconditioner is a cheap approximation to , and the solver works on .
- The error shrinks by a factor set by ; for well-chosen steps, the number of rounds grows with the condition number.
- A good preconditioner brings the condition number near 1 while staying cheap to apply, which is why it is combined with conjugate gradient in practice.
- Read next: Conjugate Gradient for the solver that uses it, and Condition Number for the measure it improves.
Check yourself
QuestionWhat is the condition number of a symmetric positive definite matrix?Show answer
It is the ratio of its largest to smallest eigenvalue. Large values mean the problem is badly scaled and iterative methods need many steps.
QuestionWhat is the condition number of ?Show answer
The eigenvalues are 5 and 0.5, so .
QuestionWhy is the ideal preconditioner not used in practice?Show answer
Applying means solving with , which is the original hard problem. The preconditioner must be cheap to apply, so it is only an approximation to .
QuestionA problem has condition number and plain conjugate gradient needs about 1000 steps. A preconditioner lowers the condition number to 100. Using the rule that steps grow with the square root of the condition number, roughly how many steps are needed now?Show answer
The square root drops from to , so about 10 steps are needed under that rule. The rule is an upper bound, so the real count may be lower.