When the problem arrives again

The first count names the rank

A kept Cholesky factor on a drift of rank r takes r + 1 conjugate gradient iterations, and each vector kept from one member to the next removes exactly one. The best number to keep is the rank, which a caller does not know. A rule that adds one vector a member while the count falls finds it, settling at r + 1 by member r + 2 as predicted, and pays 13 to 25 per cent over keeping the rank from the start, which is over the predicted fifteen at ranks 2 and 16. It also needs every vector to buy exactly one iteration: on a drift whose directions turn by a thousandth of a radian a member, or one with no low rank, the count does not fall at the first vector and the rule stops there. The first member's count is r + 1 already. Keeping one fewer than it took costs less than knowing the rank in advance, and stays within five per cent of the best fixed choice on every drift but one turning a tenth of a radian a member, where keeping nothing is best.

Worth reading first: The problem that arrives again · Changing the condition number on purpose · A parameter that counts steps.

A kept vector buys one iteration found a law with no slack in it. A sequence of symmetric positive definite matrices drifts from one that has been factorised; the old Cholesky factor preconditions conjugate gradients on each new member; and when the drift has rank rr, the preconditioned matrix is the identity plus a rank-rr term, so every member takes exactly r+1r + 1 iterations. Conjugate gradients has found the rr directions that matter by the end of each run, and throws them away. Keep kk of them, refreshed by Rayleigh–Ritz from one member to the next, and the count is r+1−kr + 1 - k, exactly, until it reaches one. Each kept vector costs half an iteration a member in extra products and projections, so the least work is at k=rk = r.

The rank is a property of the drift, and nothing a caller usually knows. That essay therefore predicted, with a sign, what a program could do without it: add one vector each member while the count is falling, stop at the first member where it does not fall, and so reach within one of the rank, within about rr members, at a total cost within fifteen per cent of keeping the right number from the start.

The first two parts hold exactly. The cost is over the prediction at two ranks of four. And the rule has a weakness the prediction did not consider, which a second rule, one line shorter, does not have.

Growing the kept set one vector at a time

The sequences are the earlier essay’s: a matrix of order 80 with condition number 10410^4, factorised once; 24 members, each a drift of rank rr on its smallest eigenvalues, growing by a fixed step each member; a fresh random right-hand side each member, solved to a relative residual of 10−1010^{-10}. The growing rule starts with nothing kept, keeps one after the first member, and after every later member keeps one more if that member’s count fell below the previous one’s. At the first member where the count does not fall, it stops growing and holds.

Along 24 members of a sequence whose drift from the factored matrix has rank 8, the conjugate gradient iterations each member takes with vectors kept by a rule that adds one while the count falls, by one that reads the rank off the first count, and with 8 kept from the start, and the vectors each rule keepsIterations, growing: 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1; reading the first count: 9, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1; 8 from the start: 9, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1. Vectors kept, growing: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9; reading the first count: 0, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8. Work: 150, 127 and 132 iteration-equivalents.04812162024024681012141618member of the sequenceiterations, or vectors keptkept, growingiterations, growingiterations, first countiterations, 8 from the startorder 80 · κ = 10⁴ · tolerance 10⁻¹⁰the first count already says the rank
Fig. 1 Iterations each member takes under the growing rule, under a rule that reads the rank off the first count, and with the rank kept from the start, with the vectors the growing rule keeps. The dial sets the drift’s rank.

At rank 8 the growing rule’s counts read 9, 8, 7, 6, 5, 4, 3, 2, 1, each kept vector removing exactly one iteration as the law said. At member 10 it keeps nine, the count stays at one, and it stops. At every rank on the dial it ends one vector above the rank, at r+1r + 1, and has stopped by member r+2r + 2. That is “within one of the true rank, within rr members of the start” to the letter, give or take the one member it takes to notice that the count has stopped falling.

What climbing costs

The work along 24 members, in iteration-equivalents with each kept vector charged, of keeping none, of growing the kept set while the count falls, of keeping the rank from the start, and of reading the rank off the first count, at four ranks of driftrank 2: none 72, growing 61, 2 from the start 51, first count 50; rank 4: none 120, growing 88, 4 from the start 78, first count 76; rank 8: none 216, growing 150, 8 from the start 132, first count 127; rank 16: none 408, growing 303, 16 from the start 243, first count 230.0100200300400a drift of rank 2keep none72grow while the count falls61keep 2 from the start51read the first count50a drift of rank 4keep none120grow while the count falls88keep 4 from the start78read the first count76a drift of rank 8keep none216grow while the count falls150keep 8 from the start132read the first count127a drift of rank 16keep none408grow while the count falls303keep 16 from the start243read the first count230work along the sequence, iteration-equivalentsno rebuild · one factorisationgrowing costs the triangle it climbs
Fig. 2 The work along 24 members, in iteration-equivalents with every kept vector charged, of keeping none, of the growing rule, of keeping the rank from the start, and of reading the rank off the first count, at four ranks.

The cost of finding the rank this way is the triangle the iteration counts climb down. At rank 16, the first seventeen members take 17, 16, 15 and so on down to one, about 150 iterations where keeping sixteen from the start would take 33, and they carry a growing set of vectors on the way. The rule’s total is 303 iteration-equivalents against 243 for keeping sixteen from the start, a ratio of 1.25. At ranks 2, 4 and 8 it is 1.20, 1.13 and 1.14. So the prediction’s fifteen per cent holds at the middle two ranks and fails at the ends: at rank 16 because the triangle grows like r2/2r^2/2 while the saving grows like rr times the remaining members, and at rank 2 because the one extra vector the rule keeps past the rank is a large fraction of a small kept set. Keeping nothing, for comparison, costs 72, 120, 216 and 408: the growing rule recovers between half and four-fifths of what knowing the rank would have saved.

That is a respectable result for a rule that knows nothing in advance. But the triangle is waste the sequence never needed to pay, because the first member already said what the rank was.

The first count is the rank plus one

Under the law, the first member, solved with nothing kept, takes r+1r + 1 iterations. So a rule can read the rank off it: keep one fewer vector than the first member took iterations, and hold. At rank 8 the first member takes nine, the rule keeps eight from the second member on, and every later member takes one. That is the second line on the dial’s figure, and it drops straight from the first count to one.

Its cost at the four ranks is 50, 76, 127 and 230, which is below keeping the rank from the start, 51, 78, 132 and 243. The difference is the first member, which the reading rule solves with nothing kept and so without paying for any vectors, while a program that keeps the rank from the start has no vectors to keep at the first member either but is charged as if it did in the accounting the earlier essay used. The saving is small and it is not the point. The point is that the rule needs no growth, no triangle and no knowledge, and lands on the rank in one member.

Why a count can be read as a rank

The law the reading rule leans on is a fact about polynomials, and it is worth seeing why it is exact, because that says when it will not be. Conjugate gradients on a symmetric positive definite matrix produces, at step jj, the error that the best polynomial of degree jj with constant term one can leave, measured in the matrix’s own norm. When the preconditioned matrix is the identity plus a term of rank rr, it has at most r+1r + 1 distinct eigenvalues: one, and the rr others the drift moved. A polynomial of degree r+1r + 1 can vanish on all of them, so the error is zero after r+1r + 1 steps in exact arithmetic, and to the tolerance in practice. It cannot be zero sooner unless some of the rr coincide or the right-hand side has no component along some of them, which a random right-hand side always has.

So the first member’s count is not an estimate of the rank. It is the rank plus one, as long as three things hold: the drift’s directions are exactly rr in number, each moves its eigenvalue far enough from one that the tolerance cannot be met without resolving it, and the right-hand side touches all of them. The first of these is the assumption the growing rule and the reading rule share. The second is a matter of tolerance: an outlier moved by 10−1210^{-12} would be inside a 10−1010^{-10} tolerance from the start and would never be counted, and would cost nothing to ignore either. The third is why the right-hand sides here are random.

Each of the three can fail, and when one does the count is still a measurement, just of something else: the number of eigenvalues the tolerance cannot tolerate, which is the number of vectors worth keeping. That is a better quantity for the purpose than the rank, and the reading rule gets it for free. A Krylov space for a problem that is not linear leans on the same polynomial view from the other direction, where the count of steps a method takes is what its nonlinearity costs.

When one vector does not buy one iteration

The growing rule rests on a signal: that adding one vector makes the count fall. The earlier essay measured where that signal fails. When the drift’s directions turn by an angle from one member to the next, the kept vectors are slightly out of date, and “by an angle of 10−410^{-4} a member a kept set no longer brings the count to one”. A rule that needs the count to fall by one each time it adds a vector is a rule that needs the law to hold exactly.

Along 24 members of a rank-8 drift whose directions turn by a thousandth of a radian each member, the iterations each member takes with nothing kept, under the growing rule and under the rule that reads the first countNothing kept: 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9; growing: 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, keeping 1; first count: 9, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, keeping 8. Work 216, 231 and 153.048121620240246810member of the sequenceiterationsnothing keptgrowing: stops at 1first count: keeps 8a turn of 10⁻³ a memberone vector no longer buys one iteration
Fig. 3 Iterations along a rank-8 drift whose directions turn by a thousandth of a radian each member, with nothing kept, under the growing rule and under the rule that reads the first count.

At a turn of a thousandth of a radian a member, one kept vector does not take off an iteration: the count stays at nine. The growing rule reads that as the end of the fall and stops, keeping one vector to the end of the sequence, which helps nothing and costs half an iteration a member: 231 iteration-equivalents against 216 for keeping none. The reading rule keeps eight, and the count drops to two and stays there, for 153 against the best fixed choice’s 158. At a turn of a hundredth the reading rule’s counts settle at three, at 178 against the best fixed 183, and the growing rule again keeps one. Every turning drift measured, at a thousandth, a hundredth and a tenth of a radian and at ranks 4 and 8, stops the growing rule at one vector.

The reason the reading rule survives is that it does not need the law to hold at every vector. It needs only the first count, which is a property of the drift alone, before anything is kept. Whether the kept vectors then deliver the full saving or part of it, the rule has chosen the number the best fixed choice would have chosen.

A drift with no rank to find

Along 24 members of a drift on the smaller half of the spectrum, which has no low rank, the iterations each member takes with nothing kept, under the growing rule and under the rule that reads the first count, capped at 24 vectorsNothing kept: 27, 35, 38, 42, 44, 46, 46, 46, 49, 49, 49, 51, 51, 51, 51, 52, 53, 53, 53, 53, 54, 55, 53, 55; growing: 27, 33, 36, 40, 42, 44, 43, 44, 46, 48, 47, 48, 48, 49, 49, 50, 50, 51, 51, 51, 51, 52, 51, 53, keeping 1; first count: 27, 13, 13, 14, 15, 15, 16, 16, 16, 17, 17, 17, 17, 16, 17, 16, 17, 17, 17, 17, 17, 17, 17, 17, keeping 24. Work 1156, 1133 and 822; the best fixed count, 24, costs 845.048121620240102030405060member of the sequenceiterationsnothing keptgrowing: stops at 1first count: keeps 24the count rises as the drift growsa falling count never comes
Fig. 4 Iterations along a drift on the smaller half of the spectrum, which has no low rank, with nothing kept, under the growing rule and under the rule that reads the first count, capped at 24 vectors.

The earlier essay’s other drift spreads over the smaller half of the spectrum and grows with the sequence, so its count rises member by member: 27 at the first, 46 by the sixth, 55 by the last, with nothing kept. On that drift the growing rule never sees a fall to grow on. Its second member, with one vector kept, takes 33 iterations where the first took 27, the rule stops, and it ends with one vector and a total of 1,133 iteration-equivalents against 1,156 for keeping none. The reading rule reads 27, wants 26 vectors, is capped at 24, and brings the counts down to 13 to 17 a member, for a total of 822. The best fixed count measured is also 24, at 845.

This is the case the growing rule’s premise is furthest from, and it is also a common one: a sequence whose systems get harder as it proceeds, as a barrier method’s do near its end, has a count that rises whatever is kept. A rule that reads improvement as a fall in the count reads a rising count as no improvement, when in fact the kept vectors were taking off as much as they could from a count that would otherwise have risen faster. The comparison that would have told the truth is with the count the member would have taken without the vectors, and that count is never observed.

Both rules against the best a caller could do

Each rule's work along the sequence over the least work any fixed number of kept vectors reaches, on drifts of four ranks with fixed directions, the wide drift, and a rank-8 drift turning at three ratesrank 2, fixed directions: growing 1.20, first count 0.98, best fixed 2; rank 4, fixed directions: growing 1.14, first count 0.97, best fixed 4; rank 8, fixed directions: growing 1.13, first count 0.96, best fixed 8; rank 16, fixed directions: growing 1.25, first count 0.95, best fixed 16; the wide drift: growing 1.34, first count 0.97, best fixed 24; rank 8, turning 0.001: growing 1.46, first count 0.97, best fixed 8; rank 8, turning 0.01: growing 1.26, first count 0.97, best fixed 8; rank 8, turning 0.1: growing 1.07, first count 1.07, best fixed 0.0.911.11.21.31.41.5rank 2, fixed directions: growing1.20rank 2, fixed directions: first count0.98rank 4, fixed directions: growing1.14rank 4, fixed directions: first count0.97rank 8, fixed directions: growing1.13rank 8, fixed directions: first count0.96rank 16, fixed directions: growing1.25rank 16, fixed directions: first count0.95the wide drift: growing1.34the wide drift: first count0.97rank 8, turning 0.001: growing1.46rank 8, turning 0.001: first count0.97rank 8, turning 0.01: growing1.26rank 8, turning 0.01: first count0.97rank 8, turning 0.1: growing1.07rank 8, turning 0.1: first count1.07work over the best fixed count'sone is the best any caller who knew could dothe first count is nearly that
Fig. 5 Each rule’s work along the sequence over the least work any fixed number of kept vectors reaches, on four ranks with fixed directions, the wide drift, and a rank-8 drift turning at three rates.

Measured against the best fixed choice in every case, the least work any number of kept vectors from none to 24 reaches, the reading rule is at 0.95 to 0.98 on the fixed drifts, 0.97 on the wide drift and on the drifts turning a thousandth and a hundredth of a radian, and 1.07 at a tenth. The growing rule is at 1.13 to 1.25 on the fixed drifts, 1.34 on the wide one, 1.46 and 1.26 on the slow turns, and 1.07 at a tenth, where both rules are beaten by keeping nothing.

The one case the reading rule loses is the fast turn, where the kept vectors age between members faster than they help. At a turn of a tenth of a radian a member, a rank-4 drift keeps four vectors under the reading rule for 144 iteration-equivalents, where keeping none costs 120: a fifth too much. Nothing in the first count can see that, since the first count is taken before any vector has been kept or has aged. A program that wanted to guard against it would compare the second member’s count with the first, and drop the vectors if the saving was below their cost, which is a check on one member rather than a rule that climbs.

What this changes in a program

The earlier essays in this sequence priced the alternatives against each other. Where the drift lands found that the cost of a kept factor depends on which end of the spectrum the drift falls on. What a rebuild is worth priced factorising afresh against carrying the old factor, and a factorisation kept past its date found where the crossover lies. The kept vectors were the third option, and their size was the parameter left to the caller. This measurement takes it away from the caller. The first solve along a sequence reports its own iteration count, and on a low-rank drift that count is the rank plus one.

The same idea shows up elsewhere in the subject as a principle: a Krylov method’s iteration count is a reading of the spectrum, and a program that discards it has discarded a measurement. The problem that arrives again made the general case that a solve is one step of an outer loop and its by-products are inputs to the next step, and a warm start is degree zero found that even the previous answer, the simplest by-product, is worth an order of magnitude when it is used well. The penalty for keeping it is a ratio used a count in this way to price an incomplete factorisation’s ageing. Here it sets a size, and it sets it better than an adaptive rule that watches the counts over many members, because the many members are exactly the ones on which the law can be disturbed.

Put together, the recipe a program needs is two lines long. After the first member, keep one fewer vector than it took iterations, up to whatever the program can afford to store. After the second, compare its count with the first: if the vectors took off less than their own cost, which on these sequences is half an iteration each a member, drop them and solve the rest of the sequence with the factor alone. On every sequence measured here, that recipe lands within five per cent of the best fixed choice except on the fast turn, and the check on the second member is aimed at exactly that case. It is not measured here, which is why it appears below as a prediction and not as a result.

What one matrix and four ranks cannot tell

One matrix of order 80, one condition number, drifts of a chosen form whose rank is exact. On a drift whose rank is approximate, with a few large directions and a tail of small ones, the first count is r+1r + 1 plus whatever the tail costs, and the reading rule would keep vectors for the tail too; whether that over-keeps, and by how much, is not measured. The cap of 24 binds on the wide drift and nowhere else. The accounting charges each kept vector half an iteration a member, which is a model of a code whose products dominate; a code whose projections are expensive would move every ratio. And the sequences have 24 members: on a longer sequence the growing rule’s triangle is a smaller share of the whole, and its excess would fall toward the extra vector it keeps past the rank.

Still open: an approximate rank, and the barrier

A drift with a tail. Add to a rank-8 drift a second component on the next eight eigenvalues at a hundredth of its size. The prediction with a sign is that the first count is then between 12 and 17, that the reading rule keeps that many less one, and that its work is still within ten per cent of the best fixed count, because the tail’s directions each take off an iteration only once they are kept and cost no more to keep than the drift’s own.

The barrier sequence. On the sequence of what survives one step of the barrier, whose changing entries are a few diagonal values with directions that turn by large angles, the prediction is that the reading rule’s vectors save under one iteration in four, as the earlier essay predicted for any kept set, and that the reading rule’s own check on the second member, keep the vectors only if the saving exceeds their cost, drops them there and costs under five per cent more than keeping none.

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 factorisationConjugate gradientsEigenvalueKrylov subspacePreconditioningSequence of solves