Where the flop count stopped predicting the time

The order the products are taken in

The sparsity field's first essay says the elimination order decides the memory. This is the same sentence about arithmetic: a contraction of several tensors over shared indices has one value and many evaluation orders, and on the inner product of two trains they differ by a factor of two million.

Worth reading first: The same arithmetic at a different price · Two ends of the same arrow · The format that does not notice the dimension.

The sparsity field opens with a sentence: the elimination order decides the memory. A symmetric permutation changes no answer and changes the fill by a factor of eight, so the order is a decision rather than a detail.

This is that sentence about a different resource. A contraction of several tensors over shared indices is an expression with one value and many evaluation orders, and the orders differ by orders of magnitude in arithmetic — with no approximation anywhere and no answer changing at all.

Multiply-adds in three contraction networks, under the cheapest, greedy and dearest evaluation orderEvery bar is an exact count and every order returns the same numbers: nothing is approximated anywhere on this picture. The matrix chain's orders run from 15,125 to 512,793,750, a factor of 3.39·10⁴. The inner product of two trains with 5 cores runs from 3,344 to 6.581·10⁹ — a factor of 1.968·10⁶, because its worst order forms the whole tensor the trains represent. The alternating-least-squares step runs from 105,120 to 113,040, a factor of 1.075, which is the counterweight: on that network the search is not worth running, and nothing about the shape of it says so in advance.chain · cheapest1.51·10⁴chain · greedy5.06·10⁴chain · dearest5.13·10⁸train-inner · cheapest3344train-inner · greedy1.51·10⁴train-inner · dearest6.58·10⁹als-step · cheapest1.05·10⁵als-step · greedy1.13·10⁵als-step · dearest1.13·10⁵multiply-adds, on a logarithmic scaleone value, many priceschain, best ⁄ worst3.4·10⁴train, best ⁄ worst2·10⁶als step, best ⁄ worst1.1worst greedy excess4.5no answer changesand the price does
Fig. 1 Three networks, each under its cheapest, greedy and dearest evaluation order. Every bar is an exact count and every order returns the same numbers.

What is counted

Two tensors contracted over their shared indices cost one multiply-add per entry of the union of their open indices, and the result carries whatever indices are still needed elsewhere. So both quantities this page reports fall out of the label sets alone and neither needs a number to be multiplied:

  • cost, the total multiply-adds over a whole evaluation;
  • peak, the largest intermediate ever held.

An index is closed once every tensor carrying it is inside the group being contracted, and open otherwise. That single rule is the whole cost model, and it is why the exhaustive answer is computable: a dynamic program over the 2^t subsets of the network’s tensors, which is affordable to about twelve of them.

The same arithmetic, twice, with M = 144 words of fast memoryThree counters against the matrix size on logarithmic axes. The operation count is one curve, because both orderings perform exactly the same operations — 338,120 of them at n = 80. The words moved between fast and slow memory are two curves a factor of 3.24 apart. The factorisations they produce are identical to the last bit.10²10³10⁴10⁵matrix size ncountoperations, bothwords, unblockedwords, blocked (b = 6)the answer does not move‖PA − LU‖/‖A‖, unblocked2.8·10⁻¹⁶‖PA − LU‖/‖A‖, blocked2.8·10⁻¹⁶difference between them0the dashed curve is both orderings' operation countthe solid pair is what they cost
Fig. 2 The field’s own reminder about what a count of arithmetic is worth, from the essay that introduces it: three quantities that do not agree about which implementation is faster.

The three networks

A matrix chain. Six matrices with the dimensions 30, 35, 15, 5, 10, 20, 25 — the example every algorithms course uses. Cheapest 15,125; dearest 512,793,750; a factor of 33,900.

The inner product of two trains. Ten cores, five per train, contracted to a scalar. Cheapest 3,344; dearest 6,580,895,744; a factor of 1,968,000. The dearest order contracts all five cores of one train first, which forms the whole tensor the train was representing — the exact object the format exists to avoid — and then does the same to the other.

One alternating-least-squares step. A four-index tensor against three factor matrices. Cheapest 105,120; dearest 113,040; a factor of 1.075.

The third is the counterweight, and it is the finding worth having beside the other two. On that network the search is not worth running, every order is within eight per cent, and nothing about the shape of the network says so in advance. A code that ran an exhaustive search on every contraction would spend more on the search than the search saves, on some networks and not others, and knowing which is itself the problem.

Multiply-adds in three contraction networks, under the cheapest, greedy and dearest evaluation orderEvery bar is an exact count and every order returns the same numbers: nothing is approximated anywhere on this picture. The matrix chain's orders run from 15,125 to 512,793,750, a factor of 3.39·10⁴. The inner product of two trains with 3 cores runs from 1,296 to 4.014·10⁵ — a factor of 309.7, because its worst order forms the whole tensor the trains represent. The alternating-least-squares step runs from 105,120 to 113,040, a factor of 1.075, which is the counterweight: on that network the search is not worth running, and nothing about the shape of it says so in advance.chain · cheapest1.51·10⁴chain · greedy5.06·10⁴chain · dearest5.13·10⁸train-inner · cheapest1296train-inner · greedy2816train-inner · dearest4.01·10⁵als-step · cheapest1.05·10⁵als-step · greedy1.13·10⁵als-step · dearest1.13·10⁵multiply-adds, on a logarithmic scaleone value, many priceschain, best ⁄ worst3.4·10⁴train, best ⁄ worst310als step, best ⁄ worst1.1worst greedy excess3.3no answer changesand the price does
Fig. 3 The same three at three cores per train, where the train’s spread is narrower because its worst order has less to build.
Multiply-adds in three contraction networks, under the cheapest, greedy and dearest evaluation orderEvery bar is an exact count and every order returns the same numbers: nothing is approximated anywhere on this picture. The matrix chain's orders run from 15,125 to 512,793,750, a factor of 3.39·10⁴. The inner product of two trains with 6 cores runs from 4,368 to 8.424·10¹¹ — a factor of 1.928·10⁸, because its worst order forms the whole tensor the trains represent. The alternating-least-squares step runs from 105,120 to 113,040, a factor of 1.075, which is the counterweight: on that network the search is not worth running, and nothing about the shape of it says so in advance.chain · cheapest1.51·10⁴chain · greedy5.06·10⁴chain · dearest5.13·10⁸train-inner · cheapest4368train-inner · greedy2.12·10⁴train-inner · dearest8.42·10¹¹als-step · cheapest1.05·10⁵als-step · greedy1.13·10⁵als-step · dearest1.13·10⁵multiply-adds, on a logarithmic scaleone value, many priceschain, best ⁄ worst3.4·10⁴train, best ⁄ worst1.9·10⁸als step, best ⁄ worst1.1worst greedy excess4.9no answer changesand the price does
Fig. 4 And at six, where the spread has widened again — the only one of the three that moves.

Why this belongs in this field

The field’s premise is that a count of arithmetic stopped deciding which of two implementations is faster about thirty years ago, and every other essay in it measures something else — words moved, messages sent, a block size that is a property of the machine.

This one measures arithmetic, which looks like a step backwards and is not. The point is not that 15,125 multiply-adds take less time than 512,793,750; that is not in doubt and needs no measurement. The point is that both counts describe the same expression, so the arithmetic a computation performs is not a property of what it computes.

That is the same kind of statement as the rest of the field makes, one level up. Blocking says the same multiplications at a different price; this says a different number of multiplications for the same answer. Together they say that neither the count nor the price is fixed by the problem, and a cost model that quotes either as though it were is quoting a decision as a fact.

The order also interacts with everything else the field measures. The cheapest order in arithmetic may hold a larger intermediate, which changes what fits in a fast memory; and on a parallel machine the order decides what can be done at once. Those are not measured here and they are why a real library’s heuristic is not the one this page prices.

The same arithmetic, twice, with M = 400 words of fast memoryThree counters against the matrix size on logarithmic axes. The operation count is one curve, because both orderings perform exactly the same operations — 338,120 of them at n = 80. The words moved between fast and slow memory are two curves a factor of 3.41 apart. The factorisations they produce are identical to the last bit.10²10⁴10⁵matrix size ncountoperations, bothwords, unblockedwords, blocked (b = 11)the answer does not move‖PA − LU‖/‖A‖, unblocked2.8·10⁻¹⁶‖PA − LU‖/‖A‖, blocked2.8·10⁻¹⁶difference between them0the dashed curve is both orderings' operation countthe solid pair is what they cost
Fig. 5 The field’s own three quantities at a larger fast memory, for the reminder that the count on this page is one of several.
Communication for a 512×12 factorisation on 16 processorsTwo counts for the same factorisation. Rounds on the critical path: 48 for the column sweep, 4 for the reduction tree, 4 for Cholesky QR — a factor of n between the first and the other two. Words sent: 1170, 1170 and 2160 — the sweep and the tree send the same number, and the method with the fewest rounds sends the most.rounds on the critical pathHouseholder sweep48reduction tree4Cholesky QR4words sentHouseholder sweep1170reduction tree1170Cholesky QR2160two counts, two rankingsrounds, sweep ÷ tree12words, Cholesky ÷ tree1.8arithmetic, tree ÷ sweep1.5the rounds separate the threeand the words do not
Fig. 6 And the resource a parallel machine actually pays in, which an ordering also decides.

Two rules that sound like the same idea

An exhaustive search is exponential in the number of tensors, so no library runs it. What they run is greedy: pair two operands, repeat.

There are two obvious ways to choose the pair and both are one line.

Pair the two that are cheapest to multiply. Minimise the immediate cost of the contraction.

Pair the two that leave the smallest result. Minimise the size of the intermediate produced.

Both are plausible, both are greedy, and the argument for either is a sentence. Priced against the exhaustive answer over sixty random networks of seven tensors:

rule optimal on median excess worst
cheapest product 1.7% 1.446 25.4
smallest result 50% 1.003 2.76

The second is the rule the libraries ship, and the measurement is what says it is the better one. Nothing about the two descriptions would have separated them; the median excess differs by a factor of a hundred and forty in the deficit.

The spread being searched over is on the same figure: the median network’s best and worst orders differ by a factor of 607, and the worst by 10,590. So a heuristic with a median excess of 1.003 is capturing essentially all of a very large saving.

Two greedy contraction rules against the exhaustive optimum, over 60 random networksEach curve is one rule's excess over the exhaustive answer, sorted, so the horizontal axis is the share of networks at or below that excess. Pairing whichever two operands are cheapest to multiply is optimal on 1.7 per cent of them, has a median excess of 1.446 and a worst case of 25.4. Pairing whichever two leave the smallest result — the rule the libraries ship — is optimal on 50.0 per cent with a median of 1.0026. The upper curve is the spread between each network's own best and worst orders, median 607, which is the size of the thing being searched for.020406080100110¹10²10³10⁴share of networks, per centexcess over the exhaustive orderthe exhaustive orderdashes: each network's own best-to-worst spreadpair by cheapest productpair by smallest resulttwo rules, one line apartby cost, median1.4by cost, worst25by size, median1by size, worst2.8spread, median607both are plausibleand one is thirty times better
Fig. 7 The two rules and the spread they are searching, as sorted curves — the share of networks at or below each excess.
Two greedy contraction rules against the exhaustive optimum, over 120 random networksEach curve is one rule's excess over the exhaustive answer, sorted, so the horizontal axis is the share of networks at or below that excess. Pairing whichever two operands are cheapest to multiply is optimal on 3.3 per cent of them, has a median excess of 1.471 and a worst case of 25.4. Pairing whichever two leave the smallest result — the rule the libraries ship — is optimal on 53.3 per cent with a median of 1.0000. The upper curve is the spread between each network's own best and worst orders, median 558.9, which is the size of the thing being searched for.020406080100110¹10²10³10⁴share of networks, per centexcess over the exhaustive orderthe exhaustive orderdashes: each network's own best-to-worst spreadpair by cheapest productpair by smallest resulttwo rules, one line apartby cost, median1.5by cost, worst25by size, median1by size, worst4.4spread, median559both are plausibleand one is thirty times better
Fig. 8 Twice as many networks, where the medians have not moved and the tails have.

A median is not a worst case

The two columns of that table are different kinds of number and the difference is this field’s own.

The median is knowable from twenty networks. It settles almost immediately, it is what a benchmark reports, and it is what makes a heuristic shippable.

The worst case is not knowable from any finite sample. The cheapest-product rule’s worst of sixty is 25.4, and there is no reason to think a hundred and twenty would not find worse — the figure at 120 networks shows exactly that.

A heuristic that is optimal on 1.7 per cent of networks and within a factor of one and a half on half of them is a good heuristic. A coverage number that reported only the first would say the opposite, and one that reported only the median would hide the tail. Both are quoted here for that reason, which is the same discipline the refutations index applies to this site’s own claims.

Multiply-adds in three contraction networks, under the cheapest, greedy and dearest evaluation orderEvery bar is an exact count and every order returns the same numbers: nothing is approximated anywhere on this picture. The matrix chain's orders run from 15,125 to 512,793,750, a factor of 3.39·10⁴. The inner product of two trains with 4 cores runs from 2,320 to 5.141·10⁷ — a factor of 2.216·10⁴, because its worst order forms the whole tensor the trains represent. The alternating-least-squares step runs from 105,120 to 113,040, a factor of 1.075, which is the counterweight: on that network the search is not worth running, and nothing about the shape of it says so in advance.chain · cheapest1.51·10⁴chain · greedy5.06·10⁴chain · dearest5.13·10⁸train-inner · cheapest2320train-inner · greedy8960train-inner · dearest5.14·10⁷als-step · cheapest1.05·10⁵als-step · greedy1.13·10⁵als-step · dearest1.13·10⁵multiply-adds, on a logarithmic scaleone value, many priceschain, best ⁄ worst3.4·10⁴train, best ⁄ worst2.2·10⁴als step, best ⁄ worst1.1worst greedy excess3.9no answer changesand the price does
Fig. 9 The named networks again at four cores, for the reader wanting the spread on a case rather than a distribution.

The other resource

The cheapest order is not always the leanest one, and the two objectives are two dynamic programs over the same subsets.

Over 120 random networks they disagree on three. Where they disagree the difference is worth having: the cheapest-cost order on the worst of them peaks at 1,188 numbers and the leanest peaks at 396 — a factor of three in memory — for nine per cent more arithmetic.

So the best order is not a well-formed phrase until the resource has been named. That is the same finding the sparsity field’s threshold-pivoting essay reaches about fill against growth, and the same one this field’s blocking essay reaches about operations against words moved: two resources, one decision, and no exchange rate between them that is not a property of the machine.

Three networks in 120 is also worth reporting as a small number. On most networks the two objectives agree, so a code that optimises arithmetic gets the memory for free — which is a convenient fact and not a theorem, and would not have been visible without running both.

Fill against growth as the pivot threshold moves, on the 6×6 gridTwo curves against the pivot threshold on a logarithmic horizontal axis. One falls steeply from left to right; the other rises gently. A vertical line marks the value libraries default to.10⁻³10⁻²10⁻¹1110¹10²10³10⁴pivot threshold τgrowth factor · entries in L+U, ÷ entries in Agrowthfillthe library default‖PA − LU‖/‖A‖ at τ = 0.12.9·10⁻¹⁶growth at τ = 0.138entries in L+U at τ = 0.1372one knob, two measurements, opposite directionsand the default is most of both
Fig. 10 The sparsity field’s version of two resources traded against one decision, from the essay that measures it.
Words moved against the block size, n = 48, M = 100A U-shaped curve on logarithmic axes. Too small a block refactors the panel too often; too large a block does not fit in the fast memory and the tiled update evicts what it is about to read. The minimum is at b = 8, which is √M − 2. The three-line count says √(M/3) = 5, which has the right scaling and the wrong constant.110¹10⁴10⁵block size bwords movedthe count: √(M/3) = 5measured best: b = 8words movedat the best block1.6·10⁴at b = 13.9·10⁴at b = 243.9·10⁴derived from M with no measurement, and scannedthe two agree
Fig. 11 And this field’s, where the resource that decides is the size of a fast memory.

Where the orders come from

It is worth saying what makes the train’s inner product span two million, because the number sounds like an artefact and is not.

Two trains of five cores each, with ranks four and mode sizes eight. Contracting them left to right sweeps a small matrix along the chain: at every step the intermediate carries one rank index from each train, so it is 4 × 4 = 16 numbers, and the whole thing is 3,344 multiply-adds.

Contracting one train’s cores together first builds the tensor it represents: 8⁵ = 32,768 entries, and then the same for the other, and then an inner product of two dense arrays. That is the entire content of the format thrown away by an ordering decision, and the resulting count is 6.6·10⁹.

So the format’s advantage is not a property of the representation alone. It is a property of the representation and the order operations are performed in, and a code that stores trains and contracts them carelessly has a data structure and no algorithm.

Entries against numbers stored, for sin of a sum on 6 points a side, as indices are addedThe upper line is the tensor: 6^d entries, which is a straight line on a logarithmic axis and reaches 46,656 at d = 6. The lower one is the train, which for this family is 4n(d − 1) exactly — 24, 48, 72, 96, 120 — a straight line on a *linear* axis and therefore a logarithm on this one. Its fitted slope against d is 24.0, which is 4n. The two are the same object to within 1.39·10⁻¹⁵, so nothing has been given up: the ratio at d = 6 is 389, and it grows by a factor of n with every index added.123456710¹10²10³10⁴10⁵number of indicesnumbersentries: 6^dstored: 4n(d − 1)exponential against linearentries at d = 64.7·10⁴numbers stored120ratio389slope against d24‖T − T_tt‖ ⁄ ‖T‖1.4·10⁻¹⁵one line is n^dthe other is a constant per index
Fig. 12 The advantage being thrown away, from the field that measures it: storage linear in the number of indices rather than exponential.
Train ranks at each of the 4 cuts of a 5-index tensor on 6 points a side, four familiesCut the index list after position k, put the first k indices on the rows and the rest on the columns, and take the rank of the matrix that results. There are 4 such cuts and each rank is an ordinary matrix rank. sin(x₁ + … + x_d) has rank exactly two at every one of them, for every d, because the addition formula separates it into two terms at every cut — a rank written down rather than measured, and the computed values are 2, 2, 2, 2. The reciprocal family climbs to 9, the product family is one everywhere, and independent normal entries reach 36, which is the largest rank the cut allows. Storage runs sinsum 96, reciprocal 1,206, product 30, noise 10,440 against 7,776 entries.012345061218243036cut after index krank of the reshapesinsum · 2 2 2 2reciprocal · 6 9 9 6product · 1 1 1 1noise · 6 36 36 64 cuts, 4 rankssinsum stored96reciprocal stored1206product stored30noise stored10⁴entries7776one rank per cutand one of them is a theorem
Fig. 13 And the ranks that make the left-to-right sweep small, which is the whole of the cheapest order.

Why an exhaustive search is affordable at all

The dynamic program is over subsets, so it is 2^t states and 3^t transitions — 2,187 for seven tensors and about 60,000 for ten. That is nothing, and it is nothing because t is the number of tensors rather than the number of indices.

The contrast with the sparsity field’s version is worth drawing. Choosing an elimination order optimally is NP-hard in the size of the matrix, which is why that field measures heuristics — minimum degree, nested dissection — against each other rather than against an optimum. Here the optimum is computable for the network sizes that occur, so the heuristics can be priced against the answer rather than against one another.

That is a rare position on this site and it is why this page can say 1.003 rather than the two rules are comparable.

Nonzeros in the Cholesky factor of the 12×12 grid Laplacian, by orderingA horizontal bar chart comparing the number of nonzero entries in the Cholesky factor under four elimination orderings, with reference marks for the matrix itself and for a dense factor.natural1739reverse Cuthill–McKee1354minimum degree1026nested dissection1413matrix: 408 entries · dense factor: 10440bandwidth 12 · 4.26× the matrixbandwidth 12 · 3.32× the matrixbandwidth 123 · 2.51× the matrixbandwidth 108 · 3.46× the matrixn = 144, five-point stencilevery ordering fills in; none avoids it
Fig. 14 The sparsity field’s heuristics, from the essay that ranks them — measured against each other, because the optimum is not available.
The 12×12 grid Laplacian and its Cholesky factor, ordered by naturalTwo square sparsity plots side by side. The left shows the nonzeros of the matrix; the right shows the nonzeros of its Cholesky factor, with the entries created by elimination marked in a second colour.the matrix, lower triangle408 entriesits Cholesky factor1739 entries · 1331 created‖A − LLᵀ‖/‖A‖1.4·10⁻¹⁶fill, symbolic1331fill, numeric1331n = 144 · density 3.2% · bandwidth 12same matrix, renumberedthe answer is identical to rounding
Fig. 15 And what those orderings decide, which is the same decision as this page’s about a different resource.

What a code should actually do

The measurements support a short rule and it is worth stating, because “search the orders” is not implementable and “use the greedy rule” throws away the tail.

Use the smallest-result rule by default. Median excess 1.003 over sixty networks, optimal on half of them, worst case 2.76. It costs t² comparisons per contraction and is essentially free.

Search exhaustively when t is small and the contraction is repeated. A dynamic program over ten tensors is 60,000 transitions, which is nothing compared with one evaluation of the network it is ordering — and inside an iterative method the same network is contracted thousands of times, so the search is amortised to nothing.

Report the spread. The one number that says whether either of the above mattered is the ratio of the worst order to the best, and it is a by-product of the exhaustive search. On the alternating step it is 1.075 and the whole exercise was unnecessary; on the train’s inner product it is two million.

That last is the same recommendation this collection makes about every heuristic it prices: the useful output is not the answer but the answer together with the size of what was being chosen between.

Two greedy contraction rules against the exhaustive optimum, over 40 random networksEach curve is one rule's excess over the exhaustive answer, sorted, so the horizontal axis is the share of networks at or below that excess. Pairing whichever two operands are cheapest to multiply is optimal on 0.0 per cent of them, has a median excess of 1.337 and a worst case of 25.4. Pairing whichever two leave the smallest result — the rule the libraries ship — is optimal on 42.5 per cent with a median of 1.0140. The upper curve is the spread between each network's own best and worst orders, median 639.8, which is the size of the thing being searched for.020406080100110¹10²10³10⁴share of networks, per centexcess over the exhaustive orderthe exhaustive orderdashes: each network's own best-to-worst spreadpair by cheapest productpair by smallest resulttwo rules, one line apartby cost, median1.3by cost, worst25by size, median1by size, worst2.8spread, median640both are plausibleand one is thirty times better
Fig. 16 The spread as a distribution, which is what the third recommendation is asking a code to report per network.

The refusal

The claim under test is the one every expression invites: that a formula with one value has one cost.

The assertion that the cheapest and dearest orders of the matrix chain are within one per cent of each other is fed the pair. It fails by a factor of 33,900.

The refusal is the whole page in one line, and it is worth having in the file rather than in the prose because the claim is not usually stated — it is assumed, by every piece of code that writes a contraction in whatever order the indices came out in.

The file’s other refusals cover the two directions this page could be over-read in. One is fed the sixty random networks and required to refuse the claim that the greedy rule is nearly always optimal, which is the flattering reading and is false at 1.7 per cent. The other is fed the train’s inner product and required to refuse the claim that its cheapest cost is zero — a network whose labels all appear twice has arithmetic to do, and a search that reported none would mean the model had not run.

The generalisation nobody can take

One boundary is worth naming, because it is the reason contraction ordering is a research subject rather than a solved one.

The dynamic program above is exponential in the number of tensors, and it is affordable because the networks that occur in this field have five or ten of them. The networks that occur in quantum many-body simulation and in the analysis of contraction as a model of computation have hundreds, and finding the optimal order for those is NP-hard — by a reduction from treewidth, which is the same quantity the sparsity field’s elimination-order problem turns on.

So the two orderings this page compares are the same hard problem seen twice. A contraction network’s optimal order is a tree decomposition of its index graph, an elimination order for a sparse matrix is a tree decomposition of the matrix’s graph, and the heuristics on both sides are the same family: greedy by degree, nested dissection, simulated annealing.

That is worth the paragraph because it means the sparsity field’s measurements transfer. Its finding that nested dissection loses to minimum degree at every size drawn — 1,413 against 1,026 on a 12 × 12 grid, despite the better asymptotics — is a finding about tree decompositions of small graphs, and the networks here are small graphs.

Nonzeros in the Cholesky factor of the 8×8 grid Laplacian, by orderingA horizontal bar chart comparing the number of nonzero entries in the Cholesky factor under four elimination orderings, with reference marks for the matrix itself and for a dense factor.natural519reverse Cuthill–McKee428minimum degree359nested dissection434matrix: 176 entries · dense factor: 2080bandwidth 8 · 2.95× the matrixbandwidth 8 · 2.43× the matrixbandwidth 49 · 2.04× the matrixbandwidth 48 · 2.47× the matrixn = 64, five-point stencilevery ordering fills in; none avoids it
Fig. 17 That finding at a smaller grid, from the essay that made it: a complexity class losing to a heuristic at every size anyone draws.
Every box a search over [−3, 3]² leaves behind, at a stopping width of 0.05A square divided into rectangles of three kinds. 42 are proved to contain no root at all; 2 are proved to contain exactly one, and each holds one of the two roots at (±√2, ±√2); 0 are undecided. The whole square is covered, and it took 87 evaluations of the operator.grey: proved empty · filled: proved to contain exactly one roota covered squareboxes proved empty42boxes proved unique2undecided0operator evaluations87every rectangle carries a proofand the two crosshairs are where the roots are
Fig. 18 And the combinatorial field’s picture of a search whose branches are pruned by a bound, which is what an exhaustive contraction search becomes past ten tensors.

At other settings

Two greedy contraction rules against the exhaustive optimum, over 20 random networksEach curve is one rule's excess over the exhaustive answer, sorted, so the horizontal axis is the share of networks at or below that excess. Pairing whichever two operands are cheapest to multiply is optimal on 0.0 per cent of them, has a median excess of 1.296 and a worst case of 7.53. Pairing whichever two leave the smallest result — the rule the libraries ship — is optimal on 50.0 per cent with a median of 1.0034. The upper curve is the spread between each network's own best and worst orders, median 810.1, which is the size of the thing being searched for.020406080100110¹10²10³10⁴share of networks, per centexcess over the exhaustive orderthe exhaustive orderdashes: each network's own best-to-worst spreadpair by cheapest productpair by smallest resulttwo rules, one line apartby cost, median1.3by cost, worst7.5by size, median1by size, worst2.8spread, median810both are plausibleand one is thirty times better
Fig. 19 Twenty networks, which is enough for the medians and not for the tails.
Two greedy contraction rules against the exhaustive optimum, over 90 random networksEach curve is one rule's excess over the exhaustive answer, sorted, so the horizontal axis is the share of networks at or below that excess. Pairing whichever two operands are cheapest to multiply is optimal on 1.1 per cent of them, has a median excess of 1.443 and a worst case of 25.4. Pairing whichever two leave the smallest result — the rule the libraries ship — is optimal on 50.0 per cent with a median of 1.0026. The upper curve is the spread between each network's own best and worst orders, median 538.6, which is the size of the thing being searched for.020406080100110¹10²10³10⁴share of networks, per centexcess over the exhaustive orderthe exhaustive orderdashes: each network's own best-to-worst spreadpair by cheapest productpair by smallest resulttwo rules, one line apartby cost, median1.4by cost, worst25by size, median1by size, worst2.8spread, median539both are plausibleand one is thirty times better
Fig. 20 And ninety, for reading how the two curves settle.
Multiply-adds in three contraction networks, under the cheapest, greedy and dearest evaluation orderEvery bar is an exact count and every order returns the same numbers: nothing is approximated anywhere on this picture. The matrix chain's orders run from 15,125 to 512,793,750, a factor of 3.39·10⁴. The inner product of two trains with 3 cores runs from 1,296 to 4.014·10⁵ — a factor of 309.7, because its worst order forms the whole tensor the trains represent. The alternating-least-squares step runs from 105,120 to 113,040, a factor of 1.075, which is the counterweight: on that network the search is not worth running, and nothing about the shape of it says so in advance.chain · cheapest1.51·10⁴chain · greedy5.06·10⁴chain · dearest5.13·10⁸train-inner · cheapest1296train-inner · greedy2816train-inner · dearest4.01·10⁵als-step · cheapest1.05·10⁵als-step · greedy1.13·10⁵als-step · dearest1.13·10⁵multiply-adds, on a logarithmic scaleone value, many priceschain, best ⁄ worst3.4·10⁴train, best ⁄ worst310als step, best ⁄ worst1.1worst greedy excess3.3no answer changesand the price does
Fig. 21 The named networks at the shortest train drawn.
Multiplications in one product with the 3-dimensional Laplacian, assembled against reshapedBoth curves are exact counts rather than estimates. The assembled matrix has n^3 rows, so multiplying by it is n^6 multiplications; applying the 3 one-dimensional factors along their own indices is 3·n^4. The fitted slopes are 6.00 and 4.00 against 6 and 4 exactly. At n = 256 that is 2.81·10¹⁴ against 1.29·10¹⁰, a factor of 2.18·10⁴ — and the ratio is n^2, so it grows with every size rather than settling.10¹10²10²10⁵10⁸10¹¹10¹⁴n, points along one axismultiplicationsassembled: n^6reshaped: 3n^4two exponentsfitted dense slope62d6fitted factored slope4d + 14ratio at n = 2562.2·10⁴nothing is approximatedthe matrix was never anything else
Fig. 22 The tensor field’s version of an ordering decision made once and for all, where applying factors along their own indices is the cheapest order and nothing has to search for it.
Four factorisations of one 512×12 matrix, κ = 7151A ranked bar chart of the departure from orthogonality, on a logarithmic scale. Classical Gram–Schmidt loses 4.6·10⁻¹⁰, modified 1.5·10⁻¹², Householder 2·10⁻¹⁴. The reduction tree, which touches the matrix once instead of 12 times, is of the same size as Householder's — and its error does not grow with the depth of the tree.classical Gram–Schmidt4.62·10⁻¹⁰modified Gram–Schmidt1.49·10⁻¹²Householder, one sweep2.03·10⁻¹⁴reduction tree, 16 leaves1.48·10⁻¹⁵departure from orthogonality, logarithmicthe tree, at four depths‖AᵀA − RᵀR‖/‖AᵀA‖, depth 13.4·10⁻¹⁵‖AᵀA − RᵀR‖/‖AᵀA‖, depth 24.3·10⁻¹⁵‖AᵀA − RᵀR‖/‖AᵀA‖, depth 31.7·10⁻¹⁵‖AᵀA − RᵀR‖/‖AᵀA‖, depth 41.5·10⁻¹⁵the same algebra, four timestwo of them are products of reflections
Fig. 23 This field’s own reordering of an arithmetic that returns the same factorisation, for comparison.
Implied orthogonality of four factorisations of a 256×8 matrixFour curves against the condition number, both axes logarithmic. Cholesky QR's implied orthogonality has a fitted slope of 1.99 and reaches 0.373; the same routine run twice has a slope of 0.96 and reaches 3.75·10⁻⁹, which is where the Householder sweep and the reduction tree are.10²10³10⁴10⁵10⁶10⁷10⁸10⁻¹⁴10⁻¹¹10⁻⁸10⁻⁵10⁻²condition number‖QᵀQ − I‖one passsweeptwicetreewhat the second pass removesfitted slope, one pass2fitted slope, two passes0.96rounds, two passes8rounds, the sweep32one pass squares the condition numberand two do not
Fig. 24 And the version where the reordering buys communication rather than operations.
The arrowhead matrix, eliminated from each endThree sparsity plots. The first shows an arrowhead matrix with a dense first row and column. The second shows its Cholesky factor, completely dense. The third shows the factor obtained after moving the dense row to the end, which has no fill at all.the matrix17 entriestip eliminated first45 entriestip eliminated last17 entries‖A − LLᵀ‖/‖A‖, tip first1.1·10⁻¹⁶‖A − LLᵀ‖/‖A‖, tip last1.1·10⁻¹⁶dense factor is n(n+1)/2 = 45 · sparse factor is 2n − 1 = 17one row swapped to the endnothing numerical chose between them
Fig. 25 The sparsity field’s cleanest picture of one matrix numbered two ways, which is this page’s sentence about memory.
What one symmetric permutation does to the storage, on a matrix it does not changeThe same 256 × 256 matrix, its rows and columns renumbered by one permutation and its columns by the same one. The condition number is 24.3948 either way, to eight digits; the Frobenius norm is 6139.964 either way, to twelve. Nothing a norm can see has moved. Clustered, the partition stores 27,008 numbers. Shuffled, the admissibility test finds no admissible pair anywhere — every cluster of a shuffled numbering spans the whole interval, so every q is infinite — and the format degenerates to dense storage exactly. The rule with no test to fail does worse than that: it compresses every off-diagonal block regardless, gets ranks up to 119 out of 128, and stores 118,208 numbers — 1.80 times the matrix it was compressing. A rank-119 factorisation of a 128-column block is a more expensive way to write down the block than the block.numbers stored, 256 × 256clustered, strong27,008clustered, weak24,064the dense matrix65,536shuffled, strong65,536shuffled, weak118,208the same matrix, twiceκ, clustered24κ, shuffled24‖A‖_F, clustered6140‖A‖_F, shuffled6140shuffled weak ⁄ dense1.8the compressibility is in the numberingand the numbering is not in the matrix
Fig. 26 And the hierarchy field’s, where a numbering that no norm can see decides a representation’s size.
The largest train rank of a 5-index reciprocal tensor against the accuracy asked forEvery point is a decomposition that met its tolerance: the measured errors are 0.0041, 4.2·10⁻⁴, 3.4·10⁻⁵, 3.3·10⁻⁷, 5.7·10⁻⁹, 6.6·10⁻¹², 1.6·10⁻¹³ against tolerances of 10⁻², 10⁻³, 10⁻⁴, 10⁻⁶, 10⁻⁸, 10⁻¹⁰ and 10⁻¹². The rank runs 3, 4, 5, 7, 8, 10, 11 and the storage 264, 448, 680, 1,160, 1,664, 2,208, 2,504, against 32,768 entries. That is 0.80 of rank per decade of accuracy over the whole range — a constant, with no cliff and no regime where a digit costs more than the last one, which is the same shape the hierarchy field measured for a kernel matrix and is not something either field's geometry promises.-13-11-9-7-5-3-1024681012log₁₀ of the accuracy asked forlargest train rank0.80 of rank per decadea cost that is typed inentries3.3·10⁴stored at 10⁻²264stored at 10⁻¹²2504rank per decade0.8worst error ⁄ tolerance0.57the storage is chosena constant of rank a decade
Fig. 27 What the format costs at a given accuracy, for the reader pricing a whole computation rather than one contraction.

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.

Alternating least squaresBlock methodsContraction orderElimination orderFill-reducing orderingFlop countKhatri–Rao productMemory hierarchyTensor networkTensor train