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

gpr/ml/GaussianProcessRegression.cpp

Construction, hyperparameters, priors, cache stamps, dispatch

initialize, setHyperparameters, prepareTrainingPermutation, currentLaplacePosteriorStamp, calculateVarianceDispatched, evaluateEnergyLocalOnly

gp/Predict.cpp

Posterior mean and the mean-prediction dispatch

refreshPosteriorWeights, calculateMeanPrediction, calculatePotential, calculatePotentialDispatched

gp/Variance.cpp

MAP variance and the local variants

calculateVariance, calculatePotentialLocal, calculateVarianceLocal, calculateObservationPosteriorCovariance

gp/CovarianceAssembly.cpp

Training and cross covariance assembly

evaluateTrainingCovarianceMatrix, evaluateCovarianceMatrix, assembleCrossCovarianceDistributed

gp/Decompose.cpp

Cholesky and HSSVD factorisation entry points

decomposeCovarianceMatrix, decomposeCovarianceMatrixScalapack, buildHssvdDualLocalModel

gp/EnergyGradient.cpp

Training objective and its gradient

evaluateEnergy, evaluateGradient, evaluateEnergyAndGradient

gp/Optimize.cpp

Hyperparameter optimisation drivers and adaptation

optimize, monitorAndAdaptHyperparameters, updateModelWithFullData

gp/KrylovObjective.cpp

Matrix-free objective and its backend choice

evaluateKrylovObjective, evaluateKrylovGradient, planObjectiveBackend

gp/Hessian.cpp

Directional curvature and the exact Hessian

evaluateDirectionalCurvature, assembleExactHessian, assembleHessianInDirections

gp/LaplacePosterior.cpp

Laplace posterior cache and factors

ensureLaplacePosterior, buildLaplacePosteriorState, calculateVarianceLaplace

gp/LaplaceSlice.cpp

Slice, PSIS and delta-method Laplace arms

ensureSliceLaplacePosterior, ensurePsisLaplacePosterior, ensureLaplaceDeltaCache, calculatePotentialLaplace

gp/INLA.cpp

INLA mode finder

optimizeLaplaceINLA, computeInlaPosteriorMode

gp/BMA.cpp

Bayesian model averaging arm

runBMAGrid, calculatePotentialBMA, calculateVarianceBMA

gp/SVGD.cpp

SVGD particle arm

fitSVGDFromScratch, calculatePotentialSVGD, calculateVarianceSVGD

gp/RFF.cpp

Random Fourier feature arm

buildRFFModel, calculatePotentialRFF, calculateVarianceRFF

gp/RFFSelection.cpp

Held-out automatic random-feature selection

selectRFFFeatures, planRFFFeatureValidation, rffFarthestPointOrder

gp/ActivePosterior.cpp

Posterior conditioning on a retained full posterior

fitActivePosterior, conditionActivePosterior, calculateActivePosteriorMean

gp/HyperparameterPosterior.cpp

Shared hyperparameter quadrature for local models

buildHyperparameterPosterior, conditionOnHyperparameterPosterior

gp/AtomicEnvironment.cpp

Atomic-environment observations

fitAtomicEnvironmentModel, calculateAtomicEnvironmentPotential

gp/RobustRows.cpp

Student-t scale mixture for training rows

updateRobustRowWeights

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

gp/StableBasis.cpp

Hilbert-Schmidt SVD stable basis for the squared-exponential kernel

gpr/ml/GaussianProcessRegression.h, gpr/neb/GPNEB.cpp

gp/PairLocalKernel.cpp

The Sexpat kernel on radial pair features, and its pair-local tiles

gpr/ml/GaussianProcessRegression.h, gp/Variance.cpp

gp/LowRankSolve.cpp

Pivoted partial Cholesky and Woodbury noisy solve

tests/gpr/ml/gp/LowRankSolveTest.cpp only

gp/DerivativeSKI.cpp

D-SKI and D-SKIP structured kernel interpolation for a gradient-enhanced GP

tests/gpr/ml/gp/DerivativeSKITest.cpp, benchmarks/bench_dskip_rank.cpp

gp/DerivativeVecchia.cpp

Derivative-aware Vecchia local conditioning

tests/gpr/ml/gp/DerivativeVecchiaTest.cpp, benchmarks/bench_vecchia_accuracy.cpp

gp/IterGP.cpp

IterGP posterior and computational uncertainty

tests/gpr/ml/gp/IterGPTest.cpp only

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.h holds inline leaf functions shared by the translation units, in gpr::detail. The core file has using namespace gpr::detail;; the other files add using detail::X; for the helpers they call.

  • gp/LaplacePosteriorTypes.h holds the full definitions of LaplacePosteriorStamp, LaplacePosteriorSignature, LaplacePosteriorState and SliceLaplaceState. 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:

  1. Declare the methods in gpr/ml/GaussianProcessRegression.h, next to calculatePotentialBMA and calculatePotentialSVGD.

  2. Create a .cpp named after the arm under gpr/ml/gp/. Include ../GaussianProcessRegression.h and, when needed, Helpers.h and LaplacePosteriorTypes.h.

  3. Define the methods at namespace scope, for example void GaussianProcessRegression::calculatePotentialFOO(...).

  4. List the file in meson.build among the other gpr/ml/gp/ entries.

  5. Add the arm to calculatePotentialDispatched in gp/Predict.cpp and to calculateVarianceDispatched in gpr/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.