Where the disagreement comes from
Worth reading first: The same program, twice · The order they are added in · Cancellation takes the answer, not a digit.
Two essays have now measured a disagreement without explaining it. This one explains it, in a sentence that turns out to carry everything the field needs:
A rounding is committed at every partial sum, and its size is the spacing of that partial sum, not of the answer.
Everything follows. The size of the disagreement, the fact that dividing the work reduces it, the fact that the value cannot be predicted, and the reason a vector of positive numbers shows nothing — all four are consequences of where the roundings are committed rather than of how many there are.
Reading the picture
Two walks. They separate within the first handful of terms and never meet again, ending at 2.4·10⁻¹⁴ and 7.6·10⁻¹⁴ — a factor of three apart, on the same numbers, with the same algorithm.
Neither is a curve with noise on it. Each is a path: at every step the arithmetic commits one rounding of size at most half the spacing at the current running total, and adds it to what has accumulated. Sometimes the new rounding cancels part of what is there and the curve dips. Nothing about the path is deterministic in any useful sense, because it depends on the low bits of every partial sum.
The horizontal axis is where the mechanism is visible. This vector’s running total climbs to 52 on its way to an answer of 1.6·10⁻⁵. That is what a summation condition number of 10⁸ means in concrete terms: the arithmetic spends the entire computation handling numbers seven orders of magnitude larger than the one it returns, and rounds each of them at its scale rather than at the answer’s.
A rounding committed at a partial sum of 52 is worth about 5.8·10⁻¹⁵ in absolute terms. Relative to the answer of 1.6·10⁻⁵, it is worth 3.6·10⁻¹⁰. One rounding, in the middle of the loop, is already ten orders larger than the last bit of the result. There are 2,048 of them.
Why the answer’s own size is irrelevant
This is the point at which the field parts company with the ordinary reading of floating-point error, so it is worth stating twice.
The usual mental model is that each operation contributes a relative error of about u to the answer, so n operations contribute about nu. That model is right when the running total stays near the answer — which is what a sum of positive numbers does, and why the order they are added in can talk about a million reciprocals losing accuracy in a way that is proportional to how many of them there are.
When the terms cancel, the running total is nowhere near the answer, and the errors are committed at a scale the answer never sees. The right model is that each operation contributes about u·|running total| in absolute terms, and the answer’s smallness is what turns those absolutes into enormous relatives. That is the same mechanism cancellation takes the answer describes for one subtraction, applied n times to a running total instead of once to a pair.
The consequence is that the number of terms almost drops out. Fix κ and vary the length: the relative error of a single-accumulator reduction is 4.2·10⁻⁹ at 128 terms and 3.1·10⁻⁹ at 8,192, a fitted exponent in n of −0.083. No power of n at all, where the classical bound carries a full one — which a bound every answer satisfies works out in detail, and which comes out of exactly the two square roots this essay is about.
The two square roots
Written out once, because the cancellation of the two is what makes the whole field’s numbers small and stable.
The first √n is the roundings. They do not conspire. n roundings of similar size and independent sign accumulate like a random walk, reaching about √n times one of them rather than n times one of them. This is what the probabilistic error analysis of the last decade formalises, and it is why the deterministic bound’s factor of n is pessimistic by √n on any real data.
The second √n is the data. A vector of n mixed-sign terms with a fixed Σ|xᵢ| has entries of typical size Σ|xᵢ|/n, so its partial sums are themselves a walk and reach about √n · Σ|xᵢ|/n = Σ|xᵢ|/√n. The roundings are committed at that scale, which shrinks as the vector gets longer.
Multiply them: √n roundings, each of size u·Σ|xᵢ|/√n, gives u·Σ|xᵢ|. The length has gone. What is left is a quantity proportional to the sum of magnitudes, which divided by the answer is exactly κu — the constant this field reports, measured at 0.25 and derived here at 1.
The factor of four between the derivation and the measurement is honest and worth keeping: the derivation treats the roundings as independent and of full size, and they are neither. What the derivation buys is not the constant, it is the shape — no n, one κ, one u — and the shape is what survived ten decades of measurement at a spread of 1.02.
Why more workers is more accurate
Now the consequence that surprises everybody, including the author of the refusal this essay publishes.
Each accumulator in a p-way reduction sees n/p terms, so its own walk reaches about Σ|xᵢ|/(p√(n/p)) · √(n/p) — shorter by √p than the single accumulator’s. The roundings committed inside it are smaller in proportion. The final combination of p partial sums adds log₂p more roundings, at the scale of the answer, which is negligible when the answer is small.
So a divided reduction should be more accurate by about √p. Measured over eight vectors at 2,048 terms:
| pieces | mean absolute error | mean peak partial sum |
|---|---|---|
| 1 | 4.78·10⁻¹⁴ | 52.1 |
| 4 | 3.74·10⁻¹⁴ | 44.6 |
| 16 | 2.00·10⁻¹⁴ | 37.4 |
| 64 | 8.15·10⁻¹⁵ | 33.8 |
A factor of 5.9 from one accumulator to sixty-four, where √64 = 8. The prediction is right in direction and right within 25% in size, and the peak partial sum falls alongside it, which is the mechanism showing its work.
This is the same fact a reduction that changes the order measures in the communication field, where a tall-skinny QR computed as a tree of independent block factorisations returns a better backward error than the sweep it replaces — 1.65·10⁻¹⁵ against 9.95·10⁻¹⁵. That essay reads the result as a statement about communication being free of a stability cost. Read from here it is the same √p: the tree’s local factorisations each see less of the matrix.
So the folk claim that parallel arithmetic is less accurate is not merely unproven, it is backwards. What parallel arithmetic is, is different — and different is the whole problem, because the consumer of the number is a comparison rather than a reader.
Why the value is unpredictable
Everything above is a statement about the scale of the walk. None of it says where the walk ends.
That is not a gap in the analysis; it is the nature of the object. A random walk’s end point is not a function of its step sizes. Two walks with identical step-size distributions end in different places, and the difference between their end points has the same scale as either of them.
The practical consequence is the asymmetry this field lives with:
- the size of the disagreement is computable in advance, from data the caller has, at a cost of one pass;
- the answer any particular machine will return is not computable at all, short of running that machine.
Numerical analysis is usually in the opposite position — a worst case that is rarely attained, and an achieved error that is stable and reproducible. This is the one place on the site where the statistics are tight and the individual outcome is a coin flip.
Why sorting changes everything, and why nobody can
The derivation above assumed the partial sums wander. Break that assumption and the mechanism gives a different answer, which is the strongest evidence that the mechanism is the right one.
Sort a vector by magnitude and the partial sums stop wandering: they climb monotonically, so the walk is a line and the errors accumulate in a line too. That is why sorting matters at all — the order they are added in measures a factor of 470 from sorting a million reciprocals — and it is why the factor of n comes back for sorted data.
For a positive vector, sorting ascending is the classical repair. For a cancelling vector it is worse than useless: sorting by magnitude puts all the positives before all the negatives, drives the running total to its maximum possible value, and maximises every rounding on the way. The best ordering for a cancelling sum is one that keeps the running total small, which means interleaving the signs — and that is a decision that has to be made about the data, by somebody who has seen it.
Which is precisely what a parallel runtime cannot do. It divides the vector by index, because index is all it has. The ordering that would help is one no scheduler is in a position to choose, and the orderings it does choose are drawn from the family whose end points are unpredictable.
The order of the data, which the runtime cannot see either
There is a second ordering in play and it is easy to miss, because the field has spent three essays talking about the order the arithmetic combines things in. The terms also arrive in an order, and that one is the caller’s.
Take one vector and present it three ways to the same seven partitionings:
| the terms, arranged | peak partial sum | error at one accumulator | spread across seven reductions |
|---|---|---|---|
| shuffled | 46.0 | 6.3·10⁻¹⁴ | 5.7·10⁻⁹ |
| sorted by magnitude | 67.4 | 5.4·10⁻¹⁴ | 5.2·10⁻⁹ |
| all positives, then all negatives | 838.9 | 4.2·10⁻¹³ | 4.8·10⁻⁸ |
The third row is the one to read. Grouping by sign drives the running total to 839 — eighteen times the shuffled arrangement’s peak — because the sum climbs the whole way up and then comes the whole way down. Every rounding on that journey is committed eighteen times too large, and both the error and the run-to-run spread move by an order of magnitude.
Nothing about the arithmetic changed. The terms are the same multiset and the algorithm is the same algorithm; what changed is a property of the data’s layout, which in real code is decided by whatever assembled the vector — a sparse format, a sort somewhere upstream, the order the mesh was numbered in.
Two consequences worth carrying:
A benchmark on shuffled data understates the effect, which is the same warning the vector that hides it makes about positive data, one level down. Grouped signs are not exotic; they are what a physical problem with a source and a sink produces.
And this is why the ordering that would help cannot be chosen by the machine. Keeping the running total small means interleaving the signs, which requires having looked at the values. A runtime divides by index because index is all it has, so the one intervention that would shrink every rounding at once is available only to whoever built the vector — and available cheaply only to them, since a pass that inspects signs costs what the reduction costs.
What this predicts, checked
A mechanism earns its place by predicting something it was not built to explain. Three predictions, all checked every time this page is produced:
A positive vector should show almost nothing. Its partial sums climb to the answer and stay there, so every rounding is at the answer’s scale and the relative error is a few nu. Measured: 1.6·10⁻¹⁵ across seven partitionings, against 4.9·10⁻⁷ on a cancelling vector at κ = 10¹⁰.
Compensated summation should be accurate and still irreproducible. Kahan’s loop removes most of each rounding but not all, and what is left is still committed at the running total’s scale. So the error should fall a long way and the count of distinct answers should not fall to one. Measured over four hundred permutations: 119 distinct answers, against 303 for a plain loop — three times better and not remotely reproducible.
The disagreement should be immune to a wider float. Every quantity in the derivation carries one factor of u, so doubling the precision moves everything down together and changes nothing about the shape. That is the prediction most often assumed away — use doubles is the standard advice, and it buys accuracy while buying no agreement, exactly as the tolerance that buys no agreement measures for a tolerance rather than for a format.
What it does not explain
Two things, named because a mechanism that explained everything would be suspicious.
It does not explain the constant. The derivation gives u·Σ|xᵢ| and the measurement gives about a quarter of it. The gap is the independence assumption — consecutive roundings are correlated, because a partial sum that has just been rounded up is more likely to round down next — and recovering the constant would need a model of that correlation. The site’s habit is to report the measured number and to say which part of it was derived, which is what the direction the error leans does for a rounding mode: the size of one rounding is set by the precision, and how ten thousand of them combine is set by something else, with fitted exponents of 0.47 and 1.01 for two modes on identical data.
It does not explain the tail. The measurements here are means over seeds; the worst of twenty runs is about twice the mean and the analysis says nothing about how much worse a rare one can be. For a walk the answer is a Gaussian tail, and the honest version of that claim needs a distribution rather than a mean — which is the shape of statement the randomised field already makes, and a bound that holds with probability is where this site keeps its vocabulary for it.
The one line
The error of a reduction is a walk over its own partial sums. What a machine changes is which walk, the length of the vector nearly cancels out of the answer, dividing the work shortens each walk and improves the average, and none of that says where any particular walk ends.
At other settings
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.
- A coin flip that fixes the average — both name error accumulation, unit roundoff
- A rank that depends on the thread count — both name reduction order, run-to-run variation
- A stopping test is a race — both name reduction order, run-to-run variation
- The fifth author — both name reduction order, run-to-run variation
- The residual the method reports — both name random walk, unit roundoff
- The rounding that was not the problem — both name error accumulation, random walk
Named objects
A flat tag is an object no other essay names yet.
Error accumulationPairwise summationRandom walkReduction orderReduction treeRun-to-run variationSummation condition numberUnit roundoff