struct gpr::neb::ActiveLearningSession

Overview

Shared GP + training data state for an active-learning saddle search session. More…

#include <gpr/neb/Session.h>
 
struct ActiveLearningSession {
    // typedefs
 
    typedef std::function<bool(GaussianProcessRegression&, const AtomsConfiguration&, const Observation&)> AfterInitialise;
 
    // structs
 
    struct ImageModel;
    struct IndexedObservation;
    struct LocalKernelSeed;
    struct SecantReplaySample;
    struct SurrogateFingerprint;
 
    // classes
 
    class ModelLease;
    class PolicyScope;
 
    // fields
 
    gpr::Observation training_obs;
    gpr::Observation virtual_obs;
    std::vector<double> virtual_retire_radii;
    double virtual_obs_noise_sigma2 = 0.04;
    bool ci_active_at_outer_start = false;
    int ci_stable_outer_count = 0;
    bool stagnation_handoff = false;
    double last_max_chain_energy_variance                                   = std::numeric_limits<double>::quiet_NaN();
    std::vector<IndexedObservation> current_chain_certificates;
    gpr::GaussianProcessRegression gp;
    std::vector<ImageModel> image_models;
    int min_per_image_n_train = 3;
    int per_image_knn = 10;
    double per_image_prior_s2_log = 0.1;
    gpr::AtomsConfiguration atoms_config;
    gpr::InputParameters input_parameters;
    std::function<void(gpr::InputParameters&, gpr::AtomsConfiguration&)> gp_setup;
    double path_energy_ceiling = std::numeric_limits<double>::infinity();
    bool initialised = false;
    bool resolution_dedup_enabled_ = false;
    long resolution_dedup_rejected_ = 0;
    EndpointSymmetry endpoint_symmetry_;
    long symmetry_rows_admitted_ = 0;
    long symmetry_rows_rejected_ = 0;
    std::vector<int> training_multiplicity;
 
    // methods
 
    static int selectMmfModelOwner(bool dimer_use_global_gp, bool image_model_eligible, int image_idx);
    static bool integratesHyperparameters(const gpr::GaussianProcessRegression& model);
    void setSecantHessianConfig(const optim::SecantHessianConfig& config);
 
    template <class Measure>
    bool purchaseSecantConsistencyProbe(Measure&& measure);
 
    const optim::SecantHessian& globalSecantHessian() const;
    const optim::SecantHessian* imageSecantHessian(int image_idx) const;
    void noteTrueForceSecant(int image_idx, const Eigen::VectorXd& positions, double energy, const Eigen::VectorXd& gradient);
    std::size_t secantReplaySize() const;
    std::size_t secantReplayTrainingRows() const;
    bool secantReplayHoldsTrainingRow(const Eigen::VectorXd& position) const;
    optim::SecantCurvatureCounts secantCounts() const;
    void addSecantCounts(const optim::SecantCurvatureCounts& extra);
    SharedParameterState sharedParameterState() const;
    bool sharesGlobalHyperparameters(const gpr::GaussianProcessRegression& model) const;
    std::uint64_t imageModelSurrogateRevision(int image_idx) const;
    std::uint64_t trainingRevision() const;
    std::uint64_t globalModelSurrogateRevision() const;
    SurrogateFingerprint surrogateFingerprint(int owner) const;
    int mmfModelOwner(int image_idx, bool dimer_use_global_gp) const;
    SurrogateFingerprint mmfSurrogateFingerprint(int image_idx, bool dimer_use_global_gp) const;
    void setLikelihoodNoiseFloorRms(const double* noise_rms);
    void setRefitTrainingRevisions(std::uint64_t revisions);
    std::uint64_t refitTrainingRevisions() const;
    std::uint64_t surfaceEpoch() const;
    void refreshLikelihoodNoiseFloor();
    void initialise();
    bool applySeededModel();
    void setAfterInitialise(AfterInitialise hook);
    int priorObservations() const;
    void notePriorObservations(int count);
    void noteLocalKernelSeed(double signal_variance, double length_scale);
    const LocalKernelSeed& localKernelSeed() const;
    void noteExternalHyperparameterFit();
    bool updateFrozenEnvironment(const gpr::Coord& band);
    void initializePerImage(int n_images);
    int boundActiveSetToBand(const gpr::Coord& band_positions, Eigen::Index max_rows);
    double observationResolutionFloor() const;
    double nearestTrainingDistance(const Eigen::VectorXd& positions) const;
    void appendObservation(const Eigen::VectorXd& positions, double energy, const Eigen::VectorXd& gradient, ObservationRetention retention = ObservationRetention::RecordAcquisition, optim::SecantAccounting secant_accounting = optim::SecantAccounting::Count);
    void setEndpointSymmetry(EndpointSymmetry symmetry);
    const EndpointSymmetry& endpointSymmetry() const;
    long symmetryRowsAdmitted() const;
    long symmetryRowsRejected() const;
    void setResolutionDedup(bool on);
    bool withinTrainingResolution(const Eigen::VectorXd& positions) const;
    long resolutionDedupRejected() const;
    int admitObservation(const Eigen::VectorXd& positions, double energy, const Eigen::VectorXd& gradient, optim::SecantAccounting secant_accounting = optim::SecantAccounting::Count);
    void appendSymmetryImage(int source_row, const Eigen::VectorXd& positions, double energy, const Eigen::VectorXd& gradient);
    void syncTrainingMultiplicity();
    void noteExternalTrainingEdit();
    void markCurrentTrainingRevisionRetainedByPolicy(const policy::TrainingPolicy* policy);
    bool retainTrainingRowsForPolicy(const policy::TrainingPolicy& policy);
    bool addVirtualObservation(const Eigen::VectorXd& positions, double retire_radius);
    void retireVirtualObservationsNear(const Eigen::VectorXd& positions);
    void syncVirtualNoiseTag();
    gpr::Observation composedTrainingObs() const;
    void appendObservation(int image_idx, const Eigen::VectorXd& positions, double energy, const Eigen::VectorXd& gradient, ObservationRetention retention = ObservationRetention::RecordAcquisition, optim::SecantAccounting secant_accounting = optim::SecantAccounting::Count);
    bool attachImageObservation(int image_idx, int global_row_index);
    void appendCurrentChainObservation(int image_idx, const Eigen::VectorXd& positions, double energy, const Eigen::VectorXd& gradient, ObservationRetention retention = ObservationRetention::RecordAcquisition, optim::SecantAccounting secant_accounting = optim::SecantAccounting::Count);
    void recordCurrentChainCertificate(int image_idx, const Eigen::VectorXd& positions);
    void recordCurrentChainCertificate(int image_idx, const Eigen::VectorXd& positions, double energy, const Eigen::VectorXd& gradient);
    bool currentChainCertificateMatchesGeometry(int image_idx, const Eigen::VectorXd& positions) const;
    std::optional<IndexedObservation> currentChainObservation(int image_idx, const Eigen::VectorXd& positions) const;
    bool hasCurrentChainCertificate(int image_idx, const Eigen::VectorXd& positions) const;
    void setImageNeighborhood(int i, const std::vector<int>& emd_indices, const Eigen::VectorXd* image_position = nullptr);
    std::vector<uint64_t> selectArchivedNeighbors(const std::vector<int>& kept, const Eigen::VectorXd* image_position, Eigen::Index D);
    bool setImageInternalCoordinateChart(int i, std::shared_ptr<const gpr::geometry::InternalCoordinateChart> chart);
    bool setGlobalInternalCoordinateChart(std::shared_ptr<const gpr::geometry::InternalCoordinateChart> chart);
    void clearGlobalInternalCoordinateChart();
    const std::shared_ptr<const gpr::geometry::InternalCoordinateChart>& globalInternalCoordinateChart() const;
    double globalInternalCoordinateLengthScale() const;
    bool setBandGeodesicReferencePath(const gpr::Coord& reference_path);
    bool setImageGeodesicReferencePath(int i, const gpr::Coord& reference_path);
    bool refitImageGP(int i);
    void ensureSingletonForGlobal();
    bool ensureSingletonForImage(int i);
    void markModelMaterialized(int owner, const Eigen::VectorXd& theta, const SharedParameterState& shared_state);
    ModelLease acquireGlobalModel();
    ModelLease acquireImageModel(int i);
    bool imageModelEligibleForPrediction(int i) const;
    void predictAtImage(int i, gpr::Observation& probe);
    void observationVarianceAtImage(int i, gpr::Observation& probe);
 
    template <typename Use>
    void withImageChartFallback(int i, Use&& use);
 
    template <typename Use>
    void withImageModel(int i, Use&& use);
 
    void compactAfterRowRemoval(int removed_row);
    bool rollbackTrainingObservations(Eigen::Index row_count);
    void appendIndexedObservations(const std::vector<IndexedObservation>& observations);
    bool rollbackTrainingObservationsRetaining(Eigen::Index row_count, const std::vector<IndexedObservation>& retained_observations);
    int pruneTrainingObservationsAdaptive(const gpr::Coord& band_positions);
    int pruneTrainingObservationsToBudget(const gpr::Coord& band_positions, Eigen::Index max_rows);
    int pruneLeastInfluentialRow(const gpr::Coord& band_positions, bool ignore_noise);
    int pruneImageModelsAdaptive(const gpr::Coord& band_positions);
    bool refitGP(bool reinit_seeds);
    const policy::PolicyContext* activePolicyContext() const;
    void publishPolicyProgress(int iteration, int oracle_calls, int refits, int training_size);
    bool hyperparametersNeedRefit() const;
    bool refitGPIfTrainingChanged(bool reinit_seeds);
    bool wouldRefitAtNextRefresh() const;
    void refreshCovarianceCache();
    bool conditionGPOnConsistentRows(const gpr::Observation& acquired, ConvergenceNormType force_norm, Eigen::Index max_rows = 0, double force_tolerance = std::numeric_limits<double>::infinity(), gpr::GaussianProcessRegression::RefitTrustReport* trust_report = nullptr);
    void setEvidenceRefitTrigger(bool enabled);
    bool evidenceRefitTrigger() const;
    double acquiredEvidenceNats() const;
    bool acquiredEvidenceRequestsRefit(double batch_nats);
    bool conditionGPOnResolvedRows(const gpr::Observation& acquired, ConvergenceNormType force_norm, Eigen::Index max_rows, double force_tolerance);
    void conditionGPOnTrainingData();
};

Detailed Documentation

Shared GP + training data state for an active-learning saddle search session. Caller-owned, passed by pointer to ~gpNEB~ and ~AtomicDimer~ entry points.

Two GP tiers live here:

  • ~gp~ + ~training_obs~ :: the global GP, owning every oracle call from every phase (NEB explore, NEB CI, Dimer MMF). Used for hyperparameter optimisation and for prediction when the local GP at a given image lacks data.

  • ~image_models[i]~ :: per-image local GP slot. Each image i owns the subset of oracle calls evaluated while it was the worst image (NEB picker) or while it was the CI image (OCINEB burst). Local GPs inherit global theta; compatible EB and Laplace models also share its hyperparameter distribution. The image GP answers ~predictAtImage~ when the slot has at least ~min_per_image_n_train~ direct oracle rows; otherwise the call falls back to the global GP.

Fields

gpr::Observation training_obs

Growing training data. Appended by every oracle call from every phase (NEB explore, NEB CI, Dimer MMF).

gpr::Observation virtual_obs

Conditioning-only virtual observations (Riihimaki-Vehtari style conjugate constraints). Each row sits at an internal-trust clip point with targets equal to the prior mean there, so the fitted residual is exactly zero: the posterior is pinned toward the prior at geometries the trust certifier has declared unpredictable. Rows enter covariance conditioning and prediction only hyperparameter optimisation (SCG) and seed derivation see ~training_obs~ alone, so theta is calibrated against real oracle data. A row retires as soon as a real observation lands within its retire radius.

std::vector<double> virtual_retire_radii

Per-row coordinate-norm retire radii, aligned with ~virtual_obs~.

double virtual_obs_noise_sigma2 = 0.04

Extra heteroscedastic noise sigma^2 on virtual rows (energy in eV^2, forces in (eV/A)^2 under the raw-target classic stack). Soft pins: large against the learned data noise (~1e-3) so a pin biases the posterior toward the prior without forcing an interpolation constraint through it; hard pins bend the posterior violently between nearby data and the pin (measured: max_gp_F 27 -> 175 on 17_claisen when pinned at shared noise).

bool ci_active_at_outer_start = false

CI already active when the current GP-NEB outer began. OCINEB uses this so force-only Helped after same-outer CI activation restores the pre-burst geometry instead of locking a high false TS.

int ci_stable_outer_count = 0

Consecutive outers that began with CI active. Force-only Helped restores unless this is >= 1 (CI already active at outer start) and the converged mode has negative curvature.

bool stagnation_handoff = false

The climbing-image walk has stopped improving while its true force is still above the final tolerance: a curvature-cap limit cycle that the band stall ended, or a fixed point whose granted MMF burst the adaptive bar would otherwise refuse. The next OCINEB hook keeps the flag until the dimer lease is taken, or until the certified handoff declines it. A closed information gate does not clear it. A walk that is still descending does not set it, and the 0.1 eV/A handoff bar is unchanged for that walk.

double last_max_chain_energy_variance                                   = std::numeric_limits<double>::quiet_NaN()

Latest max per-image chain energy variance from the GP-NEB outer loop’s acquisition probe. NaN until the first probe. The OCINEB hook compares it against the likelihood noise floor to decide whether the OIE can still supply admissible information.

std::vector<IndexedObservation> current_chain_certificates

Per-image true-PES evidence at a live chain geometry. Certificates own their exact energy and gradient independently of the GP training transaction, so model rollback cannot erase convergence evidence.

Global GP instance. Initialised lazily via ~initialise()~ from ~gp_setup~. Owns hyperparameter optimisation and the dense distributed Cholesky used for chain-wide variance probes.

std::vector<ImageModel> image_models

Per-image local GPs. One slot per path image; endpoints are present for index alignment but are only used when explicitly sampled.

int min_per_image_n_train = 3

Fallback threshold: ~predictAtImage(i, …)~ routes through the global ~gp~ until image i’s geometric neighbourhood has this many distinct oracle observations. Once reached, the local GP takes over for image-resolved predictions.

int per_image_knn = 10

Neighbourhood size for the per-image local GP: image i’s local training set is the ~per_image_knn~ observations of the global ~training_obs~ nearest (EMD) to image i’s current position, recomputed every outer iteration. Keying the local set on geometry rather than on the picker index keeps the per-image surrogate tracking the moving chain: an image picks up its chain neighbours’ oracle calls, and a converged image is no longer conditioned on the scattered positions it has left.

double per_image_prior_s2_log = 0.1

Variance of the hierarchical-Bayes prior on the per-image log-kernel-parameters: ~log(theta_i) ~ N(log(theta_global), per_image_prior_s2_log * I)~. Default 0.1 corresponds to roughly ~30% drift around the global MAP per parameter (in linear lengthscale / magnSigma2). Without this prior, per-image SCG on 3-10 rows is unregularised and drifts to noisy local optima; the resulting inflated per-image variance stalls the NEB acquisition picker in Phase 1. Tighter values pull per-image theta_i closer to the global anchor.

Atoms configuration cached from ~gp_setup~. Required by ~setHyperparameters~ and the EMD distance metric.

gpr::InputParameters input_parameters

Input parameters cached from ~gp_setup~. Per-image local GPs are clones of the global setup and do not re-enter the caller’s setup callback.

std::function<void(gpr::InputParameters&, gpr::AtomsConfiguration&)> gp_setup

Callback that builds the (parameters, atoms_config) pair the GP needs to ~initialize()~. Same shape as ~GPNEBConfig::gp_setup~. Populated by the caller (typically from a loaded ~.con~ frame).

double path_energy_ceiling = std::numeric_limits<double>::infinity()

Optional absolute saddle-energy limit supplied by the caller and shared with the OCINEB burst. Infinity disables it. Sampled path energies do not supply an upper bound on the continuous path maximum.

bool initialised = false

True once ~initialise()~ has populated ~gp~ + ~atoms_config~ from ~gp_setup~. Idempotent across calls.

std::vector<int> training_multiplicity

Repeated-observation count per training row (>= 1), aligned with ~training_obs~ rows.

Methods

void setSecantHessianConfig(const optim::SecantHessianConfig& config)

Configure true-gradient secants independently of GP row retention. Changing the method rebuilds the global stream and every per-image stream from the measurements already consumed. Rows retained before any secant existed have no image index, so they enter the global stream only.

template <class Measure>
bool purchaseSecantConsistencyProbe(Measure&& measure)

Compare the fitted GP Hessian action with the latest true-force secant. A disagreement buys one forward force probe. measure evaluates that probe and retains it, and returns false when the oracle budget or the oracle itself did not deliver it; that probe is not counted.

void noteTrueForceSecant(int image_idx, const Eigen::VectorXd& positions, double energy, const Eigen::VectorXd& gradient)

True-force secant only. Training retention is unchanged.

std::size_t secantReplaySize() const

Samples kept so reconfigure can rebuild per-image secant seeds.

std::size_t secantReplayTrainingRows() const

Replay samples that record an admitted training row.

bool secantReplayHoldsTrainingRow(const Eigen::VectorXd& position) const

True when an admitted-row sample still holds ~position~.

void addSecantCounts(const optim::SecantCurvatureCounts& extra)

A dimer that owns its surrogate passes its full counts. A dimer leasing this session’s GP passes the ledger only; the shared GP’s quadratic-mean uses are already on gp.

void setLikelihoodNoiseFloorRms(const double* noise_rms)

Set a live RMS floor for the Gaussian likelihood noise. The session squares valid positive values into sigma^2 during ~refitGP~; null, non-finite, and non-positive values disable the floor.

void setRefitTrainingRevisions(std::uint64_t revisions)

SCG refit cadence: full hyperparameter refits run every this many training-set appends, for every model profile. Default 5 is the Baker-measured value; ActiveGP makes the knob explicit. Zero means refit on every refresh.

std::uint64_t surfaceEpoch() const

Monotone surface epoch. Bumps when the factorized posterior changes (refit or materialize). Mix into a consumer cache key so a frozen GprMeanPotential cannot relax on a stale PES.

void refreshLikelihoodNoiseFloor()

Reduce the rank-owned noise floor into the shared value the materialise paths read. This call is collective: every rank must reach it, so it belongs at a point in the outer loop that no rank-local branch can skip after an oracle batch, never inside a per-image or owned-image block.

void initialise()

Idempotent: build ~gp~ + ~atoms_config~ from ~gp_setup~. After this the GP is ready for ~setHyperparameters~ + ~optimize~ but holds no training data yet.

bool applySeededModel()

Install a warm-start kernel after the search has applied its model profile and pair cutoff. initialise() leaves the GP on the profile default, so the saved kernel would not match yet. False when this search had no seed or the seed hook refused to install the kernel.

void setAfterInitialise(AfterInitialise hook)

Runs from applySeededModel(), after the search profile and the pair cutoff are on the GP. A warm start installs saved hyperparameters here.

int priorObservations() const

Rows loaded from a seed file. Not an oracle-call count.

void noteExternalHyperparameterFit()

applySeededModel() installed hyperparameters for the rows held now. Later appends still request a refit.

bool updateFrozenEnvironment(const gpr::Coord& band)

Select one frozen environment over every image, retaining physical observations and invalidating models that depend on its pair features.

void initializePerImage(int n_images)

Allocate per-image local GPs sized to the NEB chain. Each local GP gets the same kernel setup as the global ~gp~ (same ~gp_setup~ -> identical kernel functions / atoms config) but starts with an empty training set. Idempotent: redundant calls with the same ~n_images~ are no-ops; resizing to a different chain length blows away the previous per-image state.

int boundActiveSetToBand(const gpr::Coord& band_positions, Eigen::Index max_rows)

Retain band support and acquired corrections within a row budget. A sweep of recent acquisitions protects rejected trial and dimer observations outside the retained band. Each band image then reserves its nearest row in the prediction kernel’s metric. Among the other rows the one whose removal changes the posterior mean least in the kernel norm is dropped first; the observation archive is intact.

double observationResolutionFloor() const

Spacing below which a new row carries no information the model can use, taken from the model’s own state rather than set as a number.

This is the dimer’s information floor, d = l * sqrt(noise/magn) / 2: the posterior curvature recoverable from observations spaced d apart halves there, so rows closer than that add no curvature information at the live noise level and only degrade conditioning. The dimer has bounded itself with it for a while; GPNEB.h says in as many words that the band path needs the same and does not have it.

Returns a non-positive value when the model cannot state one yet, in which case the caller admits the row.

double nearestTrainingDistance(const Eigen::VectorXd& positions) const

Nearest training row to positions, in the metric the floor is stated in.

EMD, not a Cartesian norm. The floor above is the dimer’s, and the dimer compares it against dist_emd; the archive’s own neighbourhood selection uses dist_emd too. A Cartesian norm would be a different metric wearing the same threshold, and it would also call two configurations far apart when they differ only by relabelling equivalent atoms.

void appendObservation(const Eigen::VectorXd& positions, double energy, const Eigen::VectorXd& gradient, ObservationRetention retention = ObservationRetention::RecordAcquisition, optim::SecantAccounting secant_accounting = optim::SecantAccounting::Count)

Append one observation row to ~training_obs~. Mirrors the internal ~appendObservation~ helper in ~GPNEB.cpp~; lives here so the controller can use it directly without leaking that helper. Every distinct oracle acquisition is a joint energy-and-force observation and is retained in full.

void setEndpointSymmetry(EndpointSymmetry symmetry)

Exchange symmetry of the band’s endpoints. While it is set, every admitted oracle row also enters at its symmetry image, which is an exact observation of the same potential (see ~EndpointSymmetry~). The image is not an acquisition: it never reaches the observation archive, and an archived row regenerates it on adoption. Rows already in the training set enter at their images when it is set, unless the image is already a row. An empty symmetry clears it.

long symmetryRowsAdmitted() const

Symmetry-image rows admitted, and those refused because a training row already lay within the model’s resolution of the image, or within the operation’s own (~EndpointSymmetry::resolution~).

void setResolutionDedup(bool on)

Admit rows only when they are farther apart than the model can resolve. Off by default: it declines data, and what that costs in acquisitions wants measuring before it is anyone’s default.

bool withinTrainingResolution(const Eigen::VectorXd& positions) const

True when ~appendObservation~ would refuse a row at positions under the resolution gate: a training row already lies closer than the model’s own resolution floor, so a measurement there is informationless and the posterior at positions is the data. Certificates that demand “current oracle data” at an image must accept this state as observed, or they wait forever for a row the session will never store.

int admitObservation(const Eigen::VectorXd& positions, double energy, const Eigen::VectorXd& gradient, optim::SecantAccounting secant_accounting = optim::SecantAccounting::Count)

The row holding positions after a merge or an append, or -1 when the resolution gate refused it.

void appendSymmetryImage(int source_row, const Eigen::VectorXd& positions, double energy, const Eigen::VectorXd& gradient)

Enter the symmetry image of the row at source_row. A repeated image merges like a repeated draw, which keeps it the image of the source row’s count-weighted target. The resolution gate applies whatever gp-resolution-dedup says: the image of a geometry the symmetry fixes, the saddle among them, lands on its source to rounding, and a derived row inside the model’s resolution of a training row adds nothing.

void syncTrainingMultiplicity()

Keep ~training_multiplicity~ aligned with ~training_obs~: new rows enter with multiplicity one, suffix truncation drops the tail. Interior removals are handled at their removal site.

void noteExternalTrainingEdit()

Rows of ~training_obs~ were replaced outside append and prune. The fitted factor no longer matches, so the next refit rebuilds it.

bool retainTrainingRowsForPolicy(const policy::TrainingPolicy& policy)

Apply ~policy.retain_training_rows~. An identity list does nothing. Any other list rebuilds the training set, the multiplicity, every image index map, and the factor at the current hyperparameters. The fitted revision is left alone: theta was not re-optimised.

bool addVirtualObservation(const Eigen::VectorXd& positions, double retire_radius)

Pin the posterior toward the prior at ~positions~ with a conditioning-only virtual observation (targets = prior mean and prior gradient there, residual zero under the model’s own prior-mean subtraction). Skipped when a real or virtual row already sits within ~retire_radius~ (coordinate norm): a real row means the model has genuine information there; a virtual one means the pin already exists. Bounded at ~kMaxVirtualObservations~ rows, oldest replaced first. Returns true when a row was inserted; the caller re-conditions via ~refreshCovarianceCache~.

void retireVirtualObservationsNear(const Eigen::VectorXd& positions)

Drop every virtual row whose retire radius covers ~positions~. Called on each real append: a genuine measurement supersedes the prior pin in its neighbourhood.

void syncVirtualNoiseTag()

Push the current virtual-geometry set and its noise into the likelihood so every subsequent covariance assembly tags the matching rows. Real-only assemblies contain no matching geometry and stay bit-identical.

gpr::Observation composedTrainingObs() const

~training_obs~ with the virtual rows appended, for covariance conditioning and prediction. Hyperparameter fitting keeps using ~training_obs~ directly.

void appendObservation(int image_idx, const Eigen::VectorXd& positions, double energy, const Eigen::VectorXd& gradient, ObservationRetention retention = ObservationRetention::RecordAcquisition, optim::SecantAccounting secant_accounting = optim::SecantAccounting::Count)

Dual-update overload: append to the global ~training_obs~ AND to image ~image_idx~’s local training set. The per-image set drives ~predictAtImage(image_idx, …)~ once its direct row count crosses the ~min_per_image_n_train~ threshold; below threshold those calls fall through to the global ~gp~. Out-of-range ~image_idx~ (or per-image storage uninitialised) just degenerates to a global-only append, matching the single-argument overload.

bool attachImageObservation(int image_idx, int global_row_index)

Bind an acquired canonical row to an image without treating its reuse as another draw from the oracle. Image targets use the canonical mean.

void appendCurrentChainObservation(int image_idx, const Eigen::VectorXd& positions, double energy, const Eigen::VectorXd& gradient, ObservationRetention retention = ObservationRetention::RecordAcquisition, optim::SecantAccounting secant_accounting = optim::SecantAccounting::Count)

Append a force-quality observation at the live chain geometry and bind its certificate to that image and position. The row is durable because path certificates must survive restart and covariance refresh.

void setImageNeighborhood(int i, const std::vector<int>& emd_indices, const Eigen::VectorXd* image_position = nullptr)

Rebuild image ~i~’s local training set as the trajectory-aware union of two index sets over the global ~training_obs~:

  • ~emd_indices~ :: the EMD k-nearest observations to image ~i~’s current position. Tracks the moving chain so an image picks up its neighbours’ oracle calls.

  • ~model.directIndices()~ :: every row image ~i~ was oracled at directly its own search / climb trajectory.

The EMD set alone is a recent spatial cluster: for a climbing image it is the last few uphill steps, and a GP fit on that extrapolates the ascent without bound. Unioning the image’s own oracle history keeps the trajectory that bounds the climb. Recomputed every outer iteration; a no-op when the union already matches the slot’s selection, otherwise the row set changed and the cached per-image factor is invalidated so the next predict refits. image_position, when given, additionally re-selects archived rows: acquisitions the global pruner removed from ~training_obs~ but which sit EMD-nearer to this image than its farthest kept training row come back from the readcon-db corpus. The double-GP sets are disjoint views; the archive is what makes that divergence non-destructive.

std::vector<uint64_t> selectArchivedNeighbors(const std::vector<int>& kept, const Eigen::VectorXd* image_position, Eigen::Index D)

Archived-row candidates for one image: rows in the corpus that no longer coincide with any active training row and whose EMD to the image position is within the admission radius (the image’s farthest kept training row; unbounded while no rows are kept). At most ~per_image_knn~ rows, nearest first.

bool setImageInternalCoordinateChart(int i, std::shared_ptr<const gpr::geometry::InternalCoordinateChart> chart)

Anchor image ~i~’s local GP to a nonredundant molecular tangent chart. The intrinsic scalar length is inherited by matching the fitted global GP’s tangent force variance. An unavailable global metric clears a stale chart and leaves prediction on the ordinary global fallback.

bool setGlobalInternalCoordinateChart(std::shared_ptr<const gpr::geometry::InternalCoordinateChart> chart)

Anchor the GLOBAL Sexpat energy-force tensor on a nonredundant molecular tangent chart. The isotropic intrinsic length is matched to the current global force variance. A missing metric or an invalid chart leaves Cartesian Sexpat in place; a heat prior composes with it.

bool setBandGeodesicReferencePath(const gpr::Coord& reference_path)

Supply the GLOBAL GP with a band reference path for the soft geodesic heat prior, without touching per-image local models. The additive amplitude is evidence-fitted at each ~refitGP~ (a zero optimum retains the base covariance; see docs/orgmode/explanation/theory/soft_geodesic_heat_kernel.org and scripts/derive_soft_geodesic_energy_force_gp.py).

bool setImageGeodesicReferencePath(int i, const gpr::Coord& reference_path)

Supply image ~i~’s local GP with the live whole-band geometry used to construct its soft geodesic heat covariance. The path amplitude is fitted from this image’s joint energy-gradient observations at refit.

bool refitImageGP(int i)

Refit image ~i~’s local GP on its current training data, with theta inherited from the global ~gp~. Compatible EB and Laplace models share its parameter measure and condition on local rows. Distinct conditioning sets can give different boundary predictions. Returns false when no valid local posterior can be materialized.

void ensureSingletonForGlobal()

Ensure the global ~gp~ owns the singleton. Cheap when already active with a usable posterior; refactorises the global K when the recorded owner has lost the process-wide factor or when switching from a per-image owner. Call before any ~gp.calculate*~ or any ~gp~ predict that needs the cached factor.

bool ensureSingletonForImage(int i)

Ensure image ~i~’s local GP owns the singleton, refitting on demand. Cheap when already active; otherwise re-syncs theta from the global and refactorises the per-image K. Call before any ~image_models[i]. gp() ->calculate*~ predict.

void predictAtImage(int i, gpr::Observation& probe)

Per-image predict with global fallback. Returns the predicted (energy, gradient) in ~probe~. If image ~i~’s local set has at least ~min_per_image_n_train~ neighbourhood rows the call goes through the local GP; otherwise it routes through the global ~gp~.

void observationVarianceAtImage(int i, gpr::Observation& probe)

Per-image joint energy-and-gradient variance with global fallback. The returned Observation carries every channel used by acquisition.

template <typename Use>
void withImageChartFallback(int i, Use&& use)

Run ~use~ on image ~i~’s model, or on the global model when the image has too few rows of its own. A chart is built from the primitives that are defined along the path when it is attached; a training row or a probe that puts three atoms of a dihedral on a line leaves that primitive undefined, and the chart no longer describes the region the model covers. The image then drops its chart and the call runs again on the Cartesian pair kernel. Only an undefined primitive is recovered; any other error, and any error on an image without a chart, passes on unchanged.

template <typename Use>
void withImageModel(int i, Use&& use)

Run ~use~ on image ~i~’s model, dropping a chart that is undefined at a row or probe and running again on the Cartesian pair kernel.

void compactAfterRowRemoval(int removed_row)

A row was removed from ~training_obs~ (rollback of speculative rows): compact every per-image model’s index views in step.

bool rollbackTrainingObservations(Eigen::Index row_count)

Remove speculative suffix rows from the global training buffer and compact every per-image view that references those rows.

int pruneTrainingObservationsAdaptive(const gpr::Coord& band_positions)

Adaptive pruning: drop training observations whose removal moves the posterior energy and every Cartesian force at every band point by less than the likelihood noise. The influence is the exact block downdate (see ~GaussianProcessRegression::observationBandInfluence~ and scripts/derive_adaptive_pruning_influence.py), so the threshold is a unit comparison against noise rather than a tuned constant: a row that cannot move any band prediction by one sigma carries no information the band posterior uses, while it still costs O(n^3) in every later refit.

Per-image models hold global row indices, so every removal is mirrored through ~ImageModel::compactAfterRowRemoval~, which drops references to the removed row and shifts the rest down. Removals run highest index first so earlier compactions never disturb the indices still to be removed. Returns the number of pruned observations.

int pruneTrainingObservationsToBudget(const gpr::Coord& band_positions, Eigen::Index max_rows)

Prune down to a row budget, least influential first.

The threshold prune below removes a row only when it moves the band by less than one likelihood sigma. On these runs that never holds: no [prune] line appears in any campaign log while the training set climbs past 150 observations. Nothing is redundant by that test, so nothing is dropped, and the set grows without bound.

That is what makes an outer iteration cost grow: the kernel order is the observation count times (1 + 3 natoms), the append is two O(m^3) steps, and summing that over a run is quartic in the outer count. A budget converts it to linear.

Influence is recomputed between removals for the reason the threshold prune states: deleting a row changes what every other row is worth, so a batch decided against one stale vector collapses correlated groups. That costs an influence evaluation per removal, which is cheap beside the factorisation it saves.

Returns:

rows removed.

int pruneLeastInfluentialRow(const gpr::Coord& band_positions, bool ignore_noise)

Remove the single least influential row. ignore_noise drops it regardless of the one-sigma test, which is what a budget needs: the question there is not whether the row is redundant but whether it is the least useful of the ones that no longer fit.

int pruneImageModelsAdaptive(const gpr::Coord& band_positions)

Per-image adaptive pruning across every activated single-image GP: each model prunes against its own band point only. The global set stays as the double-GP concept demands the global model hands over to the single-image ones, and each of those conditions on an adaptively pruned local set.

bool refitGP(bool reinit_seeds)

Convenience: refit hyperparameters then optimize. ~reinit_seeds~ controls whether ~setHyperparameters~ re-derives seeds from data statistics (cold) or warm-starts from the previous fit. See ~GPNEB.cpp~ for the cold/warm rationale. Returns false when a training policy keeps the hyperparameters and only the factor is updated.

bool hyperparametersNeedRefit() const

A covariance refresh can condition the current theta on new rows, but only ~refitGP~ calibrates theta against those rows. This predicate keeps the two states distinct for phases that append data between outer-loop refits.

bool refitGPIfTrainingChanged(bool reinit_seeds)

Warm-refit only when the training set changed since the fitted theta. Returns true when a refit was performed.

bool wouldRefitAtNextRefresh() const

True when the next ~refreshCovarianceCache~ would run a full hyperparameter refit rather than a fixed-theta rematerialize.

Pruning is only free at such a point. A refit rebuilds the factorization from scratch anyway, so dropping rows costs nothing extra there; dropping them between refits instead turns the next rematerialize from a suffix append into a full O(n^3) rebuild, because the training matrix is no longer an extension of the one the cached factor was built on.

void refreshCovarianceCache()

Rebuild ~gp~’s internal model state (R_matrix, R_indices, energy_and_gradient, distributed Cholesky factor, posterior weights) from the current ~training_obs~ WITHOUT re-running hyperparameter optimisation. Use after a sibling phase (e.g. OCINEB MMF burst) mutates ~training_obs~ between outer-iter retrains: the burst’s internal AtomicDimer GP factorises a different-sized covariance into the singleton ~DistributedState~ cache, so ~gp~’s distributed L is stale by the time the next NEB iter probes variance / runs a solve. ~updateModelWithFullData~ reassembles R_matrix and calls ~decomposeCovarianceMatrix~, which repopulates the singleton cache with ~gp~’s factor at the new training size. Cheaper than ~refitGP~ (no SCG NLML evaluations); the next outer iter’s natural retrain handles hyperparameter updates.

bool conditionGPOnConsistentRows(const gpr::Observation& acquired, ConvergenceNormType force_norm, Eigen::Index max_rows = 0, double force_tolerance = std::numeric_limits<double>::infinity(), gpr::GaussianProcessRegression::RefitTrustReport* trust_report = nullptr)

Condition acquired rows when their forces agree with the proposing posterior. The caller appends them to training_obs without conditioning the GP first, so the comparison uses predictions made without the rows. Exceeding the row ceiling requires pruning and a full refit.

void setEvidenceRefitTrigger(bool enabled)

Switch the refit decision of ~conditionGPOnConsistentRows~ from the force-resolution test to the accumulated contradiction evidence.

double acquiredEvidenceNats() const

Contradiction evidence (nats) of the rows conditioned since the last hyperparameter fit.

bool acquiredEvidenceRequestsRefit(double batch_nats)

Add a batch’s evidence to the running sum. True when the sum reaches one nat, the amount a refit can learn about theta; the sum then restarts at the next fit and is left unchanged here.

bool conditionGPOnResolvedRows(const gpr::Observation& acquired, ConvergenceNormType force_norm, Eigen::Index max_rows, double force_tolerance)

Assimilate a statistically consistent measurement, then require its conditioned force error and uncertainty to resolve the physical scale. A broad predictive distribution can narrow when the measured row is added; broad uncertainty alone is not evidence against the kernel. False requests a refit and may leave the new rows conditioned.

void conditionGPOnTrainingData()

Condition every retained observation at the fitted kernel parameters. The fitted training revision remains unchanged so a continued search can distinguish posterior conditioning from hyperparameter fitting.