Where the flop count stopped predicting the time

The preconditioner that knew how many

A coarse hierarchical preconditioner set at a hundredth loses to the direct solve after 20.8 right-hand sides on the easiest matrix at 512 unknowns. Choose its tolerance for the count instead and the best is a tenth for one or two, a hundredth for five or ten, 10⁻⁴ for twenty and fifty, and the full accuracy of the direct solve from a hundred on. Every best sits at the coarse edge of a plateau of equal step counts, because steps are whole numbers and nothing else falls as the tolerance tightens. Tuning moves the crossing from 21 to 32, and on the harder matrix from 7 to 16. It does not make the two routes one: the cheapest step of an iteration is a coarse solve and a product with the operator, and the product is half a solve, so the iteration's floor is 1.49 direct solves a right-hand side and it loses from about thirty on, however it is tuned.

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 10−810^{-8} 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 10−310^{-3} for twenty, 10−610^{-6} 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 10−810^{-8} and solves. The iterative route runs conjugate gradients to a relative residual of 10−810^{-8}, multiplying by the operator in its 10−810^{-8} format and preconditioning with a second copy compressed to a coarser tolerance ε′\varepsilon', which now runs over ten values from 0.3 down to 10−810^{-8}. For kk right-hand sides the total is the preconditioner’s setup once, plus kk times the steps times the cost of one product and one coarse solve. All of it is counted in multiplications by the same counter.

The total multiplications for 20 right-hand sides by conjugate gradients preconditioned by a hierarchical solve at tolerance ε′, over the direct solve at 10⁻⁸, against ε′, at 512 unknowns on two matrices512 unknowns, easiest: 1.78 at 0.3, 1.20 at 0.1, 1.10 at 0.03, 0.97 at 0.01, 0.93 at 10⁻³, 0.82 at 10⁻⁴, 0.95 at 10⁻⁵, 1.10 at 10⁻⁶, 1.30 at 10⁻⁷, 1.13 at 10⁻⁸; cheapest 10⁻⁴ at 0.82. 512 unknowns, harder: 5.60 at 0.3, 5.38 at 0.1, 3.66 at 0.03, 2.15 at 0.01, 1.45 at 10⁻³, 1.29 at 10⁻⁴, 1.08 at 10⁻⁵, 1.33 at 10⁻⁶, 1.47 at 10⁻⁷, 1.17 at 10⁻⁸; cheapest 10⁻⁵ at 1.08. Below one the iteration is cheaper than the direct route.-8-7-6-5-4-3-2-100.40.81.21.622.4log₁₀ ε′, the preconditioner's tolerancetotal over the direct route's512 unknowns, easiest512 unknowns, harder512 unknowns · relative residual 10⁻⁸the floor moves and rises
Fig. 1 The total for k right-hand sides through the preconditioned iteration, over the direct solve’s, against the preconditioner’s tolerance, at 512 unknowns on two matrices. The dial sets k.

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 10−410^{-4}, at 0.82: still a fifth cheaper than the direct route, but most of the advantage is gone. At a hundred it is at 10−810^{-8}, 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 10−310^{-3} for two and five, at 10−510^{-5} for ten and twenty, and at 10−810^{-8} from fifty on.

The prediction’s second number, 10−310^{-3} for twenty, is a decade too coarse: 10−310^{-3} costs 13 per cent more there than 10−410^{-4}. Its third, 10−610^{-6} or tighter for a hundred, holds, but the best for a hundred is not 10−610^{-6}. It is two decades tighter still, and the reason is in the next figure.

Steps are whole numbers

The steps conjugate gradients takes to a relative residual of 10⁻⁸ when preconditioned by a hierarchical solve at tolerance ε′, against ε′, on four matrices512 unknowns, easiest: 10 at 0.3, 6 at 0.1, 5 at 0.03, 4 at 0.01, 3 at 10⁻³, 2 at 10⁻⁴, 2 at 10⁻⁵, 2 at 10⁻⁶, 2 at 10⁻⁷, 1 at 10⁻⁸; 512 unknowns, harder: 23.3 at 0.3, 21 at 0.1, 13.3 at 0.03, 7 at 0.01, 4 at 10⁻³, 3 at 10⁻⁴, 2 at 10⁻⁵, 2 at 10⁻⁶, 2 at 10⁻⁷, 1 at 10⁻⁸; 256 unknowns, easiest: 9.3 at 0.3, 6 at 0.1, 5 at 0.03, 4 at 0.01, 3 at 10⁻³, 2 at 10⁻⁴, 2 at 10⁻⁵, 2 at 10⁻⁶, 2 at 10⁻⁷, 1 at 10⁻⁸; 256 unknowns, harder: 18.3 at 0.3, 17 at 0.1, 12 at 0.03, 6.3 at 0.01, 4 at 10⁻³, 3 at 10⁻⁴, 2 at 10⁻⁵, 2 at 10⁻⁶, 2 at 10⁻⁷, 1 at 10⁻⁸.-8-7-6-5-4-3-2-10510152025log₁₀ ε′, the preconditioner's tolerancesteps, mean of three right-hand sides512 unknowns, easiest512 unknowns, harder256 unknowns, easiest256 unknowns, harderthe steps are whole numbersa staircase, flat from 10⁻⁴ to 10⁻⁷
Fig. 2 The steps conjugate gradients takes to a relative residual of 10⁻⁸, preconditioned at each tolerance, on four matrices.

On the easiest matrix at 512 unknowns the steps fall 10, 6, 5, 4, 3 as the tolerance tightens from 0.3 to 10−310^{-3}, then sit at 2 from 10−410^{-4} all the way to 10−710^{-7}, and drop to one at 10−810^{-8}. 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 10−510^{-5} and the same single step at 10−810^{-8}. 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 10−810^{-8} 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 10−410^{-4} rather than 10−310^{-3}: 10−410^{-4} is where the plateau of two steps begins, and 10−310^{-3} is still paying for a third. And it is why the best for a hundred jumps past 10−610^{-6} to 10−810^{-8}: the whole stretch from 10−410^{-4} to 10−710^{-7} 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

The preconditioner tolerance that makes the total cheapest, against the number of right-hand sides, on four matrices512 unknowns, easiest: 0.1 for 1, 0.1 for 2, 0.01 for 5, 0.01 for 10, 10⁻⁴ for 20, 10⁻⁴ for 50, 10⁻⁸ for 100, 10⁻⁸ for 200, 10⁻⁸ for 500; 512 unknowns, harder: 0.01 for 1, 10⁻³ for 2, 10⁻³ for 5, 10⁻⁵ for 10, 10⁻⁵ for 20, 10⁻⁸ for 50, 10⁻⁸ for 100, 10⁻⁸ for 200, 10⁻⁸ for 500; 256 unknowns, easiest: 0.1 for 1, 0.1 for 2, 0.01 for 5, 10⁻⁴ for 10, 10⁻⁴ for 20, 10⁻⁸ for 50, 10⁻⁸ for 100, 10⁻⁸ for 200, 10⁻⁸ for 500; 256 unknowns, harder: 0.01 for 1, 10⁻³ for 2, 10⁻⁵ for 5, 10⁻⁵ for 10, 10⁻⁸ for 20, 10⁻⁸ for 50, 10⁻⁸ for 100, 10⁻⁸ for 200, 10⁻⁸ for 500.00.511.522.5-8-7-6-5-4-3-2-1log₁₀ of the number of right-hand sideslog₁₀ of the cheapest ε′512 unknowns, easiest512 unknowns, harder256 unknowns, easiest256 unknowns, harderten tolerances from 0.3 to 10⁻⁸it tightens in jumps
Fig. 3 The preconditioner tolerance that makes the total cheapest, against the number of right-hand sides, on four matrices.

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 10−410^{-4} for twenty and fifty, and at 10−810^{-8} from a hundred on. It never visits 10−310^{-3}, nor anything between 10−510^{-5} and 10−710^{-7}, 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, 10−310^{-3}, 10−510^{-5} and 10−810^{-8}, 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 10−410^{-4} and at fifty rather than a hundred for 10−810^{-8}. 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 multiplications one more right-hand side costs through the preconditioned iteration at tolerance ε′, over what it costs through the direct solve at 10⁻⁸, against ε′, on four matrices512 unknowns, easiest: 6.74 at 0.3, 4.46 at 0.1, 3.97 at 0.03, 3.39 at 0.01, 2.91 at 10⁻³, 2.16 at 10⁻⁴, 2.33 at 10⁻⁵, 2.52 at 10⁻⁶, 2.75 at 10⁻⁷, 1.49 at 10⁻⁸; least 1.49; 512 unknowns, harder: 17.03 at 0.3, 16.31 at 0.1, 10.99 at 0.03, 6.28 at 0.01, 3.97 at 10⁻³, 3.27 at 10⁻⁴, 2.38 at 10⁻⁵, 2.68 at 10⁻⁶, 2.84 at 10⁻⁷, 1.52 at 10⁻⁸; least 1.52; 256 unknowns, easiest: 6.39 at 0.3, 4.50 at 0.1, 4.08 at 0.03, 3.45 at 0.01, 2.93 at 10⁻³, 2.19 at 10⁻⁴, 2.33 at 10⁻⁵, 2.53 at 10⁻⁶, 2.73 at 10⁻⁷, 1.49 at 10⁻⁸; least 1.49; 256 unknowns, harder: 14.18 at 0.3, 13.67 at 0.1, 10.40 at 0.03, 5.89 at 0.01, 4.10 at 10⁻³, 3.37 at 10⁻⁴, 2.44 at 10⁻⁵, 2.72 at 10⁻⁶, 2.86 at 10⁻⁷, 1.53 at 10⁻⁸; least 1.53.-8-7-6-5-4-3-2-1110¹log₁₀ ε′, the preconditioner's toleranceper right-hand side, over direct512 unknowns, easiest512 unknowns, harder256 unknowns, easiest256 unknowns, harderone step = one product and one coarse solveno tolerance gets under 1.49
Fig. 4 What one more right-hand side costs through the preconditioned iteration at each tolerance, over what it costs through the direct solve, on four matrices.

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 10−410^{-4} and to its least at the single step, 10−810^{-8}, 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 total multiplications for k right-hand sides by three iterative routes, over the direct solve's, against k, at 512 unknowns on the easiest matrixthe plain iteration: 0.32 at 1, 1.50 at 5, 4.82 at 20, 8.67 at 50, 11.82 at 100, 16.65 at 500; preconditioned at a hundredth: 0.18 at 1, 0.39 at 5, 0.97 at 20, 1.65 at 50, 2.20 at 100, 3.05 at 500; preconditioned, tuned to the count: 0.14 at 1, 0.39 at 5, 0.82 at 20, 1.19 at 50, 1.31 at 100, 1.44 at 500. The fixed hundredth crosses the direct route at 20.8 right-hand sides, the tuned one at 32.0, the plain iteration at 3.2.00.511.522.510⁻¹110¹log₁₀ of the number of right-hand sidestotal over the direct route'sthe plain iterationpreconditioned at a hundredthpreconditioned, tuned to the count512 unknowns · tuned crossing at 32tuning moves the crossing, it does not remove it
Fig. 5 The totals of three iterative routes over the direct solve’s, against the number of right-hand sides, at 512 unknowns on the easiest matrix. The vertical line marks where the tuned route crosses.

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 10−510^{-5} 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 10−810^{-8}, 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 10−810^{-8} 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 10−810^{-8} 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 10−610^{-6} instead of 10−810^{-8}, with the stopping tolerance left at 10−810^{-8} 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 10−610^{-6}, 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.

Named objects

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

Conjugate gradientsFlop countHierarchical matrixIterative refinementPreconditioningWoodbury identity