- 9,000lines of plain Rust that define every metric
- 32Rust integration tests, plus fifteen CUDA test files
- 3spectral metrics that exist only as the CPU reference
A GPU kernel that computes a statistic is a poor definition of that statistic. It is tuned for throughput and it reorders its reductions. So every metric my CUDA engine computes exists twice: once as a kernel and once as plain Rust on the CPU, and the CPU version is the definition. The reference library is about 9,000 lines across thirteen modules, cohesion, diversity, substructure, spatial, dual-space, quantum, spectral, sigma, composites, exact search and top-k among them. The kernels are checked against it, and the documentation is checked against both.
What the twin is for
The reference is written for clarity, not speed, so a reader can confirm the formula by inspection. It is also where the edge cases are decided, and the kernel must match the reference on them.
When a kernel is wrong, it is wrong at speed.
Three metrics in the spectral family live only in the reference. They need the eigenvalues of a Gaussian Gram matrix, which caps them at 2,000 members, and until the kernel exists the CPU version is the metric.
The tolerance
The triangle
A kernel, its reference and its lineage file can each drift from the other two. The lineage file for every kernel group records the formula, the kernel, the Rust wrapper, the destination column in PostgreSQL, the edge-case conventions and the measured timings. A consistency matrix checks all three against each other for every group: GPU against CPU, CPU against the documented formula, documented formula against the GPU. Every group passes. When the check was first run it found the gaps it was built to find, including metric identifiers that meant different things in the database layer and in the kernels.
Tests as the proof
What this demonstrates
Numerical GPU code held to a written definition rather than to its own output. The reference library is the contract, the tolerance is derived from the arithmetic, and the consistency check keeps code, reference and documentation from drifting apart.