GP module layout¶
Status: implemented. This page describes the files under gpr/ml/gp/ as they are in the source tree.
The class gpr::GaussianProcessRegression is declared once, in gpr/ml/GaussianProcessRegression.h, and defined across 20 translation units: the core file gpr/ml/GaussianProcessRegression.cpp and 19 files under gpr/ml/gp/ that hold one concern each. They share the private members of the class through the public header. Six more .cpp files under gpr/ml/gp/ are standalone units that do not define the class. Meson compiles all of them.
The canonical C++ source root is gpr/, and the tests are under tests/gpr/. A second copy of ml/, neb/ or the dimer code outside gpr/ is not allowed: a parallel tree bypasses the build graph and makes source searches disagree with the code that is compiled.
Files that define the class¶
The split by concern lets a change to one uncertainty arm or one linear-algebra entry point stay in one file. The method names are the ones defined in each file.
File |
Concern |
Representative methods |
|---|---|---|
|
Construction, hyperparameters, priors, cache stamps, dispatch |
|
|
Posterior mean and the mean-prediction dispatch |
|
|
MAP variance and the local variants |
|
|
Training and cross covariance assembly |
|
|
Cholesky and HSSVD factorisation entry points |
|
|
Training objective and its gradient |
|
|
Hyperparameter optimisation drivers and adaptation |
|
|
Matrix-free objective and its backend choice |
|
|
Directional curvature and the exact Hessian |
|
|
Laplace posterior cache and factors |
|
|
Slice, PSIS and delta-method Laplace arms |
|
|
INLA mode finder |
|
|
Bayesian model averaging arm |
|
|
SVGD particle arm |
|
|
Random Fourier feature arm |
|
|
Held-out automatic random-feature selection |
|
|
Posterior conditioning on a retained full posterior |
|
|
Shared hyperparameter quadrature for local models |
|
|
Atomic-environment observations |
|
|
Student-t scale mixture for training rows |
|
Standalone units¶
These six files under gpr/ml/gp/ each have a header of the same name and do not define GaussianProcessRegression methods.
File |
Content |
Used by |
|---|---|---|
|
Hilbert-Schmidt SVD stable basis for the squared-exponential kernel |
|
|
The Sexpat kernel on radial pair features, and its pair-local tiles |
|
|
Pivoted partial Cholesky and Woodbury noisy solve |
|
|
D-SKI and D-SKIP structured kernel interpolation for a gradient-enhanced GP |
|
|
Derivative-aware Vecchia local conditioning |
|
|
IterGP posterior and computational uncertainty |
|
The last four are built into libgpridge, but no other source file includes their headers. Only their tests and benchmarks use them.
Private headers¶
The headers in gpr/ml/gp/ are not public API. Two of them exist because of the split:
gp/Helpers.hholds inline leaf functions shared by the translation units, ingpr::detail. The core file hasusing namespace gpr::detail;; the other files addusing detail::X;for the helpers they call.gp/LaplacePosteriorTypes.hholds the full definitions ofLaplacePosteriorStamp,LaplacePosteriorSignature,LaplacePosteriorStateandSliceLaplaceState. The public header forward-declares them, so all Laplace files share one definition.
The other headers belong to one concern each: ArrowheadSpectrum.h, CalibrationBounds.h, KernelGeometryIdentity.h, OptimizerState.h, QuadraticEvidence.h, TiedLengthScaleObjective.h, and the headers of the standalone units above.
Add an uncertainty arm¶
The how-to guide Add an uncertainty arm gives the steps with the configuration side. The steps that concern this layout are:
Declare the methods in
gpr/ml/GaussianProcessRegression.h, next tocalculatePotentialBMAandcalculatePotentialSVGD.Create a
.cppnamed after the arm undergpr/ml/gp/. Include../GaussianProcessRegression.hand, when needed,Helpers.handLaplacePosteriorTypes.h.Define the methods at namespace scope, for example
void GaussianProcessRegression::calculatePotentialFOO(...).List the file in
meson.buildamong the othergpr/ml/gp/entries.Add the arm to
calculatePotentialDispatchedingp/Predict.cppand tocalculateVarianceDispatchedingpr/ml/GaussianProcessRegression.cpp.
History¶
The class was split on 2026-05-09 in a series of refactor(ml): extract ... into gp/... commits. The files for the later features (Vecchia, D-SKI, IterGP, active posterior, atomic environments) were added after that date; git log --diff-filter=A -- 'gpr/ml/gp/*.cpp' lists them with their dates.