Unified InputParameters schema¶
Status: implemented for gprn, not for gprd. schema/params.capnp is the
configuration of the NEB driver: gprn --config run.toml (or a binary
Cap’n Proto message) is read through managers/io/UnifiedConfigMessage and
managers/io/TomlConfigLoader.cpp. The dimer driver gprd still reads the
older schema/gprd_params.capnp through managers/io/CapnProtoManager.cpp,
and both files stay in the tree. The schema is not the only source of
run-time options. Command-line-only flags and a set of GPR_* environment
variables remain (see “What is still outside the schema” below). For the
key tables of the TOML file see the key reference. For the
versioning rules and the binary format see
the Cap’n Proto reference.
The file id of params.capnp is @0xcb672719fc31b8e4. currentSchemaVersion
is 7.
Why one schema¶
Before this schema, configuration was split over three mechanisms that did not know about each other:
Mechanism |
Scope |
Discoverability |
|---|---|---|
|
the dimer driver ( |
typed, schema |
hand-written |
the NEB driver ( |
source only |
|
deep in the GP library |
invisible |
The dimer had a typed schema. The NEB driver had its own parser, and a few behaviours, among them length-scale priors, block leave-one-out and length-scale tracing, could be switched on only by an environment variable read in the middle of a GP fit. A new option could land in any of the three, so no single place listed everything that can be configured.
The rule that follows is that a new option is a field of this schema, with a
comment that names the flag it matches, not a new getenv call and not a
new bare strcmp branch. The four variables in the migration table below
(GPR_LS_PRIOR, GPR_PC, GPR_BLOCK_LOO, GPR_TRACE_LS) are gone from the
code. The rule has exceptions that exist today, listed next.
What is still outside the schema¶
main_neb.cppstill parses the command line with a flag table (kFlagDocs) and 19std::strcmpcalls. Many flags have no schema field and are available only on the command line.gprddoes not readparams.capnp.The library reads
GPR_*environment variables for debugging and for kernel-path switches. List the names that a source search finds:
cd "${GPRIDGE_ROOT:-.}"
grep -rhoE --include='*.h' --include='*.cpp' --include='*.cu' --include='*.inl' \
'getenv\("GPR_[A-Z0-9_]+"' gpr managers python main.cpp main_neb.cpp \
| sed 's/getenv("//; s/"//' | sort -u
Twenty names were found when this page was written. The configuration page Configuration documents a subset of them.
Struct layout¶
The schema reads from top to bottom as reusable enums, reusable
building-block structs, the shared blocks, the method-specific parameter
sets and the top-level InputParameters. The authoritative list of enums,
structs and fields is the file itself; the lists in the earlier draft of
this page had fallen behind it.
The top-level InputParameters holds the run setup (potential, model,
reactant, product, configFile, output, conOutput,
cellDimensions, seed, device), the shared blocks and a method union:
Field |
Type |
Role |
|---|---|---|
|
|
GP model settings |
|
|
hyperparameter fit, objective, length-scale priors |
|
|
HS-SVD stable-basis solver options |
|
|
linear algebra mode, threads, ScaLAPACK layout |
|
|
uncertainty mode and variance arm |
|
|
what to record |
|
their own structs |
ancillary controls |
|
|
potential-provider settings |
|
list of |
marks GP initial values set explicitly, so an explicit zero differs from omission |
|
|
revision the writer used |
|
|
method-specific parameters |
The method union means a run is either a dimer search or a NEB, never
both. Every shared block applies to whichever method is selected. The GP-OIE
setup in main_neb.cpp (makeGpSetup) uses the same GprModel and
HyperparameterOptimization fields as the dimer, so the defaults exist once.
NebParams has the sub-blocks NebLbfgs, NebTrust and NebMmf.
The enum and struct names that params.capnp shares with
gprd_params.capnp are DimerOptimizer, HyperparameterOptimizer,
ScgCurvatureMode, DistanceMetric, ConvergenceForceNorm,
ConvergenceCriteria, IterationControl, TranslationParams,
InitialRotationControl, RelaxationControl, GprModel,
HyperparameterOptimization, LinearAlgebra, Pruning, Debug,
RunSelector and EarlyStopping. DimerParams holds the dimer-specific
fields of the old InputParameters.problem group.
Enums that this schema adds include HyperparameterObjective
(nlml, loo, blockLoo), UncertaintyMode and VarianceArm. blockLoo
leaves out the energy and all gradient rows of one geometry together.
VarianceArm replaces the three booleans --use-psis-laplace,
--use-psis-deterministic and --use-delta-method, whose legal combinations
were implicit, with one choice. NebMode and AcquisitionType are typed
mirrors of gpr::neb::NEBMode and gpr::neb::AcquisitionType. List all
enums with:
cd "${GPRIDGE_ROOT:-.}"
grep -n '^enum ' schema/params.capnp
Migration table¶
Each removed flag or environment variable maps to one field. The comment on
the field in params.capnp records the same mapping.
Old flag or variable |
Field |
|---|---|
|
|
|
|
|
|
|
|
|
|
(h5 con-v2 geometry store) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
The --hyperparameter-mode values scg, inla and map_lbfgs map onto
the C++ enum gpr::HyperparameterOptimizationMode. The schema exposes the
choice through HyperparameterOptimizer and the SCG/Adam union.
How to extend¶
The files to touch for a new option are listed once, in the Contributing guide: Add a TOML configuration key. The schema rules behind those steps are:
Put the field in the sub-struct that owns it: shared GP settings in
GprModel, a NEB-only knob inNebParamsor one ofNebLbfgs,NebTrustandNebMmf, a new uncertainty arm inUncertaintywith theUncertaintyModeorVarianceArmenums. A new method is a new arm of themethodunion, not a top-level field.Give the field the next free
@nordinal of its struct, never reuse or reorder an ordinal, and give it a default that reproduces the behaviour without it. Add a new enum value at the end of its enum.Raise
currentSchemaVersionby one.Record the addition in
schema/params.capnp.ordinals. The meson testtest_capnp_evolution_paramsfails on a renumbered, retyped or removed member and on a member that the record lacks:
python scripts/check_capnp_evolution.py --write schema/params.capnp schema/params.capnp.ordinals
git diff schema/params.capnp.ordinals
Add the key to
managers/io/TomlConfigLoader.cppwith asetIfPresentcall, and carry it throughCapnProtoNebLoader.cppandmain_neb.cppas the Contributing guide describes.Check that the schema compiles. The schema imports
/capnp/c++.capnpand the rgpotPotentials.capnp, socapnp compileneeds both include directories:
cd "${GPRIDGE_ROOT:-.}"
capnp compile -I "$(dirname "$(command -v capnp)")/../include" \
-I subprojects/rgpot/CppCore -o- schema/params.capnp > /dev/null
A meson build with -Duse_capnp=true (the default is false) compiles
the schema as well.