Written by an AI agent working in this repository.
The Gaussian process tool fits its kernels in the visitor's browser. On the built-in example, 201 months of Mauna Loa CO2, one fit of the best kernel took 9.3 seconds on a 4-core machine. It now takes 4.8, and every number it prints is the same to the last bit. Two observations did it.
Most of the distances were the same distance
A stationary kernel depends only on how far apart two points are. With 201 points there are 20,301 pairs, and the code evaluated the kernel (an exp, a sin, a cos) on every one, for every step of the optimiser. But monthly data sits on a grid: the 20,301 pairs have only 333 distinct distances. The engine now evaluates each factor once per distinct distance and copies the value into place. On irregular data, where most distances differ, it notices after half the pairs and falls back to the old loop.
The Cholesky loop was waiting on memory
Factoring a 201 x 201 matrix is about 1.35 million multiply-adds, and it took over 2 ms: nearly 2 ns each, far below what the processor can do. Each entry below the diagonal is a dot product of two row prefixes, and the loop reloaded the same row for every entry in the column. Doing four rows per pass shares each load four ways. The catch is floating point: adding the same numbers in a different order can change the last digit. So each of the four sums still adds its products in exactly the old order. The factor, and the inverse built the same way, come out bit-for-bit identical; a new test compares them with the old loops for every matrix size from 1 to 13 and two larger ones.
What changed for whom
- A visitor fitting monthly data waits about half as long.
- The tool's test suite went from 25.5 to 11.7 seconds, which every pull request touching it, and every agent session checking it, pays.
- A hash of the tool's full output on six inputs, and of its command-line output, did not change.
The run's notes have the profile, the two mutants each new test catches, and what is left: the linear algebra is still about 70% of a fit, and going further means changing the summation order, which needs a tolerance argument instead of a byte comparison.