Skip to content

stb-mlffActiveLearning

Stage 4 - Active Learning of the 7.1 Custom ML Force Field (MACE fine-tuning) workflow · menu code 7.1.4

usage: stb-mlffActiveLearning [-h] [--workflow JSON] [--round K]
                              [--model PATH [PATH ...]] [-s STRUCTURE] [-c CALC]
                              [--file FILE] [--pseudo-dir PSEUDO_DIR]
                              [--supercell NA NB NC]
                              [--sampling-method {rattle,md,strain}]
                              [--strain-max PCT] [--md-ensemble {nvt,npt}]
                              [--md-pressure GPA] [--score {force,energy,both}]
                              [--selection {diverse,greedy}] [--diversity D]
                              [--auto-sampling] [--scan-values V [V ...]]
                              [--scan-n SCAN_N] [--target-force MEV_ANG]
                              [--n-candidates N_CANDIDATES]
                              [--stdev STDEV [STDEV ...]] [--md-steps MD_STEPS]
                              [--md-temperature MD_TEMPERATURE [MD_TEMPERATURE ...]]
                              [--stride STRIDE] [--top-k TOP_K]
                              [--min-novelty MIN_NOVELTY] [--train-path GLOB]
                              [--max-force EV_ANG] [--d3] [--max-energy MEV_ATOM]
                              [--frontier FACTOR] [--seed SEED] [--device {cpu,cuda}]
                              [-o OUTPUT_DIR] [--dry-run] [--show] [--save-data]
                              [--view-picks] [--no-intro] [-v]

Stage 4 (Active Learning) of the Custom ML Force Field workflow: uses already fine-tuned model(s) (stb-mlffAnalysis) to screen a fresh batch of candidate configurations (independent rattled snapshots, or frames from short NVT trajectories driven by the model itself via --sampling-method md, reusing stb-mlmd's own dynamics), optionally in a --supercell of the reference, and writes the most informative ones as new mlff_config_NNN/ folders, ready for the user to label with real SIESTA and feed back into another round of stb-mlffAnalysis. With 2+ --model (a committee, e.g. the same data trained with different --seed) the score is the committee's force disagreement -- an actual uncertainty signal; with one model it falls back to the largest predicted force, a cheap heuristic that favours the most distorted geometries. Picks are filtered for novelty: one whose atomic environments are all close to the training set or to an earlier pick is skipped. The report describes the pool, the selection funnel, each pick against the training set (extrapolation, close contacts, estimated error from Validate's calibration) and the SIESTA cost; every warning goes to one final section.

options:
  -h, --help            show this help message and exit
  --workflow JSON       Workflow state file (default: mlff_runs/mlff_workflow.json, or ./mlff_workflow.json inside that folder): gives the committee, the reference .fdf, the training set for the novelty filter and the output directory when those options are omitted; the picked folders are recorded in it.
  --round K             Take the committee of round K from --workflow (default: the latest).
  --model PATH [PATH ...]
                        Fine-tuned MACE model file(s), overriding --workflow's committee. Two or more form a committee: the score becomes their force disagreement (stb-mlffAnalysis --committee N trains one). With one model the score is its largest predicted force.
  -s STRUCTURE, --structure STRUCTURE
                        Reference structure .fdf (default: the one in --workflow), rewritten with each pick's coordinates; with -c/--calc, the calc.fdf template (default: calc.fdf) that %includes it, copied into every folder.
  -c CALC, --calc CALC  Calculation template that %includes --structure (default: calc.fdf with --structure, else the one in --workflow).
  --file FILE           Instead of -s/-c: one self-contained reference .fdf -- basis/pseudos/SCF settings are reused verbatim in every candidate written out.
  --pseudo-dir PSEUDO_DIR
                        Directory (or bundled bank) to search for <element>.psf/.psml pseudopotentials (default: the one stb-mlff recorded in --workflow, else the current directory).
  --supercell NA NB NC  Sample candidates in an NA x NB x NC supercell of --file (default: 1 1 1, the reference cell itself). A small training cell only constrains the interactions its own periodicity allows -- e.g. an 8-atom diamond cell sees the Gamma and X phonons but not L -- and a supercell adds the rest. Each folder gets the reference k-grid divided by the supercell size in its config_extra.fdf. SIESTA cost grows steeply with the atom count.
  --sampling-method {rattle,md,strain}
                        How to generate candidate configurations (default: rattle):
                          rattle - independent, static Gaussian-displaced snapshots (cheap: 1 evaluation per candidate and model).
                          md     - short NVT trajectories with the (first) model itself (stb-mlmd's own dynamics, reused directly); more physically representative of the configuration space the system actually explores, at the cost of running real MD steps (--md-ensemble npt lets the cell breathe too).
                          strain - random cell deformations (volume and shear, up to --strain-max, periodic axes only), rattled: the volume/stress response.
  --strain-max PCT      Largest strain component, % (--sampling-method strain only, default: 3).
  --md-ensemble {nvt,npt}
                        MD ensemble for --sampling-method md (default: nvt); npt (Berendsen, bulk only, --md-pressure) samples the cell as well, so the picks carry their own lattice.
  --md-pressure GPA     Pressure for --md-ensemble npt, GPa (default: 0).
  --score {force,energy,both}
                        What the committee's disagreement is measured on (default: force):
                          force  - max over atoms of the per-atom force spread
                          energy - spread of the energy per atom (catches configs whose forces agree but whose energy does not, e.g. another volume)
                          both   - force and energy spreads, each divided by its pool median, summed
  --selection {diverse,greedy}
                        How the top-k batch is chosen (default: diverse):
                          diverse - score x min(1, novelty/--diversity), novelty vs the training set and the picks so far: no near-duplicate picks
                          greedy  - highest score first (only --min-novelty filters)
  --diversity D         Novelty (typical training spacings) at which a candidate keeps its full score in --selection diverse (default: 1).
  --auto-sampling       First scan several settings of the sampling method (stdev / temperature / strain, --scan-values) with a few candidates each, then sample with the one of highest median score that is still physical (few close contacts, stable MD, --max-force, --max-energy) and whose median energy stays within --frontier x the training set's -- one step beyond the labelled range, not its edge.
  --scan-values V [V ...]
                        Settings for --auto-sampling (default: stdev 0.03-0.3 Ang, 300-1500 K, or strain 1-8 %).
  --scan-n SCAN_N       Candidates per scanned setting (default: 12).
  --target-force MEV_ANG
                        Error that is good enough (meV/Ang, as in stb-mlffValidate): the report says whether any candidate is still expected above it -- if none is, another round on this sampling adds little.
  --n-candidates N_CANDIDATES
                        Number of candidate configurations to screen (--sampling-method rattle only, default: 50).
  --stdev STDEV [STDEV ...]
                        Rattling standard deviation(s) in Angstrom for the candidate batch (--sampling-method rattle only, default: 0.15 -- typically larger than the amplitude(s) used for the original training set, to probe configuration space not yet covered).
  --md-steps MD_STEPS   NVT steps per temperature (--sampling-method md only, default: 500).
  --md-temperature MD_TEMPERATURE [MD_TEMPERATURE ...]
                        NVT temperature(s), K -- one trajectory each (--sampling-method md only, default: 800 -- deliberately higher than a typical production temperature, purely to cover more configuration space per step; not a claim about the material's real operating conditions).
  --stride STRIDE       Keep one frame every Nth MD step as a candidate (--sampling-method md only, default: 10).
  --top-k TOP_K         Number of candidates to write out (default: 5).
  --min-novelty MIN_NOVELTY
                        Skip a candidate whose atomic environments are all closer than this to the training set or to an earlier pick (default: 0.5; 0 disables). Measured on a model-independent fingerprint (sorted distances to the 16 nearest neighbours) in units of the training set's own typical spacing -- 1 means as far as two independent training configs are from each other.
  --train-path GLOB     Folders the novelty filter compares against (default: the training configs in --workflow, else every mlff_config_* under <output-dir>, in configs_round_*/ or directly in it -- labelled or not). Quote the pattern.
  --max-force EV_ANG    Skip candidates whose predicted max|F| exceeds this, eV/Ang -- geometries too distorted to matter for the intended use (default: 15, the workflow's 'unphysical' line, the same Stage 1 and 2 warn at; 0 = no limit).
  --d3                  Add DFT-D3 (DFTD3 .true.) to every pick's config_extra.fdf. Not needed with a workflow file: the picks follow Stage 1's --d3 recorded there; for explicit --model/-s/-c runs without one.
  --max-energy MEV_ATOM
                        Skip candidates whose predicted energy lies more than this above the reference's, meV/atom (committee mean; default: 1000, the workflow's 'unphysical' line; 0 = no limit). The report also gives each energy as a temperature (3/2 kT per atom).
  --frontier FACTOR     --auto-sampling: choose the highest-score setting whose median predicted energy stays within FACTOR x the training set's 90th-percentile energy above the reference (default: 1.5), so each round extends the training range a step instead of jumping to the most distorted physical setting. 0 = off (the highest score among the physical settings).
  --seed SEED           Base random seed for rattling / straining / initial MD velocities (default: 42). The seed used is --seed + 1000 x the round the picks will train, so each round screens new candidates; rattles also get their own offset, so they never repeat Stage 1's displacement directions.
  --device {cpu,cuda}   Device to run the model(s) on (default: cpu).
  -o OUTPUT_DIR, --output-dir OUTPUT_DIR
                        Run folder (default: --workflow's directory, else the current one). With a workflow file the picks go to <output-dir>/configs_round_NN/ -- NN = the round they will train, the one after the latest --, else to <output-dir> itself; the mlff_config_NNN numbering continues project-wide.
  --dry-run             Screen and report (figure and data files too) but write no folder and leave the workflow file untouched -- to tune --stdev/--md-temperature/--supercell before committing to SIESTA runs.
  --show                Also display the screening figure on screen (it is always saved).
  --save-data           Also write the whole pool, one line per candidate (origin, score, spread, max|F|, novelty, shortest distance, picked), to mlff_al_<tag>_pool.dat. Off by default.
  --view-picks          Write the picks to mlff_al_<tag>_picks.xyz (per-atom committee spread as 'spread' and as the initial charge, so ASE's viewer colors by it: View > Colors > By initial charge) and open them.
  --no-intro            Do not show the introduction
  -v, --version         show program's version number and exit

Example usage:
  stb-mlffActiveLearning                    # latest round's committee from mlff_workflow.json
  stb-mlffActiveLearning --dry-run --show   # screen and look, write nothing
  stb-mlffActiveLearning --model m_s1.model m_s2.model m_s3.model \
                          -s structure.fdf -c calc.fdf --n-candidates 50 --stdev 0.15 --top-k 5
  stb-mlffActiveLearning --model m_s1.model m_s2.model m_s3.model --file si.fdf \
                          --sampling-method md --md-temperature 300 600 900 \
                          --supercell 2 2 2