When the problem arrives again

A kept vector buys one iteration

A kept Cholesky factor with a drift of rank r in the matrix takes exactly r + 1 iterations at every member, at any drift rate, because the preconditioned matrix is the identity plus a rank-r term. The run has found those directions and throws them away. Keep some from one member to the next and each one removes exactly one iteration: keep sixteen on a drift of rank sixteen and every later member takes one. Each vector also costs half an iteration a member, so the saving is half what it looks like, and past the rank it is all cost. On a drift across half the spectrum there is no rank to reach: sixteen vectors halve the iterations and save a fifth of the work, and rebuilding the factor still wins until a rebuild costs more than a hundred iterations.

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 M=A0M = A_0 and the member is A0+EA_0 + E, then M−1A=I+A0−1EM^{-1}A = I + A_0^{-1}E. For EE of rank rr, that matrix is the identity plus a rank-rr term. So it has at most r+1r + 1 distinct eigenvalues, and conjugate gradients terminates in at most r+1r + 1 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 rr smallest eigenvectors, at the same overall relative size.

Conjugate gradient iterations against the member of a drifting sequence with one kept Cholesky factor, on a drift of rank 16, keeping none or some of the extreme Ritz vectors from the member beforekeeping 0: 17, 17, 17, 17, 17; keeping 4: 17, 13, 13, 13, 13; keeping 8: 17, 9, 9, 9, 9; keeping 16: 17, 1, 1, 1, 1 at members 1, 6, 12, 18 and 24.0481216202404812162024member of the sequenceiterationsnothing keptkeep 4keep 8keep 1680 unknowns · drift on 16 eigenvaluesone iteration a vector
Fig. 1 Conjugate gradient iterations against the member of a drifting sequence with one kept Cholesky factor, keeping none or some of the extreme Ritz vectors from the member before. The dial sets the rank of the drift.

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 kk kept vectors, finds the exact solution on their span, and makes every search direction AA-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 last member's iterations against the number of kept vectors, for drifts of five ranks, one kept factor throughoutrank 2: 3, 2, 1, 1, 1, 1, 1; rank 4: 5, 4, 3, 1, 1, 1, 1; rank 8: 9, 8, 7, 5, 1, 1, 1; rank 16: 17, 16, 15, 13, 9, 1, 1; rank 32: 39, 37, 36, 32, 27, 17, 1 keeping 0, 1, 2, 4, 8, 16, 32.110¹0510152025303540vectors kept; none is drawn at a halfiterations on the last memberrank 2rank 4rank 8rank 16rank 3280 unknowns · 24 membersr + 1, less one for each vector
Fig. 2 The last member’s iterations against the number of kept vectors, for drifts of five ranks, one kept factor throughout.

The law is exact: on a drift of rank rr keeping k≤rk \le r vectors, the last member takes r+1−kr + 1 - k iterations, at ranks 2, 4, 8 and 16 and every kk 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 dd distinct eigenvalues is dd. 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 AWAW, 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.

The whole sequence's work in iteration-equivalents against the number of kept vectors, with one rebuild's worth of setup at a hundred iterations, for three ranks of driftrank 4: 220, 211, 200, 178, 228, 327, 527; rank 16: 508, 503, 498, 485, 450, 343, 545; rank 32: 1000, 987, 979, 954, 904, 819, 570 keeping 0, 1, 2, 4, 8, 16, 32.110¹02004006008001000vectors kept; none is drawn at a halfwork in iteration-equivalentsrank 4rank 16rank 32the first setup included · 24 membersthe least is at the rank, and past it cost rises
Fig. 3 The whole sequence’s work in iteration-equivalents against the number of kept vectors, with one setup at a hundred iterations, for three ranks of drift.

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 TT the saving is T−1T - 1 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.

Iterations against the member on a drift across the whole smaller half of the spectrum, with one kept factor, for four numbers of kept vectorskeeping 0: 27, 46, 51, 53, 55, 1156 in all; keeping 4: 27, 38, 43, 45, 46, 970 in all; keeping 8: 27, 32, 36, 37, 38, 816 in all; keeping 16: 27, 22, 25, 26, 26, 575 in all.048121620240102030405060member of the sequenceiterationsnothing keptkeep 4keep 8keep 1680 unknowns · drift on forty eigenvaluestoo many directions to keep
Fig. 4 Iterations against the member on a drift across the whole smaller half of the spectrum, with one kept factor, for four numbers of kept vectors.

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.

The three cheapest policies for a sequence, by the setup's cost in iterations, on a low-rank drift and on a drift across half the spectruma drift of rank 4, setup 5: keep 4 vectors 83, keep 2 vectors 105, rebuild every 6 106; a drift of rank 4, setup 20: keep 4 vectors 98, keep 2 vectors 120, never rebuild 140; a drift of rank 4, setup 100: keep 4 vectors 178, keep 2 vectors 200, never rebuild 220; a drift of rank 4, setup 500: keep 4 vectors 578, keep 2 vectors 600, never rebuild 620; a drift on half the spectrum, setup 5: rebuild every 1 170, rebuild every 3 236, rebuild every 6 362; a drift on half the spectrum, setup 20: rebuild every 3 356, rebuild every 6 422, rebuild every 1 530; a drift on half the spectrum, setup 100: rebuild every 6 742, rebuild every 12 808, keep 32 vectors 849; a drift on half the spectrum, setup 500: keep 32 vectors 1249, keep 16 vectors 1420, keep 8 vectors 1521.10030010003000a drift of rank 4, setup 5keep 4 vectors83keep 2 vectors105rebuild every 6106a drift of rank 4, setup 20keep 4 vectors98keep 2 vectors120never rebuild140a drift of rank 4, setup 100keep 4 vectors178keep 2 vectors200never rebuild220a drift of rank 4, setup 500keep 4 vectors578keep 2 vectors600never rebuild620a drift on half the spectrum, setup 5rebuild every 1170rebuild every 3236rebuild every 6362a drift on half the spectrum, setup 20rebuild every 3356rebuild every 6422rebuild every 1530a drift on half the spectrum, setup 100rebuild every 6742rebuild every 12808keep 32 vectors849a drift on half the spectrum, setup 500keep 32 vectors1249keep 16 vectors1420keep 8 vectors1521work in iteration-equivalentsdot in blue: the cheapestvectors win when a rebuild is dear
Fig. 5 The three cheapest policies for a sequence, by the setup’s cost in iterations, on a low-rank drift and on a drift across half the spectrum.

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 n/12n/12 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.

The last member's iterations against how far the drift's directions turn per member, with and without kept vectors, at two ranksrank 8: nothing kept 9, 9, 9, 9; keeping 8 1, 2, 3, 5; rank 4: nothing kept 5, 5, 5, 5; keeping 4 1, 2, 3, 3 at angles 0.000001, 0.0001, 0.01, 0.1 a member.10⁻⁶10⁻⁵10⁻⁴10⁻³10⁻²10⁻¹048121620angle turned per member, in radiansiterations on the last memberrank 8, nothing keptrank 8, keep 8rank 4, nothing keptrank 4, keep 424 members · refreshed every membera kept vector ages with its direction
Fig. 6 The last member’s iterations against how far the drift’s directions turn per member, with and without kept vectors, at two ranks.

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 10−610^{-6}. At 10−410^{-4} 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 10−410^{-4} a direction left over by that angle needs its own iteration to reach a tolerance of 10−1010^{-10}. 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 10−410^{-4} 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 AA 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 pp diagonal values at each step and the change is of rank pp, 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 rr 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.

Named objects

A flat tag is an object no other essay names yet.

Cholesky factorisationCondition numberConjugate gradientsEigenvaluePreconditioningSequence of solves