The preconditioner that knew how many
Worth reading first: Which pairs are allowed to be small · Changing the condition number on purpose · A parameter that counts steps.
The second right-hand side split a hierarchical solve into a setup and a slope. At 512 unknowns and a tolerance of the setup is 7,104,739 multiplications and each right-hand side after it is 124,804, so a program that keeps the factorisation pays a fifty-seventh of the first solve for every one after. Against that, conjugate gradients preconditioned by the same format compressed to a hundredth was cheaper in total until 20.8 right-hand sides on the easiest matrix and until 1.6 on the softest, and the plain iteration lost after three.
The hundredth was a choice made once, in the accuracy worth paying for, for one right-hand side. That essay found the cheapest preconditioner tolerance for a single solve and noticed that it moved by six decades between an easy matrix and a hard one. A program that knows how many right-hand sides are coming could choose again. The earlier essay predicted what it would choose: coarser than a tenth for one right-hand side, near for twenty, or tighter for a hundred, at which point “the iteration is doing a step or two and is essentially the direct route with a refinement behind it, so that the two routes converge on one method rather than crossing”.
The shape of that is right. Each number in it is off, in a direction that has a single cause, and the last clause fails for a reason that is plain once the counter is read.
What the count does to the cheapest tolerance
The setting is the earlier essay’s: kernel matrices of a smooth function with a softening parameter, built as hierarchical matrices with leaves of sixteen, solved by the recursive Woodbury identity. The direct route compresses to and solves. The iterative route runs conjugate gradients to a relative residual of , multiplying by the operator in its format and preconditioning with a second copy compressed to a coarser tolerance , which now runs over ten values from 0.3 down to . For right-hand sides the total is the preconditioner’s setup once, plus times the steps times the cost of one product and one coarse solve. All of it is counted in multiplications by the same counter.
At one right-hand side the easiest matrix’s curve has its floor at the coarse end: 0.14 of the direct route’s cost at a tenth. The direct route is paying a full factorisation for a single use, and anything that avoids it wins by a factor of seven. Everything from 0.3 to a hundredth is within a third of the floor, so for one right-hand side the choice hardly matters as long as it is coarse. The prediction said the floor would be coarser than a tenth. It is at a tenth: 0.3 costs 7 per cent more. That is a narrow miss and a flat curve, and the dial shows why it was never going to be coarser by much.
Turn the dial to five and the floor moves to a hundredth, at 0.39 of direct. At twenty it moves to , at 0.82: still a fifth cheaper than the direct route, but most of the advantage is gone. At a hundred it is at , the full accuracy of the direct solve, and the whole curve is above one. On the harder matrix, the same kernel with its softening multiplied by sixteen, everything happens sooner: the floor is at a hundredth for one right-hand side, at for two and five, at for ten and twenty, and at from fifty on.
The prediction’s second number, for twenty, is a decade too coarse: costs 13 per cent more there than . Its third, or tighter for a hundred, holds, but the best for a hundred is not . It is two decades tighter still, and the reason is in the next figure.
Steps are whole numbers
On the easiest matrix at 512 unknowns the steps fall 10, 6, 5, 4, 3 as the tolerance tightens from 0.3 to , then sit at 2 from all the way to , and drop to one at . On this matrix the three right-hand sides measured at each tolerance agree to the step everywhere; across all four matrices they differ, by a single step, at five settings of forty. The harder matrix starts higher, 23 at 0.3 and 21 at a tenth, falls faster, and reaches the same plateau of two at and the same single step at . At 256 unknowns the staircases are nearly the same.
Between two jumps the steps do not change, and everything else gets dearer as the tolerance tightens: the preconditioner’s ranks rise from 2 at 0.3 to 13 at on the easiest matrix, its setup from 216,523 to 7,104,739 multiplications, its cost a solve from 22,688 to 124,804. So nothing inside a plateau can be the cheapest point except its coarse end. That is why the best tolerance for twenty is rather than : is where the plateau of two steps begins, and is still paying for a third. And it is why the best for a hundred jumps past to : the whole stretch from to is one plateau, and once the count is large enough that saving a step beats any setup, the only cheaper point is the next jump down. On every count and every matrix measured, the cheapest tolerance is the coarse edge of its plateau, and no coarser tolerance takes the same number of steps.
The prediction treated the cheapest tolerance as something that slides smoothly as the count rises. It jumps, between a handful of values fixed by where the step count changes, and a model that interpolates between them lands in the middle of a plateau, at its most expensive point.
The cheapest tolerance against the count
Read against the count, the cheapest tolerance is a descending staircase of its own, and each of its treads is a plateau edge from the figure above. On the easiest matrix at 512 unknowns it sits at a tenth for one and two right-hand sides, at a hundredth for five and ten, at for twenty and fifty, and at from a hundred on. It never visits , nor anything between and , because those tolerances are interior to a plateau and are beaten by the plateau’s coarse edge at every count. The harder matrix visits a different set of edges, a hundredth, , and , because its staircase is shifted: its plateau of two steps starts a decade tighter.
The direction is what the prediction said, and it is what intuition says too. A large count makes the slope matter and the setup not, so it pays to spend setup on a tighter preconditioner that saves steps. What the figure adds is how few choices there are. Across four matrices and nine counts the cheapest tolerance takes only six values of the ten on the grid, and it never loosens as the count rises. A program choosing a tolerance for a count is choosing among the three or four places where its own step count changes, and choosing the coarsest of them that the count can afford to leave behind.
The two sizes of the easiest matrix track each other closely, with the smaller reaching each tread a little sooner, at ten rather than twenty for and at fifty rather than a hundred for . That is the setup’s share again: at 256 unknowns the direct route’s setup is 43 solves’ worth rather than 57, so the count at which the setup stops mattering arrives sooner, and every tread moves left with it.
What a step costs
The slope of the iterative route is the steps times the cost of a step, and a step is two operations: a product with the operator and a solve with the preconditioner. At a tenth on the easiest matrix that is six steps of 61,440 plus 31,236, or 4.4 direct solves a right-hand side. It falls with the steps, to 2.2 on the plateau at and to its least at the single step, , where it is 61,440 plus 124,804: 1.49 direct solves.
That 1.49 is the floor. On the four matrices it is 1.49, 1.52, 1.49 and 1.53, and no tolerance gets under it, because one step of conjugate gradients with a perfect preconditioner is one solve with that preconditioner and one product with the operator to check it. The solve is the direct route’s whole cost a right-hand side. The product is the extra, and on a hierarchical matrix a product is not small next to a solve: 61,440 against 124,804, very nearly half. That is a property of this format, where the solve’s slope is a product at each level plus small dense systems, so the product is most of what a solve does.
The routes still cross
This is where the prediction’s last clause fails. “Essentially the direct route with a refinement behind it” is exactly what the iteration becomes at a hundred right-hand sides: its preconditioner is the direct route’s factorisation, its one step is a solve, and its check is a product. But a refinement behind a solve is not free. It costs the product, every time, and the direct route never pays it.
The plain iteration, at 37.7 steps of a product each, crosses the direct route at 3.25 right-hand sides. The iteration preconditioned at a fixed hundredth crosses at 20.8, as the earlier essay found. The iteration whose tolerance is chosen afresh for each count is the lower envelope of all ten curves, and it crosses at 32.0. Past that it lies above the direct route and approaches 1.49 times it from below, 1.31 at a hundred, 1.38 at two hundred, 1.44 at five hundred, without ever reaching one.
So tuning buys about half again on the easiest matrix, from 21 right-hand sides to 32. On the harder matrix it buys more, from 6.7 to 16.4, because there the fixed hundredth is far from the best for any count, while on the easiest it is the best for five and ten. The harder matrix’s own staircase makes the same point from the other side. Its iteration at a hundredth takes seven steps, against four on the easiest, so the fixed choice there sits on an expensive tread; at it takes two, and the setup that buys those five steps is repaid within a handful of right-hand sides. A fixed tolerance chosen on an easy matrix and carried to a harder one is wrong by exactly the distance between their staircases, and that distance is what tuning recovers. At 256 unknowns the crossings move from 15.2 to 22.9 and from 5.3 to 11.0. In every case the crossing moves and stays finite. The two routes do not converge on one method. At large counts they converge on one factorisation, used in two ways, and the way that checks every answer with a product pays for the check.
What the counter says a program should do
The rule that comes out of this is shorter than the one the earlier essay gave. That essay’s crossing formula, the difference in setups over the difference in slopes, assumed a fixed preconditioner. With the tolerance free, a program needs one more thing, the step staircase, and the staircase is cheap to learn: the steps change at only a few tolerances, and one solve at each of them gives the whole picture to within the agreement measured here between right-hand sides. Then the cheapest tolerance for a count is one of the staircase’s edges, and the crossing against the direct route is where the cheapest edge’s total meets the direct total.
On these matrices that rule says three things that do not depend on the details. Below about five right-hand sides, use a preconditioner as coarse as the iteration will tolerate; the exact value is worth a few per cent. Between five and the crossing, tighten to the edge where the step count drops to two, which is where most of the iterative route’s advantage lives. Past the crossing, factorise and solve, and do not iterate at all. A refinement step costs half a solve and earns nothing when the solve is already accurate to the tolerance the iteration was asked for.
That last point is the one the counter adds to the usual advice. The gap refinement can close shows refinement earning its keep where the solve is inaccurate, and there the product it costs is worth paying. Here the solve is already at , the target, and the step finds nothing to correct. A program that refines by reflex, to be safe, is paying a factor of 1.49 for safety on every right-hand side, and on a hundred of them that is more than the whole setup of the direct route. The check is not worthless in principle. It is what tells a program its answer met the tolerance, and an iteration that stops on its residual has a certificate that a direct solve does not. But a direct solve at on a hierarchical matrix already has one, in the compression tolerance it was built to and the conditioning of the matrix, and a program that wants the residual as well can compute it once, on one right-hand side, at the cost of one product, rather than on every right-hand side as part of an iteration that changes nothing.
The same accounting appears wherever something built once is used many times. What a rebuild is worth prices refreshing a factorisation along a sequence of matrices against carrying an old one, and a kept vector buys one iteration prices recycled directions against their cost. Both find the answer in the same two numbers, a setup and a slope, and both find that the right choice depends on a count the program usually knows. Where the format starts paying was the first crossing in this series, for one solve, and the number in it, 0.16 of a dense factorisation at 512 unknowns, is a single point on the curves here.
Where this measurement stops
Two sizes, two softenings, one kernel, one stopping tolerance. The steps come from three right-hand sides at each setting, and the step counts are the most fragile thing measured, since a slightly different stopping rule moves a jump and with it the cheapest tolerance; the knob that moved two things found the same tolerance moving accuracy and cost together, and a stopping rule tied to the forward error rather than the residual might change the staircase. The ten tolerances are a grid, and a jump can fall between two of them, in which case the true coarse edge is a little coarser than the grid says. The operator’s product is counted at in every iterative route; an iteration that multiplied by a coarser operator would have a lower floor and a less accurate answer, and is not measured. An accuracy that is a backward error is the reason that trade is not free: an iteration converged on a compressed operator has solved the compressed problem, and its residual against the true one is the compression’s own tolerance, whatever the iteration reports. And multiplications are the unit throughout. On a machine where the product streams memory and the solve does not, the floor’s 1.49 would be a different number, though not, on this format, a number below one.
Still open: the operator’s own tolerance, and a count that is not known
A cheaper product. The floor is the product with the operator. The prediction with a sign is that multiplying by the operator compressed to instead of , with the stopping tolerance left at on the residual of that operator, lowers the floor from 1.49 to between 1.30 and 1.40 and moves the tuned crossing on the easiest matrix from 32 to over 45, while the forward error against the true solution rises to near , so that the extra right-hand sides are bought with exactly the digits the cheaper product gives up.
Right-hand sides whose number is not known. A program that does not know its count can start coarse and tighten. The prediction is that a rule which starts at a tenth and moves to the next staircase edge each time the running total of right-hand sides passes the crossing between two edges stays within 15 per cent of the best fixed choice made with hindsight, at every count from one to five hundred, on both matrices at 512 unknowns, because the envelope is flat near each of its corners and the rule pays at most one wasted setup per edge.
Shares its objects with
Essays that name at least two of the same things, and that neither author linked.
- A preconditioner that arrives past the answer — both name conjugate gradients, flop count, preconditioning
- The penalty for keeping it is a ratio — both name conjugate gradients, flop count, preconditioning
- Where the drift lands — both name conjugate gradients, flop count, preconditioning
- A count that marks the edge and not the pace — both name conjugate gradients, preconditioning
- A guess worth two per cent — both name conjugate gradients, flop count
- A jump is two numbers — both name conjugate gradients, preconditioning
Named objects
A flat tag is an object no other essay names yet.
Conjugate gradientsFlop countHierarchical matrixIterative refinementPreconditioningWoodbury identity