Loading...
Searching...
No Matches
EngineRegistry.cpp
Go to the documentation of this file.
1// SPDX-License-Identifier: MIT
2// Copyright (c) gpridge developers
3// See LICENSE for details.
4
5#include "EngineRegistry.h"
6
7#include <algorithm>
8#include <cstdlib>
9#include <filesystem>
10#include <fstream>
11#include <iterator>
12#include <sstream>
13#include <stdexcept>
14
15#include "AotiPackageIsa.h"
16#include "RgpotFactory.h"
17#include "gpr/StartupReport.h"
20
21// The params messages come from rgpot's RPC schema, which a build without
22// the RPC arm does not generate.
23#if defined(USE_CAPNP) && __has_include("rgpot/rpc/Potentials.capnp.h")
24#define GPR_ENGINE_REGISTRY_SCHEMA 1
25#include <capnp/message.h>
26#include <capnp/serialize.h>
27
28#include "rgpot/rpc/Potentials.capnp.h"
29#endif
30
31namespace pot {
32
33namespace {
34
35enum class Arm { Uma, Metatomic, Cpmd, Cp2k, Lammps, Builtin, None };
36
37struct Entry {
38 const char* name;
39 Arm arm;
40 const char* library;
41 const char* builtin;
42 bool generic;
43 const char* subdir;
44};
45
46// One table: a --potential name, the params arm its engine reads, and the
47// library that serves it. Analytic and compiled-in backends without a
48// shipped engine library keep an empty name and need --potential-library.
49constexpr Entry kTable[] = {
50 {"uma", Arm::Uma, "libuma_engine.so", "", true, "UmaPot"},
51 {"omol", Arm::Uma, "libuma_engine.so", "", true, "UmaPot"},
52 // The deck is BLYP at 70 Ry. Silicon's channel is LMAX=D and LOC=D,
53 // nitrogen's is LMAX=P and LOC=P, both Kleinman-Bylander.
54 {"cpmd", Arm::Cpmd, "libcpmd_engine.so", "", true, "CPMDPot"},
55 // PBE with DZVP-MOLOPT-SR-GTH and GTH-PBE at 650/70 Ry, unrestricted
56 // Kohn-Sham. libcp2k_engine.so dlopens the libcp2k shim
57 // libcp2kc_rgpot.so; it does not link CP2K.
58 {"cp2k", Arm::Cp2k, "libcp2k_engine.so", "", true, "CP2KPot"},
59 // Pair style, coefficients and the type map come from --lammps-params.
60 // liblammps_engine.so dlopens liblammpc.so; it does not link LAMMPS.
61 {"lammps", Arm::Lammps, "liblammps_engine.so", "", true, ""},
62 {"metatomic", Arm::Metatomic, "libmetatomic_engine.so", "", false,
63 "MetatomicPot"},
64 {"xtb", Arm::Builtin, "libxtb_engine.so", "xtb", false, "XTBPot"},
65 {"gfn2", Arm::Builtin, "libxtb_engine.so", "xtb", false, "XTBPot"},
66 {"gfnff", Arm::Builtin, "libxtb_engine.so", "gfnff", false, "XTBPot"},
67 {"lj", Arm::Builtin, "", "lj", false, ""},
68 {"morse", Arm::Builtin, "", "morse", false, ""},
69 {"cuh2", Arm::Builtin, "", "cuh2", false, ""},
70 {"mopac", Arm::Builtin, "", "mopac", false, ""},
71};
72
73const Entry* find(const std::string& name)
74{
75 for (const auto& entry: kTable) {
76 if (name == entry.name) return &entry;
77 }
78 return nullptr;
79}
80
81std::string executableDirectory()
82{
83 std::error_code ec;
84 const auto path = std::filesystem::read_symlink("/proc/self/exe", ec);
85 return ec ? std::string() : path.parent_path().string();
86}
87
88std::string joinPath(const std::string& dir, const std::string& name)
89{
90 if (dir.empty()) return name;
91 return dir.back() == '/' ? dir + name : dir + "/" + name;
92}
93
97void locateLibrary(const EngineRequest& request, const std::string& name,
98 EngineBinding& binding)
99{
100 if (!request.engine_dir.empty()) {
101 // An explicit directory is authoritative: no search past it.
102 binding.library = joinPath(request.engine_dir, name);
103 return;
104 }
105 binding.searched = engineSearchDirectories(request, request.potential);
106 // First directory holding the file; else the bare name, left to the
107 // loader's own search (rpath, LD_LIBRARY_PATH).
108 binding.library = name;
109 for (const std::string& dir: binding.searched) {
110 const std::string candidate = joinPath(dir, name);
111 std::error_code ec;
112 if (std::filesystem::exists(candidate, ec)) {
113 binding.library = candidate;
114 break;
115 }
116 }
117}
118
119bool readParamsFile(const std::string& path, std::vector<unsigned char>& out,
120 std::string& err)
121{
122 std::ifstream in(path, std::ios::binary);
123 if (!in) {
124 err = "cannot read engine parameters " + path;
125 return false;
126 }
127 out.assign(std::istreambuf_iterator<char>(in), {});
128 if (in.bad()) {
129 err = "cannot read engine parameters " + path;
130 return false;
131 }
132 return true;
133}
134
135bool resolvePlugin(const EngineRequest& request, const char* table_library,
136 EngineBinding& binding, std::string& err)
137{
138 binding = {};
139 binding.model_path = request.model_path;
140 const std::string label =
141 request.plugin_name.empty() ? request.potential : request.plugin_name;
142 if (!request.library.empty()) {
143 if (request.library.find('/') != std::string::npos)
144 binding.library = request.library;
145 else
146 locateLibrary(request, request.library, binding);
147 } else if (table_library != nullptr && table_library[0] != '\0') {
148 locateLibrary(request, table_library, binding);
149 } else {
150 err = "engine parameters for '" + label +
151 "' need a library: pass --potential-library or set "
152 "[oracle.plugin] library_path";
153 return false;
154 }
155 if (!request.params_payload.empty()) {
156 binding.config = request.params_payload;
157 } else if (!readParamsFile(request.params_path, binding.config, err)) {
158 return false;
159 }
160 binding.params_arm = "plugin:" + label;
161 return true;
162}
163
164#ifdef GPR_ENGINE_REGISTRY_SCHEMA
165std::vector<unsigned char> serialize(capnp::MessageBuilder& message)
166{
167 const kj::Array<capnp::word> words = capnp::messageToFlatArray(message);
168 const kj::ArrayPtr<const kj::byte> bytes = words.asBytes();
169 return std::vector<unsigned char>(bytes.begin(), bytes.end());
170}
171
172std::string trim(const std::string& text)
173{
174 const auto first = text.find_first_not_of(" \t\r");
175 if (first == std::string::npos) return {};
176 const auto last = text.find_last_not_of(" \t\r");
177 return text.substr(first, last - first + 1);
178}
179
180bool parseBool(const std::string& text, bool& out)
181{
182 if (text == "on" || text == "true" || text == "yes" || text == "1") {
183 out = true;
184 return true;
185 }
186 if (text == "off" || text == "false" || text == "no" || text == "0") {
187 out = false;
188 return true;
189 }
190 return false;
191}
192
196bool readLammpsParamsFile(::LammpsParams::Builder params,
197 const std::string& path, std::string& err)
198{
199 std::ifstream in(path);
200 if (!in) {
201 err = "cannot read --lammps-params " + path;
202 return false;
203 }
204 std::string units = "metal";
205 std::string atom_style = "atomic";
206 std::string pair_style;
207 std::string boundary = "f f f";
208 bool newton = true;
209 std::vector<std::string> coeffs;
210 std::vector<int> types;
211 std::vector<double> masses;
212 std::string line;
213 int lineno = 0;
214 while (std::getline(in, line)) {
215 ++lineno;
216 const std::string text = trim(line);
217 if (text.empty() || text[0] == '#') continue;
218 const auto gap = text.find_first_of(" \t");
219 const std::string key =
220 gap == std::string::npos ? text : text.substr(0, gap);
221 const std::string value =
222 gap == std::string::npos ? std::string() : trim(text.substr(gap));
223 auto fail = [&](const std::string& why) {
224 err = path + ":" + std::to_string(lineno) + ": " + why;
225 return false;
226 };
227 if (key == "units") {
228 if (value.empty()) return fail("units needs a style");
229 units = value;
230 } else if (key == "atom_style") {
231 if (value.empty()) return fail("atom_style needs a style");
232 atom_style = value;
233 } else if (key == "pair_style") {
234 if (value.empty()) return fail("pair_style needs arguments");
235 pair_style = value;
236 } else if (key == "pair_coeff") {
237 if (value.empty()) return fail("pair_coeff needs arguments");
238 coeffs.push_back(value);
239 } else if (key == "type") {
240 try {
241 std::size_t used = 0;
242 const int z = std::stoi(value, &used);
243 if (used != value.size() || z <= 0)
244 return fail("type takes one positive atomic number");
245 types.push_back(z);
246 } catch (const std::exception&) {
247 return fail("type takes one positive atomic number");
248 }
249 } else if (key == "mass") {
250 try {
251 std::size_t used = 0;
252 const double mass = std::stod(value, &used);
253 if (used != value.size() || !(mass > 0.0))
254 return fail("mass takes one positive mass in amu");
255 masses.push_back(mass);
256 } catch (const std::exception&) {
257 return fail("mass takes one positive mass in amu");
258 }
259 } else if (key == "boundary") {
260 if (value.empty()) return fail("boundary needs three tokens");
261 boundary = value;
262 } else if (key == "newton_pair") {
263 if (!parseBool(value, newton))
264 return fail("newton_pair takes on or off");
265 } else if (key == "extra" || key == "suffix") {
266 return fail(key + " is not applied by lammpc");
267 } else {
268 return fail("unknown key '" + key + "'");
269 }
270 }
271 if (pair_style.empty()) {
272 err = path + ": pair_style is required";
273 return false;
274 }
275 if (types.empty()) {
276 err = path + ": at least one type line is required";
277 return false;
278 }
279 if (coeffs.empty()) {
280 err = path + ": at least one pair_coeff line is required";
281 return false;
282 }
283 if (!masses.empty() && masses.size() != types.size()) {
284 err = path + ": mass lines must match type lines, or be omitted";
285 return false;
286 }
287 params.setUnitsStyle(units);
288 params.setAtomStyle(atom_style);
289 params.setPairStyle(pair_style);
290 auto coeff_list = params.initPairCoeffs(coeffs.size());
291 for (std::size_t i = 0; i < coeffs.size(); ++i)
292 coeff_list.set(i, coeffs[i]);
293 auto type_list = params.initTypeToAtomicNumber(types.size());
294 for (std::size_t i = 0; i < types.size(); ++i)
295 type_list.set(i, types[i]);
296 if (!masses.empty()) {
297 auto mass_list = params.initMasses(masses.size());
298 for (std::size_t i = 0; i < masses.size(); ++i)
299 mass_list.set(i, masses[i]);
300 }
301 params.setNewtonPair(newton);
302 params.setBoundary(boundary);
303 return true;
304}
305#endif
306
307} // namespace
308
309bool engineIsGeneric(const std::string& potential)
310{
311 const Entry* entry = find(potential);
312 return entry != nullptr && entry->generic;
313}
314
316{
317 return !request.params_payload.empty() || !request.params_path.empty();
318}
319
320OraclePathChoice selectOraclePath(const std::string& requested,
321 const std::string& potential, bool plugin)
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}
329
330OraclePathChoice selectOraclePath(const std::string& requested,
331 const std::string& potential)
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}
345
346std::string formatOraclePath(const OraclePathChoice& choice,
347 const std::string& potential)
348{
349 return gpr::startup::line("oracle",
350 {{"path", choice.engine ? "engine" : "direct"},
351 {"potential", potential},
352 {"reason", "\"" + choice.reason + "\""}});
353}
354
356{
358 if (run == nullptr) return false;
359 run->logParam("oracle.path", choice.engine ? "engine" : "direct");
360 run->flush();
361 return true;
362}
363
364std::vector<std::string> engineSearchDirectories(const EngineRequest& request,
365 const std::string& potential)
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}
403
404bool engineRegistryKnows(const std::string& potential)
405{
406 return find(potential) != nullptr;
407}
408
409bool resolveEngine(const EngineRequest& request, EngineBinding& binding,
410 std::string& err)
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}
613
614std::unique_ptr<EnginePotential> openEngine(const EngineRequest& request,
615 std::string& err,
616 EngineBinding* binding,
617 int oracle_threads)
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}
638
640 const EngineBinding& binding)
641{
642 return reportEngine(engine, binding,
643 binding.model_path.empty()
644 ? std::string()
645 : gpr::sha256File(binding.model_path));
646}
647
649 const EngineBinding& binding,
650 const std::string& model_sha256)
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}
661
662std::shared_future<std::string> startModelDigest(const std::string& model_path)
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}
671
672std::string formatEngineReport(const EngineReport& report)
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}
686
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}
701
702} // namespace pot
Host check for the instruction set an AOTInductor package needs.
@ z
Definition Enums.h:28
void logParam(std::string_view key, std::string_view value)
void flush()
Send buffered metrics, params and tags to the tracking server.
const std::string & resolvedPath() const noexcept
Absolute path of the loaded object, from the dynamic loader.
int abiVersion() const noexcept
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)
const std::string & library() const noexcept
eon_relax_band_t eon_relax_surface_fn void eon_relax_outcome_t * out
std::string line(const std::string &topic, const std::vector< Field > &fields)
MlflowRun * activeRun() noexcept
std::string sha256File(const std::string &path)
Digest of a file's contents; empty when the file cannot be read.
Definition Sha256.cpp:134
Potential wrappers and the batched oracle interface.
bool resolveEngine(const EngineRequest &request, EngineBinding &binding, std::string &err)
bool engineRegistryKnows(const std::string &potential)
True when the registry maps potential to an engine params arm.
bool recordOraclePath(const OraclePathChoice &choice)
Record the choice on the active tracking run as oracle.path.
std::unique_ptr< EnginePotential > openEngine(const EngineRequest &request, std::string &err, EngineBinding *binding, int oracle_threads)
resolveEngine followed by EnginePotential::open.
bool engineIsGeneric(const std::string &potential)
bool engineRequestIsPlugin(const EngineRequest &request)
std::string formatOraclePath(const OraclePathChoice &choice, const std::string &potential)
std::vector< unsigned char > potentialConfigArm(const std::vector< unsigned char > &config, const std::string &potential)
OraclePathChoice selectOraclePath(const std::string &requested, const std::string &potential, bool plugin)
bool recordEngineProvenance(const EngineReport &report)
void requireAotiPackageRunsOnHost(const std::string &path)
std::string formatEngineReport(const EngineReport &report)
std::shared_future< std::string > startModelDigest(const std::string &model_path)
std::vector< std::string > engineSearchDirectories(const EngineRequest &request, const std::string &potential)
EngineReport reportEngine(const EnginePotential &engine, const EngineBinding &binding)
A name resolved to an engine library and the capnp params message it takes.
std::string params_arm
capnp root struct, e.g. UmaParams
std::string library
path or soname for dlopen
std::string model_path
std::vector< std::string > searched
std::vector< unsigned char > config
flat-array message
What a run needs to state about the engine that answered it.
std::string library
as requested of the loader
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()
What a driver knows when it asks for a potential by name.
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 engine_dir
std::string task_name
–task-name (UMA task head)
std::string potential
–potential: uma, omol, metatomic, ...
std::string lammps_params_path
–lammps-params: pair style, coefficients and type map for lammps.
std::string device
–device
std::string executable_dir
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
std::string params_path
std::vector< unsigned char > params_payload
Which route a run takes to its potential, and why.