=========================================== TPE acquisition for GP-OIE oracle targeting =========================================== **Status:** implemented, and the default. ``--acquisition tpe`` selects it, ``GPNEBConfig::acquisition`` defaults to ``AcquisitionType::TPE`` (``gpr/neb/GPNEB.h``), and the schema field ``NebParams.acquisition`` defaults to ``tpe`` (``schema/params.capnp``). The policy is in ``gpr/neb/oie/AcquisitionPolicy.h`` and ``gpr/neb/oie/AcquisitionPolicy.cpp``, and ``gpr/neb/GPNEB.cpp`` calls it. The page replaces an earlier design draft; the last section lists where the code departs from that draft. What it decides --------------- The GP-OIE outer loop of ``gprn`` spends oracle calls on interior images of the band. Each outer iteration needs a target: the image that gets the next true energy and force. The policy picks that image from the posterior of the per-image GP. It uses a Tree-structured Parzen Estimator (TPE, Bergstra et al. 2011, as in Optuna's ``TPESampler``) over the discrete interior image index. A utility scores each interior image. The pick is the image with the largest log density ratio of the best-scoring images to the rest. The policy takes four whole-band vectors, indexed ``0 .. n_images-1``: the posterior energies, the posterior energy variances, the NEB force norms and the posterior force variances. The endpoints are never targets. Where it runs in the outer loop ------------------------------- ``gpr/neb/GPNEB.cpp`` first builds a target decision with ``OieOracleTargetPlanner`` (declared in ``gpr/neb/GPNEB.h``). Each decision carries an ``OieOracleSelectionArm``: ``RejectedProposal``, ``ActivationPriority``, ``CurrentChainPriority``, ``CertificateDeficit``, ``AcceptedDrift``, ``PredictionKernelDrift``, ``FrozenSweep``, ``CurrentClimbingImage``, ``Variance``, ``FirstUnobserved`` or ``RecoveryModelGrowth``. A posterior acquisition may replace only the arms ``Variance``, ``FirstUnobserved`` and ``CertificateDeficit`` (``OieOracleTargetDecision::replaceableByPosteriorAcquisition``). The other arms keep their target. When ``config.acquisition =`` AcquisitionType\:\:TPE= and the decision is replaceable, or the planner is idle while the band force is still unresolved, the loop does the following: 1. It builds the eligibility mask: an interior image is eligible when neither ``image_evaluated`` nor ``image_observed_current`` is set for it and its posterior variance exceeds the likelihood noise floor ``gp.getSigma2()``. A noise floor that is not positive disables the variance test. 2. It picks the objective with ``tpeObjectiveForSaddleState(ci_active, ci_candidate_posterior_confident, chain_certificate_met)``. The result is ``SaddleIdentity`` when the climbing image is active, its candidate is not yet confident and the chain certificate deficit is within its threshold. In every other case it is ``ForceAccuracy``. 3. It calls ``AcquisitionPolicy::selectTpeOracleTarget`` with the outer iteration ``outer + 1 + config.acquisition_seed_offset``. The offset is nonzero only for restarts after an unconverged attempt, so that restart :math:`k` takes a different deterministic path than restart :math:`k-1`. 4. It passes the picked image to ``OieOracleTargetPlanner::selectPosteriorAcquisitionTarget`` with the arm ``TPE``. The planner returns the earlier decision unchanged when the sweep is frozen, when a rejected proposal owns the target, or when the image already has true current oracle data. The fixed-point proposal path calls the free function ``oie::selectTpeOracleTarget`` (every interior image eligible) to choose a preferred image for the proposal. ``--acquisition`` also accepts ``ucb``, ``imspe``, ``ei``, ``max_variance``, ``thompson``, ``priorityCascade`` and ``psbax`` (``parseAcquisitionType`` in ``main_neb.cpp``); ``AcquisitionType::PriorityCascade`` is the name of the earlier hand-ordered selector. ``gpr/neb/AcquisitionStrategy.cpp`` scores each unevaluated image for ``TPE`` by ``jointVarianceTrace``, the trace of the joint energy and gradient variance; that function does not run the chain-level policy. The utility ----------- The policy standardizes each channel over the interior images: :math:`z(a)_i = (a_i - \bar a)/\sigma_a`, with the population standard deviation. A constant channel becomes zero. Let :math:`M` be the number of interior images and :math:`t` the outer iteration used by the schedule, at least 1. The exploration weight is the square root of the GP-UCB schedule of Srinivas et al. (2010) for a finite decision set of size :math:`M`, with :math:`\delta = 1/t`: .. math:: \sqrt{\beta_t} = \sqrt{2 \ln \frac{M\, t^2 \pi^2}{6 \delta}} This is ``ucbBeta(outer_iter, n_candidates)``, which returns the square root. It grows with the iteration and the band size, and there is no :math:`\kappa` to set. Force-accuracy objective ~~~~~~~~~~~~~~~~~~~~~~~~ The objective is the accuracy of the NEB force. The squared force error splits into a bias term and the force posterior variance. The predicted force norm :math:`|F|` stands in for the bias, because an unrelaxed or extrapolating GP gradient is what the oracle has to correct. The derivation is in ``scripts/oie_acquisition_accuracy_derivation.py``. The utility for image :math:`i` is .. math:: U_i = z(|F|)_i + \sqrt{\beta_t}\, z(\mathrm{Var}F)_i When the band is confident (next section), the energy joins it: .. math:: U_i = z(E)_i + z(|F|)_i + \sqrt{\beta_t}\, z(\mathrm{Var}F)_i The energy variance does not enter either form. A call with an empty force-variance vector uses zeros for that channel (``oieUtility``). Saddle-identity objective ~~~~~~~~~~~~~~~~~~~~~~~~~ With ``TpeObjective::SaddleIdentity``, the utility measures how likely each image is to change which interior image has the highest energy (``saddleIdentityUtility``). For the current maximum :math:`c` and a challenger :math:`i`, the policy computes the probability that the challenger energy reaches the maximum energy, under independent Gaussian marginals: .. math:: p_i = \Phi\!\left(\frac{E_i - E_c}{\sqrt{\mathrm{Var}E_c + \mathrm{Var}E_i}}\right) The utility of the challenger is :math:`p_i` times its posterior standard deviation. The utility of the current maximum adds :math:`p_i` times its own standard deviation for every interior challenger, and the same product for each endpoint taken as a challenger. This objective never takes the interior-maximum pick below. The gate is still computed and reported in ``TpePickResult``. The confidence gate and the climbing-image pick ----------------------------------------------- ``saddleExists(energies)`` is true when the largest interior energy is strictly above both endpoint energies. No single-hump shape is assumed. ``confidenceMet`` is true when posterior uncertainty no longer reaches across the barrier being resolved: .. math:: \sqrt{\beta_t}\, \max_i \sqrt{\mathrm{Var}E_i} \;\le\; \max_i E_i - \max(E_0, E_{n-1}) The maximum runs over the interior images. The right side is the prominence of the interior maximum above the higher endpoint. The gate is false when the prominence is not positive, so confidence implies ``saddleExists``. The prominence is the yardstick, and the band span is not: on an exothermic band the span includes the reaction energy and would pass the gate before the barrier top is resolved. In the force-accuracy objective, a confident band with ``saddleExists`` returns the interior image with the highest energy (``from_ci_saddle = true``), when that image is eligible. In every other case the policy continues to the TPE pick. The TPE pick ------------ ``tpePick`` works on the utilities of the eligible interior images and returns an interior index. 1. Sort the :math:`n` eligible images by utility. The best :math:`\gamma = \min(\lceil 0.1\, n \rceil, 25)` images, and at least one, form the good set. The rest are the bad set. This is Optuna's default quantile split. With one eligible image, that image is the pick. 2. Fit a Parzen estimator :math:`l` to the good set and :math:`g` to the bad set over the index range :math:`0 .. M-1`. Each estimator is a Gaussian mixture with one kernel per image and one prior kernel at the middle of the range with a bandwidth equal to the range width. 3. The bandwidth of an image kernel is the larger gap to its two neighbours in the sorted index list, padded with the range ends, and is clipped to :math:`[\,w / \min(100,\, 1 + n_k),\; w\,]`, where :math:`w` is the range width and :math:`n_k` the kernel count including the prior. For the good estimator, the kernels at the ends of the sorted list take the gap to their interior neighbour only, and a lone kernel takes the smallest allowed bandwidth. 4. Kernel weights: the good estimator weights each image kernel by :math:`\exp(U_i - U_{\max})`, normalized to :math:`n` pseudo-counts, and gives the prior one count. The bad estimator weights its image kernels equally, with the same prior. 5. The pick is the eligible index that maximizes :math:`\ln l(x) - \ln g(x)`, the first one on a tie. The constants 0.1, 25 and 100 are the reference algorithm's own definitions. No numeric option of the policy is exposed. Interfaces ---------- All of these are in the namespace ``gpr::neb::oie`` (``gpr/neb/oie/AcquisitionPolicy.h``). .. table:: +--------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------+ | Symbol | Role | +==================================================+=======================================================================================================================+ | ``AcquisitionPolicy`` | Holds the eligibility mask and the objective; ``selectTpeOracleTarget`` returns a ``TpePickResult``. | +--------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------+ | ``TpePickResult`` | ``image_index`` (full-band index, or -1), ``from_ci_saddle``, ``confident``, ``saddle_exists``, ``interior_utility``. | +--------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------+ | ``TpeObjective`` | ``ForceAccuracy`` or ``SaddleIdentity``. | +--------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------+ | ``tpeObjectiveForSaddleState`` | Chooses the objective from the climbing-image and certificate state. | +--------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------+ | ``selectTpeOracleTarget`` | Free function; every interior image eligible, force-accuracy objective. | +--------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------+ | ``oieUtility``, ``saddleIdentityUtility`` | The two utilities. | +--------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------+ | ``confidenceMet``, ``saddleExists``, ``ucbBeta`` | The gate, the predicate and the schedule. | +--------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------+ | ``tpePick`` | The density-ratio pick over interior utilities. | +--------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------+ | ``drawPosteriorObservationSample`` | One joint posterior draw, for the PS-BAX acquisition. It is not part of the TPE pick. | +--------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------+ Configuration ------------- .. code:: bash gprn --acquisition tpe ... The TOML key is ``acquisition.kind = "tpe"``, and the key reference lists the other values. The enum ``AcquisitionType`` in ``schema/params.capnp`` lists every value; ``tpe`` is ordinal 7. Tests ----- ``tests/gpr/neb/AcquisitionPolicyTest.cpp``, the meson test ``test_neb_acquisition_policy``, covers the policy with these cases: .. table:: +----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------+ | Test | Checks | +====================================================+========================================================================================================================================================+ | ``UnconfidentBandExploresMaxVarianceImage`` | An unconfident band picks the image with the largest variance and no climbing image. | +----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------+ | ``ConfidentBandPicksTrueInteriorMaximum`` | A confident band with a saddle picks the interior energy maximum. | +----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------+ | ``ConfidentMonotonicBandCommitsNoClimbingImage`` | A confident band with no interior maximum above the endpoints commits no climbing image. | +----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------+ | ``ExothermicBandConfidenceUsesProminenceNotSpan`` | The gate uses the prominence, not the span, on an exothermic band. | +----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------+ | ``TpeSelectsFromEligibleInteriorImages`` | The pick comes from the eligible set only. | +----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------+ | ``AmbiguousSaddleIdentityOverridesForceOutlier`` | The saddle-identity objective picks the ambiguous saddle where the force-accuracy objective picks a force outlier. | +----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------+ | ``SaddleIdentityRequiresResolvedChainCertificate`` | ``tpeObjectiveForSaddleState`` returns ``SaddleIdentity`` only for an active climbing image with an unconfident candidate and a met chain certificate. | +----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------+ | ``InactiveTpeDecisionHasDistinctLogName`` | ``tpeObjectiveLogName`` returns ``inactive``, ``force`` or ``saddle_identity``. | +----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------+ | ``UcbBetaScheduleGrowsAndStaysFinite`` | The schedule grows with iteration and band size and is finite at :math:`t = 1`. | +----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------+ | ``ConfidentSaddleAtBoundaryInteriorImage`` | The pick works when the saddle sits at the first or last interior image. | +----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------+ Differences from the earlier design draft ----------------------------------------- The first draft of this page proposed the policy before it existed. The implementation differs in these ways: - The force-accuracy utility has no energy-variance term. The draft combined energy variance, force variance, energy and force norm. - The confidence gate compares against the barrier prominence. The draft compared against the whole energy span. - The policy replaces the replaceable planner arms only. The draft described a policy that took over all of ``selectOieOracleTarget``, and the planner arms that must come first (rejected proposals, certificates, drift) remain in front. - The eligibility mask, the saddle-identity objective and the noise-floor test are additions. - The comments in ``AcquisitionPolicy.h`` and ``AcquisitionPolicy.cpp`` cite a Python prototype, ``refs/tpe_oie_prototype.py``. That file is not in the repository, and neither is the Optuna source tree that the draft cited by file and line. The draft's prototype output, its Optuna line references and its Baker-set barrier figure were not kept, because none can be reproduced from the repository.