The second right-hand side
Worth reading first: Which pairs are allowed to be small · Where the format starts paying · A parameter that counts steps.
Where the format starts paying drew the first crossover for hierarchical matrices: a solve by the recursive Woodbury identity costs 1.48 times a dense factorisation at 64 unknowns and 0.16 times at 512. The accuracy worth paying for then asked the same format to precondition an iteration, and found total work at its least at a rank-one representation on an easy problem and six decades further along on a hard one. In both, one right-hand side is being solved. That is natural enough, since a single solve is what a benchmark does and what the counter reports. It is not what most programs that keep a representation do.
A representation is kept because the matrix is going to be used again. Boundary integral codes solve for many incident fields against one operator. Interior-point iterations reuse a preconditioner. Anything that estimates a trace or a diagonal hits one matrix with many random probes. Each extra right-hand side is an extra iteration for a method that does not store anything, and it is almost free for one that does. How almost, and when that matters, is the whole question here.
One solve splits into two numbers
The recursive Woodbury solve multiplies by the low-rank factors at each level to build small dense systems, and that work does not depend on how many columns are being solved. Everything else is linear in the columns. So asking the counter for one column, two columns and nine separates the two exactly: a setup , and a cost per right-hand side. The third reading is a check, and on every size and tolerance measured, the count at nine columns equals to within rounding of the arithmetic.
At on the smooth kernel the ratio is 31, 43 and 57 at 128, 256 and 512 unknowns. So the second right-hand side costs about a fifty-eighth of what the first did at the largest size. The representation’s accuracy moves it: at a hundredth, where the ranks are 3 and 4 rather than 10 to 13, the ratio is 12, 16 and 20, because the setup scales with a higher power of the rank.
That is less front-loaded than the factorisation people usually have in mind. A dense factorisation’s setup over one back-substitution is , or 43, 85 and 171, and it grows in proportion to the size. The hierarchical ratio grows from 31 to 57 across the same range, about the 0.45 power of measured between these sizes. Which is to say that the direct hierarchical method is further from being a one-shot method than dense elimination is, by less than one might have guessed. Part of the setup’s cost reappears in the solve, since is itself about twice the storage rather than the storage itself.
A dense factor also has one advantage here that the single-solve comparison hides. Each further right-hand side costs with a dense factor, and at 128 unknowns and that is 16,384 multiplications against the hierarchical solve’s 17,920. So at that size the format’s solve is more expensive per right-hand side than a stored dense factor, and the dense route, whose larger setup is 151,000 more, catches up after 97 right-hand sides. At 256 and 512 the format’s per-solve cost is already below and the crossing does not exist: 48,800 against 65,536, and 124,800 against 262,144. The first crossover has a second one behind it that runs in the opposite direction, and it disappears by 256.
The ratio is the rank times the depth
The three sizes and two tolerances above already hint at something simple, and the four softenings make it possible to check. Across every combination measured, twenty-four of them, the rank of the largest block runs from 2 to 13, the number of levels in the recursion from three to five, and the setup over the slope from 6 to 57. Divide that ratio by the rank times the number of levels and what is left runs from 0.82 to 1.40, and from 0.82 to 1.18 wherever the rank is three or more.
So is close to , and it is a formula with a plain reason behind it. The setup at each level solves for the block’s low-rank factors as if they were extra columns, so a level’s setup costs about times what its right-hand side costs. Summed over all the levels, with the cost per column falling as the blocks shrink but with the number of blocks rising, the total is about the rank times the depth times the cost of one right-hand side. The setup goes with the square of the rank and the slope with the first power: between ranks of 7 and 13 at 512 unknowns the measured exponents are 2.13 and 1.08.
This is what makes the ratio useful. A dense factor’s setup over a solve is one number, , fixed by the size. The hierarchical one is set by a thing that can be read off the representation before any solve is attempted, and it is what the choice of tolerance is really moving. Ask for fewer digits and the rank falls, and with it the number of right-hand sides over which the setup has to be spread. So the format at pays for its setup in twenty right-hand sides, and it reaches that from the far side: its slope is about a third of the tight format’s and its setup an eighth.
It also implies the direction of the extrapolation that this essay’s largest numbers invite. The rank of these blocks grows slowly with the size, and the levels grow by one per doubling. So the setup’s share rises roughly as a logarithm times a slow rank growth, which is the 0.45 power measured across the small range here and is not a true power at all. Ask the question on a kernel whose rank grows faster and the ratio moves with it.
Four routes on one axis
The picture has four routes in it, each now a straight statement of a setup and a slope. The dense factorisation has a setup of 44.7 million and a slope of 262,144 at 512 unknowns. The hierarchical factorisation at has a setup of 7.1 million and a slope of 124,804. Conjugate gradients on the same format has no setup at all, and a slope of 38 steps times 61,440 multiplications for a product, which is 2.3 million. And conjugate gradients preconditioned by a coarse copy of the format, at a hundredth, has a setup of 899,000 and a slope of four steps times the product and the coarse solve, or 423,000.
Read from the left, the order of the four is the reverse of what it will be at the right. For one right-hand side the coarse iteration is cheapest at 1.3 million multiplications, the plain iteration close at 2.3 million, the direct route 7.2 million and the dense factorisation 45 million. By 256 right-hand sides the direct route is cheapest at 39 million, the coarse iteration and the dense factorisation have met near 110 million, and the plain iteration has reached 590 million. The two slopes that started out cheapest are now the most expensive.
The direct route passes the plain iteration at 3.2 right-hand sides. It passes the coarse iteration at 20.8. It never meets the dense factorisation, which runs parallel at a slope about twice as high. The first of those numbers is the one a person would likely guess. The second is the one that matters in practice, because nobody who has built a hierarchical format would run conjugate gradients without using the format as a preconditioner.
Like with like
That comparison would mean nothing if the routes did not deliver the same answer, and a direct route’s answer is set differently from an iteration’s. The representation tolerance fixes the direct route’s error, while the iteration’s error is fixed by a stopping test.
They do agree here, within what the comparison needs. On the easiest matrix the three iterative and direct errors are all between and at every size, and on the softest they run from to . Across these matrices every route is within a factor of 300 of the others on the same problem, and they fall in the same order. The plain iteration is always the least accurate, partly because its product is with the matrix, whose error it has to overcome, and partly because of how large a residual tolerance turns out to be on a soft kernel. The representation at and the iteration’s stopping test at happen to be about the same strength, and a rule like the one the knob that moved two things examined would need to be applied in any real code to set the first from the answer’s required digits.
How the conditioning moves the count
The kernel has a softening parameter, and this field has already met it as the one setting that moves the condition number and the ranks at once. At 256 unknowns, multiplying it by 1, 4, 16 and 64 gives condition numbers of 24, 220, 2,100 and 17,000.
The two iterations respond very differently. Plain conjugate gradients at 512 unknowns goes from 38 steps to 84, 160 and 223 as the softening is multiplied by 1, 4, 16 and 64. The steps rise with the size as well. The coarse format holds it to 4, 5, 7 and 18, and the three sizes lie close together until the softest kernel, and that is the thing a preconditioner is for. And the direct route gets cheaper: the softer kernel has lower ranks, 13, 12, 10 and 7 at 512 unknowns, so its setup falls from 7.1 million to 1.9 million.
So a harder matrix makes both iterations dearer and the factorisation cheaper, and the crossover moves for both reasons.
At 512 unknowns the coarse iteration holds out until 20.8, 13.8, 6.7 and 1.6 right-hand sides as the softening is multiplied. At the softest kernel a code that expects even two right-hand sides should factorise. That spread, a factor of thirteen on one size of matrix with nothing changed but the kernel’s softening, says that “how many right-hand sides justify a factorisation” has no answer that transfers. It is also what the single-solve number could never have shown, since the setup and slope have moved in opposite directions under the same knob.
Size pushes the other way, more slowly. On the easiest kernel the crossing is at 10.3, 15.2 and 20.8 across the three sizes, roughly the square root of the size. The coarse iteration’s step count does not grow at all there, four at each size, so its slope grows like a product, and the setup of the direct route grows a little faster than that slope does. If this continued, a matrix of ten thousand unknowns would need around ninety right-hand sides before the factorisation was worth it, and the size where a block’s rank stops growing is one of the reasons such an extrapolation might well be wrong.
Against the plain iteration the count is 2.3 to 3.2 on the easiest kernel, between one and two at the next softening, and below one on the two softest. So on half of these matrices an unpreconditioned iteration costs more than a factorisation even for a single right-hand side, and on the other half it loses after three. The earlier comparison in the accuracy worth paying for counted a product with the dense matrix rather than the format at each step, since that iteration ran on the true operator; here it runs on the format, at a quarter of the price, and it still loses.
What a code would do with this
The measurements come down to one formula a program can use, which needs only numbers that it can read from its own counter. Take the setup and the slope of the direct route from one solve at one and two columns. Take the slope of the iteration from one solve, with its own steps, and take the setup of its preconditioner. Then the crossing is the difference in setups over the difference in slopes. It takes one iterative solve and one direct solve to compute, and it costs less than either route’s advantage once more than a handful of right-hand sides are expected.
The same arithmetic at a different price is a warning that a count of multiplications is not a time, and that matters directly here. A low-rank product is a tall thin matrix times a vector, a dense leaf is small, and an iteration touches the whole format on every step with almost no chance of reuse, whereas a batched solve of many columns gets the full benefit of what a block size buys. All of that favours the direct route further than the count does, and the size of the effect depends on the machine.
One more cost is not counted at all. The representation has to be built before either iteration or factorisation can use it, and building it is a matter of an SVD per block, or of products alone if the matrix is not available. That cost is shared by every route except the dense one, and it does not change who wins among those.
Where this measurement stops
Everything here is on one family, a smooth kernel with a softening parameter, in one dimension, with a clustered ordering that gives ranks of a dozen or so. A kernel with larger ranks would raise the setup faster than the slope, because the setup goes with a higher power of the rank, and move every crossing to the right. The test that costs what it saves shows how much rank depends on the partition.
The iteration’s preconditioner was fixed at a tolerance of a hundredth rather than optimised for each problem, and the essay on what accuracy is worth has already shown that the optimum moves by six decades, which would reduce the coarse iteration’s costs on the easy matrices and raise them on hard ones. A first right-hand side warm-started from nothing is also what every count here assumes. Sequences of related right-hand sides, in which an iteration starts from a good guess, are a very different economy, and a warm start is degree zero measures that side of it.
And the solver being counted recomputes the setup on each call, because that is how the recursion is written: a program calling it once per right-hand side pays every time, which is the worst of both routes. The factorisation’s whole advantage exists only if the columns arrive together or if the small dense systems are stored. A counter that reads one solve at a time would report that the format has no advantage for many right-hand sides at all.
Still open: right-hand sides that arrive one at a time
Storing what the recursion rebuilds. Keeping the small dense systems and their factors at each level turns the setup into storage. The prediction with a sign is that keeping them raises the stored numbers by less than a factor of two at every size here, that it gives the same once and an within a factor of 1.2, and that the crossing against the coarse iteration is unchanged to within one right-hand side, since a code that batches all its right-hand sides and a code that stores its factors pay the same.
A preconditioner tuned to the count. If the number of right-hand sides is known in advance, the best coarse tolerance depends on it. The prediction is that for one right-hand side the cheapest tolerance on the easiest kernel at 512 unknowns is coarser than a tenth, that for twenty it is near , and that for a hundred it is at or tighter, 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.
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.
- The penalty for keeping it is a ratio — both name condition number, conjugate gradients, flop count, preconditioning
- What a rebuild is worth — both name condition number, conjugate gradients, flop count, preconditioning
- Where the drift lands — both name condition number, conjugate gradients, flop count, preconditioning
- A correction cheaper than the problem — both name condition number, flop count, lu factorisation
- A kept vector buys one iteration — both name condition number, conjugate gradients, preconditioning
- A preconditioner that arrives past the answer — both name conjugate gradients, flop count, preconditioning
Named objects
A flat tag is an object no other essay names yet.
Condition numberConjugate gradientsFlop countHierarchical matrixLU factorisationPreconditioningWoodbury identity