Cap'n Proto configuration schema ================================ gpridge has two Cap'n Proto schemas. ``schema/params.capnp`` is the unified schema that ``gprn --config`` reads, as a TOML file or as a binary message. ``schema/gprd_params.capnp`` is the older dimer schema that ``gprd`` reads through ``loadParametersFromCapnp``; the :doc:`serialization how-to <../../howto/rpc>` covers it. This page covers the unified schema: how ``gprn`` loads it, the version and evolution rules, and the checks that guard them. Both encodings need a build with ``-Duse_capnp=true``. The option defaults to false. Without it, ``gprn --config FILE`` prints ``--config requires a build with use_capnp=true`` and exits with status 1. Choose an encoding ------------------ ``gprn`` picks the encoding from the file name. A path ending in ``.toml`` (any case) is read as TOML. Any other path is read as a binary Cap'n Proto message of ``params.capnp``. The TOML loader fills the same message, so both encodings pass through one reader, but the two do not combine with the command line in the same way. .. table:: +-------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | Encoding | What the file supplies | Precedence | +=========================+========================================================================================================================================================================================================================+=====================================================================================================================================================================================================+ | TOML (``run.toml``) | Any key of the tables below. A key that is absent takes the schema default. | The file is applied first and the command line is parsed after it, so an explicit flag replaces the file value. | +-------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | Binary (``params.bin``) | The ``NebParams`` block (driver knobs, L-BFGS, trust, reparameterization), the GP-conditioning blocks (HS-SVD and the length-scale prior), the ``NebMmf`` block, and the ``potentialConfig`` field (schema version 3). | The covered fields overwrite the command-line flags. The endpoints, the potential name, the model and device, ``--nimages``, the GP profile and the uncertainty selection stay on the command line. | +-------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ The TOML file may hold the top-level tables ``[band]``, ``[gp]``, ``[uncertainty]``, ``[acquisition]``, ``[trust]``, ``[oracle]``, ``[run]`` and ``[linalg]``. The loader rejects any other table and any key that its table does not list, with a message such as ``Unknown configuration key: band.foo``. :doc:`TOML configuration keys <../config_keys>` lists every key, its type, the flag that mirrors it and its default, and :doc:`Configuration files <../configuration>` says how to write a file. Two limits of the TOML encoding follow from the loader: - ``[band] mode`` accepts ``standard``, ``aie``, ``oie``, ``gp_aie`` and ``gp_oie``. It does not accept ``gp_local``; pass ``--nebmode gp_local`` on the command line. - A value of the wrong type, a fraction for an integer key, and an integer outside the range of its key are errors. Example: a TOML run with the linear-algebra options --------------------------------------------------- The file sets the endpoints, a band of 8 intermediate images in the default GP mode, and the three ``[linalg]`` keys. Each key mirrors a ``gprn`` flag, given in the comments. .. code:: toml [run] reactant = "reactant.con" product = "product.con" [band] nimages = 8 mode = "gp_oie" [linalg] mode = "library" # --linalg-mode threads = 4 # --linalg-threads training_product = "scheme2:fp64" # --training-product-library Check what the run will use before you start it. ``--dump-cli-args`` prints every parsed option and exits with status 0: .. code:: bash gprn --config run.toml --potential lj --dump-cli-args | grep -E '^(linalg_|training_product)|^\[startup\] linalg' :: linalg_mode=library linalg_threads=4 training_product_library=scheme2:fp64 [startup] linalg mode=library threads=4 Without ``--dump-cli-args`` the same command runs the search. ``[linalg] mode`` accepts ``reproducible`` (the default) and ``library``. An unknown mode, or ``threads`` below 1, is refused when the file loads, with ``Unknown linalg.mode: NAME`` or ``linalg.threads must be at least 1``. :doc:`Check run-to-run determinism <../../howto/determinism>` says what the two modes change. Versions -------- ``InputParameters.schemaVersion`` names the schema revision the writer used. The TOML loader stamps ``currentSchemaVersion``. A message written before the field existed reads as 1. A reader refuses a message whose version is newer than its own, with both versions in the error, instead of dropping the new fields. .. table:: +---------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | Version | Change | +=========+===============================================================================================================================================================================================================================================================================================================================+ | 1 | The schema before ``schemaVersion`` | +---------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | 2 | ``LinearAlgebra.mode``, ``threads`` and ``trainingProductLibrary`` | +---------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | 3 | ``InputParameters.potentialConfig``: the oracle's settings as an rgpot ``PotentialConfig`` | +---------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | 4 | ``InputParameters.oraclePlugin``. A version 4 message that omits ``gpr.prior`` still reads as zeros, as does every older message and a legacy ``gprd_params`` message | +---------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | 5 | ``NebParams.vibrationalStencil`` and ``DimerParams.vibrationalStencil``: ``full`` or ``vibrational``. Canonical dimer defaults publish ``prior.nu = 20`` and ``prior.s2 = 1``. A message whose schema version is at least 5 that omits ``gpr.prior`` reads as those values. GP initialization rejects a non-positive nu or s2 | +---------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | 6 | ``Uncertainty.stablePosteriorVariance``: the process-wide ``--stable-posterior-variance`` switch. ``GprModel.useRigidNullDeflation`` opts into rigid-motion nullspace deflation. | +---------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | 7 | ``InputParameters.gpInit``: a trained GP file for ``--gp-init`` | +---------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ Evolution rules --------------- - A field keeps its ordinal and its type for good. - A new field takes the next ordinal of its struct and a default that reproduces the behaviour without it; ``currentSchemaVersion`` rises by one. - A field is never renumbered, retyped or removed. A field that loses its meaning stays, documented as ignored. ``schema/params.capnp.ordinals`` and ``schema/gprd_params.capnp.ordinals`` record every field and enumerant. The tests ``test_capnp_evolution_params`` and ``test_capnp_evolution_gprd_params`` run ``scripts/check_capnp_evolution.py``, which fails on a renumbered, retyped or removed member and on a new member that the record lacks. Run the check on the unified schema: .. code:: bash cd "$GPRIDGE_ROOT" python3 scripts/check_capnp_evolution.py schema/params.capnp schema/params.capnp.ordinals To record an addition, run the script with ``--write`` and inspect the diff. It must hold only added lines: .. code:: bash python3 scripts/check_capnp_evolution.py --write schema/params.capnp schema/params.capnp.ordinals git diff schema/params.capnp.ordinals Potentials over RPC ------------------- The potential protocol (``Potentials.capnp`` and the ``potserv`` server) belongs to rgpot. gpridge uses the protocol's ``PotentialConfig`` schema, which is why a build with ``use_capnp=true`` also builds rgpot with ``with_rpc=true``. The serialization how-to describes what gpridge does with potentials.