xnn.common.config.translate#

Key-name translation registry: upstream GNN-code configs -> xnn names.

xnn keeps one canonical spelling for every option (the typed ModelConfig fields plus each model’s documented extra keys). Other codes spell the same knobs differently (MACE-CLI r_max/num_radial_basis/E0s, NequIP num_layers, …). Rather than teaching every Model.from_config a pile of aliases, a per-model translation table rewrites the foreign spellings to the canonical names once, inside the from_dict() funnel – so keys copied verbatim from an upstream MACE / NequIP / Allegro yaml just work, in every frontend (YAML / argparse / Hydra).

Rules#

  • Translation applies to the raw model: section only, selected by its name (models without a registered table pass through untouched).

  • The xnn canonical spelling always wins when both spellings are present.

  • Untranslated unknown keys are left as-is (they fold into ModelConfig.extra downstream).

  • Only key names are rewritten; values pass through verbatim (each from_config coerces upstream value forms such as MACE’s E0s: '{1: -13.6}' strings).

Add a table for a new model family (or extend an existing one) with register_key_translation().

Functions

register_key_translation(name, table)

Register (or extend) the upstream -> xnn key table for one model family.

translate_model_keys(section)

Rewrite upstream key spellings in a raw model: section to xnn names.