Every equal tail has a cliff
Worth reading first: A norm that overflows before it is a norm · The order they are added in · The same program, twice.
The division the norm did not need ended on a vector that was built to be awkward. One entry of size one, then 4,095 entries of , in binary32, with every route protected against the overflow that breaks a norm before it is a norm. Each of them returned exactly 1, where the truth is 1.000122, and that is an error of 2,047 units of the format’s roundoff. The explanation was arithmetic that could be done by hand: binary32’s spacing just above one is , the square of is , exactly half a spacing, and round-to-even returns the running sum unchanged. Every square vanished on arrival.
That essay read the result as a depth. The squares are lost because the entries sit at half the significand’s depth below the largest, and on a sweep over integer depths the error was a single cliff at , falling by four a step on the deeper side and absent on the shallower. Two predictions with a sign followed from that reading. A tail drawn log-uniformly over a factor of four around the depth would keep between 500 and 1,500 units, and over a factor of a hundred would fall below 100. And a routine that counted the entries below half the depth on its first pass, which it already makes to find the largest, could compensate only when more than eight were found and keep the worst error under eight units everywhere.
Both predictions are wrong, in instructive directions, and for one reason. The cliff was never a depth.
The same sweep, at a fiftieth of a step
The earlier sweep took at whole numbers, and a whole-number is the most special depth there is. The entry has a one-bit significand, its square is a power of two, and a power of two above is added to a sum near one exactly. That is why depths 4 to 11 showed nothing. Taking in steps of a fiftieth instead gives entries with full significands.
At 4,095 entries the red curve is a forest. The cliff at twelve is still there, at 2,047 units, and it is the tallest tree by a little. Next to it, at , the error is 1,742 units in the other direction: the norm comes out too large. At 0.003, which is about and so eight bits shallower than the cliff, it is 1,965. At 0.01 it is 405. Of the 400 depths from 4 up to 12, 88 per cent have an error above 102 units, a fortieth of the length, and a third of them are above a thousand. The whole-number depths are the exceptions, each a narrow notch in the forest, and the earlier sweep happened to sample nothing but notches.
The dial moves the length, and the picture scales without changing shape. At 255 entries the worst is 127 units; at 1,023 it is 508; at 4,095 it is 2,047. The forest is the same forest, with every tree grown in proportion to the number of entries.
The blue curve is the same scaled norm with the squares added as a tree rather than a line: pairs, then pairs of pairs, until one number remains. It uses the same additions, the same scaling and the same square root, and its worst error at any depth and any length on the dial is 2.0 units.
One rounding, repeated
A sum of a large term and many equal small ones behaves in a way that is easy to state once seen. The running sum starts at one and stays between one and two, where the spacing is a fixed . Each square arrives and the result is rounded to the grid, so it moves by rounded to a multiple of . The rounding error of one addition is , and because every addend is the same and the grid is the same, so is . After additions the squared norm is off by exactly, and the norm, being its square root, by half that relative to its size. That is a prediction with no free parameter in it: compute one addition in binary32, multiply by the length.
Between depths seven and nine at 1,023 entries the two agree to within one unit on every depth with a predicted error above one, and across the whole sweep at all three lengths they agree to within one unit and one per cent. The tree heights are therefore not a statistic. They are where the fraction happens to land: a square that is a whole number of spacings is added exactly and leaves a notch, and one that is a whole number and a half is rounded by half a spacing, the most rounding allows, in a direction fixed by round-to-even and the sum’s last bit. Between those, the error moves through every value in proportion to how far the fraction is from a whole number.
The cliff at twelve is not a different phenomenon. It is the particular case in which is exactly one half and the sum is even, so round-to-even returns the sum and : the square is lost entirely rather than rounded. That is a striking way to lose it, and the first essay drew attention to it rightly, but in units it is no worse than its neighbours. At 0.003 the square is 75.5 spacings, the rounding is again half a spacing, and the 4,095 roundings add up to as much as 4,095 lost squares did, from entries that are a three-hundredth of the largest and nowhere near any threshold.
This is the shape a repeated rotation drifts in a straight line found for a product of one rotation with itself: the same factor’s rounding defect, applied a million times, accumulated linearly at 622,127 units where fresh factors walked like a square root. An equal tail is the additive version. A random sequence of roundings partly cancels and grows like , which is what three walks and one bound found measured sums actually doing against a bound of ; one rounding repeated cannot cancel against itself and grows like . The direction the error leans is the general setting, where a rounding mode with a bias drifts in proportion to the number of operations, and an equal tail is round-to-nearest given one input and so one bias.
The count reads the one depth it was told about
The test predicted to catch the cliff counts the entries at or below times the largest and compensates when it finds more than eight. On the tail sweep it does exactly what it was designed to do, and that turns out to be very little.
It fires at 201 of the 601 depths, every one of them at or deeper than twelve, and there the compensated sum’s error is at most 1.5 units. At the other 400 depths it has nothing to count, and the error is the uncompensated one, up to 2,031 units at . The test’s premise is that a small entry is dangerous because of its depth, and so it reads depth. The danger is in the repetition, which a depth cannot see: every entry of the tail at 0.003 is perfectly ordinary in size, and only the fact that all 4,095 of them round the same way makes them a problem.
A test that did read for repetition is easy to imagine and hard to want. It would have to notice that the squares fall on the same fraction of a spacing, which is a question about the whole vector’s values rather than about any one entry. The alternative is to remove the condition rather than detect it, and the pairwise tree does that for free.
Why the tree does not care
Pairwise addition adds each square first to another square of its own size. Two copies of make exactly, since doubling is exact in binary floating point; four make ; and the tail sums itself to with almost no rounding, before ever meeting the large entry. The large entry and the tail’s total then meet once, in one addition with one rounding, and that single rounding is the half unit the result carries.
The line, in contrast, meets the large entry with every square. Each addition puts a small term against a large one, which is exactly the arrangement in which rounding is largest relative to what is added. The order they are added in made this argument for sums in general, and its bound for pairwise addition grows with rather than with . What an equal tail adds to the general argument is that the line’s is not a worst case approached by unlucky data but an exact value attained by the most regular data there is.
Against the length the three lines added in order are straight with slope one, through four decades: entries of lose 7 units at 15 entries and 8,186 at 16,383, entries of 0.003 lose 8 and 7,104, entries of 0.01 lose 2 and 1,556. The pairwise curve does not rise at all; its worst over the three values and six lengths is under two units, which is less than the the bound would allow. At 16,383 entries of 0.003 the line’s error is 7,104 units, a relative error of in a format whose roundoff is , and the tree’s is 0.07.
The two repairs in the earlier essay fare differently on the forest. Kahan’s compensation keeps an equal tail’s error under 1.5 units at every one of the 601 depths, since it carries each addition’s rounding forward into the next and so cannot let accumulate. Sorting the squares smallest first, which removed the cliff at twelve just as well, does not: its worst over the same depths is 383 units. A sorted equal tail is still summed in a line, against its own growing partial sum instead of against the large entry, and a line of equal terms repeats its roundings in runs for as long as the partial sum stays in one binade. The tree is the arrangement in which no addend ever meets a sum much larger than itself. Compensation costs four additions an entry in place of one; the tree costs a stack of partial sums, or in a blocked implementation almost nothing, since summing blocks and then summing the block totals is already pairwise at one level.
Spreading the tail does not average it
The second prediction concerned a tail that is not exactly equal: entries drawn log-uniformly over a factor around . It said a factor of four would keep 500 to 1,500 units of the cliff and a factor of a hundred would leave under 100. If the cliff were a depth, those numbers would follow from the share of the tail still near it. Since the cliff is a repeated rounding, the question is what happens to the repetition when the entries are allowed to differ.
The first tenth of spread destroys it. At the median error falls from 2,047 to 24 units and the worst of forty draws is 95, because the squares now land at every fraction of a spacing and their roundings point both ways. Then, as the spread widens, the error comes back: 54 units at 1.5, 172 at 2, 288 at 4, and then slowly down again, 255 at 10, 153 at 100, 102 at a thousand. Neither predicted number holds. A factor of four keeps 288 units, well under the predicted lower limit of 500, and a factor of a hundred keeps 153, half again above the predicted ceiling.
The reason the curve rises is that a spread around the critical depth always puts half the tail below it, and below it the squares are not rounded but lost. In one draw at the lost squares account for 964 units of error downwards, and the squares just above the depth, rounded up to a whole spacing, for 986 upwards. The two halves cancel to within the noise, because a narrow spread gives them the same size. At the lost half sits further below and the half above is no longer rounded up as much: 547 units down, 277 up, and a net of 270. At the losses are smaller, since the lost squares are smaller, and so are the gains: 218 down and 72 up. The error a spread tail keeps is the imbalance between what it loses entirely below the depth and what it gains just above it, and that imbalance has a maximum near a factor of four.
So the depth matters after all, in the one way the earlier reading did not predict. It is not where the error is; it is the place where rounding to nearest changes from rounding into rounding away, and a spread that straddles it turns an unbiased rounding into a biased one. Pairwise addition removes that too. Its worst over all nine spreads and forty draws is 4.0 units, at a factor of a thousand.
Where real data repeats
None of this would matter much if equal tails were rare, and in floating point that is assumed rather than known. Data from a sensor, an image or an audio file is quantised before it is ever a float: its values are integers times a step. A unit impulse with a little noise, which the earlier essay offered as an ordinary vector to meet the cliff on, is the natural place to look.
The answer has three regimes, and the middle one is the trouble. At a coarse step of the noise takes six distinct magnitudes and every square is a short binary fraction that the sum holds exactly, so the error is under a unit. At a fine step of or below the samples take three to four thousand distinct values and their roundings are as good as random, with medians of nine to eleven units. Between them, at a step of , the noise takes 238 distinct magnitudes, each repeated about seventeen times, and the median error is 298 units, with a worst of 328. That is a vector with nothing special in its range or its sizes, quantised the way thirteen-bit data is, losing about as much as the spread tail at its worst.
Added pairwise, every one of the six steps is under 2.4 units.
What this does not settle
The measurements are of one norm in simulated binary32, with the reference computed in binary64, on vectors constructed to isolate one effect and then on one family of quantised noise. The predicted law was checked only where the running sum stays in its first binade; a tail large enough to push the sum past two, such as 16,383 entries of 0.01, changes the spacing midway, and the law then needs two pieces, which were not derived. Fp16 shows the same forest at a smaller scale, a worst of 375 units on 1,023 entries, and was not taken further.
The pairwise tree is measured as a plain recursive pairing. Real reductions are usually blocked, summing a block of some dozens in order and then the block totals; a block of 64 equal squares added in order would carry 64 of the repeated roundings rather than 4,095, and the error would be bounded by the block length rather than the vector’s. That is a smaller cliff rather than none, and how blocked kernels in practice compare was not measured. Where the disagreement comes from traced run-to-run variation to exactly that blocking, a rounding committed at each partial sum’s own scale, and an equal tail is the input on which a block’s length would show in the answer. Nor was speed: the tree’s additions are the same in number but not in dependency, and on most hardware a reduction with independent partial sums is faster rather than slower, which is why libraries already use one.
What is settled is narrower. A norm’s large error on these vectors is the number of entries times one addition’s rounding, to a unit and a per cent; it is attained by any equal tail at almost any depth and by quantised data with moderate resolution; it is invisible to a test that looks at entry sizes; and the order of the same additions removes it. The vector that hides it made the point that a sum’s error hides from tests that look at the answer. Here it hides from a test that looks at the inputs, as long as the test asks about size.
Still open: the blocked reduction, and stochastic rounding against repetition
A block of equal squares. A blocked norm adds 32 or 64 squares in order and then sums the block totals. The prediction with a sign is that on an equal tail its worst error over all depths is the block length times half a unit, within ten per cent, at every vector length from 1,024 to 16,384, so that a blocked reduction caps the forest at the block’s height rather than removing it, and that a block of eight is already under the five units pairwise reaches. If so, the block length is the one number a library’s documentation should state for its norm.
A coin flip against one bias. A coin flip that fixes the average showed stochastic rounding removing the drift of a biased sum. An equal tail is the extreme case of a bias, the same rounding every time, and stochastic rounding turns it into a random walk. The prediction is that a scaled norm with stochastic rounding of the additions has an error of about units on every equal tail, 32 at 4,095 entries, at every depth, so that it removes the forest’s dependence on depth entirely but leaves an error sixteen times larger than the pairwise tree’s at that length, and that the two together, a tree with stochastic rounding, do no better than the tree alone.
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 far well in a byte — both name summation, unit roundoff
- The formula sets the power, the sum sets the constant — both name pairwise summation, unit roundoff
- The generator that rounded its own product — both name summation, unit roundoff
Named objects
A flat tag is an object no other essay names yet.
Binary32Compensated summationPairwise summationQuantisationScaled normSummationUnit roundoff