When the index is a tuple

A chain grown from its ends gets lost

A tensor of eight indices in train format stores 72 numbers in one order and 8,322 in another, and a greedy chain built from cheap pairwise slices had found the good order on every tensor tried. Searching all 20,160 orders confirms that 72 and 180 are the true least on the two earlier tensors. But on a tensor of two pairs and a chain of four, placed on the indices six different ways, the least is 108 every time and the greedy chain finds it on three placements and stores 396 on the other three. The six are one tensor with its indices renamed, so the chain's success depended on the names. A rule that links the strongest couplings into paths, from the same table, finds 108 on all six.

Worth reading first: The format that does not notice the dimension · A block nobody can call sparse · A model that is a rational function.

The order of the indices is not free wrote one tensor of eight indices, each taking three values, in train format in several orders. Every rank in a train is the rank across one cut, between the indices to the left of it and those to the right, so which indices are written next to which decides the ranks. A tensor made of four couplings between separated pairs stored 8,322 numbers in its natural order and 72 with each pair side by side. A median random order stored 1,584. And a greedy chain built from a table of pairwise slices, one small matrix per pair of indices read through a fixed base point, found the cheap order on all three of its tensors from under a twentieth of the entries.

The orders it called best had been chosen by construction and then confirmed by the chain. So the essay signed two predictions. An exhaustive search across all 8!/28!/2 orders would find nothing below 72 on the pairs and nothing below 180 on a shuffled chain of seven couplings, so that those are true minima. And on a mixed tensor, two pairs and a chain of four, the greedy order would be within a factor of two of the true least.

The question is an old one in a new format. The same matrix numbered twice found a hierarchical matrix’s off-diagonal ranks, and so its whole cost, decided by how its rows were numbered, with nothing about the operator changed. A train is more exposed to the same choice, because its cores multiply the ranks on both sides of them, so one coupling placed badly is paid for at every cut it crosses rather than once. And a Tucker format, which a decomposition made only of SVDs built from one unfolding per index, has no order to choose at all: every index is cut from the rest separately, which is its advantage and the reason its core grows as the product of all the ranks.

The search is affordable because the rank across a cut depends on the set of indices to its left and not on their order. Eight indices have at most 128 such sets up to complement, so every one of the 20,160 orders, an order and its reverse being the same train, is read from 128 numerical ranks computed once.

The two minima are true

Every order of eight indices of one tensor in train format, four separated pairs: the share of the 20,160 orders that store at most a given number of entries, with the least, the greedy chain's and the median markedfour separated pairs: least 72 entries, reached by 192 orders; within twice the least, 192; median 1,584; most 8,322. The greedy chain stores 72 and the linked paths 72.10²10³10⁴0255075100entries storedper cent of orders at or belowshare of orderslines at the least, the greedy chain and the medianthe best orders are a sliver
Fig. 1 The share of all 20,160 orders that store at most a given number of entries, with vertical lines at the least, at the greedy chain’s storage and at the median. The dial sets the tensor.

On the four separated pairs the least over every order is 72 entries, as predicted, and 192 orders reach it. None stores between 72 and 144; the next level up is far above, and the median is 1,584. On the shuffled chain the least is 180, as predicted, reached by four orders only, and 32 orders store within twice it. The worst order of either tensor stores 8,322, more than the 6,561 entries of the array itself. The first half of the prediction holds exactly, and the greedy chain sits at the least on both.

The count of best orders is worth a moment. A tensor of four independent pairs has 4!=244! = 24 ways to order the pairs and 24=162^4 = 16 ways to orient them, 384 orders, which is 192 once a train and its reverse are identified. Every one of them stores 72, and nothing else does. So the best order is not a point but a class, and the class is exactly the set of orders that keep each coupling’s two indices adjacent. The shuffled chain has only its two directions and two near-equivalents, because a chain of seven couplings can be laid down without crossing in very few ways.

The least, median and largest storage over all 20,160 orders of three tensors in train format, with how many orders reach the leastfour separated pairs: least 72 by 192 orders, median 1584, most 8322; a shuffled chain: least 180 by 4 orders, median 3252, most 8322; two pairs and a chain, shuffle 1: least 108 by 96 orders, median 1908, most 8322.1001,00010,000four separated pairsthe least over every order72the median order1,584the worst order8,322a shuffled chainthe least over every order180the median order3,252the worst order8,322two pairs and a chain, shuffle 1the least over every order108the median order1,908the worst order8,322entries storedthe array itself is 6,561 entriesseventy-two and 180 are minima
Fig. 2 The least, median and worst storage over all 20,160 orders of three tensors: four separated pairs, a shuffled chain, and two pairs and a chain of four.

The mixed tensor’s least is 108 entries, reached by 96 orders, with a median of 1,908. It is cheaper than the chain because it has fewer couplings and dearer than the pairs because one coupling more must cross a cut somewhere. Ninety-six is more than the 24 arrangements of the three pieces and their orientations, because a cut with a single index on one side has rank at most three whatever crosses it: near either end of the train, an index can sit one place away from its partner at no cost, and the extra orders are those swaps.

The greedy chain misses on half of one tensor

The mixed tensor is one tensor, but its pieces can sit on the eight indices in many ways. Six shuffles place the two pairs and the chain of four on six different sets of index names. Since renaming the indices only renames the orders, each of the six has the same least, 108, reached by the same number of orders, and the same distribution of storage over all 20,160. The greedy chain reads the slice table and builds an order on each.

Storage of the order each of two rules builds from the same slice table, the greedy chain and the linked paths, against the exhaustive least and the shortest path over the subsets of indices, on eight tensorsfour separated pairs: least 72, greedy 72, paths 72, subset path 72; a shuffled chain: least 180, greedy 180, paths 180, subset path 180; two pairs and a chain, shuffle 1: least 108, greedy 396, paths 108, subset path 108; two pairs and a chain, shuffle 2: least 108, greedy 108, paths 108, subset path 108; two pairs and a chain, shuffle 3: least 108, greedy 108, paths 108, subset path 108; two pairs and a chain, shuffle 4: least 108, greedy 396, paths 108, subset path 108; two pairs and a chain, shuffle 5: least 108, greedy 396, paths 108, subset path 108; two pairs and a chain, shuffle 6: least 108, greedy 108, paths 108, subset path 108.50100200500four separated pairsleast72greedy chain72linked paths72shortest path over the subsets72a shuffled chainleast180greedy chain180linked paths180shortest path over the subsets180two pairs and a chain, shuffle 1least108greedy chain396linked paths108shortest path over the subsets108two pairs and a chain, shuffle 2least108greedy chain108linked paths108shortest path over the subsets108two pairs and a chain, shuffle 3least108greedy chain108linked paths108shortest path over the subsets108two pairs and a chain, shuffle 4least108greedy chain396linked paths108shortest path over the subsets108two pairs and a chain, shuffle 5least108greedy chain396linked paths108shortest path over the subsets108two pairs and a chain, shuffle 6least108greedy chain108linked paths108shortest path over the subsets108entries storedthe six mixed tensors are one tensor relabelledthe chain's luck is the labels'
Fig. 3 The storage of the order each of two rules builds from the same table of pairwise slices, the greedy chain and the linked paths, against the least over every order, on the two earlier tensors and six placements of the mixed one.

On shuffles 2, 3 and 6 the greedy chain stores 108, the least. On shuffles 1, 4 and 5 it stores 396, three and two-thirds times the least. The prediction of a factor of two fails on half of the placements, and it fails on a tensor whose six placements are the same problem. Nothing about the couplings differs between a shuffle the chain gets right and one it gets wrong; only the labels on the indices do, and those enter the chain through the order in which it breaks ties between couplings of equal strength.

Every coupling here is the same function, 1/(1+x+y)1/(1 + x + y), so the slice table holds five entries of the same size, one for each coupling, and twenty-three near zero. The greedy rule starts at the strongest pair in the table, and with five equal candidates the first in index order wins. When that is one of the chain’s three couplings, the chain grows correctly in both directions, finishes, and then appends the pairs. When it is one of the two separated pairs, there is nothing coupled to either end of it, the rule picks the strongest of the near-zero entries, and it attaches an index from the middle of the chain of four. From then on the chain’s other couplings can only be reached through an end, and one of them never is.

What the lost chain costs at each cut

The rank across each of the seven cuts of one mixed tensor of two pairs and a chain of four, in the order the greedy chain builds and in the order the linked paths buildGreedy chain, order 0, 4, 1, 2, 6, 3, 5, 7: ranks 3, 3, 9, 3, 9, 3, 3, storing 396. Linked paths, order 0, 4, 5, 7, 1, 2, 6, 3: ranks 3, 3, 3, 1, 3, 1, 3, storing 108.12345670246810cut, between the first k indices and the restrank across the cutgreedy chainlinked pathsrank three is one coupling crossingnine is two
Fig. 4 The rank across each of the seven cuts of the mixed tensor on its first shuffle, in the order the greedy chain builds (red) and the order the linked paths build (blue).

On the first shuffle the greedy chain’s order is 0, 4, 1, 2, 6, 3, 5, 7. The couplings are the pairs (1, 2) and (3, 6) and the chain 0–4–5–7. Its ranks across the seven cuts are 3, 3, 9, 3, 9, 3, 3. Each coupling has rank three, so a cut crossed by one coupling has rank three and a cut crossed by two has rank nine, and the chain’s link from 4 to 5 crosses every cut between positions two and six, where it meets each of the two pairs in turn. The linked paths’ order, 0, 4, 5, 7, 1, 2, 6, 3, has ranks 3, 3, 3, 1, 3, 1, 3: the chain first, then each pair, with a rank of one at each cut between pieces because nothing crosses it.

This is the arithmetic that the format that does not notice the dimension introduced, applied to a bad order: storage is a sum over cores of the product of the ranks on either side, so the two cuts at rank nine cost far more than their share, and 396 against 108 is the price of one coupling stretched across two others.

Linking couplings into paths

A rule that cannot get lost has to treat the couplings as what they are, edges of a graph on the indices, and lay the graph down without crossing. That is a known problem in another form: an order in which each index’s strongest couplings are its neighbours is a path through the graph, and a set of pieces is a set of paths. The rule used here is the obvious greedy for that: take the couplings strongest first, keep one unless it would give an index a third neighbour or close a loop, and finally lay the resulting paths end to end in any order. It reads exactly the same slice table as the chain.

It finds the least on all eight tensors: 72 on the pairs, 180 on the shuffled chain and 108 on every placement of the mixed one. It cannot be misled by a tie in the way the chain is, because it never commits to an end; a pair accepted first is simply a finished path of two, and the chain’s couplings join each other whenever they are reached. Its order on the first shuffle, the one drawn above, puts the chain of four first and the pairs after it, which is one of the 96 best orders.

There is a strong resemblance here to choosing an elimination order for a sparse matrix. The least fill there is measured a minimum-degree ordering against the true least fill on graphs small enough to search, and eliminating a vertex is a graph operation is the reason an ordering problem on a matrix becomes one on a graph. In both settings a local rule built for the easy cases is right on many inputs and wrong on others that differ from them only in labelling, and a search small enough to be exhaustive is the only way to tell which is which.

The exhaustive reading suggests something stronger than either rule. The storage of a train is a sum over its cores, and the core between the cut after the first kk indices and the cut after the first k+1k + 1 costs r(S) n r(S∪{j})r(S)\,n\,r(S \cup \{j\}), where SS is the set of indices to the left and jj the next one. That cost depends on two sets and on nothing about the order inside them. So the least storage over every order is a shortest path through the subsets of the indices, from the empty set to the full one, adding one index at each step, with the cost of each step read from two ranks. At eight indices that is 256 subsets and 2,048 steps against 20,160 orders, and the 254 nonempty proper subsets are the unfoldings the memo already held.

The shortest path gives the exhaustive least on all eight tensors: 72, 180 and 108 six times. It is exact rather than heuristic, and its cost grows as 2dd2^d d rather than as d!/2d!/2, so at twelve indices it is 49,152 steps against 240 million orders, and at sixteen about a million against 101310^{13}. The price that does grow is the unfoldings: each of the 2d2^d subsets needs one numerical rank of a matrix with up to nd/2n^{d/2} rows, which at sixteen indices of three values is a matrix of 6,561 by 6,561 for the balanced cuts. A slice table of pairs reads under a twentieth of the tensor; the subset path reads every unfolding, which is the whole tensor many times over. So the two are not competitors at scale. The slice rules are what a code can afford on a tensor too large to hold, and the subset path is what says, on a tensor small enough to hold, whether a slice rule was right.

How rare a good order is

The share of all 20,160 orders of each tensor that store no more than twice the leastfour separated pairs: 192 orders, 0.95 per cent; a shuffled chain: 32 orders, 0.16 per cent; two pairs and a chain, shuffle 1: 288 orders, 1.43 per cent.0.010.1110four separated pairs0.95%a shuffled chain0.16%two pairs and a chain, shuffle 11.43%per cent of orders within twice the leasta random order is almost never neara rule has to be right, not lucky
Fig. 5 The share of all 20,160 orders of three tensors that store no more than twice the least.

The other reason the search matters is the scale of what a rule is choosing among. On the pairs, 0.95 per cent of orders are within twice the least, and all of those are at the least. On the chain it is 0.16 per cent, 32 orders. On the mixed tensor 1.43 per cent, 288 orders. A random order is within a factor of two of the least about once in a hundred tries at best, and the median order stores ten to twenty times the least. A rule that is right on half its inputs and a factor of four out on the rest is far better than chance, and that is the reason a greedy chain looked so good on the three tensors it was first tried on. It is not the same as a rule that is right.

Five indices are cheaper than two found that reshaping a matrix into more indices can lower its cost dramatically; the price of that advice is an order to choose, and the chance of a good one by accident falls as the indices multiply. Eight indices give 20,160 orders. Twelve give about 240 million, and at that size no search is exhaustive and every claim about a rule is a claim about the cases it was tried on.

What this measured and what it did not

Every tensor here is a product of couplings between pairs of indices, all with the same smooth function, on a grid of three points per index, with ranks read at a relative tolerance of 10−810^{-8}. That is the setting in which the slice table is clean: five large entries and twenty-three small. With couplings of different strengths, ties would be rare and the greedy chain’s choice of starting pair would be decided by strength rather than by labels; whether it then finds the least more often is a separate measurement and was not made. Couplings of more than two indices at once, which no pairwise slice can show, were not tried, and the earlier essay’s first open question about them stands.

The tolerance matters too, and in a known direction. The digit that costs more than the tensor found that each crossing coupling is charged again for every digit asked of the train, so a bad order’s penalty over a good one grows as the tolerance tightens. With three points per index a coupling’s rank cannot exceed three, so on these tensors the tolerance has nothing left to charge and the ratio of 396 to 108 holds at any tolerance below 10−810^{-8}. On a finer grid each coupling’s rank would rise with the digits asked, and a cut where two couplings cross pays the product of the two, so a bad order’s penalty would grow with the accuracy as well as with the number of couplings it stretches.

The path rule is a greedy rule as well. It is right on all eight tensors here, which are made of paths, and a tensor whose coupling graph is a tree with a branch, or a cycle, cannot be laid down as paths without some coupling crossing cuts; what the rule does then is open. What is firm is that 72 and 180 are minima, that the best orders are classes of 192, 4 and 96 rather than single orders, and that the earlier chain’s success on its three tensors was in part the luck of its labels.

Still open: a branch, and couplings of unequal strength

A coupling graph with a branch. Take three couplings meeting at one index, a star, plus a pair elsewhere. No order keeps all three of the star’s couplings adjacent, so at least one crosses a cut. The prediction with a sign is that the exhaustive least then puts the star’s centre between two of its leaves with the third leaf adjacent on one side, so that one coupling crosses exactly one extra cut, and that the path rule, which must drop one of the star’s couplings to keep degrees at two, finds that least on every placement, while the greedy chain is within twice it on fewer than four of six.

Unequal strengths. Give the five couplings of the mixed tensor strengths spread over a factor of ten, so that the slice table has no ties. The prediction is that the greedy chain then succeeds exactly on the placements where the strongest coupling belongs to the chain of four, three in five of random strength assignments, and that the path rule succeeds on all, so that removing the ties removes the dependence on labels and leaves the dependence on which piece happens to be strongest.

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.

Fill-reducing orderingGreedy algorithmLow-rank approximationNumerical rankTensor trainUnfolding