Loading...
Searching...
No Matches
pot Namespace Reference

Potential wrappers and the batched oracle interface. More...

Classes

class  ActiveGP
struct  ActiveGPConfig
class  ActiveGPPotential
struct  AotiPackageTarget
 The fields of an AOTInductor package that name the hardware it targets. More...
struct  EngineAbiStamp
struct  EngineBinding
 A name resolved to an engine library and the capnp params message it takes. More...
struct  EngineCaps
struct  EngineDerivativeReport
class  EngineError
class  EnginePotential
struct  EngineReport
 What a run needs to state about the engine that answered it. More...
struct  EngineRequest
 What a driver knows when it asks for a potential by name. More...
class  GprMeanPotential
struct  HostIsa
class  NestedEngineOracle
struct  OracleBatchLayout
 How a step's oracle points are shared out. More...
struct  OracleBatchOutcome
struct  OracleEvaluationScope
struct  OraclePathChoice
 Which route a run takes to its potential, and why. More...
class  PotentialWrapper
 Type-erased wrapper around any potential that provides a force() interface. More...
struct  RgpotBackend
struct  RgpotRequest
 Backend inputs shared by the path and single-ended drivers. More...

Typedefs

using OracleBatchComm = int

Enumerations

enum class  OracleBatchStatus : int { Ok = 0 , Failed = 1 , Restart = 2 , WallClockLimit = 3 }
 What one rank reports about its groups before the value collectives. More...

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)
 requireAotiPackageRunsOnHost against an explicit host description.
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)
 Record the choice on the active tracking run as oracle.path.
std::vector< std::string > engineSearchDirectories (const EngineRequest &request, const std::string &potential)
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)
std::unique_ptr< EnginePotential > openEngine (const EngineRequest &request, std::string &err, EngineBinding *binding=nullptr, int oracle_threads=1)
 resolveEngine followed by EnginePotential::open.
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)
OracleBatchComm oracleBatchWorld () noexcept
 The communicator of the whole run, or the no-MPI placeholder.
int oracleBatchOwner (Eigen::Index point, Eigen::Index count, const OracleBatchLayout &layout) noexcept
 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)
void allreduceOwnedOracleValues (std::vector< double > &energies, Eigen::MatrixXd &gradients, const OracleBatchLayout &layout, double *communication_seconds)
void allreduceOwnedOracleMask (std::vector< char > &accepted, const OracleBatchLayout &layout)
void resetOracleEvaluations () noexcept
long oracleEvaluations () noexcept
void pushOracleEvaluations (long evaluations) noexcept
void popOracleEvaluations () noexcept
bool energyVarianceAccepted (const double variance) noexcept
double energyVarianceToRms (const double variance)
std::vector< RgpotBackend > rgpotBackends ()
 The same table drives construction, name validation and CLI discovery.
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)
 Resolve shared model settings from the typed configuration for reporting.
void configureRgpotRuntime (const RgpotRequest &request)
std::unique_ptr< rgpot::PotentialBase > makeRgpotPotential (const RgpotRequest &request)

Variables

constexpr double kEnergyVarianceNegativeRtol = 1.0e-8

Detailed Description

Potential wrappers and the batched oracle interface.

Typedef Documentation

◆ OracleBatchComm

using pot::OracleBatchComm = int

Definition at line 39 of file OracleBatch.h.

Enumeration Type Documentation

◆ OracleBatchStatus

enum class pot::OracleBatchStatus : int
strong

What one rank reports about its groups before the value collectives.

Enumerator
Ok 
Failed 

A geometry was refused or a value was not finite; message set.

Restart 

The oracle asked for a session restart; takes precedence.

WallClockLimit 

The enclosing search deadline expired; no further point may start.

Definition at line 78 of file OracleBatch.h.

78 : int {
79 Ok = 0,
81 Failed = 1,
83 Restart = 2,
86};
@ WallClockLimit
The shared monotonic wall-clock deadline was reached.
@ Restart
The oracle asked for a session restart; takes precedence.
Definition OracleBatch.h:83

Function Documentation

◆ agreeOracleBatchStatus()

OracleBatchOutcome pot::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.

Definition at line 93 of file OracleBatch.cpp.

96{
97 OracleBatchOutcome outcome;
98 outcome.status = local_status;
99 outcome.message = local_message;
100 outcome.owner = local_status == OracleBatchStatus::Ok ? -1 : layout.rank;
101#ifdef GPR_HAVE_MPI
102 if (layout.nprocs > 1 && mpiRunning()) {
103 // One reduction carries both decisions: the highest status and
104 // the lowest failing rank (encoded so that MPI_MAX picks the
105 // lowest rank among the highest status).
106 const int local_code =
107 static_cast<int>(local_status) * (layout.nprocs + 1) +
108 (local_status == OracleBatchStatus::Ok
109 ? 0
110 : layout.nprocs - layout.rank);
111 int code = 0;
112 MPI_Allreduce(&local_code, &code, 1, MPI_INT, MPI_MAX, layout.comm);
113 outcome.status =
114 static_cast<OracleBatchStatus>(code / (layout.nprocs + 1));
115 const int tag = code % (layout.nprocs + 1);
116 outcome.owner = tag == 0 ? -1 : layout.nprocs - tag;
117 if (outcome.status == OracleBatchStatus::Ok) {
118 outcome.message.clear();
119 return outcome;
120 }
121 std::string message =
122 layout.rank == outcome.owner ? local_message : std::string();
123 if (message.size() > 4096) message.resize(4096);
124 int length = static_cast<int>(message.size());
125 MPI_Bcast(&length, 1, MPI_INT, outcome.owner, layout.comm);
126 message.resize(static_cast<std::size_t>(length));
127 if (length > 0)
128 MPI_Bcast(message.data(), length, MPI_CHAR, outcome.owner,
129 layout.comm);
130 outcome.message = std::move(message);
131 return outcome;
132 }
133#endif
134 if (outcome.status == OracleBatchStatus::Ok) outcome.message.clear();
135 return outcome;
136}
OracleBatchStatus
What one rank reports about its groups before the value collectives.
Definition OracleBatch.h:78
OracleBatchComm comm
Definition OracleBatch.h:62
std::string message
The failing owner's message, identical on every rank.
Definition OracleBatch.h:91
int owner
The lowest rank that failed, or -1.
Definition OracleBatch.h:93
OracleBatchStatus status
Definition OracleBatch.h:89

◆ allreduceOwnedOracleMask()

void pot::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.

Definition at line 187 of file OracleBatch.cpp.

189{
190#ifdef GPR_HAVE_MPI
191 if (layout.nprocs <= 1 || !mpiRunning() || accepted.empty()) return;
192 std::vector<unsigned char> bits(accepted.begin(), accepted.end());
193 for (std::size_t offset = 0; offset < bits.size();) {
194 const int count = static_cast<int>(std::min(
195 bits.size() - offset,
196 static_cast<std::size_t>(std::numeric_limits<int>::max())));
197 MPI_Allreduce(MPI_IN_PLACE, bits.data() + offset, count,
198 MPI_UNSIGNED_CHAR, MPI_BOR, layout.comm);
199 offset += static_cast<std::size_t>(count);
200 }
201 for (std::size_t i = 0; i < bits.size(); ++i)
202 accepted[i] = static_cast<char>(bits[i] ? 1 : 0);
203#else
204 (void)accepted;
205 (void)layout;
206#endif
207}

◆ allreduceOwnedOracleValues()

void pot::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.

Definition at line 138 of file OracleBatch.cpp.

142{
143 if (static_cast<Eigen::Index>(energies.size()) != gradients.rows())
144 throw std::invalid_argument(
145 "oracle batch: energies and gradient rows differ");
146#ifdef GPR_HAVE_MPI
147 if (layout.nprocs <= 1 || !mpiRunning()) return;
148 const auto start = std::chrono::steady_clock::now();
149 static_assert(sizeof(double) == sizeof(std::uint64_t) &&
150 std::numeric_limits<double>::is_iec559);
151 const auto gradient_count = static_cast<std::size_t>(gradients.size());
152 std::vector<std::uint64_t> bits(energies.size() + gradient_count);
153 if (!energies.empty())
154 std::memcpy(bits.data(), energies.data(),
155 energies.size() * sizeof(double));
156 if (gradient_count > 0)
157 std::memcpy(bits.data() + energies.size(), gradients.data(),
158 gradient_count * sizeof(double));
159 // Each entry has one owner. Positive zero contributes no set bits, so
160 // integer OR preserves the owner's signed zero and subnormal values.
161 // Energies and gradients share a collective; no floating sum is needed.
162 for (std::size_t offset = 0; offset < bits.size();) {
163 const int count = static_cast<int>(std::min(
164 bits.size() - offset,
165 static_cast<std::size_t>(std::numeric_limits<int>::max())));
166 MPI_Allreduce(MPI_IN_PLACE, bits.data() + offset, count, MPI_UINT64_T,
167 MPI_BOR, layout.comm);
168 offset += static_cast<std::size_t>(count);
169 }
170 if (!energies.empty())
171 std::memcpy(energies.data(), bits.data(),
172 energies.size() * sizeof(double));
173 if (gradient_count > 0)
174 std::memcpy(gradients.data(), bits.data() + energies.size(),
175 gradient_count * sizeof(double));
176 if (communication_seconds) {
177 *communication_seconds += std::chrono::duration<double>(
178 std::chrono::steady_clock::now() - start)
179 .count();
180 }
181#else
182 (void)layout;
183 (void)communication_seconds;
184#endif
185}

◆ applyRgpotConfig()

void pot::applyRgpotConfig ( RgpotRequest & request)

Resolve shared model settings from the typed configuration for reporting.

Definition at line 782 of file RgpotFactory.cpp.

783{
784 Parameters parameters(request);
785 const auto name = canonicalRgpotName(request.potential);
786#ifdef GPR_FACTORY_SCHEMA
787 if (parameters.configured() && !request.overrides.empty()) {
788 capnp::MallocMessageBuilder message;
789 message.setRoot(parameters.root());
790 auto root = capnp::toDynamic(message.getRoot<::PotentialConfig>());
791 KJ_IF_MAYBE (field, root.which()) {
792 auto native = root.get(*field).as<capnp::DynamicStruct>();
793 const auto set = [&](const char* key, const char* field_name,
794 auto value) {
795 if (!request.overrides.contains(key)) return;
796 // e75577bd's MetatomicParams has no charge, spin, or task
797 // name. Skip an override the pinned schema cannot store.
798 KJ_IF_MAYBE (found,
799 native.getSchema().findFieldByName(field_name)) {
800 native.set(*found, value);
801 }
802 };
803 if (name == "uma" || name == "metatomic") {
804 set("model_path", "modelPath",
805 capnp::Text::Reader(request.model_path));
806 set("device", "device", capnp::Text::Reader(request.device));
807 set("task_name", "taskName",
808 capnp::Text::Reader(request.task_name));
809 set("charge", "charge", request.charge);
810 set("spin", "spin", request.spin);
811 } else if (name == "mopac") {
812 set("charge", "charge", request.mopac_charge);
813 set("spin", "spin", request.mopac_spin);
814 set("model", "model", request.mopac_model);
815 }
816 }
817 request.config =
818 serializeConfig(message.getRoot<::PotentialConfig>().asReader());
819 }
820#endif
821 if (name == "uma" || name == "metatomic") {
822 request.model_path = parameters.get("model_path", request.model_path);
823 request.device = parameters.get("device", request.device);
824 request.task_name = parameters.get("task_name", request.task_name);
825 request.charge = parameters.get("charge", request.charge);
826 request.spin = parameters.get("spin", request.spin);
827 }
828}
void set(FieldMatrixd &mat, Index_t i, const Eigen::Vector3d &vec)
std::string canonicalRgpotName(const std::string &name)
std::set< std::string > overrides
Constructor fields explicitly supplied on the command line.
std::string task_name
std::string model_path
std::string potential
std::vector< unsigned char > config
std::string device

◆ canonicalRgpotName()

std::string pot::canonicalRgpotName ( const std::string & name)

Definition at line 732 of file RgpotFactory.cpp.

733{
734 const auto* entry = find(name);
735 return entry ? entry->name : name;
736}

◆ configureRgpotRuntime()

void pot::configureRgpotRuntime ( const RgpotRequest & request)

Apply tensor-runtime settings before constructing a model. Repeated compatible requests share the process runtime; incompatible ones throw.

Definition at line 830 of file RgpotFactory.cpp.

831{
832 const auto name = canonicalRgpotName(request.potential);
833 if (name != "uma" && name != "metatomic") return;
834#if defined(RGPOT_HAS_METATOMIC) || defined(RGPOT_HAS_UMA)
835 Parameters parameters(request);
836 const int intra = parameters.get("intraop_threads", 1);
837 const int inter = parameters.get("interop_threads", 1);
838 static std::mutex runtime_mutex;
839 std::lock_guard lock(runtime_mutex);
840 if (inter > 0 && at::get_num_interop_threads() != inter)
841 at::set_num_interop_threads(inter);
842 if (intra > 0) {
843 at::set_num_threads(intra);
844 if (at::get_num_threads() != intra)
845 throw std::runtime_error(
846 "The tensor runtime cannot apply intraopThreads");
847 }
848 if (name == "uma" && parameters.get("deterministic_algorithms", false))
849 at::globalContext().setDeterministicAlgorithms(true, false);
850#endif
851}

◆ energyVarianceAccepted()

bool pot::energyVarianceAccepted ( const double variance)
inlinenoexcept

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.

Definition at line 45 of file PotentialWrapper.h.

46{
47 return std::isfinite(variance) && variance >= -kEnergyVarianceNegativeRtol;
48}
constexpr double kEnergyVarianceNegativeRtol

◆ energyVarianceToRms()

double pot::energyVarianceToRms ( const double variance)
inline

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.

Definition at line 54 of file PotentialWrapper.h.

55{
56 if (!energyVarianceAccepted(variance))
57 throw std::domain_error(
58 "PotentialWrapper: rgpot energy variance must be finite and "
59 "non-negative");
60 if (variance < 0.0) return 0.0;
61 return std::sqrt(variance);
62}
bool energyVarianceAccepted(const double variance) noexcept

◆ engineIsGeneric()

bool pot::engineIsGeneric ( const std::string & potential)

True when the registry has an engine that loads through the generic rgpot_engine_* table (UMA, CPMD, CP2K, LAMMPS).

Definition at line 309 of file EngineRegistry.cpp.

310{
311 const Entry* entry = find(potential);
312 return entry != nullptr && entry->generic;
313}

◆ engineLibraryForSpecArm()

std::string pot::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.

Definition at line 9 of file NestedEngineOracle.cpp.

10{
11 if (arm == "uma") return "libuma_engine.so";
12 if (arm == "metatomic") return "libmetatomic_engine.so";
13 if (arm == "nwchem") return "libnwchem_engine.so";
14 if (arm == "cpmd") return "libcpmd_engine.so";
15 if (arm == "cp2k") return "libcp2k_engine.so";
16 if (arm == "lammps") return "liblammps_engine.so";
17 // builtin carries its own library path when it needs one, and the
18 // analytic potentials have no plugin at all.
19 return {};
20}

◆ engineRegistryKnows()

bool pot::engineRegistryKnows ( const std::string & potential)

True when the registry maps potential to an engine params arm.

Definition at line 404 of file EngineRegistry.cpp.

405{
406 return find(potential) != nullptr;
407}

◆ engineRequestIsPlugin()

bool pot::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.

Definition at line 315 of file EngineRegistry.cpp.

316{
317 return !request.params_payload.empty() || !request.params_path.empty();
318}
std::string params_path
std::vector< unsigned char > params_payload

◆ engineSearchDirectories()

std::vector< std::string > pot::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.

Definition at line 364 of file EngineRegistry.cpp.

366{
367 std::vector<std::string> dirs;
368 auto add = [&dirs](const std::string& dir) {
369 if (dir.empty()) return;
370 if (std::find(dirs.begin(), dirs.end(), dir) == dirs.end())
371 dirs.push_back(dir);
372 };
373 add(request.engine_dir);
374 if (const char* env = std::getenv("RGPOT_ENGINE_PATH")) {
375 std::string list = env;
376 std::size_t start = 0;
377 while (start <= list.size()) {
378 const std::size_t colon = list.find(':', start);
379 add(list.substr(start, colon == std::string::npos
380 ? std::string::npos
381 : colon - start));
382 if (colon == std::string::npos) break;
383 start = colon + 1;
384 }
385 }
386 std::string exe = request.executable_dir;
387 if (exe.empty()) exe = executableDirectory();
388 if (!exe.empty()) {
389 const std::filesystem::path base(exe);
390 add((base / ".." / "lib").lexically_normal().string());
391 add((base / ".." / "lib64").lexically_normal().string());
392 add(base.lexically_normal().string());
393 const Entry* entry = find(potential);
394 if (entry != nullptr && entry->subdir[0] != '\0') {
395 add((base / "subprojects" / "rgpot" / "CppCore" / "rgpot" /
396 entry->subdir)
397 .lexically_normal()
398 .string());
399 }
400 }
401 return dirs;
402}
std::string engine_dir
std::string executable_dir

◆ formatEngineReport()

std::string pot::formatEngineReport ( const EngineReport & report)

One startup line (gpr/StartupReport.h): "[startup] engine library=... abi=1 arm=UmaParams model=... sha256=...".

Definition at line 672 of file EngineRegistry.cpp.

673{
674 std::vector<gpr::startup::Field> fields = {
675 {"library", report.resolved_path},
676 {"abi", std::to_string(report.abi_version)},
677 {"arm", report.params_arm}};
678 if (!report.model_path.empty()) {
679 fields.emplace_back("model", report.model_path);
680 fields.emplace_back("sha256", report.model_sha256.empty()
681 ? "unreadable"
682 : report.model_sha256);
683 }
684 return gpr::startup::line("engine", fields);
685}
std::string line(const std::string &topic, const std::vector< Field > &fields)
std::string resolved_path
file the loader mapped
std::string model_path
empty for engines that load no model
std::string params_arm
capnp root struct the engine read
std::string model_sha256
digest of the model file; empty if unread
int abi_version
rgpot_engine_abi_version()

◆ formatOraclePath()

std::string pot::formatOraclePath ( const OraclePathChoice & choice,
const std::string & potential )

One startup line (gpr/StartupReport.h): "[startup] oracle path=engine potential=uma reason=\"...\"".

Definition at line 346 of file EngineRegistry.cpp.

348{
349 return gpr::startup::line("oracle",
350 {{"path", choice.engine ? "engine" : "direct"},
351 {"potential", potential},
352 {"reason", "\"" + choice.reason + "\""}});
353}

◆ formatPotentialCatalog()

std::string pot::formatPotentialCatalog ( )

Definition at line 738 of file RgpotFactory.cpp.

739{
740 std::ostringstream out;
741 out << "Potential\tDirect backend\tAliases / requirements\n";
742 for (const auto& entry: entries()) {
743 out << entry.name << '\t' << (entry.make ? "compiled" : "not compiled")
744 << '\t';
745 for (const auto& alias: entry.aliases)
746 out << alias << ' ';
747 out << entry.requirement << '\n';
748 }
749 out << "lammps\tengine plugin\tliblammps_engine.so, --lammps-params\n"
750 << "UMA, CPMD, CP2K and LAMMPS use the engine path by default; "
751 "--oracle-path direct selects the compiled backend.\n"
752 << "Compiled frontends can require external libraries or model "
753 "files.\n";
754 return out.str();
755}
eon_relax_band_t eon_relax_surface_fn void eon_relax_outcome_t * out

◆ makeRgpotPotential()

std::unique_ptr< rgpot::PotentialBase > pot::makeRgpotPotential ( const RgpotRequest & request)

Creates one owned rgpot instance; unavailable names and mismatched configuration arms throw.

Definition at line 899 of file RgpotFactory.cpp.

901{
902 if (request.thread_count < 1)
903 throw std::invalid_argument("rgpot thread count must be at least one");
904 Parameters parameters(request);
905 configureRgpotRuntime(request);
906 auto potential = construct(request, parameters);
907 const auto configure_threads = [&]<class Potential>(Potential& instance) {
908 if constexpr (requires {
909 instance.setThreadCount(request.thread_count);
910 })
911 instance.setThreadCount(request.thread_count);
912 };
913 configure_threads(*potential);
914 return potential;
915}
void configureRgpotRuntime(const RgpotRequest &request)

◆ missingIsa()

std::vector< std::string > pot::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.

Definition at line 238 of file AotiPackageIsa.cpp.

240{
241 std::vector<std::string> missing;
242 for (const std::string& token: target.cpu_isa) {
243 bool present = true;
244 if (token == "DEFAULT" || token == "NONE")
245 present = true;
246 else if (token == "AVX2")
247 present = host.avx2 && host.fma;
248 else if (token == "AVX512")
249 present =
250 host.avx512f && host.avx512dq && host.avx512bw && host.avx512vl;
251 else if (token == "AVX512_VNNI")
252 present = host.avx512_vnni;
253 else if (token == "AVX512_BF16")
254 present = host.avx512_bf16;
255 else if (token == "AMX" || token == "AMX_TILE")
256 present = host.amx_tile;
257 else if (token == "AMX_BF16")
258 present = host.amx_bf16;
259 else if (token == "AMX_INT8")
260 present = host.amx_int8;
261 else {
262 missing.push_back("unknown:" + token);
263 continue;
264 }
265 if (!present) missing.push_back(token);
266 }
267 return missing;
268}
std::vector< std::string > cpu_isa
AOTI_CPU_ISA tokens, upper case.

◆ openEngine()

std::unique_ptr< EnginePotential > pot::openEngine ( const EngineRequest & request,
std::string & err,
EngineBinding * binding,
int oracle_threads )

resolveEngine followed by EnginePotential::open.

Definition at line 614 of file EngineRegistry.cpp.

618{
619 EngineBinding local;
620 EngineBinding& target = binding != nullptr ? *binding : local;
621 if (!resolveEngine(request, target, err)) return nullptr;
622 const Entry* entry = find(request.potential);
623 const bool uses_torch = entry != nullptr && (entry->arm == Arm::Uma ||
624 entry->arm == Arm::Metatomic);
625 const bool torch_cuda = uses_torch && request.device.rfind("cuda", 0) == 0;
626 auto engine = EnginePotential::open(target.library, target.config, err,
627 torch_cuda, oracle_threads);
628 if (!engine && !target.searched.empty() &&
629 target.library.find('/') == std::string::npos) {
630 // The name was found nowhere: say where it was looked for.
631 err += "; searched";
632 for (const std::string& dir: target.searched)
633 err += " " + dir + ",";
634 err += " then the loader's search path (rpath, LD_LIBRARY_PATH)";
635 }
636 return engine;
637}
static std::unique_ptr< EnginePotential > open(const std::string &library, const std::vector< unsigned char > &config, std::string &err, bool torch_cuda=false, int oracle_threads=1)
bool resolveEngine(const EngineRequest &request, EngineBinding &binding, std::string &err)
A name resolved to an engine library and the capnp params message it takes.
std::string library
path or soname for dlopen
std::vector< std::string > searched
std::vector< unsigned char > config
flat-array message
std::string potential
–potential: uma, omol, metatomic, ...
std::string device
–device

◆ oracleBatchOwner()

int pot::oracleBatchOwner ( Eigen::Index point,
Eigen::Index count,
const OracleBatchLayout & layout )
noexcept

Owner rank of one point of a batch of count points.

Definition at line 57 of file OracleBatch.cpp.

59{
60 if (layout.nprocs <= 1 || count <= 1 || point < 0) return 0;
61 const Eigen::Index unit = layout.chunk > 0 ? point / layout.chunk : point;
62 const long long offset =
63 ((layout.owner_offset % layout.nprocs) + layout.nprocs) % layout.nprocs;
64 return static_cast<int>((unit + offset) % layout.nprocs);
65}

◆ oracleBatchWorld()

OracleBatchComm pot::oracleBatchWorld ( )
noexcept

The communicator of the whole run, or the no-MPI placeholder.

Definition at line 34 of file OracleBatch.cpp.

35{
36#ifdef GPR_HAVE_MPI
37 return MPI_COMM_WORLD;
38#else
39 return 0;
40#endif
41}

◆ oracleEvaluations()

long pot::oracleEvaluations ( )
nodiscardnoexcept

Definition at line 25 of file PotentialWrapper.cpp.

26{
27 return oracle_evaluations.load(std::memory_order_relaxed);
28}

◆ ownedOracleGroups()

std::vector< std::vector< Eigen::Index > > pot::ownedOracleGroups ( Eigen::Index count,
const OracleBatchLayout & layout )

The groups this rank evaluates, each one batch call, in point order.

Definition at line 67 of file OracleBatch.cpp.

69{
70 std::vector<std::vector<Eigen::Index>> groups;
71 if (count <= 0) return groups;
72 if (layout.chunk <= 0) {
73 std::vector<Eigen::Index> owned;
74 for (Eigen::Index i = 0; i < count; ++i) {
75 if (oracleBatchOwner(i, count, layout) == layout.rank)
76 owned.push_back(i);
77 }
78 if (!owned.empty()) groups.push_back(std::move(owned));
79 return groups;
80 }
81 for (Eigen::Index first = 0; first < count; first += layout.chunk) {
82 if (oracleBatchOwner(first, count, layout) != layout.rank) continue;
83 const Eigen::Index last = std::min(count, first + layout.chunk);
84 std::vector<Eigen::Index> chunk;
85 chunk.reserve(static_cast<std::size_t>(last - first));
86 for (Eigen::Index i = first; i < last; ++i)
87 chunk.push_back(i);
88 groups.push_back(std::move(chunk));
89 }
90 return groups;
91}
int oracleBatchOwner(Eigen::Index point, Eigen::Index count, const OracleBatchLayout &layout) noexcept
Owner rank of one point of a batch of count points.

◆ popOracleEvaluations()

void pot::popOracleEvaluations ( )
noexcept

Definition at line 37 of file PotentialWrapper.cpp.

38{
39 if (oracle_evaluation_depth > 0) --oracle_evaluation_depth;
40}

◆ potentialConfigArm()

std::vector< unsigned char > pot::potentialConfigArm ( const std::vector< unsigned char > & config,
const std::string & potential )

Validate the selected arm and return its native params message for an engine.

Definition at line 769 of file RgpotFactory.cpp.

771{
772 RgpotRequest request;
773 request.potential = potential;
774 request.config = config;
775 Parameters parameters(request);
776#ifdef GPR_FACTORY_SCHEMA
777 if (parameters.configured()) return serializeConfig(parameters.values());
778#endif
779 return {};
780}
Backend inputs shared by the path and single-ended drivers.

◆ pushOracleEvaluations()

void pot::pushOracleEvaluations ( long evaluations)
noexcept

Definition at line 30 of file PotentialWrapper.cpp.

31{
32 if (oracle_evaluation_depth == 0 && evaluations > 0)
33 oracle_evaluations.fetch_add(evaluations, std::memory_order_relaxed);
34 ++oracle_evaluation_depth;
35}

◆ readAotiPackageTarget()

AotiPackageTarget pot::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.

Definition at line 209 of file AotiPackageIsa.cpp.

210{
211 AotiPackageTarget target;
212 std::vector<std::string> entries;
213 try {
214 entries = metadataEntries(path);
215 } catch (const std::out_of_range&) {
216 // A truncated archive carries no readable metadata; the loader
217 // reports the damaged package itself.
218 return target;
219 }
220 for (const std::string& json: entries) {
221 target.metadata_found = true;
222 if (target.device.empty())
223 target.device = jsonString(json, "AOTI_DEVICE_KEY");
224 std::istringstream words(jsonString(json, "AOTI_CPU_ISA"));
225 for (std::string word; words >> word;) {
226 std::transform(word.begin(), word.end(), word.begin(),
227 [](unsigned char ch) {
228 return static_cast<char>(std::toupper(ch));
229 });
230 if (std::find(target.cpu_isa.begin(), target.cpu_isa.end(), word) ==
231 target.cpu_isa.end())
232 target.cpu_isa.push_back(word);
233 }
234 }
235 return target;
236}
The fields of an AOTInductor package that name the hardware it targets.
std::string device
AOTI_DEVICE_KEY, e.g. "cpu" or "cuda".
bool metadata_found
any *_metadata.json entry read

◆ readPotentialConfig()

std::vector< unsigned char > pot::readPotentialConfig ( const std::string & path)

Definition at line 757 of file RgpotFactory.cpp.

758{
759 if (path.empty()) return {};
760 std::ifstream input(path, std::ios::binary);
761 if (!input)
762 throw std::invalid_argument("Cannot open PotentialConfig: " + path);
763 std::vector<unsigned char> bytes{std::istreambuf_iterator<char>(input), {}};
764 if (input.bad() || bytes.empty())
765 throw std::invalid_argument("Cannot read PotentialConfig: " + path);
766 return bytes;
767}

◆ recordEngineProvenance()

bool pot::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.

Definition at line 687 of file EngineRegistry.cpp.

688{
690 if (run == nullptr) return false;
691 run->logParam("engine.library", report.resolved_path);
692 run->logParam("engine.abi_version", static_cast<long>(report.abi_version));
693 run->logParam("engine.params", report.params_arm);
694 if (!report.model_path.empty()) {
695 run->logParam("engine.model_path", report.model_path);
696 run->logParam("engine.model_sha256", report.model_sha256);
697 }
698 run->flush();
699 return true;
700}
void logParam(std::string_view key, std::string_view value)
void flush()
Send buffered metrics, params and tags to the tracking server.
MlflowRun * activeRun() noexcept

◆ recordOraclePath()

bool pot::recordOraclePath ( const OraclePathChoice & choice)

Record the choice on the active tracking run as oracle.path.

Definition at line 355 of file EngineRegistry.cpp.

356{
358 if (run == nullptr) return false;
359 run->logParam("oracle.path", choice.engine ? "engine" : "direct");
360 run->flush();
361 return true;
362}

◆ reportEngine() [1/2]

EngineReport pot::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.

Definition at line 639 of file EngineRegistry.cpp.

641{
642 return reportEngine(engine, binding,
643 binding.model_path.empty()
644 ? std::string()
645 : gpr::sha256File(binding.model_path));
646}
std::string sha256File(const std::string &path)
Digest of a file's contents; empty when the file cannot be read.
Definition Sha256.cpp:134
EngineReport reportEngine(const EnginePotential &engine, const EngineBinding &binding)
std::string model_path

◆ reportEngine() [2/2]

EngineReport pot::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.

Definition at line 648 of file EngineRegistry.cpp.

651{
652 EngineReport report;
653 report.library = engine.library();
654 report.resolved_path = engine.resolvedPath();
655 report.params_arm = binding.params_arm;
656 report.abi_version = engine.abiVersion();
657 report.model_path = binding.model_path;
658 if (!binding.model_path.empty()) report.model_sha256 = model_sha256;
659 return report;
660}
const std::string & resolvedPath() const noexcept
Absolute path of the loaded object, from the dynamic loader.
int abiVersion() const noexcept
const std::string & library() const noexcept
std::string params_arm
capnp root struct, e.g. UmaParams
What a run needs to state about the engine that answered it.
std::string library
as requested of the loader

◆ requireAotiPackageRunsOn()

void pot::requireAotiPackageRunsOn ( const std::string & path,
const HostIsa & host )

requireAotiPackageRunsOnHost against an explicit host description.

Definition at line 270 of file AotiPackageIsa.cpp.

271{
272 // A model that cannot be read is the loader's to report, with its own
273 // message; this check only refuses packages it can read.
274 std::error_code ignored;
275 if (!std::filesystem::is_regular_file(path, ignored)) return;
276 const AotiPackageTarget target = readAotiPackageTarget(path);
277 if (!target.metadata_found || target.cpu_isa.empty()) return;
278 std::string lacking, unknown;
279 for (const std::string& token: missingIsa(target, host)) {
280 if (token.rfind("unknown:", 0) == 0)
281 unknown += (unknown.empty() ? "" : " ") + token.substr(8);
282 else
283 lacking += (lacking.empty() ? "" : " ") + token;
284 }
285 if (!unknown.empty())
286 std::cerr << "[model] " << path << " names CPU extensions this check "
287 << "does not know (" << unknown
288 << "); loading it unchecked\n";
289 if (lacking.empty()) return;
290 std::string isa;
291 for (const std::string& token: target.cpu_isa)
292 isa += (isa.empty() ? "" : " ") + token;
293 std::string available;
294 const std::pair<const char*, bool> extensions[] = {
295 {"AVX2", host.avx2 && host.fma},
296 {"AVX512",
297 host.avx512f && host.avx512dq && host.avx512bw && host.avx512vl},
298 {"AVX512_VNNI", host.avx512_vnni},
299 {"AVX512_BF16", host.avx512_bf16},
300 {"AMX_TILE", host.amx_tile},
301 {"AMX_BF16", host.amx_bf16},
302 {"AMX_INT8", host.amx_int8}};
303 for (const auto& [name, present]: extensions)
304 if (present)
305 available += (available.empty() ? "" : " ") + std::string(name);
306 if (available.empty())
307 available = "none of the vector extensions above SSE";
308 throw std::runtime_error(
309 "model package " + path + " requires CPU extensions " + isa +
310 "; this host provides " + available + " and lacks " + lacking +
311 ", so the package would stop with an illegal instruction. AOTInductor "
312 "packages are compiled per host family: run on a host with " +
313 lacking + " or pass a package exported on this host family");
314}
bool available() noexcept
Definition CutlassGemm.h:43
AotiPackageTarget readAotiPackageTarget(const std::string &path)
std::vector< std::string > missingIsa(const AotiPackageTarget &target, const HostIsa &host)

◆ requireAotiPackageRunsOnHost()

void pot::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.

Definition at line 316 of file AotiPackageIsa.cpp.

317{
319}
void requireAotiPackageRunsOn(const std::string &path, const HostIsa &host)
requireAotiPackageRunsOnHost against an explicit host description.
static HostIsa detect() noexcept
CPUID and XGETBV of the calling host; all false off x86-64.

◆ resetOracleEvaluations()

void pot::resetOracleEvaluations ( )
noexcept

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.

Definition at line 20 of file PotentialWrapper.cpp.

21{
22 oracle_evaluations.store(0, std::memory_order_relaxed);
23}

◆ resolveEngine()

bool pot::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.

Definition at line 409 of file EngineRegistry.cpp.

411{
412 const Entry* entry = find(request.potential);
413 if (engineRequestIsPlugin(request))
414 return resolvePlugin(request, entry ? entry->library : nullptr, binding,
415 err);
416 if (entry == nullptr) {
417 err =
418 "no engine is registered for potential '" + request.potential + "'";
419 return false;
420 }
421 binding = {};
422 binding.model_path = request.model_path;
423 if (!request.library.empty()) {
424 binding.library = request.library;
425 } else if (entry->library[0] != '\0') {
426 locateLibrary(request, entry->library, binding);
427 } else {
428 err = "potential '" + request.potential +
429 "' has no shipped engine library; pass --potential-library";
430 return false;
431 }
432#ifdef GPR_ENGINE_REGISTRY_SCHEMA
433 if (!request.potential_config.empty()) {
434 try {
435 binding.config =
437 if (!binding.config.empty()) {
438 switch (entry->arm) {
439 case Arm::Uma:
440 binding.params_arm = "UmaParams";
441 break;
442 case Arm::Metatomic:
443 binding.params_arm = "MetatomicParams";
444 break;
445 case Arm::Cpmd:
446 binding.params_arm = "CPMDParams";
447 break;
448 case Arm::Cp2k:
449 binding.params_arm = "CP2KParams";
450 break;
451 case Arm::Lammps:
452 binding.params_arm = "LammpsParams";
453 break;
454 default:
455 err =
456 "The selected engine does not accept native "
457 "constructor settings; use --oracle-path direct";
458 return false;
459 }
460 if (entry->arm == Arm::Uma)
462 return true;
463 }
464 } catch (const std::exception& error) {
465 err = error.what();
466 return false;
467 }
468 }
469 capnp::MallocMessageBuilder message;
470 switch (entry->arm) {
471 case Arm::Uma: {
472 if (request.model_path.empty()) {
473 err = "--model is required for '" + request.potential + "'";
474 return false;
475 }
476 try {
478 } catch (const std::exception& error) {
479 err = error.what();
480 return false;
481 }
482 auto params = message.initRoot<::UmaParams>();
483 params.setModelPath(request.model_path);
484 params.setTaskName(request.task_name);
485 params.setDevice(request.device);
486 params.setCharge(request.charge);
487 params.setSpin(request.spin);
488 binding.params_arm = "UmaParams";
489 break;
490 }
491 case Arm::Metatomic: {
492 if (request.model_path.empty()) {
493 err = "--model is required for '" + request.potential + "'";
494 return false;
495 }
496 auto params = message.initRoot<::MetatomicParams>();
497 params.setModelPath(request.model_path);
498 params.setDevice(request.device);
499 binding.params_arm = "MetatomicParams";
500 break;
501 }
502 case Arm::Cpmd: {
503 auto params = message.initRoot<::CPMDParams>();
504 params.setFunctional("BLYP");
505 params.setCutOffRy(70.0);
506 auto sections = params.initInputSections(3);
507 auto system = sections[0].initSystem();
508 system.setSymmetry(1);
509 system.setAngstrom(true);
510 system.setCutOffRy(70.0);
511 system.setCellAbsolute(true);
512 system.setCellDegree(true);
513 // 14 Angstrom cube. CELL ABSOLUTE DEGREE takes a,b,c and the
514 // angles.
515 auto cell = system.initCell(6);
516 cell.set(0, 14.0);
517 cell.set(1, 14.0);
518 cell.set(2, 14.0);
519 cell.set(3, 90.0);
520 cell.set(4, 90.0);
521 cell.set(5, 90.0);
522 auto atoms = sections[1].initAtoms();
523 auto pp = atoms.initPseudopotentials(2);
524 pp[0].setElement("Si");
525 pp[0].setPath("Si_MT_BLYP.psp");
526 pp[0].setLmax(2);
527 pp[0].setLoc(2);
528 pp[0].setKleinmanBylander(true);
529 pp[1].setElement("N");
530 pp[1].setPath("N_MT_BLYP.psp");
531 pp[1].setLmax(1);
532 pp[1].setLoc(1);
533 pp[1].setKleinmanBylander(true);
534 // OpenCPMD runs 10000 SCF steps when the deck omits MAXITER and
535 // cpmdc converges orbitals to 1e-6 when the deck omits the
536 // criterion. A geometry whose SCF cannot converge then spends
537 // hours in one force call; the request's cap and criterion make
538 // such a call a reported failure the search rejects.
539 auto cpmd = sections[2].initCpmd();
540 cpmd.setOptimizeWavefunction(true);
541 cpmd.setMaxIter(request.cpmd_scf_max_iter);
542 cpmd.setConvergenceOrbitals(request.cpmd_scf_convergence);
543 // CPMDPot dlopens this calculator. libcpmd_engine.so is the rgpot
544 // plugin; libcpmdc.so is the plane-wave engine.
545 params.setEnginePath("libcpmdc.so");
546 binding.params_arm = "CPMDParams";
547 break;
548 }
549 case Arm::Cp2k: {
550#ifdef GPR_SCHEMA_HAS_CP2K_CONFIG
551 // The amorphous SiO2 and Si3N4 reference deck: PBE, the
552 // short-range DZVP MOLOPT basis with GTH-PBE pseudopotentials,
553 // a 650 Ry grid at REL_CUTOFF 70, unrestricted Kohn-Sham, and OT
554 // with an outer SCF loop. The request's criterion and inner cap
555 // bound one force call; a call that does not converge is a
556 // reported failure the search rejects.
557 auto params = message.initRoot<::CP2KParams>();
558 params.setFunctional("PBE");
559 params.setBasisSet("DZVP-MOLOPT-SR-GTH");
560 params.setPseudopotential("GTH-PBE");
561 params.setBasisSetFile("BASIS_MOLOPT");
562 params.setPotentialFile("GTH_POTENTIALS");
563 params.setCutoffRy(650.0);
564 params.setRelCutoffRy(70.0);
565 params.setUks(true);
566 params.setPeriodic("XYZ");
567 params.setEpsScf(request.cp2k_eps_scf);
568 params.setMaxScf(request.cp2k_max_scf);
569 params.setOuterMaxScf(request.cp2k_outer_max_scf);
570 params.setOt(true);
571 // CP2KPot dlopens this shim. libcp2k_engine.so is the rgpot
572 // plugin; libcp2kc_rgpot.so links libcp2k.
573 params.setEnginePath("libcp2kc_rgpot.so");
574 binding.params_arm = "CP2KParams";
575 break;
576#else
577 err = "this rgpot schema has no CP2KParams arm";
578 return false;
579#endif
580 }
581 case Arm::Lammps: {
582 if (request.lammps_params_path.empty()) {
583 err = "--lammps-params is required for '" + request.potential +
584 "'";
585 return false;
586 }
587 auto params = message.initRoot<::LammpsParams>();
588 if (!readLammpsParamsFile(params, request.lammps_params_path, err))
589 return false;
590 binding.params_arm = "LammpsParams";
591 break;
592 }
593 case Arm::Builtin: {
594 auto params = message.initRoot<::BuiltinParams>();
595 params.setName(entry->builtin);
596 if (!request.library.empty()) params.setLibrary(request.library);
597 binding.params_arm = "BuiltinParams";
598 break;
599 }
600 case Arm::None:
601 err = "potential '" + request.potential + "' has no params arm";
602 return false;
603 }
604 binding.config = serialize(message);
605 return true;
606#else
607 err =
608 "the engine registry needs Cap'n Proto and the rgpot RPC arm "
609 "(-Duse_capnp=true with an rgpot potential that enables it)";
610 return false;
611#endif
612}
bool engineRequestIsPlugin(const EngineRequest &request)
std::vector< unsigned char > potentialConfigArm(const std::vector< unsigned char > &config, const std::string &potential)
void requireAotiPackageRunsOnHost(const std::string &path)
int charge
–uma-charge
double cpmd_scf_convergence
–cpmd-scf-convergence: CPMD's CONVERGENCE ORBITALS criterion.
std::string model_path
–model
double cp2k_eps_scf
–cp2k-eps-scf: CP2K's &SCF EPS_SCF for the default cp2k deck.
std::string task_name
–task-name (UMA task head)
std::string lammps_params_path
–lammps-params: pair style, coefficients and type map for lammps.
std::vector< unsigned char > potential_config
Optional canonical rgpot PotentialConfig shared with the direct path.
int spin
–uma-spin (multiplicity)
int cp2k_outer_max_scf
&OUTER_SCF MAX_SCF of the default cp2k deck; 0 drops the outer loop.
std::string library
–potential-library: overrides the table

◆ rgpotBackendAvailable()

bool pot::rgpotBackendAvailable ( const std::string & name)

Definition at line 726 of file RgpotFactory.cpp.

727{
728 const auto* entry = find(name);
729 return entry && static_cast<bool>(entry->make);
730}

◆ rgpotBackends()

std::vector< RgpotBackend > pot::rgpotBackends ( )

The same table drives construction, name validation and CLI discovery.

Definition at line 717 of file RgpotFactory.cpp.

718{
719 std::vector<RgpotBackend> result;
720 for (const auto& entry: entries())
721 result.push_back({entry.name, entry.aliases,
722 static_cast<bool>(entry.make), entry.requirement});
723 return result;
724}

◆ selectOraclePath() [1/2]

OraclePathChoice pot::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.

Definition at line 330 of file EngineRegistry.cpp.

332{
333 if (requested == "direct") return {false, "--oracle-path direct"};
334 if (requested == "engine") return {true, "--oracle-path engine"};
335#ifdef USE_CAPNP
336 if (engineIsGeneric(potential)) {
337 return {true, "default: " + potential + " has a generic engine"};
338 }
339 return {false, "default: " + potential + " has no generic engine"};
340#else
341 (void)potential;
342 return {false, "default: this binary has no Cap'n Proto"};
343#endif
344}
bool engineIsGeneric(const std::string &potential)

◆ selectOraclePath() [2/2]

OraclePathChoice pot::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.

Definition at line 320 of file EngineRegistry.cpp.

322{
323 if (plugin && requested != "direct")
324 return {true, requested == "engine"
325 ? "--oracle-path engine"
326 : "default: the engine parameters name a plugin"};
327 return selectOraclePath(requested, potential);
328}
OraclePathChoice selectOraclePath(const std::string &requested, const std::string &potential, bool plugin)

◆ startModelDigest()

std::shared_future< std::string > pot::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.

Definition at line 662 of file EngineRegistry.cpp.

663{
664 if (model_path.empty()) {
665 std::promise<std::string> empty;
666 empty.set_value(std::string());
667 return empty.get_future().share();
668 }
669 return std::async(std::launch::async, gpr::sha256File, model_path).share();
670}

Variable Documentation

◆ kEnergyVarianceNegativeRtol

double pot::kEnergyVarianceNegativeRtol = 1.0e-8
inlineconstexpr

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.

Definition at line 38 of file PotentialWrapper.h.