A kept vector buys one iteration
Worth reading first: The problem that arrives again · Changing the condition number on purpose · A parameter that counts steps.
A factorisation kept past its date began all of this with a simple choice. One Cholesky factor can serve several members of a drifting sequence, saving the cost of rebuilding it, at the price of more iterations each time. Where the drift lands then found that the price depends on where in the spectrum the drift falls, and what a rebuild is worth priced the rebuilding period against the setup. Every option in those essays is either keep or rebuild.
There is a third option which each conjugate gradient run makes possible and then wastes. The extra iterations caused by a stale preconditioner are spent finding the directions in which it has gone stale. Those directions come out of the run in its Lanczos tridiagonal, as extreme Ritz values, and their vectors are in the basis the run has been computing all along. Normally the run discards them. Kept instead, they can be deflated out of the next member’s iteration, which then does not need to find them again. How much that buys, and at what cost, needs only a count.
The drift has a rank, and the iterations read it
Start from what the kept factor sees. If and the member is , then . For of rank , that matrix is the identity plus a rank- term. So it has at most distinct eigenvalues, and conjugate gradients terminates in at most steps, whatever else is true of it. The earlier essays’ drifts run across all forty eigenvalues of the smaller half of the spectrum, so that bound was never close. To see the law plainly the drift here is placed on only the smallest eigenvectors, at the same overall relative size.
At rank 16, with nothing kept, every member takes 17 iterations. The figure’s red line is flat at that value from the first member to the twenty-fourth. It does not climb with the drift. This is the first thing a reader of the earlier curves might not have expected, since those curves all rise along the sequence. On a low-rank drift the count does not read the drift’s size, only its rank. A drift of rank 4 at three rates a hundred times apart takes five iterations, five and five at the last member, and keeping vectors moves those counts by the same amounts at all three.
Now keep vectors. A deflated run takes the kept vectors, finds the exact solution on their span, and makes every search direction -orthogonal to them. Each kept vector removes one direction from the problem. The result is as simple as a numerical result gets. With four vectors kept on rank 16 the count is 13 from the second member on. With eight it is 9. With sixteen it is one.
The law is exact: on a drift of rank keeping vectors, the last member takes iterations, at ranks 2, 4, 8 and 16 and every tried. A kept vector buys one iteration, no more and no less. At rank 32 the count is 39 with nothing kept rather than 33, since rounding has started to delay the termination in 80 dimensions, and the law bends. A kept vector there buys more than one. It remains the same shape.
That precision has an explanation that is close to trivial. Each kept vector is an eigenvector of the stale part. Deflating it removes one distinct eigenvalue. And a Krylov method’s step count on a matrix with distinct eigenvalues is . So the answer that arrives when the space runs out is being arranged here on purpose, and one vector more or less moves the arrival by exactly one step.
What a vector costs
A step removed is not a step saved, since the vectors have a price. Each one needs a product with the member’s new matrix to form , once per member; that is half of an iteration-equivalent by the counting in what a rebuild is worth, in which one iteration is a product and a preconditioner solve. Each one also needs two inner products in each remaining iteration, a small cost at this size. And refreshing the set takes a Rayleigh–Ritz step which has not been counted here at all, on the reasoning that its leading cost is in dense small matrices.
So a vector buys one iteration a member and costs about half of one. The net saving is about half an iteration per vector per member. Across 24 members on a drift of rank 16, with a setup of a hundred iterations, the work falls from 508 with nothing kept to 343 at sixteen vectors, not to the 148 or so that the iteration count would suggest. And it has a minimum, right at the rank. Keep four on a drift of rank 4 and the work is 178. Keep sixteen on the same drift and it is 327, with no further iteration saved. Past the rank a kept vector buys nothing and still costs its product. Since a code cannot know the rank in advance, this calls for keeping the set small and growing it only while the count keeps falling, a rule which is cheap to state and which has not been tested here.
A kept set is not useful just from having been found once, either. At each member the count is measured after the kept set has been refreshed from the previous member. The first member is always the full count, because nothing has yet been kept. So over a sequence of length the saving is members’ worth, and it is only worth setting up at all when the sequence is long enough for that to matter.
A drift with no rank to reach
The earlier essays’ drift is a different case, and it is the more realistic one: the same relative size spread over all forty eigenvectors of the smaller half.
There the count climbs along the sequence as those essays reported: 27 at the first member, rising to 55 at the last with nothing kept. Forty-one distinct eigenvalues are a ceiling that is not reached, and the rise is the larger outliers separating from the rest. Sixteen vectors take the last member to 26 and the total from 1,156 iterations to 575, about half. That looks excellent until the cost is counted: 345 iteration-equivalents for the vectors themselves. The net work falls by a fifth.
The reason the vectors do better than one iteration each here is that they are removing the most extreme outliers first, and those are what the convergence rate is reading. Sixteen vectors remove 29 iterations from the last member, about 1.8 each. They do this at the top of a list of forty, and every further vector does somewhat less. The 32-vector run is cheaper still in total iterations and costs more than it gives back at most setup costs.
Against the rebuild
The comparison all of this has been heading for is between this and just rebuilding.
On a drift of rank 4, kept vectors win at every setup cost, though by a modest amount. With a setup of a hundred iterations, keeping four costs 178 against 220 for never rebuilding, and rebuilding every twelve costs 302. The whole sequence is cheap in any case, because each member’s iterations were few to begin with. So the saving here is about a fifth of a small number. A low-rank drift is where vectors are at their most efficient and where they are least needed.
On a drift across half the spectrum the result turns around. At a setup of five, rebuilding every member costs 170. At a setup of twenty, rebuilding every third member costs 356, which is against 940 for sixteen kept vectors. At a setup of a hundred, rebuilding every sixth costs 742, against 849 for thirty-two vectors, which are now third in the list. Only at a setup of 500 do the vectors win outright, at 1,249 against a rebuild’s much larger cost.
So the two tools compete at a limited frontier, and it has a clear location. If a rebuild costs less than about a hundred iterations then rebuilding is better, on any drift that is not of very low rank. That covers a dense Cholesky of moderate size, for which the setup is iterations by the same count, and what survives one step of the barrier has already shown that a factorisation with a reusable pattern has a smaller setup still. Above that, as with a multigrid hierarchy or an expensive algebraic setup, vectors become worth having. And the penalty for keeping it is a ratio adds that at a larger size the ratio between a stale and a fresh count falls while the difference rises, which would move this frontier in an unmeasured direction.
Directions that turn
The drift so far keeps its directions. The kept vectors stay exact eigenvectors of the stale part, because only the weights grow as the sequence goes on. That is the most favourable case for them possible, and a real drift’s directions move. So the drift’s eigenvectors are now turned by a small angle per member, each towards a partner outside the drift, and the vectors are refreshed at every member from the run before, as in practice.
With nothing kept the count does not care. At rank 4 it is five iterations at every angle from none to a tenth of a radian per member, since rank is all it reads. With four vectors kept the count is one at no angle and at . At it is two, at a hundredth three, and at a tenth three. At rank 8, with eight kept, it runs one, one, two, three and five. Summed over the whole sequence, four vectors on rank 4 cost 28, 28, 51, 73 and 92 iterations, against the 120 of keeping nothing.
So a kept vector ages, and it does so gently. The law of one iteration per vector was an exact statement about exact eigenvectors, and it fails as soon as there is any angle to the vector: at a direction left over by that angle needs its own iteration to reach a tolerance of . But the loss comes in single steps as the angle grows by factors of a hundred, because a kept vector that is close to the true direction has removed all but a small remnant of it, and a remnant takes one further step to deal with whatever its size. At a tenth of a radian per member the vectors still save more than a third of the iterations of keeping nothing, across a turn that adds up to more than two radians over the sequence. That is a surprisingly durable result for something taken from a single previous run. And its cost has not changed, so at larger angles the saving of half an iteration per vector per member has gone: at rank 4 and a tenth of a radian, four vectors save 28 iterations and cost about 54 iteration-equivalents, so they no longer pay at all.
More vectors than the rank do not help here either: six on rank 4 give 73 and 102 at the two largest angles, no better than four. Keeping extra vectors in the hope of catching what has rotated does not work in this measurement, which contradicts one natural intuition about how such a set should be managed.
A guess worth two per cent measured how quickly the most obvious thing to carry between members, the previous solution, loses its value. Vectors have a better record, since a direction’s relevance outlives any particular solution’s.
Refreshing the set earns very little
The obvious management of a kept set is to refresh it at each member, by Rayleigh–Ritz on the old vectors and the new run’s basis, because a set of vectors from an old member would be expected to age. That step is the one cost not counted above, so it is worth asking what it buys. The comparison is a set harvested once, from the very first member, and then held fixed for all the rest.
It buys almost nothing. On the drift across half the spectrum, four vectors refreshed cost 970 iterations in all and frozen cost 971. Eight cost 816 and 818, and sixteen cost 575 and 577. On a rank-8 drift whose directions turn by per member, both cost 55. At a turn of a hundredth per member, the frozen set is actually a step cheaper, 76 against 77. Only at a turn of a tenth, where the directions have moved through more than two radians by the end, does the refresh become worth anything: 124 against 136, about ten per cent.
So what a kept set needs from a run is its first look. The most extreme Ritz values converge first in any Krylov run, and even a short first member finds them well. After that, the drift’s own eigenvectors hardly change on a sequence like this one, and the only way a set goes stale is if those directions truly move. It simplifies the recipe considerably. A code can keep vectors from one run, with no further eigencomputation and no storage of the following runs’ bases, and skip the only part of this technique that needs an eigensolver. It is the same lesson in a different place as the sketch that is spent, which is about the other direction: there a single use exhausted the random object, and here a single harvest has done nearly all that a harvest could.
The rule that would follow, then, is to harvest at the first member and keep that set until the iteration count starts to grow. That is a rule written entirely in numbers a loop already has, like the rebuild rule in what a rebuild is worth, and it should be measured against that rule on the same sequences.
What this is not
The right-hand sides are random at each member and unrelated. Sequences whose right-hand sides are related would get extra benefit from a good start that is left out of the measurement. The cost model counts a product with and a preconditioner solve as one iteration, and on a dense matrix that treats the two as equal; on a sparse matrix where a matrix-vector product is far cheaper than a triangular solve the balance of a kept vector improves. All of this has been measured on one matrix, at one size, with one condition number, and the harvest uses at most forty basis vectors from the previous run, which is why the counted cost of its Rayleigh–Ritz step can be left out at all.
Still open: directions that move, and a rule for how many to keep
A real sequence. Everything here has one drift whose form was chosen. The prediction with a sign is that on the barrier sequence of what survives one step of the barrier, where the changing entries are diagonal values at each step and the change is of rank , kept vectors save under one iteration in four, because the directions turn by large angles between steps, and that rebuilding remains cheaper at every setup below 200 iterations.
A rule for how many. The minimum of the work is at the rank, which is unknown. The prediction is that a rule which adds one vector each member while the count is falling and stops at the first member where it does not fall reaches within one of the true rank at ranks 2, 4, 8 and 16, within members of the start of the sequence, and that its total work is within 15 per cent of keeping the right number from the beginning, so that this can be left to a program and not to a caller who has to know it.
What links here
Computed from the collection, not written here: the essays that point at this one.
Shares its objects with
Essays that name at least two of the same things, and that neither author linked.
- A preconditioner that changes sign — both name condition number, conjugate gradients, preconditioning
- A speedup with a ceiling of its own — both name condition number, conjugate gradients, preconditioning
- Five steps is a rate — both name condition number, conjugate gradients, preconditioning
- Four orders of conditioning, and four steps — both name condition number, conjugate gradients, preconditioning
- Spread resistances make the loops easy — both name condition number, conjugate gradients, preconditioning
- The accuracy worth paying for — both name condition number, conjugate gradients, preconditioning
Named objects
A flat tag is an object no other essay names yet.
Cholesky factorisationCondition numberConjugate gradientsEigenvaluePreconditioningSequence of solves