stb-mlffAnalysis¶
Stage 2 - Train of the 7.1 Custom ML Force Field (MACE fine-tuning) workflow · menu code 7.1.2
usage: stb-mlffAnalysis [-h] [--path PATH] [--workflow JSON] [--skip-unlabelled]
[--committee COMMITTEE] [--cv K]
[--foundation-model {small,medium,large}]
[--init-from foundation|previous|PATH] [--epochs EPOCHS]
[--batch-size BATCH_SIZE] [--lr LR]
[--e0s {foundation-residual,average}]
[--stress-weight STRESS_WEIGHT] [--no-stress-training]
[--valid-fraction VALID_FRACTION] [--device {cpu,cuda}]
[--name NAME] [--seed SEED] [-o WORK_DIR]
[--skip-foundation-comparison] [--no-stability]
[--stability-temperature K]
[--stability-steps STABILITY_STEPS] [--view-worst N]
[--make-cards [ROUND]] [--show] [--save-data]
[--export-lammps] [--no-intro] [-v]
Stage 2 (Train) of the Custom ML Force Field workflow: aggregates the finished SIESTA calculations (energy + forces, best-effort stress), builds a MACE-format training set, and fine-tunes a MACE-MP foundation model on it via 'mace_run_train' -- by default a committee of 3 models (different seeds), recorded as a new round in mlff_workflow.json for Validate (stb-mlffValidate) and Active learning (stb-mlffActiveLearning). Reports the dataset, each member's training history and errors (train, validation, out-of-sample per kind, vs the raw foundation model), the committee agreement, and every warning in one final section.
options:
-h, --help show this help message and exit
--path PATH Glob pattern matching the config folders to train on (default: the training configs listed in --workflow, else every mlff_config_* here or in mlff_runs/, in configs_round_*/ subfolders or directly).
--workflow JSON Workflow state file shared by the 4 stages (default: mlff_runs/mlff_workflow.json, or ./mlff_workflow.json when run inside that folder). Read for the config list, updated with this round (committee models and metrics); created next to the config folders if missing.
--skip-unlabelled Train even when the configs meant for this round (<run>/configs_round_NN/, e.g. Stage 4's picks) have no finished SIESTA run yet -- they are left out and train a later round. Without it the stage stops and says where to run SIESTA.
--committee COMMITTEE
Number of models to train (default: 3), seeds --seed, --seed+1, ...: each gets its own train/validation split and training seed. Their force disagreement is what stb-mlffActiveLearning ranks candidates by, and stb-mlffValidate scores the committee mean. 1 trains a single model (that score then falls back to the largest predicted force).
--cv K K-fold cross-validation instead of a random --valid-fraction per member: the configs are dealt into K folds and member k validates on fold k, so EVERY config gets one out-of-sample prediction (the committee is then the K fold models; overrides --committee). Best with few configs. Default: off.
--foundation-model {small,medium,large}
MACE-MP foundation checkpoint (default: medium; small is ~2x faster). It is the starting point unless --init-from says otherwise, and always the baseline of the comparison.
--init-from foundation|previous|PATH
Starting weights: 'foundation' (default, the MACE-MP checkpoint), 'previous' (member k continues from member k of the latest round in --workflow: faster active-learning rounds) or a .model file.
--epochs EPOCHS Max training epochs (default: 100).
--batch-size BATCH_SIZE
Training batch size (default: 5).
--lr LR Learning rate (default: 0.001; 0.01 wrecks the pretrained model in the first epochs).
--e0s {foundation-residual,average}
Per-element reference energies (default: foundation-residual):
foundation-residual - fit so that the foundation model's own interaction
energy is on the SIESTA scale from the start
average - mace_run_train's own fit, which assumes zero interaction
energy (starts eV/atom off; the earlier behavior)
--stress-weight STRESS_WEIGHT
Weight of the stress term in the training loss, used when every configuration has a SIESTA stress (default: 10000; forces weigh 100, energy 1). Stress is what teaches the model the volume response -- pair it with stb-mlff --volume-strains.
--no-stress-training Train on energy and forces only, even if stress is available.
--valid-fraction VALID_FRACTION
Fraction of configurations held out for validation (default: 0.1).
--device {cpu,cuda} Training device (default: auto-detect, cuda if available).
--name NAME Experiment/model name (default: mlff_model).
--seed SEED Training random seed of the first committee member (default: 123).
-o WORK_DIR, --work-dir WORK_DIR
Working directory for this round (default: round_NN/ next to --workflow when that file exists, else the current directory). With --committee > 1 each member goes to <work-dir>/m_s<seed>/.
--skip-foundation-comparison
Skip evaluating the raw (non-fine-tuned) foundation model on the data for comparison. On by default (comparison runs unless this is passed).
--no-stability Skip the MD stability test (on by default: a short NVT then NVE run with each model, in a supercell of the reference, checking it does not blow up and how much the NVE energy drifts; it also times the model).
--stability-temperature K
Temperature of the stability MD (default: 300 K).
--stability-steps STABILITY_STEPS
NVT steps of the stability MD, 1 fs each, followed by half as many NVE steps (default: 400).
--view-worst N Write the N worst-predicted configs to <round>/worst_configs.xyz (per-atom force error as 'F_error' and as the initial charge, so ASE's viewer can color by it: View > Colors > By initial charge) and open them. Default: 0.
--make-cards [ROUND] Do not train: (re)write the model card (mlff_model_card.json) of every member of ROUND (default: the latest) from the workflow file and its SIESTA folders -- for rounds trained before the cards existed, or after a folder moved. Existing cards are overwritten, validation results are re-attached from the workflow file.
--show Also display the round summary figure on screen (it is always saved).
--save-data Also write <round>/mlff_training_errors.dat: per config, its kind, SIESTA max force, out-of-sample and foundation F RMSE and committee spread. Off by default.
--export-lammps Also compile the fine-tuned model into a TorchScript file loadable by LAMMPS's 'pair_style mace' (via mace_create_lammps_model, part of mace-torch) -- '<model>-lammps.pt'. Off by default.
--no-intro Do not show the introduction
-v, --version show program's version number and exit
Example usage:
stb-mlffAnalysis # configs from mlff_workflow.json, 3-model committee
stb-mlffAnalysis --show # also display the summary figure
stb-mlffAnalysis --path 'mlff_config_*' --epochs 100 --device cpu --committee 1
stb-mlffAnalysis --foundation-model small --device cuda
stb-mlffAnalysis --export-lammps