Where the flop count stopped predicting the time

A reduction that changes the order

A tall-skinny QR computed as a tree of independent block factorisations touches a 512×12 matrix once instead of twelve times, computes a completely different sequence of roundings from the sweep it replaces, and returns ‖AᵀA − RᵀR‖/‖AᵀA‖ = 1.65·10⁻¹⁵ against the sweep's 9.95·10⁻¹⁵. On the same matrix classical Gram–Schmidt returns 4.6·10⁻¹⁰.

Worth reading first: Orthogonal is a number · The same arithmetic at a different price.

The first essay in this field reorders an elimination and gets the identical factorisation, bit for bit. That is a comfortable result and it is not the general case.

This essay reorders a reduction — a QR factorisation of a matrix with far more rows than columns — and gets a genuinely different sequence of roundings, a genuinely different R, and the same backward error. Which is the more interesting outcome, and the reason it holds is a property this site has been measuring since its foundation phase.

Four factorisations of one 512×12 matrix, κ = 7151A ranked bar chart of the departure from orthogonality, on a logarithmic scale. Classical Gram–Schmidt loses 4.6·10⁻¹⁰, modified 1.5·10⁻¹², Householder 2·10⁻¹⁴. The reduction tree, which touches the matrix once instead of 12 times, is of the same size as Householder's — and its error does not grow with the depth of the tree.classical Gram–Schmidt4.62·10⁻¹⁰modified Gram–Schmidt1.49·10⁻¹²Householder, one sweep2.03·10⁻¹⁴reduction tree, 16 leaves1.48·10⁻¹⁵departure from orthogonality, logarithmicthe tree, at four depths‖AᵀA − RᵀR‖/‖AᵀA‖, depth 13.4·10⁻¹⁵‖AᵀA − RᵀR‖/‖AᵀA‖, depth 24.3·10⁻¹⁵‖AᵀA − RᵀR‖/‖AᵀA‖, depth 31.7·10⁻¹⁵‖AᵀA − RᵀR‖/‖AᵀA‖, depth 41.5·10⁻¹⁵the same algebra, four timestwo of them are products of reflections
Fig. 1 Four factorisations of one 512×12 matrix at κ = 7,151, ranked by departure from orthogonality on a logarithmic scale. Classical Gram–Schmidt loses 4.6·10⁻¹⁰; modified loses 1.5·10⁻¹²; Householder in one sweep loses 2.0·10⁻¹⁴. The reduction tree — which touches the matrix once instead of twelve times — is of the same size as Householder’s.

The shape of the problem

A tall-skinny matrix — 512 rows, 12 columns — is the shape that comes out of a least-squares fit with many observations, out of a block Krylov method, and out of the panel factorisation the previous essay left as the part that does not block.

A Householder sweep on it is a loop over the twelve columns. Each step computes a reflector from the column below the diagonal, applies it to the remaining columns, moves on. The arithmetic is 2mn², which at these sizes is 147,456 operations — a small number. The traffic is not small: each of the twelve steps reads the whole trailing part of the matrix, so the matrix crosses the memory twelve times.

That is a level-2 operation in the vocabulary of the previous essay, and a matrix with 512 rows is exactly the case where the reads dominate. What is wanted is a factorisation that touches the matrix once.

The tree

Split the rows into p blocks. Factor each block independently — every leaf touches only its own rows and nothing else, so the whole matrix is read exactly once and the p factorisations do not communicate at all. That leaves p small R factors, each 12×12.

Stack them in pairs and factor those. Then stack the results in pairs and factor again. After log₂p levels there is one R left, and it is the R of the original matrix.

The traffic is m words for the leaves plus a negligible amount for the tree — the internal nodes work on 24×12 matrices — against 12m for the sweep. And the leaves are independent, which is why this is the standard algorithm on any machine with more than one processor: the leaves need no communication whatever, and the tree needs log₂p rounds of it.

One Householder reflection, and the sign that keeps it stableA vector, the mirror line through the origin, and its reflection landing on the negative first axis at the same distance from the origin.the mirrorx, length 4.000Hx = (-4.000, 0)v = x − αe₁safe sign: α = −‖x‖, so v is formed from a sum and nothing cancelsunsafe sign: α = +‖x‖ gives ‖v‖ only 35.1% of ‖x‖ + ‖x‖ — the digits go‖HᵀH − I‖5·10⁻¹⁶‖Hx‖ − ‖x‖8.9·10⁻¹⁶second component2.2·10⁻¹⁶built from a unit vectororthogonality is structural
Fig. 2 The step the whole tree is built out of. A reflection is an isometry — it is its own inverse and it preserves every length — which is the property that survives being reassociated and is the reason a tree of them is as safe as a sweep of them.

Why it is the same R, and why that is not obvious

Every step of this is an orthogonal transformation, and the composition of orthogonal transformations is orthogonal. So the whole reduction is Qᵀ A = R for some orthogonal Q, and the R that comes out satisfies RᵀR = AᵀA — which pins it down to a choice of signs.

That is a statement about the algebra and it is exactly true. The question this site asks is what happens in the arithmetic, and the answer is not a corollary. The tree computes twelve reflectors per leaf, then more at each internal node, in an order that has nothing to do with the sweep’s. Different numbers are subtracted from different numbers at every step. There is no reason for the answers to agree bit for bit and they do not.

What is measured instead is ‖AᵀA − RᵀR‖/‖AᵀA‖, which is the strongest statement available without forming Q — and Q is deliberately not formed, because accumulating it is where the method’s real implementation difficulty lives and eliding that would be dishonest.

The tree returns 1.65·10⁻¹⁵. The sweep returns 9.95·10⁻¹⁵. The tree is, on this matrix, slightly better.

And the error does not grow with the depth

This is the claim that makes the method a method rather than a curiosity, and it is the one a reader should want checked.

A deeper tree is more levels of rounding. If the backward error grew with the depth then splitting the matrix further — which is what one does to move it less, and what one must do to use more processors — would be paid for in accuracy, and the method would have a size beyond which it stopped being usable.

Measured on the same matrix at four depths:

leaves depth ‖AᵀA − RᵀR‖/‖AᵀA‖
2 1 3.38·10⁻¹⁵
4 2 4.26·10⁻¹⁵
8 3 1.65·10⁻¹⁵
16 4 1.48·10⁻¹⁵

It does not grow. It wanders inside a factor of three and if anything falls, and the assertion requires the spread across the four depths to be under twenty — which is loose enough not to be measuring noise and tight enough to fail on any real growth.

The reason is the same one as before, applied to the tree rather than to the algorithm: an orthogonal transformation does not amplify. ‖Qx‖ = ‖x‖ exactly, for every x, so whatever error is present when a level begins is neither magnified nor attenuated by that level — it is carried. Errors that are carried rather than amplified accumulate like the number of levels at worst, and log₂16 = 4 levels is not a number that shows up against 10⁻¹⁵.

The same arithmetic, twice, with M = 144 words of fast memoryThree counters against the matrix size on logarithmic axes. The operation count is one curve, because both orderings perform exactly the same operations — 338,120 of them at n = 80. The words moved between fast and slow memory are two curves a factor of 3.24 apart. The factorisations they produce are identical to the last bit.10²10³10⁴10⁵matrix size ncountoperations, bothwords, unblockedwords, blocked (b = 6)the answer does not move‖PA − LU‖/‖A‖, unblocked2.8·10⁻¹⁶‖PA − LU‖/‖A‖, blocked2.8·10⁻¹⁶difference between them0the dashed curve is both orderings' operation countthe solid pair is what they cost
Fig. 3 The other reassociation in this field, for contrast. Blocking an elimination returns a factorisation identical to the last bit — the badge prints both residuals and their difference — while the tree above returns a different R with a backward error of the same size. One is a scheduling change and the other is a different algorithm with the same specification.
Loss of orthogonality against condition number, in binary64A log–log plot of the norm of Q-transpose-Q minus the identity against condition number. Classical Gram–Schmidt rises steeply, modified Gram–Schmidt rises gently, and Householder is flat.110²10⁴10⁶10⁸10¹⁰10¹²10⁻¹⁷10⁻¹⁴10⁻¹¹10⁻⁸10⁻⁵10⁻²10¹condition number κ(A)‖QᵀQ − I‖classicalmodifiedHouseholderκ²uκu8×8, eight seeds per κ, binary64all three reconstruct A
Fig. 4 The measurement this site has made since its foundation phase, across eleven decades of conditioning. Classical Gram–Schmidt loses orthogonality like κ², modified like κ, and Householder stays flat — which is the ladder the figure above adds a fourth rung to.

What classical Gram–Schmidt has that neither of them does

The bottom of the figure is this site’s oldest measurement, and it is here because it is the control.

Two Gram–Schmidts establishes that the classical process loses orthogonality like κ² and the modified one like κ, while Householder stays flat at 1.8·10⁻¹⁵ across eleven decades. On this matrix at κ = 7,151 that is 4.6·10⁻¹⁰ classical, 1.5·10⁻¹² modified, 2.0·10⁻¹⁴ Householder.

Classical Gram–Schmidt’s steps are projections, not reflections. A projection is not orthogonal: it has a null space, ‖Px‖ ≤ ‖x‖ with equality only for vectors already in its range, and subtracting one from a vector is precisely the cancellation this site’s arithmetic field is about. When the vector being orthogonalised is nearly in the span of the previous ones — which is what an ill-conditioned matrix means — the subtraction destroys the part that was wanted, and what is left is the rounding error.

So the property that makes Householder safe is exactly the property that survives being reassociated, and Gram–Schmidt has neither. That is not two separate facts about two algorithms. It is one fact about orthogonality, seen from two directions, and the tree is the demonstration that it is the right fact: reassociation is safe when the pieces do not amplify, and unsafe when they do.

The site said in its foundation phase that a reflection cannot stop being one. This is what that buys, four phases later, in a field that did not exist then.

Four factorisations of one 256×12 matrix, κ = 7069A ranked bar chart of the departure from orthogonality, on a logarithmic scale. Classical Gram–Schmidt loses 5·10⁻¹⁰, modified 1.8·10⁻¹², Householder 1.2·10⁻¹⁴. The reduction tree, which touches the matrix once instead of 12 times, is of the same size as Householder's — and its error does not grow with the depth of the tree.classical Gram–Schmidt5.03·10⁻¹⁰modified Gram–Schmidt1.8·10⁻¹²Householder, one sweep1.25·10⁻¹⁴reduction tree, 16 leaves1.69·10⁻¹⁵departure from orthogonality, logarithmicthe tree, at four depths‖AᵀA − RᵀR‖/‖AᵀA‖, depth 14.4·10⁻¹⁵‖AᵀA − RᵀR‖/‖AᵀA‖, depth 21.6·10⁻¹⁵‖AᵀA − RᵀR‖/‖AᵀA‖, depth 31.4·10⁻¹⁵‖AᵀA − RᵀR‖/‖AᵀA‖, depth 41.7·10⁻¹⁵the same algebra, four timestwo of them are products of reflections
Fig. 5 The same four factorisations on a shorter, narrower matrix. The ordering between them does not change and the gap narrows, because a matrix with fewer columns is crossed fewer times by the sweep and the tree’s advantage is proportional to that count.

What the tree costs that the sweep does not

Three things, and the essay would be dishonest without them.

Q is harder. The sweep produces Q as an accumulation of reflectors in a standard order and applying it is straightforward. The tree’s Q is a product of the leaf Qs and the tree’s internal Qs, in a structure that has to be stored and traversed. Every real implementation stores it implicitly and there is genuine engineering in doing so. Nothing here does it, and the measurement above is chosen to be the one that does not need it.

The leaves have to be tall enough. A block with fewer rows than columns is rank-deficient by construction, its R is not the R of anything, and the tree means nothing. The generator refuses a configuration where m < np rather than clamping the number of leaves — the same choice hessenberg-reduction makes at n = 8 and jacobi-convergence at n ≥ 8 — because a clamp would draw a four-leaf tree where the essay asked for eight and say nothing.

And the arithmetic is more. The tree factors p blocks and then log₂p levels of stacked pairs, so it performs strictly more operations than the sweep — about 2mn² for the leaves plus O(pn³) for the tree. On a tall matrix the second term is small, and the point of the method is that it is cheaper anyway because operations are not what is being paid for. Which is the field’s whole argument, appearing for the third time in three essays and in the strongest form: here the reordering that moves less data also does more arithmetic, and is still the one to use.

Classical and modified Gram–Schmidt: the same subtraction, in a different orderTwo panels of pseudocode differing in one argument, with the resulting pairwise dot products of the computed columns listed beneath each.for each previous column i, subtract the projection of column j onto qᵢclassicalr[i][j] = qᵢ · a[j] ↑ the ORIGINAL columnv = v − r[i][j] · qᵢthe three worst |qᵢ · qⱼ|:columns 8 and 9: 1columns 9 and 10: 1columns 7 and 8: 1modifiedr[i][j] = qᵢ · v ↑ what is LEFT of itv = v − r[i][j] · qᵢthe three worst |qᵢ · qⱼ|:columns 2 and 10: 1.8·10⁻⁴columns 1 and 10: 3.2·10⁻⁵columns 4 and 10: 7.9·10⁻⁶The two R factors agree to 2.9·10⁻⁶ relative. The two Q factors do not.the 10×10 Hilbert matrixone word, eight orders
Fig. 6 Orthogonality entry by entry rather than in norm. Every off-diagonal here is an inner product between two vectors that should be perpendicular, and the classical process leaves one of them at 1.0 while every column is still a unit vector to 10⁻¹² — which is why nothing warns you.

Where the name comes from

The literature calls this communication-avoiding QR, and this field has already been careful about that phrase once: the previous essay measures blocking’s traffic exponent at 3.182 against an unblocked 3.185 and concludes that blocking buys a constant rather than a class.

Here the phrase is better earned. The sweep reads the matrix Θ(n) times and the tree reads it once, so the ratio grows with the number of columns rather than sitting at 2.1 — and in the parallel setting, which is where the algorithm was developed, the count being reduced is the number of messages, from Θ(n log p) to Θ(log p), which genuinely is a change of class in the parameter that matters.

That distinction is worth keeping because the two essays sit next to each other and use the same words about different-sized effects. A reordering that improves a constant and a reordering that improves an exponent are both worth doing and are not the same kind of result, and this collection’s asymptotic verdict exists because they are routinely described in the same sentence.

Two reassociations, side by side

This field now contains both possible outcomes of reordering a factorisation, on adjacent pages, and the difference between them is worth stating plainly.

Blocked LU reorders an elimination and returns a bit-identical factorisation — 4.487946226420872 ·10⁻¹⁶ from both orderings, every digit. The reassociation is invisible.

The reduction tree reorders a QR and returns a different R, a different sequence of roundings and a backward error of the same size — 1.65·10⁻¹⁵ against 9.95·10⁻¹⁵. The reassociation is visible and harmless.

Those are different results and the reason for the difference is not the algorithms’ subject matter. Blocked LU defers when an accumulation runs without changing which products go into it or in what order, so every floating-point operation performed is identical to the one the unblocked version performs — it merely happens later. The tree does not defer anything; it computes an entirely different set of reflectors from entirely different data, and the only thing shared with the sweep is what the result must satisfy.

So one is a scheduling change and the other is a different algorithm with the same specification, and the safety of the second rests on a property rather than on an equivalence. Which is the more interesting kind of safety, because it survives changes the first would not: any reduction tree, at any depth, over any partition of the rows, on any number of processors.

The least-squares solution as a projection, with the right angle measuredThe column space drawn edge-on as a plane, the data vector above it, and the perpendicular dropped to the plane, with the residual marked at a right angle to it.everything Ax can reachb = (1.1, 0.4, 1.5)Ax, the closest reachable pointr = b − Ax‖Aᵀr‖ / (‖A‖‖r‖)1.7·10⁻¹⁶‖b‖² − ‖Ax‖² − ‖r‖²1.3·10⁻¹⁵‖r‖1.3200 random nearby points of the plane were tried; none is closer.a 3×2 system, Householder QRperpendicularity is checked
Fig. 7 What a projection does, drawn. Subtracting one from a vector is the step classical Gram–Schmidt takes and the step a reflection does not — and when the vector is nearly in the span already, the subtraction destroys the part that was wanted.

And what would have happened with a projection

The cleanest way to see that the property is doing the work is to imagine the tree built out of Gram–Schmidt instead.

Nothing about the tree’s structure would change. The leaves would still be independent, the matrix would still be read once, the internal nodes would still stack pairs of R factors. Every claim about data movement would go through unaltered.

What would change is that the composition of the levels would no longer be an isometry, so the error present when a level began would be amplified by that level rather than carried — and amplified by a factor that grows with how nearly dependent the columns are. A four-level tree would then be four compounding amplifications instead of four carried errors, and the depth would appear in the answer.

The measurement in the figure is the evidence that this does not happen: 3.38, 4.26, 1.65 and 1.48·10⁻¹⁵ across four depths. It is a null result, and it is the whole reason the method is usable.

The panel, closed

This field’s three essays close a loop that the second one opened.

A blocked LU factors a panel of b columns and then applies the update. The panel factorisation is unblocked by construction — it is a tall-skinny QR-shaped problem in the middle of an elimination — and the previous essay names it as the part that does not block, and as the reason the measured saving is 2.12 rather than the factor of six the count suggests.

The tree is what to do about it. A panel is n rows by b columns with n ≫ b, which is exactly the shape this essay is about, and factoring it as a reduction tree rather than as a sweep removes the bottleneck the blocking left. That is why “communication-avoiding LU” and “communication-avoiding QR” are usually described together: the second is a component of the first.

Nothing here implements that combination, and it would be the natural next measurement — three counters again, on an elimination whose panel is a tree, against one whose panel is a sweep. What is worth stating without it is that the two essays’ subjects are not two examples of one idea. They are one algorithm with the same idea applied at two levels, and the level the second one reaches is the one the first could not.

The one number the sweep has that the tree does not

Worth stating so the ladder in the figure is not read as a ranking with a winner.

The sweep produces R and a representation of Q that is standard, compact and easy to apply: the reflectors, stored in the space the matrix vacated, in a fixed order. Applying Qᵀ to a vector is a loop over them. That representation is what LAPACK returns and what every downstream routine expects.

The tree produces R and a representation of Q that is a structure — a list of leaf reflectors plus the internal nodes’ — and applying it means traversing that structure in the right order. It is perfectly doable and it is genuine engineering, and it is why the two methods are not interchangeable at an interface even though they compute the same factorisation.

So the figure ranks four algorithms on one axis, backward error, and the two at the top of it differ on an axis the figure does not have. A reader taking away “use the tree” should take away “use the tree when the matrix is tall enough that reading it twelve times is the cost, and be ready to store a Q that is not a list of reflectors”.

What is left

The parallel measurement, which is the one the algorithm exists for and which this site cannot make. Everything here is a count on a model of one memory; the interesting quantity is messages between processors, and there are none of those here.

Q, and the applications that need it. A least-squares solve needs Qᵀb rather than Q, which the tree can supply without forming Q — but a block Krylov method needs the orthonormal basis itself, and that is where the implicit representation has to be traversed rather than avoided.

And the other reassociation. The maturity phase found that the implicit double shift and the explicitly formed product agree to 2.2·10⁻¹⁵ entry by entry in absolute value while a norm of their difference is about 8, because “essentially unique” in the implicit Q theorem means up to the signs of the columns. The same caveat applies to the R here and is not measured: the tree’s R and the sweep’s may differ by a diagonal of signs, which is why the comparison is made through RᵀR rather than through R.

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.

Named objects

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

Backward stabilityData movementGram–SchmidtHouseholder reflectionOrthogonalityQR factorisationReduction treeTall skinny qr