One nonzero is a birthday problem
Worth reading first: The dimension does not appear · Randomisation does not create structure.
The sketch that is not the answer showed what a sketched preconditioner is. Sketch to a small matrix , factor it, and use its to precondition an iteration on itself. The condition number the iteration then sees is the same number at every from a hundred to ten billion, because the spectrum cancels: equals , with an orthonormal basis of the range of . So all that decides a sketched preconditioner’s quality is how well preserves one subspace.
That essay measured a dense Gaussian sketch and noted why nobody would ship one: applying it costs more than the solve it is meant to save. “The sketches that ship are subsampled randomised Hadamard transforms … or sparse embeddings, CountSketch, with one nonzero per column. The theory in this essay does not care which; the distortion is what it needs, and all three provide it at their own .” A sketch that finds the columns it can see then compared range finders on a coherent matrix, and found one nonzero in a row costing a low-rank error that three repaired. Neither measured the one number in question, and “at their own ” hides what that width is.
One number, three bases
Since is the whole story, can be removed from the experiment and chosen directly. Three orthonormal bases on 1,000 rows are used, at dimension 16. An incoherent one has every row carrying about the average share of the leverage, . A half-spiked one has half its directions on single rows and the rest incoherent. A fully spiked one is : every direction lives on exactly one row, and every leverage is either one or zero. The leverage that did not move has already measured how a row’s leverage can resist an approximation.
Six sketches are applied. A Gaussian one of rows. Sparse ones with 8, 4, 2 and 1 nonzeros in each column of , each in a random row with a random sign; the last is CountSketch. And uniform sampling of rows, scaled, which is what a sketch reduces to if it has no mixing at all. Each is run sixteen times per width, and the smallest singular value decides whether a draw counts as singular.
The first stop of the dial, the incoherent basis, is the surprise in the other direction. All four curves lie on top of one another. At twice the dimension the medians are 4.75, 4.44, 4.80 and 4.81, for Gaussian, four, two and one nonzero. At four times it is 2.61, 2.58, 2.57 and 2.68. Uniform sampling also reads 2.64 there. On an incoherent basis every sketch is a Gaussian, including the one with no mixing at all, because each row of is already small and a random selection of them is about as good as a random combination.
So what a Gaussian is buying has nothing to do with the incoherent case, and a benchmark on a random matrix cannot see any difference between these sketches. A person concluding from that benchmark that one nonzero is fine would be correct about that matrix.
Spikes separate them
Now move the dial. The half-spiked basis detaches the one-nonzero sketch from the others: its median is singular up to four times the dimension, with 10 draws of 16 singular at that width, whereas all the others stay close to 2.6. The fully spiked basis makes it stark. At four times the dimension one nonzero is singular on 14 of 16 draws, at eight times on 8 of 16, and at sixteen times on 5 of 16. Uniform sampling is singular on every draw at every width, since it would need to pick all 16 of the non-zero rows from 1,000 and it never will, and no further reading is needed for it.
The reason for one nonzero is familiar to anybody who has counted people in a room.
A column of with one nonzero sends that row of into one bucket. If two of the sixteen spiked rows land in the same bucket, two rows of are merged, and loses rank. There is nothing approximate about it: the matrix is singular and no preconditioner exists. The chance is that of two of sixteen people sharing a birthday in a year of days, which is about . At of 32, 64, 128 and 256 that chance is 0.99, 0.87, 0.62 and 0.38. The measurement gives 16, 14, 8 and 5 draws in sixteen, or 1.00, 0.88, 0.50 and 0.31.
If no collision happens, the sketch does something remarkable: it is a perfect isometry on this basis, up to signs, and is exactly 1.00. That is the median reading at sixteen times the dimension, the first median that is not singular. So a one-nonzero sketch on a spiked basis is either perfect or singular, with nothing in between, and a median across the draws hides that completely. A code that estimates from one run would see either 1.00 or a failure, and neither is a typical value of anything.
Against the width divided by the square of the dimension, three dimensions fall near a single curve, as the formula says they must. So the width that escapes this is proportional to , and that is what “its own ” means for CountSketch. At a dimension of 16, a width of 128 still fails half the time. At a dimension of 32, a width of 256 fails on 13 of 16. A sketch at the conventional four times the dimension is singular nearly always, whatever the dimension. And by a dimension of 1,000 the width needed to be safe is of the order of a million, far past the point where anything has been saved.
Two nonzeros are a long way from one
The repair needs almost nothing.
With two nonzeros in each column, a spike goes to two buckets. Collisions still happen, but two spikes must share both of their buckets to merge outright, and that is rare at any width worth using. On the fully spiked basis two nonzeros are singular on 9 of 16 at 1.5 times the dimension, 3 of 16 at twice, and on none at three times or above. At four times, the median is 2.88 against the Gaussian’s 2.68. Four nonzeros are not distinguishable from a Gaussian at any width or on any basis measured, within a fifth at every setting, and eight add nothing further.
This agrees with the range-finder measurement from the other side of the field: there, three or four nonzeros in a row brought the error back to the Gaussian’s. It does sharpen it in one way. That essay’s conclusion was that the flatness on an incoherent matrix is useful, because a code need not know its matrix in advance if it pays for three nonzeros. Here the same price buys a qualitatively different guarantee. It is not a matter of a better error: one nonzero’s failure is a singular matrix and a preconditioner that does not exist, and the difference between one and two is what stands between a solve and a Cholesky breakdown.
There is a useful mechanism for why so little suffices. Each spike has become a pair of entries, and becomes the incidence matrix of a random graph with vertices and edges, each spike an edge. Such a matrix loses rank only when an edge set forms a closed structure, and with a few times a random graph of that density is a forest with at most a few small cycles. That is the threshold behind random-graph arguments in general, and it explains why width proportional to now suffices for what needed with a single nonzero. It is a sound account of the mechanism, and these measurements do not distinguish it from others.
What a width is worth, and what a nonzero costs
The conversion from to work is the usual rate, and it says how much each width is worth. A Gaussian at twice the dimension promises 60 iterations, at three times 42, at four times 36, and at eight times 25. Two nonzeros run 71, 45, 39 and 32. So at four times the dimension two nonzeros cost three iterations out of thirty-six. A one-nonzero sketch promises no number at all until the width is beyond any width anyone uses.
And cost is where the sparse sketches win, by a margin that dwarfs all this.
For a matrix of 100,000 rows, sixteen columns and sixteen nonzeros a row, applying a Gaussian of width 64 costs multiplications, as much as all the iterations together. Applying four nonzeros costs , and two nonzeros costs . The iterations cost about in every case, and the small factorisation is sixteen thousand, a number that can be dropped from any discussion. So with sparse sketches the total is the iterations plus a few per cent. One further nonzero per column adds multiplications to a solve of : about one per cent for the guarantee that the preconditioner exists. A person choosing between one nonzero and two is choosing whether to save a little over 1 per cent, against failure on any coherent problem.
The original comparison of these three sketches, “dramatically lower” cost at “slightly worse” guarantees, was too kind by far to one of them. The dimension does not appear described the sparse case in these terms, with one nonzero in each column, and it was entirely correct for the vectors it measured, which are not spiked. It is for an arbitrary subspace, one a program has not looked at, that the two terms part company. And that is the only case where an oblivious sketch was ever needed, because a code that knows its leverages can simply sample by them.
The worst draw, which is the one a code runs
A median is the wrong summary of a method run once, and the worst of sixteen draws separates the sparse sketches further than their medians do. On the spiked basis at four times the dimension, the Gaussian’s worst is 2.85 and eight nonzeros reach 2.93, within a few per cent. Four nonzeros reach 4.25, though their median is the Gaussian’s, and two reach 5.03. Translated into iterations, those worst draws promise 38, 39, 58 and 69. At eight times the dimension they close again to 27, 26, 32 and 35. So “four nonzeros are a Gaussian” is a statement about the median, and a code that wants the Gaussian’s reliability from a single draw should either use eight nonzeros or widen the sketch. This is the same warning as what a single draw cannot report, and it costs little to act on: going from four to eight nonzeros adds multiplications to a solve of .
A retry is a different kind of insurance. A singular or nearly singular factor shows on the diagonal of at no extra cost, so a code could simply draw again. With one nonzero the chance of success on a fully spiked basis of dimension is the birthday formula’s complement, and the expected number of draws is its reciprocal. At a dimension of 16 and a width of four times that, the chance is 0.13, so about eight draws, each with its own product and factorisation. At a dimension of 32 the chance falls to 0.014 and the expected draws are seventy. At 64 it is and the expected draws are about five thousand. A retry works for small problems and then stops working, which is an unattractive property in something meant to be used without looking at the data, and one further nonzero removes the need for it at a one per cent cost.
How common is a spiked basis?
Perfectly spiked bases are not common; a data matrix does not arrive as . But one row of high leverage is common and so is a handful. The half-spiked case here, with eight rows of full leverage, already fails on ten draws of sixteen at four times the dimension, and a matrix with a few dummy variables, indicator columns, or a block of rows that dominate some direction is halfway to this. A one-hot encoding of a categorical variable with rare categories produces a column with only a few nonzero entries, and an observation that is alone in its category has a leverage of exactly one. Several of those are spikes in exactly the sense measured here. Two observations that hide each other is about the same high-leverage rows from the statistical side. A failure on such data would look like a singular in a factorisation, with no evident cause, on a matrix whose condition number is modest.
It helps to say what a code would observe. On a matrix with a few such rows, a one-nonzero sketch gives a factor with one diagonal entry many orders below the rest, on about half of the draws, and on the others a perfectly reasonable . So the failure looks intermittent, and a person debugging it will reasonably suspect the data or the seed rather than the sketch. A code that retries silently has made it invisible as well, and that code’s run time then varies from one seed to the next by a factor that has no obvious reason. That is an unusual failure mode for something usually described in terms of a modest constant.
Sixteen draws at a dimension of sixteen
Dimension 16 at 1,000 rows, sixteen draws per setting, and three bases that were built to be clear cases. Sixteen draws can only resolve a failure rate of about six per cent, so “no draw singular” is not the same as “never”. The iteration counts are from a rate formula rather than from running LSQR, although the original essay found a run to agree with its rate. The cost count treats a product by a sparse sketch as per nonzero with no regard for memory access, and the actual gap with a Gaussian on a real machine depends on which arithmetic is fast. Subsampled Hadamard transforms have not been measured here, and nor have sparse sketches with nonzeros placed in the rows rather than in the columns, which is a different object with different collisions.
Still open: how few nonzeros on real leverage, and a sketch that checks itself
Graded leverage rather than spikes. The bases here have leverages of one and zero. The prediction with a sign is that on a basis whose leverages fall geometrically by a factor of two, the one-nonzero sketch at four times the dimension is never singular, because the small leverages leave room in every bucket, but it reads a median above five, twice the Gaussian’s, while two nonzeros read within a fifth. So the failure on ordinary data would be a factor of a few rather than a catastrophe, and it would still be priced in iterations.
The half-spiked retry. A half-spiked basis has fewer spikes to collide, so its success rate is the birthday formula at half the dimension. The prediction is that with eight spikes at a width of 64, a one-nonzero sketch succeeds on two draws in three rather than the six in sixteen measured here, if the incoherent half of the basis does not contribute collisions of its own, and that the shortfall measured against that formula is a direct reading of how much of a basis’s failure is due to its incoherent part.
Shares its objects with
Essays that name at least two of the same things, and that neither author linked.
- The half of a problem a sketch may touch — both name condition number, oversampling, random projection, sketching, subspace-embedding
- An answer that changes with the seed — both name oversampling, random projection, sketching
- Built from products alone — both name oversampling, random projection, subspace-embedding
- A fade made of drops — both name random projection, sketching
- Promotion buys rank, not safety — both name random projection, sketching
- Sketching what is never unfolded — both name oversampling, sketching
Named objects
A flat tag is an object no other essay names yet.
Condition numberOversamplingRandom projectionSketch-and-preconditionSketchingSubspace-embedding