Native ABIs, Rust crates and data formats ========================================= This page lists the native libraries GPRidge calls through C interfaces, the C interfaces it exposes for plugins, the one Rust crate in the tree, and the file formats it reads and writes. The stamp checks and their messages are on :doc:`Native library ABI checks <../native_library_abi>`. The C API of ``libgpridge`` itself is on the :doc:`C API page `. What a build links ------------------ ``gprn`` and ``gprd`` print one ``[startup] abi`` line per library when a run starts. ``gprn --dump-cli-args`` prints the same lines without running a search: .. code:: bash gprn --dump-cli-args | grep '^\[startup\] abi ' GPRidge accepts rgmin C ABI major 1, minor 43 or later. The in-tree rgmin wrap currently pins a revision that declares ABI 1.52 with layout revision 1. That minor's changelog does not include ``rgmin_bfgs_hessian_update`` or ``rgmin_sr1_hessian_update``. The build accepts each symbol when the header declares it. Once Saddle tags the minor that adds the export, the minor floor has to require it. A skipped update returns ``RGMIN_HESSIAN_UPDATE_SKIPPED``. Callers compare that name. Upstream reserves 7 for ``RGMIN_NOT_CONVERGED``, so the carried name is 8. BFGS skips when ``y·s`` or ``|sᵀ B s|`` is at most 1e-12. SR1 skips when an entry of ``s`` or ``y`` is non-finite, when ``δ·s`` is non-finite, when ``|δᵀs|`` is at most 1e-12, or when ``|δᵀs|`` is below ``1e-8 ‖δ‖ ‖s‖``. ``δ·s`` is the ndarray dot. A build with that wrap, readcon-core and readcon-db and without the Rust core of rgpot prints the stamps below. rgmin is required, so every build lists it; a missing rgmin is a configure error. .. code:: bash gprn --dump-cli-args | grep '^\[startup\] abi ' :: [startup] abi library=rgmin header=1.77/7 loaded=1.77/7 status=verified [startup] abi library=readcon-core header=1.1/1 loaded=1.1/1 status=verified [startup] abi library=readcon-db header=1.3/1 loaded=1.3/1 status=verified [startup] abi library=rgpot-core header=no_rgpot.h_(rgpot_built_without_the_Rust_core) loaded=no_stamp status=UNVERIFIED [startup] abi library=gpridge header=2/920/1064 loaded=2/920/1064 status=verified The stamps depend on the revisions pinned in ``subprojects/*.wrap`` and on the build options, so another build prints other numbers. A library that is not part of the build is listed as ``not built``, never left out. ``UNVERIFIED`` does not stop a run; a mismatch does. ``gprd`` was run on a build that prints the ``UNVERIFIED`` line above and went on to read its input. From Python, ``abi_report()`` returns the same lines and ``check_abi()`` raises ``gpridge.ABIError``, a ``RuntimeError``, that names both stamps when a loaded library disagrees with its header: .. code:: python import gpridge lines = gpridge.abi_report() assert any(line.startswith("[startup] abi library=gpridge ") for line in lines) gpridge.check_abi() Reference --------- Native libraries called through C ABIs ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .. table:: +------------------+------------------------------------------------------------------+-------------------------------------------------------------------------------+ | Library | Used for | Checked | +==================+==================================================================+===============================================================================+ | rgmin | minimisers behind the hyperparameter fit, lowest eigenpair | major 1, minor 43 or later at compile time; header and loaded stamps at start | +------------------+------------------------------------------------------------------+-------------------------------------------------------------------------------+ | readcon-core | ``.con`` input and output | header and loaded stamps at start | +------------------+------------------------------------------------------------------+-------------------------------------------------------------------------------+ | readcon-db | observation archive (LMDB-backed CON frames), dimer trace corpus | header and loaded stamps at start | +------------------+------------------------------------------------------------------+-------------------------------------------------------------------------------+ | rgpot-core | potentials | header and loaded stamps at start, when the build has ``rgpot.h`` | +------------------+------------------------------------------------------------------+-------------------------------------------------------------------------------+ | rgsaddle | band and saddle sessions, the index-1 test of a converged saddle | major 1, minor 71 or later; the library is linked at build time | +------------------+------------------------------------------------------------------+-------------------------------------------------------------------------------+ | anneal, minimage | box-ensemble stage, minimum-image distances | through their C headers (``anneal-core.h``, the ``mi_*`` functions) | +------------------+------------------------------------------------------------------+-------------------------------------------------------------------------------+ The libraries are Meson subprojects pinned in ``subprojects/*.wrap``. rgsaddle is linked (ABI major 1, minor 71 or later). ``RgsaddleClient::load`` checks that stamp. ``gprn --rgsaddle-library`` and ``RGSADDLE_LIBRARY`` store the index-test selection. The linked library runs the test. Rust crate ~~~~~~~~~~ ``rust/gpridge-sys`` is a -sys crate: bindgen generates the declarations from ``gpr/capi/gpridge_c.h`` and the crate links the installed ``libgpridge``. It does not build the C++ core and does not call ``gpr_abi_check`` itself, so a program that uses it calls that function once at start. The crate is described on :doc:`the Rust page `. A CI job runs its test; no job publishes it. Plugin ABIs gpridge implements ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .. table:: +----------------------------------+---------------------------------+--------------------------------------------------------------------------------------------------------+------------------------------------------------------------------------------------------+ | ABI | Symbols | Version | Errors | +==================================+=================================+========================================================================================================+==========================================================================================+ | rgpot engine (``libgpr_engine``) | ``rgpot_engine_*`` | ``rgpot_engine_abi_version()`` returns 1; ``rgpot_engine_abi_stamp()`` returns 1.11, layout revision 1 | 0 success, positive recoverable, negative fatal; ``RGPOT_ENGINE_ERR_LOCK`` (-2) is fatal | +----------------------------------+---------------------------------+--------------------------------------------------------------------------------------------------------+------------------------------------------------------------------------------------------+ | Training product | ``gpr_training_product_*_v1`` | ``_v1`` suffix | status plus caller-supplied message buffer | +----------------------------------+---------------------------------+--------------------------------------------------------------------------------------------------------+------------------------------------------------------------------------------------------+ | stdpar environment kernels | ``gpr_stdpar_environment_*_v1`` | ``_v1`` suffix | status plus caller-supplied message buffer | +----------------------------------+---------------------------------+--------------------------------------------------------------------------------------------------------+------------------------------------------------------------------------------------------+ ``libgpr_engine`` puts the learning GP behind the generic rgpot engine C ABI, so that eOn and ASE can hold the surrogate as an ordinary potential (comment at the target in ``meson.build``). It checks an AOTInductor model package against the host CPU when it is created. The units are Angstrom for positions, eV for energy and eV/Angstrom for forces (``rgpot_engine_c_abi.h``). The base symbols are ``rgpot_engine_abi_version``, ``_available``, ``_create``, ``_destroy`` and ``_force``. eOn's loader resolves four of them (``rgpot_engine_abi_version``, ``_create``, ``_destroy``, ``_force``). The library also exports ``rgpot_engine_abi_stamp``, which returns ABI 1.11, layout revision 1, the stamp of the header copy (``RgpotEngineAbiStamp.cc``). The engine loader of the pinned rgpot reads that fifth symbol. It accepts major 1 and layout revision 1 when the plugin minor is at most the host minor (11). A library without the symbol is served as 1.0, layout revision 1, without the later optional symbols. A newer minor, for example "engine ABI stamp 1.12 (layout 1) cannot serve host stamp 1.11 (layout 1)", or a different major or layout, is refused. ``gpr/potentials/EnginePotential.cpp`` reads that stamp with the same rule. Minor 7 adds ``rgpot_engine_unload_policy``. Minor 11 adds ``rgpot_engine_set_cache``, ``rgpot_engine_cache_counts``, ``rgpot_engine_taylor_jet``, ``RgpotEngineDerivativeReport`` and the trailing ``RgpotEngineCaps.jet_order`` field. The host reads ``jet_order`` only when the plugin's caps size covers it, calls ``rgpot_engine_hvp`` only when ``analytic_hvp`` is set, and honours the unload policy only from minor 7. ``GprEngineLoaderContractTest.cpp`` fails when the library drops one of the five symbols or reports another stamp. ``_force_batch``, ``_model_state``, ``_set_callbacks``, ``_hint`` and ``_neighbor_options`` are optional; a host finds them with ``dlsym``. A training-product library is what ``--training-product-library PATH`` loads; ``libgpr_scheme2_product`` is the in-tree implementation over the CPU Scheme II engines. Symbols outside these sets are hidden. See :doc:`Training matrix products <../training_products>` for the products and :doc:`Use an rgpot engine plugin <../../howto/engine_plugins>` for the engine plugins that ``gprn`` and ``gprd`` load. Data formats ~~~~~~~~~~~~ .. table:: +---------------------------+-------------------------------------------------------------------------+---------------------------------------------+---------------------------------------------------------------------+ | Format | Written by | Read back by | Test | +===========================+=========================================================================+=============================================+=====================================================================+ | ``.con`` multi-frame file | ``gprn --write-con``, ``--trace-con``; the Python NEB export | readcon-core | ``test_readcon_loader``, ``python/tests/test_neb_con_roundtrip.py`` | +---------------------------+-------------------------------------------------------------------------+---------------------------------------------+---------------------------------------------------------------------+ | Observation archive | every oracle call, with ``--gp-observation-archive auto`` (the default) | readcon-db, per-image model selection | the archive cases in ``tests/gpr/neb/GPNEBSessionTest.cpp`` | +---------------------------+-------------------------------------------------------------------------+---------------------------------------------+---------------------------------------------------------------------+ | HDF5 band file | ``gprn --output`` (default ``gpr_neb_out.h5``); the dimer's HDF5 trace | HDF5, h5py, ``scripts/inspect_neb_band.py`` | ``test_h5_dump`` | +---------------------------+-------------------------------------------------------------------------+---------------------------------------------+---------------------------------------------------------------------+ The observation archive needs a readcon-db build; without one, ``gprn`` exits with status 2 unless the option is ``off`` (help text of the option). The dimer's trajectory corpus (``gprd --gp-dimer-trace``) is also a readcon-db corpus. The band itself is readcon output: ``gprn --write-con`` frames with energies and forces, the run summary on the first frame under ``neb_summary``, the same frames in the ``.corpus`` beside it, and the training set in the observation archive. ``gprn --output`` holds the per-outer GP trace by default (root attribute ``schema`` = ``gprn-gp-trace/2``, ``/trace//`` with band energies, measured mask, NEB force norms, acquisition variance, hyperparameters and oracle calls; ``global_gp/`` only with ``--trace-band-history true``), no file with ``--gp-trace false``, and ``--full-h5 true`` writes the whole band in the shared NEB band layout instead (``schema`` = ``neb-band/1``): ``/path/{images, gradients}`` as ``(n_images, 3N)``, ``/path/{energies,f_para,rxn_coord}``, ``/metadata/{atomic_numbers,cell,converged,oracle_calls,max_energy_image}``, 2-D ``/training/``, ``/summary/`` and ``/trace/``, every row a whole structure. Files of older runs carry ``/converged//`` instead; only readers read that layout. ``test_h5_dump`` writes nested 1-D and 2-D datasets, an integer dataset and the schema attribute, reads them back through the HDF5 C API bit for bit, and checks that a rewrite replaces one dataset and keeps the others. The command line as an interface ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ``gprn`` takes every option on the command line, and ``--dump-cli-args`` prints the resolved values. ``gprd`` has no ``--dump-cli-args``; it exits with "unrecognized option". The :doc:`CLI reference <../cli_reference>` is generated from the option tables. ``gprn --config`` reads options from TOML or a Cap'n Proto message (:doc:`schema page `).