namespace pot¶
Overview¶
Potential wrappers and the batched oracle interface. More…
namespace pot {
// typedefs
typedef int OracleBatchComm;
// enums
enum OracleBatchStatus;
// structs
struct ActiveGPConfig;
struct AotiPackageTarget;
struct EngineAbiStamp;
struct EngineBinding;
struct EngineCaps;
struct EngineDerivativeReport;
struct EngineReport;
struct EngineRequest;
struct HostIsa;
struct OracleBatchLayout;
struct OracleBatchOutcome;
struct OracleEvaluationScope;
struct OraclePathChoice;
struct RgpotBackend;
struct RgpotRequest;
// classes
class ActiveGP;
class ActiveGPPotential;
class EngineError;
class EnginePotential;
class GprMeanPotential;
class NestedEngineOracle;
class PotentialWrapper;
// global variables
double kEnergyVarianceNegativeRtol = 1.0e-8;
// global functions
AotiPackageTarget readAotiPackageTarget(const std::string& path);
std::vector<std::string> missingIsa(const AotiPackageTarget& target, const HostIsa& host);
void requireAotiPackageRunsOn(const std::string& path, const HostIsa& host);
void requireAotiPackageRunsOnHost(const std::string& path);
bool engineIsGeneric(const std::string& potential);
bool engineRequestIsPlugin(const EngineRequest& request);
OraclePathChoice selectOraclePath(const std::string& requested, const std::string& potential, bool plugin);
OraclePathChoice selectOraclePath(const std::string& requested, const std::string& potential);
std::string formatOraclePath(const OraclePathChoice& choice, const std::string& potential);
bool recordOraclePath(const OraclePathChoice& choice);
std::vector<std::string> engineSearchDirectories(const EngineRequest& request, const std::string& potential);
bool engineRegistryKnows(const std::string& potential);
bool resolveEngine(const EngineRequest& request, EngineBinding& binding, std::string& err);
std::unique_ptr<EnginePotential> openEngine(const EngineRequest& request, std::string& err, EngineBinding* binding, int oracle_threads);
EngineReport reportEngine(const EnginePotential& engine, const EngineBinding& binding);
EngineReport reportEngine(const EnginePotential& engine, const EngineBinding& binding, const std::string& model_sha256);
std::shared_future<std::string> startModelDigest(const std::string& model_path);
std::string formatEngineReport(const EngineReport& report);
bool recordEngineProvenance(const EngineReport& report);
std::string engineLibraryForSpecArm(const std::string& arm_name);
OracleBatchComm oracleBatchWorld();
int oracleBatchOwner(Eigen::Index point, Eigen::Index count, const OracleBatchLayout& layout);
std::vector<std::vector<Eigen::Index>> ownedOracleGroups(Eigen::Index count, const OracleBatchLayout& layout);
OracleBatchOutcome agreeOracleBatchStatus(OracleBatchStatus local_status, const std::string& local_message, const OracleBatchLayout& layout);
void allreduceOwnedOracleValues(std::vector<double>& energies, Eigen::MatrixXd& gradients, const OracleBatchLayout& layout, double* communication_seconds = nullptr);
void allreduceOwnedOracleMask(std::vector<char>& accepted, const OracleBatchLayout& layout);
void resetOracleEvaluations();
long oracleEvaluations();
void pushOracleEvaluations(long evaluations);
void popOracleEvaluations();
bool energyVarianceAccepted(const double variance);
double energyVarianceToRms(const double variance);
std::vector<RgpotBackend> rgpotBackends();
bool rgpotBackendAvailable(const std::string& name);
std::string canonicalRgpotName(const std::string& name);
std::string formatPotentialCatalog();
std::vector<unsigned char> readPotentialConfig(const std::string& path);
std::vector<unsigned char> potentialConfigArm(const std::vector<unsigned char>& config, const std::string& potential);
void applyRgpotConfig(RgpotRequest& request);
void configureRgpotRuntime(const RgpotRequest& request);
std::unique_ptr<rgpot::PotentialBase> makeRgpotPotential(const RgpotRequest& request);
} // namespace pot
Detailed Documentation¶
Potential wrappers and the batched oracle interface.
Global Variables¶
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¶
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.
std::vector<std::string> missingIsa(const AotiPackageTarget& target, const 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.
void requireAotiPackageRunsOn(const std::string& path, const HostIsa& host)
requireAotiPackageRunsOnHost against an explicit host description.
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.
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).
bool engineRequestIsPlugin(const EngineRequest& request)
True when the request carries its engine’s parameters message (a params path or payload), which makes it a plugin request.
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.
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.
std::string formatOraclePath(const OraclePathChoice& choice, const std::string& potential)
One startup line (gpr/StartupReport.h): “[startup] oracle path=engine
potential=uma reason="…"”.
bool recordOraclePath(const OraclePathChoice& choice)
Record the choice on the active tracking run as oracle.path.
std::vector<std::string> engineSearchDirectories(const 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.
bool engineRegistryKnows(const std::string& potential)
True when the registry maps potential to an engine params arm.
bool resolveEngine(const EngineRequest& request, 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.
std::unique_ptr<EnginePotential> openEngine(const EngineRequest& request, std::string& err, EngineBinding* binding, int oracle_threads)
resolveEngine followed by EnginePotential::open.
EngineReport reportEngine(const EnginePotential& engine, const EngineBinding& binding)
Describe a loaded engine. Hashes the model file, so call it once at startup rather than per evaluation.
EngineReport reportEngine(const EnginePotential& engine, const 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.
std::shared_future<std::string> 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.
std::string formatEngineReport(const EngineReport& report)
One startup line (gpr/StartupReport.h): “[startup] engine library=…
abi=1 arm=UmaParams model=… sha256=…”.
bool recordEngineProvenance(const EngineReport& report)
Write the report into the active tracking run as engine.* parameters, when one is active. Returns whether a run took it.
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.
OracleBatchComm oracleBatchWorld()
The communicator of the whole run, or the no-MPI placeholder.
int oracleBatchOwner(Eigen::Index point, Eigen::Index count, const OracleBatchLayout& layout)
Owner rank of one point of a batch of count points.
std::vector<std::vector<Eigen::Index>> ownedOracleGroups(Eigen::Index count, const OracleBatchLayout& layout)
The groups this rank evaluates, each one batch call, in point order.
OracleBatchOutcome agreeOracleBatchStatus(OracleBatchStatus local_status, const std::string& local_message, const OracleBatchLayout& layout)
Collective agreement on the batch’s status: the highest status wins and the message of the lowest failing rank reaches every rank.
void allreduceOwnedOracleValues(std::vector<double>& energies, Eigen::MatrixXd& gradients, const 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.
void allreduceOwnedOracleMask(std::vector<char>& accepted, const 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.
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.
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.
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.
std::vector<RgpotBackend> rgpotBackends()
The same table drives construction, name validation and CLI discovery.
std::vector<unsigned char> potentialConfigArm(const std::vector<unsigned char>& config, const std::string& potential)
Validate the selected arm and return its native params message for an engine.
void applyRgpotConfig(RgpotRequest& request)
Resolve shared model settings from the typed configuration for reporting.
void configureRgpotRuntime(const RgpotRequest& request)
Apply tensor-runtime settings before constructing a model. Repeated compatible requests share the process runtime; incompatible ones throw.
std::unique_ptr<rgpot::PotentialBase> makeRgpotPotential(const RgpotRequest& request)
Creates one owned rgpot instance; unavailable names and mismatched configuration arms throw.