Skip to content

Validate Configuration

Source code:

  • bff/workflows/validate/config.py
  • bff/workflows/validate/main.py
  • bff/workflows/campaign/

Purpose

bff validate reruns selected parameter samples, usually drawn from the posterior learned by bff learn.

The campaign runtime keys intentionally match bff sample-parameters as closely as possible.

Posterior Mode

campaign_dir: ./
posterior:
  file: ../06-learn/outputs/results.pt
  n_samples: 10
  include_mean: true
  include_map: true
  distribution: normal
  confidence: 0.9
  seed: null
source: ../01-build
systems:
  - system_id: acetate
    n_steps: 1000
gmx_cmd: gmx
job_scheduler: local

The specification stored in the results is authoritative and is copied to campaign_dir/specs.yaml. n_samples counts random draws; include_mean and include_map prepend the posterior mean and the MAP (the sampled state of highest log posterior) as deterministic samples. Supported distributions are empirical, normal, uniform, and kde. A null or omitted seed uses fresh randomness.

Explicit Mode

campaign_dir: ./
parameters: ./selected-parameters.yaml
specs: ../06-learn/outputs/specs.yaml
source: ../01-build
systems:
  - system_id: acetate
    n_steps: 1000
gmx_cmd: gmx
job_scheduler: local

Exactly one of parameters or posterior is required. specs is required only with parameters and is rejected with posterior.

Before anything is staged, validation checks that every parameter sample satisfies the bounds once implicit charges are reconstructed, and that every charge constraint gives the same equation in the validation systems as in the systems the specification was compiled for. Validation systems may lack some parameters or constraints, for example a system without calcium, but a constraint that selects atoms must still reconstruct the learned charges.

Options

General rules for all options are on the conventions page. Set exactly one of posterior and parameters.

Validation options

Key Type Default Description
posterior mapping none Draw parameters from a learned posterior; see posterior.
parameters path none YAML file with explicit parameter samples; see the format.
specs path required with parameters Parameter specification for parameters; not allowed with posterior, which embeds its own.

posterior

Key Type Default Description
posterior.file path required outputs/results.pt written by bff learn.
posterior.n_samples integer >= 0 10 Random draws.
posterior.include_mean boolean false Prepend one deterministic sample at the posterior mean.
posterior.include_map boolean false Prepend one deterministic sample at the MAP, after the mean. At least one sample must result from n_samples, include_mean, and include_map.
posterior.distribution empirical, normal, uniform, or kde normal empirical resamples posterior samples, normal draws from a fitted multivariate normal, uniform from the per-parameter central confidence interval, and kde from a Gaussian KDE.
posterior.confidence number in (0, 1) 0.9 Central interval width; used only by uniform.
posterior.seed integer none Random seed; omitted means fresh randomness.

Campaign options

Key Type Default Description
campaign_dir path required Output directory of the campaign; created if missing. An existing campaign in it must be resumed or overwritten; see Rerunning a campaign.
log path <campaign_dir>/<stage>.log Workflow log file.
gmx_cmd string required GROMACS executable, for example gmx or gmx_mpi.
job_scheduler local or slurm required Run samples on this machine (local.max_parallel_jobs at once) or as Slurm job arrays.
source path none bff build project directory. With it, systems[] lists only IDs and lengths, and each systems/<system_id>/ must contain topology.top, production.gro, index.ndx, em.mdp, production.mdp, and any bias.*.dat; the build trajectory is not needed. Without it, every system gives explicit inputs.
systems list required Systems simulated for every sample; see systems.
dispatch boolean true Run the jobs after staging them. With false, stage only (and print the sbatch command on Slurm).
compress boolean false Pack .tpr, .xtc, .yaml, .top, and .gro files of the finished campaign into <campaign_dir>.tar.gz.
cleanup boolean false Once a system's production run is complete, keep only the store suffixes and the sample's topology in its result directory. Unfinished systems keep everything a restart needs.
store list of strings [xtc] File suffixes, without dots, kept by cleanup and recorded as sample outputs (for example [xtc, pmf]).
scratch_dir string none Directory, usually node-local, in which GROMACS runs; may contain $VARIABLES expanded on the compute node. See Scratch directory.
max_restarts integer >= 0 0 Slurm only (an error with local): how often samples stopped by the time limit are resubmitted. See Time limits and restarts.
overwrite boolean false Delete an existing campaign in campaign_dir (only the files the campaign owns) and start a new one.
resume boolean false Continue the existing campaign: reuse its parameter samples and run only samples not yet completed. Cannot be combined with overwrite.
local.max_parallel_jobs integer >= 1 1 With job_scheduler: local, samples run at once; mind the CPU/GPU use of each GROMACS run.
slurm mapping none Required with job_scheduler: slurm; see slurm.

systems[]

Key Type Default Description
system_id ID required System ID; with source, the directory systems/<system_id>/ of the build.
n_steps integer >= 1 required Production MD steps per sample.
inputs mapping required without source Explicit input files; not allowed with source.
inputs.topology path required GROMACS topology.
inputs.coordinates path required Starting coordinates.
inputs.index path required GROMACS index file.
inputs.mdp_production path required Production MDP file.
inputs.mdp_em path none Energy-minimization MDP file; minimization is skipped without it.
inputs.bias path none Bias input named *.colvars.dat or *.plumed.dat.

slurm options

Key Type Default Description
slurm.sbatch mapping required sbatch options written as #SBATCH --<key>=<value> (underscores become dashes). Must not set array. Quote time ("04:00:00"): YAML reads an unquoted 4:00:00 as a number.
slurm.max_parallel_jobs integer >= 1 or -1 1 Array tasks running at once (% limit); -1 for no limit.
slurm.max_array_size integer >= 1 1000 Tasks per submitted array; keep below the cluster's MaxArraySize.
slurm.setup list of strings [] Shell lines run before each task, such as module load gromacs.
slurm.teardown list of strings [] Shell lines run after each task, also when it failed.

Rerunning a campaign

A campaign directory holds specs.yaml, samples.yaml, campaign.yaml, run.sh, tasks.txt, systems/, samples/, and slurm/. Running the stage again on a directory that contains them is an error, because new parameter draws would otherwise be mixed with old results:

  • resume: true continues the campaign, for example after the submitting process was killed or samples failed. It reuses the staged parameter samples, reruns only samples whose status is not completed, and appends to the log. The specification, system IDs, and n_steps must be unchanged; runtime options such as gmx_cmd, slurm, or scratch_dir may change. With bff sample-parameters, a larger n_samples adds the missing samples (a new Latin hypercube of its own, recorded under extensions in provenance) with the next sample IDs; existing samples are kept, and a smaller n_samples removes nothing.
  • overwrite: true deletes those campaign files (nothing else in the directory) and starts a new campaign.

Explicit Parameter File Format

The explicit mode consumes YAML only. The expected structure is a mapping from explicit parameter name to a list of sampled values; names not in the specification are rejected:

charge C1: [-0.5, -0.4, -0.3]
charge O1 O2: [-0.7, -0.6, -0.5]

Implicit charges are reconstructed from specs.yaml, so they do not need to appear in the file; columns for them, as written by results.draw(..., implicit=True), are ignored.

Validation campaigns use the same layout as sampling: each samples/<sample_id>/ holds run.out and gmx.log, with one directory per system below it. Locally dispatched campaigns show console-only progress from 0/N while the first MD job is running and advance after each completed parameter sample.

For the alternative explicit workflow, load outputs/results.pt with Results.load and call results.draw(10, fn_out="posterior-samples.yaml"). Posterior mode performs the same parameter ordering, bounds enforcement, and implicit-charge reconstruction automatically.

Analyzing a Validation Campaign

A validation campaign has the same layout as a sampling campaign: it always contains specs.yaml (copied from specs or from the posterior) next to samples.yaml, so bff build-qoi-datasets can analyze it like a sampling campaign, for example to compare validation QoIs with the reference:

training_samples:
  manifest: ../07-validate/samples.yaml
  systems:
    - system_id: acetate

samples.yaml records the parameter source under provenance: source: posterior with the results path and SHA-256, distribution, confidence, n_samples, include_mean, include_map, and the seed actually used, or source: parameters with the parameter file, its SHA-256, and specs.