Where the flop count stopped predicting the time

The prefix sits further down

A beam over contraction orders cuts twice at every level — once among the pairings out of each partial order, ranked by the size of their result, and once among the partial orders that survive, ranked by their cost so far — and one tolerance had been widening both. Measured separately, the exhaustive order's pairing is the size ranking's first choice on 34 of 60 seven-tensor networks; its prefix sits a median factor of 2.3 above the cheapest prefix on offer, and needs more room than its pairing on 49. So the width belongs at the order cut, as predicted. What was not predicted is the other half: widening the pairing cut alone is worse than not widening at all, because it hands the cost-so-far ranking more chances to choose a cheap-first prefix.

Worth reading first: The order the products are taken in · A beam ranked on what remains · The problem that arrives again.

A near-tie is a factor of four changed how a beam search over tensor-contraction orders spends its width. A beam keeps a few partial orders — some of the tensors already paired, the rest still open — and extends each by every pairing it could make next. It cuts twice at every level: out of each partial order it keeps the pairings whose results are smallest, and out of all the partial orders those pairings produce it keeps the ones whose cost so far is lowest. The earlier beams had a fixed width at each level. The essay gave it a tolerance instead — keep every candidate within a factor 1+τ1 + \tau of the best — and found that a near-tie is the wrong idea of uncertainty. A tolerance of a quarter changed nothing; the useful τ\tau was two or three, and with it the beam found the exhaustive order on 46 of 60 seven-tensor networks.

That tolerance was one number applied at both cuts. The essay measured how far down the pairing ranking the exhaustive order’s own pairing sits, level by level, and found a factor of two to four. It did not measure the other cut, and said so with a prediction: the partial-order cut “may be the one that needs the wider tolerance: the dear-first prefix is dear by the cost of its first pairing, which can be many times the others’.” Split τ\tau in two, find each one’s smallest useful value separately, and the measurement “would tell which of the two cuts was losing the exhaustive order”.

It does tell, and the answer is the one predicted. The surprise is in the half of the grid nobody was asked about.

Two rankings, two gaps

The networks are the earlier essays’: seven or nine tensors on random index graphs, eight distinct index labels, dimensions between two and twelve, sixty networks at seven and forty at nine, each with its exhaustive order computed by dynamic programming over every subset. The beam is the same machine with one change: the pairing cut keeps every pairing whose result is within 1+τpair1 + \tau_{\text{pair}} of the smallest, the order cut keeps every partial order whose cost so far is within 1+τorder1 + \tau_{\text{order}} of the cheapest, and both are capped at sixteen as before.

The first measurement needs no beam at all. Follow the exhaustive tree level by level. At each level, two numbers say how far down each ranking the exhaustive order’s next move sits: its pairing’s result size over the smallest result on offer, and its prefix’s cost so far over the cheapest prefix one pairing on from the same place. The largest of each along the walk is the 1+τ1 + \tau that cut needs to keep the exhaustive order in reach.

For every random network, the factor by which the exhaustive order's choice sits below the beam's best at the pairing cut and at the partial-order cut — the 1 + τ each cut needs to keep the exhaustive order — at seven and nine tensors7 tensors, 60 networks: median need 1.00 at the pairing cut and 2.33 at the order cut; the order cut needs more on 49. 9 tensors, 40 networks: median need 1.50 at the pairing cut and 3.20 at the order cut; the order cut needs more on 33. Points above the diagonal need the wider tolerance at the order cut.110¹110¹need at the pairing cut, 1 + τneed at the order cut, 1 + τ7 tensors9 tensorsdashed: the same need at both cutsthe prefix sits further down than the pairing
Fig. 1 Every network’s needed factor at the pairing cut against its needed factor at the order cut, seven tensors in blue and nine in red. Points above the dashed diagonal need more room at the order cut.

At seven tensors the exhaustive pairing is the size ranking’s first choice at every level on 34 networks of 60, and the median need at the pairing cut is exactly one. The median need at the order cut is 2.33. On 49 networks the order cut needs more room than the pairing cut; on most of the rest they need the same. At nine tensors the pairing cut needs a median of 1.50 and the order cut 3.20, and the order cut needs more on 33 of 40. The cloud sits above the diagonal in both colours, most of it in a column at a pairing need of one.

So the reading the earlier essay took from its pairing walk — the exhaustive pairing is a factor of two to four down the ranking — was a reading of the hard networks at the size ranking’s cut, the ones it walked because the beam failed them. Over the whole ensemble the size ranking is usually right about the next pairing. What it cannot be right about is the order in which the cheap pairings are taken relative to an expensive one, and that decision is made at the other cut.

Why the prefix sits further down

The reason is the one the prediction gave, and the walk makes it concrete. The exhaustive order on a typical network pays for one expensive pairing early — joining two tensors whose shared indices are small and whose free indices are large — because that pairing removes an index everything later would otherwise carry. At the level it takes that pairing, its prefix is dearer than the alternatives by the whole cost of that pairing, and the alternatives are prefixes that took a cheap pairing instead and will pay more later. Ranked by cost so far, the exhaustive prefix is not near the top; it is a factor of two or three down, at the level where it spent.

The walk locates the expense. The level at which the order cut’s need is largest is the first or second on 43 of the sixty seven-tensor networks and on 28 of the forty nine-tensor ones, and at that level the exhaustive order’s pairing is the size ranking’s own first choice on 41 networks of 60 and 23 of 40. So the typical failure is not that the beam never considers the right pairing. It is offered first, at the second level, by the ranking whose job is to offer it — and the next cut throws it away because it was the dearest thing anyone had done so far. A ceiling is not a target priced orders against a memory limit and found the cheapest order often peaks early; this is the same early peak, seen by a ranking that reads it as waste.

The size ranking at the pairing cut does not have that problem, because it does not look at what was spent. A pairing whose result is small is one that contracts a lot away, and the exhaustive order’s pairings are, level by level, mostly the ones that do that. A beam ranked on what remains attacked the same weakness from the other side by adding an estimate of the remaining cost to the cost so far; this measurement says where its estimate was needed, and it is at exactly the cut where a cost-so-far ranking is blind.

The share of networks whose exhaustive order stays within reach of each cut of the beam, against the tolerance, at seven and nine tensors7 tensors, pairing cut: 57%, 67%, 75%, 83%, 90%, 92%, 95%, 98%; 7 tensors, order cut: 5%, 12%, 22%, 43%, 70%, 80%, 90%, 97%; 9 tensors, pairing cut: 33%, 43%, 53%, 68%, 73%, 80%, 93%, 93%; 9 tensors, order cut: 0%, 0%, 0%, 10%, 45%, 63%, 80%, 88% at τ = 0, 0.25, 0.5, 1, 2, 3, 5, 8.020406080100tolerance τnetworks in reach, per cent00.250.5123587 tensors, pairing cut7 tensors, order cut9 tensors, pairing cut9 tensors, order cutin reach: the cut's need is within 1 + τ at every levelthe order cut needs a factor of three
Fig. 2 The share of networks whose exhaustive order stays in reach at each cut, against the tolerance: seven tensors at the pairing cut and the order cut, and nine tensors at both. The pairing cut has most networks in reach at τ = 0; the order cut needs a factor of three.

The reach figure turns the walk into the quantity a beam’s designer would choose by. At τ=0\tau = 0 — only exact ties kept — the pairing cut keeps the exhaustive order in reach on 57 per cent of seven-tensor networks and the order cut on 5 per cent. To keep it in reach on 70 per cent the order cut needs τ=2\tau = 2; the pairing cut needs a half. At nine tensors the order cut keeps none in reach until τ=1\tau = 1, and 45 per cent at 2.

Spend the width where it is needed

How many of 60 random 7-tensor networks a tie-widened beam contracts in the exhaustive order, for every pair of tolerances at its two cuts, with the pairings each pricedRows: the tolerance on the pairing cut, ranked by result size; columns: the tolerance on the partial-order cut, ranked by cost so far; each cell the networks solved exactly and, beneath, the mean pairings priced. With no widening, 31; one tolerance of 2 at both cuts, 46 for 150; the cheapest cell reaching as many has a pairing tolerance of 0.5 and an order tolerance of 8, at 98. Widening only the pairing cut to 8: 4. Widening only the order cut to 8: 35.0316032613261326234633464356435650.25316131663468347138733975417641770.52660286832763380418843914595469812162237429863310343117461244913251136214621775259033116461504916753178551863136214762294321264517048198522135422157631178181013114945207482405227054280846498418113321694623849275533125333800.250.512358τ for partial orders, ranked by cost so farτ forpairingscell: networks solved exactly · beneath: pairings pricedthe order cut needs the room
Fig. 3 Networks contracted in the exhaustive order (bold) and mean pairings priced (beneath) for every pair of tolerances: rows the pairing cut, columns the order cut. Shading groups the counts. The dial sets the number of tensors.

The grid is the measurement the earlier essay asked for. Its diagonal is the single tolerance: 31 networks at τ=0\tau = 0, 46 at τ=2\tau = 2 for 150 pairings priced, 53 at τ=8\tau = 8 for 338. Read along a row instead, and the cost of the same success falls. With the pairing cut at 0.5 and the order cut at 8, the beam finds 46 networks for 98 pairings; with the pairing cut at 1 and the order cut at 8, 51 networks for 136. Both beat the single τ\tau of two at both cuts, one for two thirds of its work and the other for less.

At nine tensors, which the dial shows, the pairing cut is not free: the walk said it needs a median factor of one and a half, and the best cells are at τpair\tau_{\text{pair}} of 0.5 to 1 with the order cut at 3 to 8 — 25 networks of 40 at (1, 5) for 510 pairings, where the single τ\tau of three found 19 for 743. Holding the pairing cut at zero, the order cut alone reaches only 14.

So the prediction holds in its own terms. The order cut is the one that was losing the exhaustive order, and its smallest useful tolerance is two to three; the pairing cut’s is a half to one.

The half of the grid nobody asked about

The prediction did not say what happens in the lower-left corner — the pairing cut widened and the order cut not — and on the reasoning that more candidates can only help, it should have been no worse than the top row. It is the worst region of the grid.

The median cost of the beam's order over the exhaustive order's, as the pairing cut's tolerance grows, with the partial-order cut held at zero and at eight, at seven and nine tensors7 tensors, orders at 0: 1.000, 1.000, 1.016, 1.042, 1.096, 1.137, 1.235, 1.446; 7 tensors, orders at 8: 1.000, 1.000, 1.000, 1.000, 1.000, 1.000, 1.000, 1.000; 9 tensors, orders at 0: 1.030, 1.036, 1.071, 1.130, 1.216, 1.359, 1.556, 1.733; 9 tensors, orders at 8: 1.008, 1.003, 1.000, 1.000, 1.000, 1.002, 1.004, 1.016, at a pairing tolerance of 0, 0.25, 0.5, 1, 2, 3, 5, 8.tolerance on the pairing cutmedian cost over the exhaustive order's00.250.5123581.01.21.41.61.87 tensors, orders at 07 tensors, orders at 89 tensors, orders at 09 tensors, orders at 8sixty and forty random networksmore choice for the worse ranking
Fig. 4 The median cost of the beam’s order over the exhaustive order’s as the pairing cut’s tolerance grows, with the order cut held at zero and at eight, at seven and nine tensors.

With the order cut at zero, widening the pairing cut from nothing to 0.5, 1, 2, 3, 5 and 8 reduces the seven-tensor networks solved from 31 to 26, 21, 14, 13, 7 and 4, and raises the median excess from exactly one to 1.016, 1.042, 1.096, 1.137, 1.235 and 1.446. At nine tensors the networks solved fall from 12 to 1 and the median rises from 1.030 to 1.733. A beam that keeps more pairings and the same number of partial orders does worse than a beam that keeps fewer of both — at the widest, a median of 45 per cent over the exhaustive order at seven tensors and 73 per cent at nine.

The mechanism is in what the order cut does with what it is given. With τorder=0\tau_{\text{order}} = 0 it keeps only the cheapest partial order. When the pairing cut keeps one pairing per state, the cheapest partial order is chosen among the few that the size ranking proposed — pairings that contract a lot away — and cost so far only breaks ties among good proposals. When the pairing cut keeps eight, it proposes cheap pairings that contract little, and the order cut, ranking by cost so far, prefers them: they cost least now. The beam becomes a cost-so-far greedy search with a size-ranked shortlist that has been lengthened until it no longer filters anything. The search that got worse as it widened found a beam whose larger width made results worse, and traced it to a ranking that was being given more rope; this is the same failure, located at one cut.

Held at τorder=8\tau_{\text{order}} = 8, the same widening of the pairing cut does no harm at seven tensors — the median is one at every τpair\tau_{\text{pair}} — and only a little at nine. A wide order cut keeps the dear prefixes alive, and then a wider pairing cut simply proposes more of them.

Networks contracted in the exhaustive order against the mean pairings priced, on sixty seven-tensor networks, along four paths through the two tolerancesone τ at both cuts: 31 for 60, 31 for 66, 32 for 76, 33 for 103, 46 for 150, 48 for 198, 52 for 270, 53 for 338; orders widened, pairings at 0.5: 26 for 60, 28 for 68, 32 for 76, 33 for 80, 41 for 88, 43 for 91, 45 for 95, 46 for 98; orders widened, pairings at 1: 21 for 62, 23 for 74, 29 for 86, 33 for 103, 43 for 117, 46 for 124, 49 for 132, 51 for 136; pairings widened, orders at 0: 31 for 60, 31 for 61, 26 for 60, 21 for 62, 14 for 62, 13 for 62, 7 for 63, 4 for 64, at τ = 0, 0.25, 0.5, 1, 2, 3, 5, 8.0102030405060pairings priced, mean per networknetworks solved exactly, of 6050100200400one τ at both cutsorders widened, pairings at 0.5orders widened, pairings at 1pairings widened, orders at 0each path's dots at τ = 0, 0.25, 0.5, 1, 2, 3, 5, 8spend the width on the order cut
Fig. 5 Networks solved exactly against mean pairings priced at seven tensors, along four paths through the tolerances: one τ at both cuts, the order cut widened with the pairing cut at 0.5 and at 1, and the pairing cut widened with the order cut at 0.

The frontier puts all four paths on one pair of axes. The two paths that widen the order cut lie above the single-τ\tau path wherever they overlap in work: at 98 pairings the order-cut path has 46 networks where the single τ\tau has 33 at 103. The path that widens the pairing cut stays at sixty-odd pairings, because a beam whose order cut keeps one state prices little whatever it is offered, and falls straight down.

What the two rankings are for

Where the width actually goes says why the split is cheaper. Averaged over the sixty networks, the beam with τpair=0.5\tau_{\text{pair}} = 0.5 and τorder=8\tau_{\text{order}} = 8 holds 1.5, 2.4, 3.1, 3.0 and 2.4 partial orders at its first five levels; the single τ\tau of two holds 2.3, 4.2, 5.6, 5.6 and 3.5. The split beam keeps fewer states at every level and solves as many networks, because the states it keeps are the dear prefixes the walk says are needed, and the states the single τ\tau adds are extra pairings out of each of them, which the walk says are mostly not. With both tolerances at zero the beam holds 1.1 to 1.3 states a level; with only the pairing cut widened to eight, 1.1 to 1.4 — almost the same width, because the order cut at zero keeps one state whatever it is offered, and a worse choice of that one state.

Widen the beam where the ranking is right widened by level and found that the beam should be wide late, not early. That result is consistent with this one without being explained by it: if the order cut’s mistakes are made at the first two levels, a beam that is narrow there has already discarded the dear prefix, and widening later can only keep the best of what survived. Widening the order cut from the first level keeps the dear prefix alive at the level it is made, which is why a narrower beam does better.

The single tolerance treated the two cuts as two places to be generous. They are two rankings with different jobs and different failures. The size ranking at the pairing cut is a forward-looking heuristic — a small result means less work later — and it is usually right about the next move; it needs only enough room to break the occasional near-tie, which at seven tensors is none and at nine is a factor of one and a half. The cost-so-far ranking at the order cut is a backward-looking record, and it is wrong about exactly the move the exhaustive order is built around, an early expensive pairing that pays for itself later. It needs room for that pairing’s whole cost.

Widening the forward-looking cut while starving the backward-looking one is the worst combination, because it feeds the blind ranking options it cannot evaluate. The order the products are taken in began the subject with a greedy rule that was almost never optimal and almost never far from it; a beam built from these two rankings can be made far better than greedy or, with the tolerances the wrong way round, far worse.

Pairings priced is the right currency for comparing beams, and the wrong one for deciding whether to run one. Each pairing priced is a product of a few integer dimensions, a handful of operations; the contraction it helps choose costs the order’s whole count of multiply-adds, which on these networks runs from a few hundred to two hundred thousand, with a median of 2,610 at seven tensors and 5,436 at nine — and on networks of realistic dimensions, many orders more. The difference between 98 pairings and 150 is small next to the difference between an order 1.4 times dearer than necessary and the exhaustive one, even here, and negligible at realistic sizes. What the split buys is not the saving in search; it is that the search’s success no longer depends on choosing one number well for two jobs, which is the kind of saving a block size is a property of the machine found in a different setting — a parameter that looked like one knob turning out to be two quantities that had been tied together.

What a hundred networks do not show

The ensembles are random graphs of small dimension, and the measured gaps are properties of them: a network family whose optimal orders never pay early — chains, for which the plan that was right at rank four priced a closed form — would show no order gap at all. The cap of sixteen bounds both cuts and is not varied; at the widest tolerances it binds, and some of the flattening at τ=5\tau = 5 and 8 is the cap’s. And the walk measures the need along the exhaustive tree only, which is a sufficient tolerance for keeping that tree in reach, not a necessary one: a beam can find an equally cheap order that is not the exhaustive tree, and the solved counts here would include it.

Still open: the estimate at the order cut, and a tolerance read off the walk

The repaired ranking at the order cut. The cost-so-far ranking is blind to an expensive early pairing, and the beam ranked on cost so far plus the largest remaining group was built to see it. The prediction with a sign is that with that estimate at the order cut, the order cut’s median need falls from 2.33 to below 1.5 at seven tensors, and a beam with both tolerances at one finds the exhaustive order on at least as many networks as the best cell here, (1, 8), for fewer than 120 pairings — which would make the width the estimate’s error and not the ranking’s.

A tolerance per network. The walk measures each network’s need only with its exhaustive tree in hand. But the first level’s gap at the order cut is visible to the beam itself: the ratio of the dearest to the cheapest prefix it is offered. The prediction is that the order cut’s need is within a factor of 1.5 of the largest first-level ratio on four networks in five, so that a beam can set τorder\tau_{\text{order}} from its own first level and find as many networks as the fixed 8 for the pairings of a fixed 2.

Named objects

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

Beam searchContraction orderFlop countGreedy algorithmTensor network