namespace gpr¶
Overview¶
Gaussian-process regression, kernels, priors, and the searches that run on the surrogate. More…
namespace gpr {
// namespaces
namespace gpr::abi;
namespace gpr::bo;
namespace gpr::bo::testing;
namespace gpr::capi;
namespace gpr::capi::testing;
namespace gpr::cli;
namespace gpr::coord;
namespace gpr::derivatives;
namespace gpr::derivatives::generated;
namespace gpr::extended;
namespace gpr::extended::directed;
namespace gpr::extended::scaled;
namespace gpr::field;
namespace gpr::geometry;
namespace gpr::htst;
namespace gpr::io;
namespace gpr::irc;
namespace gpr::itergp;
namespace gpr::kokkos_environment;
namespace gpr::laplace;
namespace gpr::linalg;
namespace gpr::linalg::backend;
namespace gpr::linalg::canonical;
namespace gpr::linalg::cutlass;
namespace gpr::linalg::fixed;
namespace gpr::linalg::kokkos_joint;
namespace gpr::linalg::linop;
namespace gpr::linalg::portable_tiles;
namespace gpr::linalg::schemeii;
namespace gpr::memory;
namespace gpr::neb;
namespace gpr::neb::oie;
namespace gpr::numerics;
namespace gpr::optim;
namespace gpr::optim_abi;
namespace gpr::pairlocal;
namespace gpr::policy;
namespace gpr::posterior;
namespace gpr::potentials;
namespace gpr::priors;
namespace gpr::quantum;
namespace gpr::quantum::bathresponse;
namespace gpr::quantum::beadcorrection;
namespace gpr::quantum::elementfluct;
namespace gpr::quantum::functionaldesign;
namespace gpr::quantum::gaussian;
namespace gpr::quantum::ratepost;
namespace gpr::quantum::ringbath;
namespace gpr::quantum::ringspread;
namespace gpr::quantum::spectraldet;
namespace gpr::readcon_abi;
namespace gpr::readcon_db_abi;
namespace gpr::rgmin_abi;
namespace gpr::rgpot_abi;
namespace gpr::runtime;
namespace gpr::sfc;
namespace gpr::ski;
namespace gpr::startup;
namespace gpr::track;
namespace gpr::uasaddle;
namespace gpr::vecchia;
// typedefs
typedef uint32_t Index_t;
typedef Eigen::Matrix<double, EigenDynamic, EigenDynamic, EigenMatrixStorage> EigenMatrix;
typedef Eigen::Matrix<double, EigenDynamic, EigenDynamic, FieldMatrixStorage> FieldMatrixd;
typedef Eigen::Matrix<int, EigenDynamic, EigenDynamic, FieldMatrixStorage> FieldMatrixi;
typedef Eigen::Matrix<Index_t, EigenDynamic, EigenDynamic, FieldMatrixStorage> FieldMatrixIdx;
typedef Eigen::Matrix<uint8_t, EigenDynamic, EigenDynamic, FieldMatrixStorage> FieldMatrixU8;
typedef FieldMatrixd Coord;
typedef Eigen::Vector3d vector3_reg;
typedef std::vector<CutoffPairFeature> CutoffPairFeatures;
typedef std::function<bool(const Eigen::VectorXd&, Eigen::VectorXd&, bool&exact_refusal)> RefusalAwareHessianAction;
typedef std::function<RefusalAwareHessianAction(const Eigen::VectorXd&, bool&exact_refusal)> RefusalAwareHessianPreparation;
typedef std::function<EigenMatrix(const std::vector<double>&lengthscales, double noise)> KernelMatrixBuilder;
// enums
enum BorderedSchurSign;
enum ChartScalarKernel;
enum GPModelProfile;
enum HyperparameterObjectiveMode;
enum HyperparameterOptimizationMode;
enum MapPriorWeightMode;
enum PriorMeanStatistic;
enum ScgCurvatureMode;
enum UncertaintyMode;
// structs
struct ARDSearchResult;
struct AdamOptimizationSettings;
struct AtomicEnvironments;
struct AtomsConfiguration;
struct AtomsPositionAndType;
struct BMAPrediction;
struct BorderedNoiseReport;
struct BorderedVarianceInterval;
struct CanonicalDimerDefaultOptions;
struct CeresOptimizationSettings;
struct CutoffPairFeature;
template <typename T>
struct Derivatives;
struct DeviceResidency;
struct EnergyAndGradient;
struct EnergySurfaceOutputInfo;
struct FactoredTrainingGeometry;
struct GPRSetup;
struct INLAPrediction;
struct Indices2D;
struct InputParameters;
struct IterationsLimits;
struct JointObservationVarianceReduction;
template <typename T>
struct KeyValuePair;
struct LBFGSInfo;
struct LazyFactoredTrainingGeometry;
struct NoiseSearchResult;
struct Observation;
struct OptimizerCommonSettings;
template <typename T>
struct Pair;
struct PhaseTimers;
struct PhaseTotals;
struct PublicLayoutBytes;
struct RFFFeatureSelection;
struct RFFValidationPlan;
struct RadialPairFeature;
struct RigidDeflationDiagnostic;
struct SaddleCertificate;
struct ScaleFreeTrustConfig;
struct ScgOptimizationSettings;
struct SexpatLocalOracleScope;
struct StableBasisPosteriorWeights;
struct StopCriteriaForDimer;
struct StructuredPermutation;
struct SupportedAtomicEnvironments;
struct TrainingKernelGeometry;
struct TrainingKernelGeometryBlock;
struct TrainingKernelGeometrySubset;
struct TransitionParameters;
template <typename T>
struct Triplet;
// classes
class ARDGridSearch;
class AdditivePairKernel;
class AtomicInducingPosterior;
class BayesianModelAveraging;
class ConditionalKernelProjection;
class ConditionalPosterior;
class ConditionedKernel;
class ConstantCF;
class ConstrainedChartCovariance;
class FactorizedLikelihood;
class FeatomicEnvironmentDescriptor;
class GaussianProcessRegression;
class GeodesicCovarianceEvidence;
class GeodesicHeat;
class GeodesicHeatEnergyForceKernel;
class InverseDistanceDescriptor;
class KernelOperator;
class Kronecker;
class LaplaceINLA;
class LikGaussian;
class LowRankCholesky;
class ManifoldEnergyForceKernel;
class Matern52;
class ModeRefitPolicy;
class MpiLifetime;
class NoiseGridSearch;
class ObservationLikelihood;
class PairCutoff;
class PriorBase;
class PriorGaussian;
class PriorLogNormal;
class PriorLogUnif;
class PriorSqrtt;
class PriorT;
class PriorUnif;
class Project;
class Pullback;
class RFFFeatureSelectionError;
class RFFModel;
class RandomFourierFeatures;
class ScaleFreeTrustRegion;
class ScopedPhaseTimer;
class ScopedPredictTimer;
class ScopedVarianceTimer;
class Sexpat;
class SexpatCF;
class SpeciesEnvironmentKernel;
class StableBasis1D;
class StableBasisND;
template <typename Radial>
class StationaryChartKernel;
class StudentTProcessRegression;
class Sum;
class TrustRadius;
class WallClockLimit;
class WallClockLimitReached;
// global variables
auto EigenDynamic = Eigen::Dynamic;
auto EigenMatrixStorage = Eigen::StorageOptions::ColMajor;
auto FieldMatrixStorage = Eigen::StorageOptions::RowMajor;
ChartScalarKernel kDefaultChartScalarKernel = ChartScalarKernel::SquaredExponential;
bool sexpat_local_oracle_active = false;
double g_geom_build_seconds = 0.0;
double g_max_cond_k = 0.0;
double g_max_abs_alpha = 0.0;
double kRFFEnergyNoiseFloor = 1e-6;
double kRFFGradientNoiseFloor = 1e-4;
double kRFFForceConvergenceTolerance = 0.0514221;
std::uint64_t kRFFValidationMemoryCapBytes = 256ull* 1024ull* 1024ull;
int kRFFFeaturesAuto = -1;
// global functions
std::optional<ConvergenceNormType> parseForceNorm(std::string_view name);
std::string_view forceNormName(std::optional<ConvergenceNormType> norm);
template <class Derived>
double forceNorm(const Eigen::MatrixBase<Derived>& force, ConvergenceNormType norm);
template <class Derived>
double forceDualNorm(const Eigen::MatrixBase<Derived>& direction, ConvergenceNormType norm);
std::vector<CutoffPairFeatures> cutoffPairFeatures(const Coord& positions, const AtomsConfiguration& configuration);
std::vector<CutoffPairFeatures> radialPairFeatures(const Coord& positions, const AtomsConfiguration& configuration);
std::vector<CutoffPairFeatures> radialPairFeatures(const Coord& positions, const AtomsConfiguration& configuration, double far_radius);
std::vector<FieldMatrixd> cutoffPairSquaredDistances(const Coord& left, const Coord& right, const AtomsConfiguration& configuration, const FieldMatrixd& lengths);
std::vector<FieldMatrixd> radialPairSquaredDistances(const Coord& left, const Coord& right, const AtomsConfiguration& configuration, const FieldMatrixd& lengths, double far_radius);
template <typename Function>
void forEachCutoffPair(const CutoffPairFeatures& left, const CutoffPairFeatures& right, Function&& function);
std::string sha256Hex(const void* data, std::size_t size);
std::string sha256File(const std::string& path);
bool conditionKernelMatrix(const Eigen::MatrixXd& joint, const std::vector<Eigen::MatrixXd>& derivatives, Eigen::Index anchor_rows, Eigen::Index query_rows, Eigen::Index dimensions, const Eigen::VectorXd& anchor_noise, Eigen::MatrixXd& covariance, std::vector<Eigen::MatrixXd>& conditional_derivatives);
bool conditionKernelMatrix(const Eigen::MatrixXd& joint, const std::vector<Eigen::MatrixXd>& derivatives, Eigen::Index anchor_rows, Eigen::Index query_rows, Eigen::Index dimensions, const Eigen::VectorXd& anchor_noise, Eigen::MatrixXd& covariance, std::vector<Eigen::MatrixXd>& conditional_derivatives, const linalg::LocalExecutor& execution);
KernelOperator::CrossCovarianceFunction makeKernelCrossCovariance(std::shared_ptr<const KernelOperator> kernel, const Eigen::MatrixXd& training);
KernelOperator::MeanFunction makeKernelMean(std::shared_ptr<const KernelOperator> kernel, const Eigen::MatrixXd& training, const Eigen::VectorXd& weights);
KernelOperator::MeanHessianFunction makeAnalyticKernelMeanHessianVector(const std::shared_ptr<const KernelOperator>& kernel, const Eigen::MatrixXd& training, const Eigen::VectorXd& weights);
KernelOperator::MeanHessianPreparation makeAnalyticKernelMeanHessian(const std::shared_ptr<const KernelOperator>& kernel, const Eigen::MatrixXd& training, const Eigen::VectorXd& weights);
KernelOperator::MeanHessianFunction makeKernelMeanHessianVector(std::shared_ptr<const KernelOperator> kernel, const Eigen::MatrixXd& training, const Eigen::VectorXd& weights);
RefusalAwareHessianPreparation makeRefusalAwareKernelMeanHessian(std::shared_ptr<const KernelOperator> kernel, const Eigen::MatrixXd& training, const Eigen::VectorXd& weights, bool* all_exact = nullptr, bool* has_exact_or_refusal = nullptr);
KernelOperator::MeanHessianPreparation makeKernelMeanHessian(std::shared_ptr<const KernelOperator> kernel, const Eigen::MatrixXd& training, const Eigen::VectorXd& weights);
KernelOperator::MeanHessianMatrixFunction makeKernelMeanHessianMatrix(std::shared_ptr<const KernelOperator> kernel, const Eigen::MatrixXd& training, const Eigen::VectorXd& weights);
std::shared_ptr<const KernelOperator> makeChartScalarKernel(std::shared_ptr<const geometry::CoordinateChart> chart, double magnitude_variance, double length_scale, ChartScalarKernel kernel);
bool ownsBlock(long block_idx, int rank, int nprocs, bool serial_per_rank);
bool ownsBlockIfReduce(long block_idx, int rank, int nprocs, bool do_reduce);
bool buildFactoredTrainingGeometry(const AtomsConfiguration& conf_info, const FieldMatrixd& x_loc, FactoredTrainingGeometry& out, double far_field_radius = 0.0);
bool buildCrossBlockDerivativesFactored(const FactoredTrainingGeometry& factors, Index_t block_n, Index_t block_m, uint8_t derivative_options, SexpatCF::CrossBlockGeometry& out);
const SexpatCF::CrossBlockGeometry* resolveTrainingBlockGeometry(const SexpatCF& covariance, const TrainingKernelGeometry& geom, const TrainingKernelGeometryBlock& block, SexpatCF::CrossBlockGeometry& scratch);
double lengthscaleProjectionFloor(double max_pair_distance, double absolute_floor);
Eigen::MatrixXd hssvdHermiteCartesianAction(const Eigen::MatrixXd& jacobian, const Eigen::MatrixXd& residuals, const Eigen::MatrixXd& force_weights, const Eigen::VectorXd& energy_kernel_weights, const Eigen::VectorXd& force_kernel_weights, const Eigen::VectorXd& force_residual_dots, double energy_kernel_weight_sum, double force_kernel_residual_dot_sum, const Eigen::MatrixXd& directions);
bool arrowheadEigenpairs(const Eigen::Ref<const Eigen::VectorXd>& diagonal, const Eigen::Ref<const Eigen::VectorXd>& spike, double corner, Eigen::VectorXd& evals, Eigen::MatrixXd& evecs);
bool extendSymmetricSpectrum(const Eigen::Ref<const Eigen::MatrixXd>& grown, const Eigen::Ref<const Eigen::VectorXd>& diagonal, const Eigen::Ref<const Eigen::MatrixXd>& basis, Eigen::VectorXd& evals, Eigen::MatrixXd& evecs);
bool priorFreeReplicatedInverse(bool cholmod, bool scalapack, bool slate, bool unregularized, bool use_hssvd_gradient);
bool useDenseFactorForTrace(bool prior_free_inverse, bool use_hssvd_gradient, bool distributed_factor, long long factor_rows, long long factor_cols, long long target_size);
RFFValidationPlan planRFFFeatureValidation(int n_geometries, int cartesian_dimension, std::uint64_t memory_cap_bytes = kRFFValidationMemoryCapBytes);
std::vector<int> rffFarthestPointOrder(const Eigen::MatrixXd& positions);
std::string formatRFFFeatureSelection(const RFFFeatureSelection& report);
bool looCalibrationIsUnityFromCholeskyDiagonal(const Eigen::VectorXd& alpha, const Eigen::VectorXd& diagonal);
double looVarianceCalibrationFactor(const Eigen::VectorXd& alpha, const Eigen::VectorXd& inv_diag);
bool stabilizePosteriorCovariance(Eigen::MatrixXd& covariance);
bool subtractStableBasisProjectedCrossCovariance(const StableBasisND& basis, const Eigen::MatrixXd& Kstar, const Eigen::MatrixXd& Kright, const Eigen::MatrixXd& prior, double total_sigma2, Eigen::MatrixXd& K_post, bool contracted_mean = false, Eigen::Index left_queries = 1, Eigen::Index right_queries = 1);
Eigen::VectorXd applyStableBasisStatisticalInverse(const StableBasisND& basis, const Eigen::VectorXd& rhs, double noise);
bool subtractStableBasisProjectedCrossCovariance(const StableBasisND& basis, const EigenMatrix& Kstar, const EigenMatrix& Kright, const EigenMatrix& prior, const double total_sigma2, EigenMatrix& K_post, bool contracted_mean, Eigen::Index left_queries, Eigen::Index right_queries);
std::optional<JointObservationVarianceReduction> jointObservationVarianceReduction(Eigen::MatrixXd candidate_covariance, const Eigen::MatrixXd& target_candidate_covariance, double target_variance, double noise_variance);
std::optional<JointObservationVarianceReduction> jointObservationVarianceReduction(const Eigen::MatrixXd& posterior_covariance, Eigen::Index query_count, Eigen::Index dimensions, Eigen::Index candidate_query, const std::vector<Eigen::Index>& target_queries, double noise_variance);
std::optional<JointObservationVarianceReduction> jointObservationForceVarianceReduction(const Eigen::MatrixXd& posterior_covariance, Eigen::Index query_count, Eigen::Index dimensions, Eigen::Index candidate_query, const std::vector<Eigen::Index>& target_queries, double noise_variance);
Eigen::VectorXd findFMode(const EigenMatrix& K, const Eigen::VectorXd& y, const ObservationLikelihood& ol, int max_iter = 30, double tol = 1e-8);
double laplaceMarginalLogLik(const EigenMatrix& K, const Eigen::VectorXd& y, const Eigen::VectorXd& f_mode, const ObservationLikelihood& ol);
StructuredPermutation buildStructuredPermutation(const Eigen::VectorXd& ind_Ddim);
StructuredPermutation buildObservationTiledPermutation(const Eigen::VectorXd& ind_Ddim);
Eigen::VectorXd permuteVector(const Eigen::VectorXd& input, const StructuredPermutation& p);
Eigen::VectorXd unpermuteVector(const Eigen::VectorXd& input, const StructuredPermutation& p);
EigenMatrix permuteMatrixRows(const EigenMatrix& input, const StructuredPermutation& p);
EigenMatrix unpermuteMatrixRows(const EigenMatrix& input, const StructuredPermutation& p);
EigenMatrix permuteSymmetricMatrix(const EigenMatrix& input, const StructuredPermutation& p);
EigenMatrix unpermuteSymmetricMatrix(const EigenMatrix& input, const StructuredPermutation& p);
void requireWallClock(const std::shared_ptr<const WallClockLimit>& limit);
bool collectiveWallClockLimitReached(const std::shared_ptr<const WallClockLimit>& limit, const linalg::MpiContext& context);
bool collectiveWallClockLimitReached(const std::shared_ptr<const WallClockLimit>& limit);
double medianPairwiseDistance(const EigenMatrix& R_train);
SaddleCertificate certifyFinalSaddle(double true_pes_saddle_force, double conv_tol, const std::vector<double>& per_image_variance, double variance_envelope);
void applyCanonicalReadconDimerDefaults(InputParameters& parameters, const CanonicalDimerDefaultOptions& options = {});
CanonicalDimerDefaultOptions gprdUnflaggedDimerOptions();
void applyGprdDimerDefaults(InputParameters& parameters, const CanonicalDimerDefaultOptions& options = gprdUnflaggedDimerOptions());
bool defaultDimerImage1EachPhase(const bool use_hssvd, const bool use_hssvd_analytic_curvature);
void requirePositiveFinitePriorParameter(const char* density, const char* name, double value);
void requireFinitePriorParameter(const char* density, const char* name, double value);
PublicLayoutBytes libraryPublicLayout();
PublicLayoutBytes consumerPublicLayout();
bool iterationAllowedByLimit(Index_t iteration, Index_t configured_limit);
bool usesClassicJointEnergyForcePrior(GPModelProfile profile);
bool launchedOnOneNode();
void excludeLibfabricBtlOnOneNode();
int reportFatal(const char* program, const char* what);
template <class Matrices, class Body>
void assembleCollectively(const MpiContext& context, Matrices& result, const Body& body);
double applyPrincipledDiagonalNugget(EigenMatrix& K, Eigen::Index n_x, Eigen::Index d, double kappa_max, bool gradient_enhanced = true);
double computePrincipledNugget(Eigen::Index n_x, Eigen::Index d, double kappa_max, bool gradient_enhanced = true);
double principledKappaMaxDefault();
double localTraceProduct(const EigenMatrix& A, const EigenMatrix& B);
Eigen::Vector3d priorParametersVector(const PriorBase& prior);
Eigen::VectorXd inlaClipToLogBox(const Eigen::VectorXd& theta, const Eigen::VectorXd& lower, const Eigen::VectorXd& upper);
void addConstantCovarianceBlock(ConstantCF* const_cov_fun, const Eigen::VectorXd& row_indices, const Eigen::VectorXd& col_indices, EigenMatrix& matrix);
template <typename EigenObject>
bool reduce_laplace_factor_vectors_in_grid_order(std::vector<EigenObject>& factor_values, linalg::BackendContext& context);
bool symmetrizeObservedInformation(Eigen::MatrixXd& H);
void writeBMAOutput(const Eigen::VectorXd& flat, Index_t N_im, Index_t D, Observation& image1);
void writePredictionVectorToObservation(const Observation& query, const Eigen::VectorXd& values, Observation& out);
} // namespace gpr
Detailed Documentation¶
Gaussian-process regression, kernels, priors, and the searches that run on the surrogate.
Typedefs¶
typedef std::function<bool(const Eigen::VectorXd&, Eigen::VectorXd&, bool&exact_refusal)> RefusalAwareHessianAction
Hessian action that reports whether an exact child refused.
typedef std::function<RefusalAwareHessianAction(const Eigen::VectorXd&, bool&exact_refusal)> RefusalAwareHessianPreparation
Query preparation that reports whether an exact child refused.
typedef std::function<EigenMatrix(const std::vector<double>&lengthscales, double noise)> KernelMatrixBuilder
Kernel matrix builder: given lengthscales and noise, return K_XX.
Global Variables¶
bool sexpat_local_oracle_active = false
Thread-local switch for the local-oracle gradient region: when true the per-pair OpenMP pragma inside SexpatCF::calculateGradOfCov- MatrixWithDerivatives* activates. Set to true ONLY inside the SVGD per-particle oracle (which runs serial_per_rank=true with no MPI/ScaLAPACK collectives); SCG/MAP/Laplace paths leave it false so the distributed Cholesky doesn’t get nested OMP teams that would oversubscribe the host.
double kRFFEnergyNoiseFloor = 1e-6
Energy-channel floor used by the production random-feature model.
double kRFFGradientNoiseFloor = 1e-4
Gradient-channel floor used by the production random-feature model.
double kRFFForceConvergenceTolerance = 0.0514221
Band force tolerance the random-feature error is not allowed to cross.
std::uint64_t kRFFValidationMemoryCapBytes = 256ull* 1024ull* 1024ull
Exact validation Gram, and the D-by-D normal matrix, stay under this.
int kRFFFeaturesAuto = -1
Sentinel stored in integer feature-count fields for the automatic rule.
Global Functions¶
std::optional<ConvergenceNormType> parseForceNorm(std::string_view name)
An omitted norm preserves the search’s dimension-dependent default.
template <class Derived>
double forceNorm(const Eigen::MatrixBase<Derived>& force, ConvergenceNormType norm)
Force magnitude in the selected convergence norm.
template <class Derived>
double forceDualNorm(const Eigen::MatrixBase<Derived>& direction, ConvergenceNormType norm)
Dual norm bounding the magnitude of direction dot force by ||direction||_* ||force||.
std::vector<CutoffPairFeatures> cutoffPairFeatures(const Coord& positions, const AtomsConfiguration& configuration)
Sorted pair features for each configuration; absent pairs are exact zeros.
std::vector<CutoffPairFeatures> radialPairFeatures(const Coord& positions, const AtomsConfiguration& configuration)
Radial features with analytic Cartesian curvature. A positive cutoff selects neighbours; zero retains every active moving-atom pair.
std::vector<CutoffPairFeatures> radialPairFeatures(const Coord& positions, const AtomsConfiguration& configuration, double far_radius)
A positive far radius compresses distant frozen atoms into linear features in the fixed reference chart. It cannot be combined with a cutoff.
std::vector<FieldMatrixd> cutoffPairSquaredDistances(const Coord& left, const Coord& right, const AtomsConfiguration& configuration, const FieldMatrixd& lengths)
Per-pairtype contributions to the Sexpat squared distance, 2 sum(delta^2/l^2).
template <typename Function>
void forEachCutoffPair(const CutoffPairFeatures& left, const CutoffPairFeatures& right, Function&& function)
Visit the union of two sparse feature rows in their common pair vocabulary.
std::string sha256Hex(const void* data, std::size_t size)
Lowercase hexadecimal SHA-256 digest of a byte range (FIPS 180-4).
std::string sha256File(const std::string& path)
Digest of a file’s contents; empty when the file cannot be read.
bool conditionKernelMatrix(const Eigen::MatrixXd& joint, const std::vector<Eigen::MatrixXd>& derivatives, Eigen::Index anchor_rows, Eigen::Index query_rows, Eigen::Index dimensions, const Eigen::VectorXd& anchor_noise, Eigen::MatrixXd& covariance, std::vector<Eigen::MatrixXd>& conditional_derivatives)
Project covariance and parameter derivatives using the same Schur complement. Joint rows are channel-major with anchors first in each channel. Anchor noise is fixed with respect to the fitted parameters.
KernelOperator::MeanFunction makeKernelMean(std::shared_ptr<const KernelOperator> kernel, const Eigen::MatrixXd& training, const Eigen::VectorXd& weights)
Owning fitted mean, using the kernel’s representation or its exact product.
KernelOperator::MeanHessianFunction makeAnalyticKernelMeanHessianVector(const std::shared_ptr<const KernelOperator>& kernel, const Eigen::MatrixXd& training, const Eigen::VectorXd& weights)
The kernel’s own Hessian preparation, or an empty function when it has none. Unlike makeKernelMeanHessian*, no meanHessianVector stand-in is made, so an empty result means the kernel has no analytic Hessian to prepare.
RefusalAwareHessianPreparation makeRefusalAwareKernelMeanHessian(std::shared_ptr<const KernelOperator> kernel, const Eigen::MatrixXd& training, const Eigen::VectorXd& weights, bool* all_exact = nullptr, bool* has_exact_or_refusal = nullptr)
Prepare a fitted kernel Hessian action that propagates exact-child refusals through composite operators.
KernelOperator::MeanHessianMatrixFunction makeKernelMeanHessianMatrix(std::shared_ptr<const KernelOperator> kernel, const Eigen::MatrixXd& training, const Eigen::VectorXd& weights)
Dense mean Hessian of a kernel from the columns of its refusal-aware action. A failed column is Refused when an exact child refused it and Unavailable when only a generic child missed; the matrix is left empty in both cases.
std::shared_ptr<const KernelOperator> makeChartScalarKernel(std::shared_ptr<const geometry::CoordinateChart> chart, double magnitude_variance, double length_scale, ChartScalarKernel kernel)
Squared-exponential Pullback unless kernel is Matern52.
bool buildCrossBlockDerivativesFactored(const FactoredTrainingGeometry& factors, Index_t block_n, Index_t block_m, uint8_t derivative_options, SexpatCF::CrossBlockGeometry& out)
Rebuild one block’s d1/d2/d12 fields from the factors, in the layout and sign convention of SexpatCF::buildCrossBlockDerivativesOnly.
const SexpatCF::CrossBlockGeometry* resolveTrainingBlockGeometry(const SexpatCF& covariance, const TrainingKernelGeometry& geom, const TrainingKernelGeometryBlock& block, SexpatCF::CrossBlockGeometry& scratch)
The derivative tensors of one geometry block: the cached copy, or, for a streamed geometry, a rebuild into scratch from the stored coordinate blocks. Returns nullptr when the block cannot be built.
double lengthscaleProjectionFloor(double max_pair_distance, double absolute_floor)
Lower edge of the feasible kernel length-scale domain for the MAP projection in optimize(). Two floors compose: a numerical collapse guard relative to the data diameter, and an absolute caller-set resolution floor (the dimer sets its finite-difference stencil diameter on its self-owned GP). A length scale below the sampling resolution fits sub-stencil noise as signal: the kernel degenerates into a delta comb whose relaxation endpoints scatter into EMD-distinct probes. The resolution floor guards against sub-resolution collapse only: when the training data spans less than the stencil (the two-row bootstrap), it is capped at the data diameter so the projection never forbids fits at the scale of the data itself. A chain-spacing floor (diameter/(n_images-1)) is deliberately NOT part of this domain: forcing the NEB session GP above chain spacing over-smooths the surrogate and moves the converged saddle (Baker14 anchor: 2.36819 eV at free length scales, 3.7772 eV with the chain bound; single-node A/B at 31b415ab).
Eigen::MatrixXd hssvdHermiteCartesianAction(const Eigen::MatrixXd& jacobian, const Eigen::MatrixXd& residuals, const Eigen::MatrixXd& force_weights, const Eigen::VectorXd& energy_kernel_weights, const Eigen::VectorXd& force_kernel_weights, const Eigen::VectorXd& force_residual_dots, double energy_kernel_weight_sum, double force_kernel_residual_dot_sum, const Eigen::MatrixXd& directions)
Cartesian action of the HS-SVD Hermite weights on directions. Equal-and-opposite energy weights cancel; the result is within one ulp of the cancelled weight scale of the exact residual.
bool arrowheadEigenpairs(const Eigen::Ref<const Eigen::VectorXd>& diagonal, const Eigen::Ref<const Eigen::VectorXd>& spike, double corner, Eigen::VectorXd& evals, Eigen::MatrixXd& evecs)
Eigenpairs of [diag(diagonal), spike; spike^T, corner], ascending. False when a pole gap is inside the symmetric backward error: the caller then uses the full eigensolver, whose basis is the one the search already runs.
bool extendSymmetricSpectrum(const Eigen::Ref<const Eigen::MatrixXd>& grown, const Eigen::Ref<const Eigen::VectorXd>& diagonal, const Eigen::Ref<const Eigen::MatrixXd>& basis, Eigen::VectorXd& evals, Eigen::MatrixXd& evecs)
Eigenpairs of grown, whose leading principal submatrix has eigenpairs diagonal / basis (columns). Each new row is one arrowhead in that basis. False when any arrowhead is too clustered for the secular roots; the caller keeps the full eigensolver.
bool priorFreeReplicatedInverse(bool cholmod, bool scalapack, bool slate, bool unregularized, bool use_hssvd_gradient)
Whether the prior-free marginal-likelihood gradient may form a replicated K^{-1}.
Eigen ‘s prior-free fit was measured on that inverse: the solve-based trace disagrees by about cond(K) * eps and the fit then stops one step early. CHOLMOD’s solve already takes the measured number of steps. ScaLAPACK and SLATE (which also defines GPR_LINALG_SCALAPACK) take the trace from the distributed factor and never read a replicated inverse, so gathering one only costs N^2 memory per rank.
bool useDenseFactorForTrace(bool prior_free_inverse, bool use_hssvd_gradient, bool distributed_factor, long long factor_rows, long long factor_cols, long long target_size)
Whether evaluateGradientWithGeometry may pass dense Cholesky factor L to the derivative trace contractions and appendLikelihoodNoiseGradient.
Prior-free Eigen fits use invC.trace() instead of L; HS-SVD Q-form gradients skip Cholesky decomposition so L may be absent or stale; ScaLAPACK/SLATE distributed fits must pass an empty factor so appendLikelihoodNoiseGradient selects the collective distributed trace.
RFFValidationPlan planRFFFeatureValidation(int n_geometries, int cartesian_dimension, std::uint64_t memory_cap_bytes = kRFFValidationMemoryCapBytes)
Counts for n_geometries rows of cartesian_dimension coordinates. The fit is the longest farthest-point prefix whose joint Gram fits in memory_cap_bytes, leaving at least one hold-out when there are two or more geometries. Feature counts are the powers of two from 1 through the largest power of two that is twice-overdetermined on both the fit and the full design and whose normal matrix fits in the same cap.
std::vector<int> rffFarthestPointOrder(const Eigen::MatrixXd& positions)
Greedy maximin on squared Euclidean distance. Index 0 is first. A tie keeps the smaller index, so the order does not use a random generator.
bool looCalibrationIsUnityFromCholeskyDiagonal(const Eigen::VectorXd& alpha, const Eigen::VectorXd& diagonal)
Certify unit LOO calibration using diag(L) without forming diag(K^-1). An inconclusive bound returns false and requires the full LOO statistic.
double looVarianceCalibrationFactor(const Eigen::VectorXd& alpha, const Eigen::VectorXd& inv_diag)
Leave-one-out variance calibration factor from posterior weights alpha and the diagonal of the noisy precision (K + sigma2 I)^-1: the median squared LOO z-score over the chi-square(1) median, floored at 1. Shared by the dense Cholesky and HS-SVD backends.
bool stabilizePosteriorCovariance(Eigen::MatrixXd& covariance)
Project a rounded covariance onto the positive-semidefinite cone while preserving its nonnegative diagonal exactly.
Returns false for a non-square, non-finite or negative-diagonal input, when a correlation ratio is not finite, when a negative eigenvalue of that correlation exceeds the rounding tolerance, or when the correlation eigensolver fails. A smaller negative eigenvalue is projected away.
bool subtractStableBasisProjectedCrossCovariance(const StableBasisND& basis, const Eigen::MatrixXd& Kstar, const Eigen::MatrixXd& Kright, const Eigen::MatrixXd& prior, double total_sigma2, Eigen::MatrixXd& K_post, bool contracted_mean = false, Eigen::Index left_queries = 1, Eigen::Index right_queries = 1)
Posterior cross covariance K(q, q’) - k*^T (K + sigma2 I)^{-1} k*’ on a stable basis. An in-range query cancels to a diagonal a few ulps of the prior diagonal from zero, the rounding of the basis column norms. For a self-covariance (&Kstar == &Kright and not a contracted mean), a negative diagonal cancellation residue is bounded by 2 * eps * local_scale. local_scale is abs(prior_ii) + abs(projected_ii) + abs(complement_ii): the absolute prior diagonal and the absolute values of the two subtracted terms. A column of n entries has a squared norm that rounds by about n*eps/2, so the raw diagonal can reach about n*eps*abs(prior). When that raw value lies within 3 times the bound, the subtraction returns the bound and keeps the sign. Cross-covariances and contracted means are left unclamped.
std::optional<JointObservationVarianceReduction> jointObservationVarianceReduction(Eigen::MatrixXd candidate_covariance, const Eigen::MatrixXd& target_candidate_covariance, double target_variance, double noise_variance)
Integrated reduction from the candidate block, target cross block, and target diagonal sum. No covariance between distinct targets is needed.
std::optional<JointObservationVarianceReduction> jointObservationVarianceReduction(const Eigen::MatrixXd& posterior_covariance, Eigen::Index query_count, Eigen::Index dimensions, Eigen::Index candidate_query, const std::vector<Eigen::Index>& target_queries, double noise_variance)
Integrated variance reduction from one joint energy-force query.
The covariance uses derivative-major Observation ordering: all query energies, followed by each Cartesian gradient component for all queries. Conditioning always uses the candidate’s complete D+1 channel block.
std::optional<JointObservationVarianceReduction> jointObservationForceVarianceReduction(const Eigen::MatrixXd& posterior_covariance, Eigen::Index query_count, Eigen::Index dimensions, Eigen::Index candidate_query, const std::vector<Eigen::Index>& target_queries, double noise_variance)
Integrated force-variance reduction from one joint energy-force query.
The candidate conditions on its complete energy-and-gradient observation block, while the target trace contains only Cartesian-gradient channels. The resulting score therefore has force-variance units and can rank acquisitions for a force-readiness decision without mixing physical units.
Eigen::VectorXd findFMode(const EigenMatrix& K, const Eigen::VectorXd& y, const ObservationLikelihood& ol, int max_iter = 30, double tol = 1e-8)
Posterior mode f_mode = argmax_f [log p(y|f) + log N(f | 0, K)] via the Rasmussen-Williams safe Newton recursion (Algo 3.1).
Uses the B = I + W^{1/2} K W^{1/2} parameterisation that avoids inverting K directly. Converges in O(log(1/tol)) iterations on log-concave likelihoods when K is well-conditioned.
Parameters:
K |
Prior covariance; pass the K_theta at the current hyperparameters (WITHOUT noise added; noise lives in W). |
y |
Observations. |
ol |
Observation-likelihood contract (log-concave). |
max_iter |
Max Newton steps; throws if exceeded without abs(Delta f) < tol * max(1, abs(f)). |
tol |
Relative convergence tolerance. |
Returns:
Converged f_mode, same size as y.
double laplaceMarginalLogLik(const EigenMatrix& K, const Eigen::VectorXd& y, const Eigen::VectorXd& f_mode, const ObservationLikelihood& ol)
Laplace approximation to log p(y | theta) given prior K and the converged posterior mode f_mode (R&W eq. 3.32):
log p(y|theta) ~= log p(y|f_mode) + log N(f_mode | 0, K)
(1/2) log|I + W K|
with W = diag(negHessDiag(y, f_mode)).
bool collectiveWallClockLimitReached(const std::shared_ptr<const WallClockLimit>& limit, const linalg::MpiContext& context)
Agree at a shared phase boundary before entering further collectives. Rank-local oracle callbacks use requireWallClock and agree their outcome through the oracle batch protocol instead.
bool collectiveWallClockLimitReached(const std::shared_ptr<const WallClockLimit>& limit)
The oracle/search process group, with a local fallback outside MPI.
double medianPairwiseDistance(const EigenMatrix& R_train)
Median of the strict-upper-triangle pairwise Euclidean row distances over a training set. Degree-1 homogeneous: median(s*X) = s*median(X).
Returns:
Median pairwise distance, or 0.0 when fewer than two rows.
SaddleCertificate certifyFinalSaddle(double true_pes_saddle_force, double conv_tol, const std::vector<double>& per_image_variance, double variance_envelope)
Combined force and variance criterion for callers that request it. The variance envelope is an optional exploration condition. A physical saddle additionally requires an independent assessment of its Hessian index; neither this helper nor a trust radius establishes that index.
void applyCanonicalReadconDimerDefaults(InputParameters& parameters, const CanonicalDimerDefaultOptions& options = {})
Apply the canonical readcon dimer defaults to parameters.
Also installs the published Student-t prior parameters (mu = 0, nu = 20, s2 = 1). initialize() copies this triple onto the Student-t magnitude, Gaussian length-scale, and log-normal priors; data-bearing setHyperparameters() later overwrites Student-t s2 with target_variance and Gaussian s2 with seed_length_scale_^2.
CanonicalDimerDefaultOptions gprdUnflaggedDimerOptions()
Options of an unflagged gprd invocation. The CLI member defaults and gpr_dimer_config_defaults both read this record.
void applyGprdDimerDefaults(InputParameters& parameters, const CanonicalDimerDefaultOptions& options = gprdUnflaggedDimerOptions())
The parameter block gprd installs before it applies flags: the canonical readcon dimer defaults, then the GP hyperparameter block in main. gpr_dimer_search starts from the same block.
bool usesClassicJointEnergyForcePrior(GPModelProfile profile)
Classic joint [E, F] inverse-distance profiles share the original Sexpat prior density (PriorSqrtt on magnSigma2, PriorGaussian on length scales, plus the packed-parameter log Jacobian).
bool launchedOnOneNode()
Whether the launcher placed every rank of this run on one node: the Open MPI launcher’s world and node-local sizes agree, a Slurm step spans one node, or no launcher started the process (a singleton). Unknown launches count as several nodes.
void excludeLibfabricBtlOnOneNode()
Open MPI’s libfabric BTL sleeps for one second when MPI_Finalize closes it (mca_btl_ofi_component_close), on every rank of every run that opened it. Ranks on one node exchange messages through the UCX or shared-memory transports and never use it, so a single-node launch leaves it out unless the caller chose the BTLs (OMPI_MCA_btl). Other MPI implementations ignore the variable.
int reportFatal(const char* program, const char* what)
Ends a driver after an exception escaped it: prints the message and returns the exit status 1. On more than one rank the job is aborted through MPI_Abort, since the other ranks may wait in a collective the failing rank never reaches; on one rank an MPI world the driver initialized is finalized. This replaces std::terminate, whose abort leaves a core dump and no message on most launchers.
template <class Matrices, class Body>
void assembleCollectively(const MpiContext& context, Matrices& result, const Body& body)
Assemble disjoint entries, propagate failures within the owning group, and replicate the tensors. The body joins its workers before returning; only the calling thread enters MPI collectives.