.. index:: pair: namespace; pot .. _doxid-namespacepot: namespace pot ============= .. toctree:: :hidden: enum_pot_OracleBatchStatus.rst struct_pot_ActiveGPConfig.rst struct_pot_AotiPackageTarget.rst struct_pot_EngineAbiStamp.rst struct_pot_EngineBinding.rst struct_pot_EngineCaps.rst struct_pot_EngineDerivativeReport.rst struct_pot_EngineReport.rst struct_pot_EngineRequest.rst struct_pot_HostIsa.rst struct_pot_OracleBatchLayout.rst struct_pot_OracleBatchOutcome.rst struct_pot_OracleEvaluationScope.rst struct_pot_OraclePathChoice.rst struct_pot_RgpotBackend.rst struct_pot_RgpotRequest.rst class_pot_ActiveGP.rst class_pot_ActiveGPPotential.rst class_pot_EngineError.rst class_pot_EnginePotential.rst class_pot_GprMeanPotential.rst class_pot_NestedEngineOracle.rst class_pot_PotentialWrapper.rst Overview ~~~~~~~~ Potential wrappers and the batched oracle interface. :ref:`More...` .. ref-code-block:: cpp :class: doxyrest-overview-code-block namespace pot { // typedefs typedef int :target:`OracleBatchComm`; // enums enum :ref:`OracleBatchStatus`; // structs struct :ref:`ActiveGPConfig`; struct :ref:`AotiPackageTarget`; struct :ref:`EngineAbiStamp`; struct :ref:`EngineBinding`; struct :ref:`EngineCaps`; struct :ref:`EngineDerivativeReport`; struct :ref:`EngineReport`; struct :ref:`EngineRequest`; struct :ref:`HostIsa`; struct :ref:`OracleBatchLayout`; struct :ref:`OracleBatchOutcome`; struct :ref:`OracleEvaluationScope`; struct :ref:`OraclePathChoice`; struct :ref:`RgpotBackend`; struct :ref:`RgpotRequest`; // classes class :ref:`ActiveGP`; class :ref:`ActiveGPPotential`; class :ref:`EngineError`; class :ref:`EnginePotential`; class :ref:`GprMeanPotential`; class :ref:`NestedEngineOracle`; class :ref:`PotentialWrapper`; // global variables double :ref:`kEnergyVarianceNegativeRtol` = 1.0e-8; // global functions :ref:`AotiPackageTarget` :ref:`readAotiPackageTarget`(const std::string& path); std::vector :ref:`missingIsa`(const :ref:`AotiPackageTarget`& target, const :ref:`HostIsa`& host); void :ref:`requireAotiPackageRunsOn`(const std::string& path, const :ref:`HostIsa`& host); void :ref:`requireAotiPackageRunsOnHost`(const std::string& path); bool :ref:`engineIsGeneric`(const std::string& potential); bool :ref:`engineRequestIsPlugin`(const :ref:`EngineRequest`& request); :ref:`OraclePathChoice` :ref:`selectOraclePath`(const std::string& requested, const std::string& potential, bool plugin); :ref:`OraclePathChoice` :ref:`selectOraclePath`(const std::string& requested, const std::string& potential); std::string :ref:`formatOraclePath`(const :ref:`OraclePathChoice`& choice, const std::string& potential); bool :ref:`recordOraclePath`(const :ref:`OraclePathChoice`& choice); std::vector :ref:`engineSearchDirectories`(const :ref:`EngineRequest`& request, const std::string& potential); bool :ref:`engineRegistryKnows`(const std::string& potential); bool :ref:`resolveEngine`(const :ref:`EngineRequest`& request, :ref:`EngineBinding`& binding, std::string& err); std::unique_ptr<:ref:`EnginePotential`> :ref:`openEngine`(const :ref:`EngineRequest`& request, std::string& err, :ref:`EngineBinding`* binding, int oracle_threads); :ref:`EngineReport` :ref:`reportEngine`(const :ref:`EnginePotential`& engine, const :ref:`EngineBinding`& binding); :ref:`EngineReport` :ref:`reportEngine`(const :ref:`EnginePotential`& engine, const :ref:`EngineBinding`& binding, const std::string& model_sha256); std::shared_future :ref:`startModelDigest`(const std::string& model_path); std::string :ref:`formatEngineReport`(const :ref:`EngineReport`& report); bool :ref:`recordEngineProvenance`(const :ref:`EngineReport`& report); std::string :ref:`engineLibraryForSpecArm`(const std::string& arm_name); :ref:`OracleBatchComm` :ref:`oracleBatchWorld`(); int :ref:`oracleBatchOwner`(Eigen::Index point, Eigen::Index count, const :ref:`OracleBatchLayout`& layout); std::vector> :ref:`ownedOracleGroups`(Eigen::Index count, const :ref:`OracleBatchLayout`& layout); :ref:`OracleBatchOutcome` :ref:`agreeOracleBatchStatus`(:ref:`OracleBatchStatus` local_status, const std::string& local_message, const :ref:`OracleBatchLayout`& layout); void :ref:`allreduceOwnedOracleValues`(std::vector& energies, Eigen::MatrixXd& gradients, const :ref:`OracleBatchLayout`& layout, double* communication_seconds = nullptr); void :ref:`allreduceOwnedOracleMask`(std::vector& accepted, const :ref:`OracleBatchLayout`& layout); void :ref:`resetOracleEvaluations`(); long :target:`oracleEvaluations`(); void :target:`pushOracleEvaluations`(long evaluations); void :target:`popOracleEvaluations`(); bool :ref:`energyVarianceAccepted`(const double variance); double :ref:`energyVarianceToRms`(const double variance); std::vector<:ref:`RgpotBackend`> :ref:`rgpotBackends`(); bool :target:`rgpotBackendAvailable`(const std::string& name); std::string :target:`canonicalRgpotName`(const std::string& name); std::string :target:`formatPotentialCatalog`(); std::vector :target:`readPotentialConfig`(const std::string& path); std::vector :ref:`potentialConfigArm`(const std::vector& config, const std::string& potential); void :ref:`applyRgpotConfig`(:ref:`RgpotRequest`& request); void :ref:`configureRgpotRuntime`(const :ref:`RgpotRequest`& request); std::unique_ptr :ref:`makeRgpotPotential`(const :ref:`RgpotRequest`& request); } // namespace pot .. _details-namespacepot: Detailed Documentation ~~~~~~~~~~~~~~~~~~~~~~ Potential wrappers and the batched oracle interface. Global Variables ---------------- .. index:: pair: variable; kEnergyVarianceNegativeRtol .. _doxid-namespacepot_1ae122404dd1fd55b033b657ef44d64948: .. ref-code-block:: cpp :class: doxyrest-title-code-block double kEnergyVarianceNegativeRtol = 1.0e-8 Negative energy variances at least this large, relative to 1 eV^2, are cancellation between the prior diagonal and the solved quadratic form. They are clamped to zero. A more negative value is an error. Global Functions ---------------- .. index:: pair: function; readAotiPackageTarget .. _doxid-namespacepot_1a3a374d23d10b4f93a044f1e0dbd35b30: .. ref-code-block:: cpp :class: doxyrest-title-code-block :ref:`AotiPackageTarget` readAotiPackageTarget(const std::string& path) Reads the target fields of the package at path. A file that is not a zip archive, or a package without metadata entries, gives metadata_found == false. Throws std::runtime_error when the file cannot be opened. .. index:: pair: function; missingIsa .. _doxid-namespacepot_1a83cec0db23f1c9ebeb005be2d8182797: .. ref-code-block:: cpp :class: doxyrest-title-code-block std::vector missingIsa(const :ref:`AotiPackageTarget`& target, const :ref:`HostIsa`& host) The ISA tokens of target that host does not provide. A token this module does not know is returned prefixed with "unknown:" so the caller can tell it from a known missing extension. .. index:: pair: function; requireAotiPackageRunsOn .. _doxid-namespacepot_1aa09f21ccb27c01636036b36642761317: .. ref-code-block:: cpp :class: doxyrest-title-code-block void requireAotiPackageRunsOn(const std::string& path, const :ref:`HostIsa`& host) requireAotiPackageRunsOnHost against an explicit host description. .. index:: pair: function; requireAotiPackageRunsOnHost .. _doxid-namespacepot_1a85609e2877ab1b6a25a525d551aacadd: .. ref-code-block:: cpp :class: doxyrest-title-code-block void requireAotiPackageRunsOnHost(const std::string& path) Throws std::runtime_error, before the package is loaded, when the package at path needs a known CPU extension the calling host lacks. A path that is not a readable file, a package without metadata, or one naming only unknown tokens passes (the loader reports a missing model); unknown tokens are reported on stderr. .. index:: pair: function; engineIsGeneric .. _doxid-namespacepot_1a2f1c6728c4bc60e89aa182afed9e337d: .. ref-code-block:: cpp :class: doxyrest-title-code-block bool engineIsGeneric(const std::string& potential) True when the registry has an engine that loads through the generic rgpot_engine\_\* table (UMA, CPMD, CP2K, LAMMPS). .. index:: pair: function; engineRequestIsPlugin .. _doxid-namespacepot_1a6d5853729e75ef37630de1ac2976d32f: .. ref-code-block:: cpp :class: doxyrest-title-code-block bool engineRequestIsPlugin(const :ref:`EngineRequest`& request) True when the request carries its engine's parameters message (a params path or payload), which makes it a plugin request. .. index:: pair: function; selectOraclePath .. _doxid-namespacepot_1a82b27c5935937531a53c9727535bfcd4: .. ref-code-block:: cpp :class: doxyrest-title-code-block :ref:`OraclePathChoice` selectOraclePath(const std::string& requested, const std::string& potential, bool plugin) As above; ``plugin`` (engineRequestIsPlugin) makes the engine the default for any name, since the request names the library and its parameters. .. index:: pair: function; selectOraclePath .. _doxid-namespacepot_1aa6f8a77a4612ec7878db3bd0a67c4312: .. ref-code-block:: cpp :class: doxyrest-title-code-block :ref:`OraclePathChoice` selectOraclePath(const std::string& requested, const std::string& potential) Pick the route. ``requested`` is "engine" or "direct" as given on the command line, or empty/"auto" for the default: the engine for a potential with a generic engine, the compiled-in backend for the rest, and for all of them when the binary has no Cap'n Proto. An explicit request is always honoured; a missing engine library is then an error, never a fall back. .. index:: pair: function; formatOraclePath .. _doxid-namespacepot_1a75f93b41fca21126b03d82808116d2bd: .. ref-code-block:: cpp :class: doxyrest-title-code-block std::string formatOraclePath(const :ref:`OraclePathChoice`& choice, const std::string& potential) One startup line (``gpr/StartupReport.h``): "[startup] oracle path=engine potential=uma reason=\"...\"". .. index:: pair: function; recordOraclePath .. _doxid-namespacepot_1a27dbba4a21645d44acc6b6bf40c4350f: .. ref-code-block:: cpp :class: doxyrest-title-code-block bool recordOraclePath(const :ref:`OraclePathChoice`& choice) Record the choice on the active tracking run as ``oracle.path``. .. index:: pair: function; engineSearchDirectories .. _doxid-namespacepot_1acb58a2faa4144599cef54b313bbe3108: .. ref-code-block:: cpp :class: doxyrest-title-code-block std::vector engineSearchDirectories(const :ref:`EngineRequest`& request, const std::string& potential) Directories searched for a table library when no engine-dir is given, in order: engine-dir (listed first when present), $RGPOT_ENGINE_PATH (colon separated), the install prefix's lib and lib64 next to the executable, the executable's own directory, then the build tree's rgpot subproject below it. .. index:: pair: function; engineRegistryKnows .. _doxid-namespacepot_1a270bf428a0b0d75d5659f07d93131119: .. ref-code-block:: cpp :class: doxyrest-title-code-block bool engineRegistryKnows(const std::string& potential) True when the registry maps ``potential`` to an engine params arm. .. index:: pair: function; resolveEngine .. _doxid-namespacepot_1a15027e6fa7d0409f26b5d20e167473df: .. ref-code-block:: cpp :class: doxyrest-title-code-block bool resolveEngine(const :ref:`EngineRequest`& request, :ref:`EngineBinding`& binding, std::string& err) Resolve a potential name to a library and a config message. The library is potential-library when given, else the table's name under engine-dir, else under $RGPOT_ENGINE_PATH, else the bare name for the loader's own search (rpath, LD_LIBRARY_PATH). A plugin request takes its config message from params_payload or params_path and needs no table entry; its library is potential-library, or the table's name when the potential has one, and a bare library name is searched the same way. .. index:: pair: function; openEngine .. _doxid-namespacepot_1a2a663c56a1ebdf071e88c3aeaa2a0709: .. ref-code-block:: cpp :class: doxyrest-title-code-block std::unique_ptr<:ref:`EnginePotential`> openEngine(const :ref:`EngineRequest`& request, std::string& err, :ref:`EngineBinding`* binding, int oracle_threads) resolveEngine followed by :ref:`EnginePotential::open `. .. index:: pair: function; reportEngine .. _doxid-namespacepot_1ad68790372fb1ad65f7d83484f614e97a: .. ref-code-block:: cpp :class: doxyrest-title-code-block :ref:`EngineReport` reportEngine(const :ref:`EnginePotential`& engine, const :ref:`EngineBinding`& binding) Describe a loaded engine. Hashes the model file, so call it once at startup rather than per evaluation. .. index:: pair: function; reportEngine .. _doxid-namespacepot_1af4955845a80ce0179a5125c4a17b71cb: .. ref-code-block:: cpp :class: doxyrest-title-code-block :ref:`EngineReport` reportEngine(const :ref:`EnginePotential`& engine, const :ref:`EngineBinding`& binding, const std::string& model_sha256) The same report with the model digest supplied by the caller: the value of startModelDigest(binding.model_path), so no file is read here. .. index:: pair: function; startModelDigest .. _doxid-namespacepot_1a9abcedb17b1680f381b9b9b230276bed: .. ref-code-block:: cpp :class: doxyrest-title-code-block std::shared_future startModelDigest(const std::string& model_path) Hash a model file on a worker thread. The digest equals the one reportEngine computes, and an empty path yields an empty digest. A driver starts it on the reporting rank before it loads the engine, so the read of the file overlaps the load instead of following it. .. index:: pair: function; formatEngineReport .. _doxid-namespacepot_1a90203c90d22077c85a7dbd8bbfbde115: .. ref-code-block:: cpp :class: doxyrest-title-code-block std::string formatEngineReport(const :ref:`EngineReport`& report) One startup line (``gpr/StartupReport.h``): "[startup] engine library=... abi=1 arm=UmaParams model=... sha256=...". .. index:: pair: function; recordEngineProvenance .. _doxid-namespacepot_1a82f4bede58cf40c8d28732b662ed2a95: .. ref-code-block:: cpp :class: doxyrest-title-code-block bool recordEngineProvenance(const :ref:`EngineReport`& report) Write the report into the active tracking run as ``engine.*`` parameters, when one is active. Returns whether a run took it. .. index:: pair: function; engineLibraryForSpecArm .. _doxid-namespacepot_1a94f3abb3a4ec43332189c87e55de060b: .. ref-code-block:: cpp :class: doxyrest-title-code-block std::string engineLibraryForSpecArm(const std::string& arm_name) Library name for a PotentialSpec arm. Kept next to the loader so the mapping from a wire arm to a plugin is stated once. Returns an empty string for an arm with no engine plugin, which the caller reports rather than guessing at a filename. .. index:: pair: function; oracleBatchWorld .. _doxid-namespacepot_1a71c86a38d98bb2683de517ec2017d6c6: .. ref-code-block:: cpp :class: doxyrest-title-code-block :ref:`OracleBatchComm` oracleBatchWorld() The communicator of the whole run, or the no-MPI placeholder. .. index:: pair: function; oracleBatchOwner .. _doxid-namespacepot_1ae91bb063592485ed2bedb6d973081bfd: .. ref-code-block:: cpp :class: doxyrest-title-code-block int oracleBatchOwner(Eigen::Index point, Eigen::Index count, const :ref:`OracleBatchLayout`& layout) Owner rank of one point of a batch of ``count`` points. .. index:: pair: function; ownedOracleGroups .. _doxid-namespacepot_1ac57cab5bee9649bf183fd435ae436ed2: .. ref-code-block:: cpp :class: doxyrest-title-code-block std::vector> ownedOracleGroups(Eigen::Index count, const :ref:`OracleBatchLayout`& layout) The groups this rank evaluates, each one batch call, in point order. .. index:: pair: function; agreeOracleBatchStatus .. _doxid-namespacepot_1a874e70e016e71acae18282c95810985c: .. ref-code-block:: cpp :class: doxyrest-title-code-block :ref:`OracleBatchOutcome` agreeOracleBatchStatus(:ref:`OracleBatchStatus` local_status, const std::string& local_message, const :ref:`OracleBatchLayout`& layout) Collective agreement on the batch's status: the highest status wins and the message of the lowest failing rank reaches every rank. .. index:: pair: function; allreduceOwnedOracleValues .. _doxid-namespacepot_1af4bd01f079804e8bda4d365cb22b50bf: .. ref-code-block:: cpp :class: doxyrest-title-code-block void allreduceOwnedOracleValues(std::vector& energies, Eigen::MatrixXd& gradients, const :ref:`OracleBatchLayout`& layout, double* communication_seconds = nullptr) Union of the owners' values. Entries a rank does not own must be zero positive zero on entry; the bitwise union preserves the owner's bits. The time spent in the collectives is added to ``communication_seconds`` when given. .. index:: pair: function; allreduceOwnedOracleMask .. _doxid-namespacepot_1a1f4f5774e06ee2f39397028760dcffdf: .. ref-code-block:: cpp :class: doxyrest-title-code-block void allreduceOwnedOracleMask(std::vector& accepted, const :ref:`OracleBatchLayout`& layout) Union of the owners' acceptance mask. A zero entry contributes no bits, so a point stays accepted only when its owner accepted it. Every rank enters the collective. A caller that cannot keep a partial batch throws on the agreed failure and does not call this. .. index:: pair: function; resetOracleEvaluations .. _doxid-namespacepot_1a3c19ca8b925d93cb799a376b6a0562b4: .. ref-code-block:: cpp :class: doxyrest-title-code-block void resetOracleEvaluations() One count of oracle evaluations for the whole process. It is not a variable of any search loop: every potential evaluation, including stencils, refinement probes and escape-path stencils, adds to it. Nested wrappers count the outermost evaluation once. .. index:: pair: function; energyVarianceAccepted .. _doxid-namespacepot_1a579c8ad21f43063fce5a9a732daa943a: .. ref-code-block:: cpp :class: doxyrest-title-code-block bool energyVarianceAccepted(const double variance) True when a raw energy variance may be kept. A non-finite value, or one below -kEnergyVarianceNegativeRtol, is rejected. A value in [-kEnergyVarianceNegativeRtol, 0) is cancellation and may stay negative on a raw-variance slot. .. index:: pair: function; energyVarianceToRms .. _doxid-namespacepot_1acf45f48b45fb771005e4ef1d835f356b: .. ref-code-block:: cpp :class: doxyrest-title-code-block double energyVarianceToRms(const double variance) Convert rgpot's energy-variance slot to the wrapper's RMS contract. A variance energyVarianceAccepted rejects is reported to the caller. A smaller negative value is clamped to zero before the square root. .. index:: pair: function; rgpotBackends .. _doxid-namespacepot_1acf2816ef986c12b8f6204742e60fce43: .. ref-code-block:: cpp :class: doxyrest-title-code-block std::vector<:ref:`RgpotBackend`> rgpotBackends() The same table drives construction, name validation and CLI discovery. .. index:: pair: function; potentialConfigArm .. _doxid-namespacepot_1a818f703ba282aa5819f6330ae29407e5: .. ref-code-block:: cpp :class: doxyrest-title-code-block std::vector potentialConfigArm(const std::vector& config, const std::string& potential) Validate the selected arm and return its native params message for an engine. .. index:: pair: function; applyRgpotConfig .. _doxid-namespacepot_1aa80d3b29b43ed34ca277a883c00ba58e: .. ref-code-block:: cpp :class: doxyrest-title-code-block void applyRgpotConfig(:ref:`RgpotRequest`& request) Resolve shared model settings from the typed configuration for reporting. .. index:: pair: function; configureRgpotRuntime .. _doxid-namespacepot_1a24691b1cff062bc78350fecff33a28c1: .. ref-code-block:: cpp :class: doxyrest-title-code-block void configureRgpotRuntime(const :ref:`RgpotRequest`& request) Apply tensor-runtime settings before constructing a model. Repeated compatible requests share the process runtime; incompatible ones throw. .. index:: pair: function; makeRgpotPotential .. _doxid-namespacepot_1a7380afc10f668976509aa7da1cbba735: .. ref-code-block:: cpp :class: doxyrest-title-code-block std::unique_ptr makeRgpotPotential(const :ref:`RgpotRequest`& request) Creates one owned rgpot instance; unavailable names and mismatched configuration arms throw.