QM Interfaces
QM interfaces connect ALF to electronic structure engines. They receive candidate structures from the sampler, run or parse a quantum-mechanical calculation, and return labeled data for storage in ALF’s HDF5 training sets.
Supported QM Packages
Package |
Associated interface |
|---|---|
|
|
|
|
|
|
|
When a QM engine already has a reliable ASE calculator, the generic ASE task is usually the easiest integration route. Write a small QM config that identifies the ASE calculator class, command, and calculator options, then let ASE handle input writing, execution, and result extraction.
Note
New VASP configurations should use
alframework.qm_interfaces.ase_calculator_interface.VASP_ase_calculator_task.
The older alframework.qm_interfaces.vaspase_interface.VASPGenerator helper
is deprecated and kept only for backward compatibility. For custom VASP-style
workflows, prefer the generic ase_calculator_task whenever the engine can
be represented as an ASE calculator.
How ALF Uses QM Interfaces
ALF uses QM code through a small set of master-configuration hooks:
- QM task
The
QM_taskfield inmaster_config.jsonis an import string for the labeling task. ALF submits this task through Parsl on thealf_QM_executorexecutor.- QM configuration
The
QM_config_pathfield points to an engine-specific JSON file. This file usually contains the executable command, method settings, CPU count, input blocks, and any engine-specific options.- Scratch directory
The
QM_scratch_dirfield controls where per-structure calculation directories are created. QM tasks typically create one subdirectory perMoleculesObjectid.- Properties
The
properties_listfield defines which properties ALF requests and how those properties are written to HDF5. It also records whether each property is system-level or atom-level and includes the unit conversion used when storing data. See Units And Property Conversion for how these multipliers are applied.
Common Configuration Fields
- Master configuration
These fields connect the ALF active-learning loop to a QM engine.
Field
Meaning
QM_taskImport string for the labeling task.
QM_config_pathJSON file containing engine-specific QM settings.
QM_scratch_dirDirectory for per-structure QM input, output, and scratch files.
properties_listRequested properties, HDF5 dataset names, property scope, and unit conversion factors.
- QM configuration
Exact fields differ by backend, but QM config files commonly include:
Field
Meaning
QM_run_commandExecutable or launch command used by the QM task.
ncpuCPU count passed to engines or input writers when supported.
environment file
Optional shell setup file, such as
orca_env_fileorqchem_env_file.method/input blocks
Engine-specific method, basis, SCF, memory, k-point, and property settings.
scratch/output paths
Backend-specific controls for where input, output, and restart files are written.
Note
ALF does not choose a universally appropriate QM method, basis set,
pseudopotential, dispersion correction, or charge / spin state setting for a
workflow. These choices should be made explicitly in the engine-specific QM
configuration and checked against the intended chemistry. For ORCA and
Q-Chem, the method, basis, and property requests come from the configured
input/rem blocks, while the current task wrappers call the generators as
neutral singlets unless customized. For VASP through the current ASE
interface, INCAR-style settings come from QM_config["input"] and ASE’s
VASP calculator behavior. The deprecated legacy VASP helper is the exception
with ALF compatibility defaults documented further below.
For HPC runs, the QM command and Parsl resource configuration must agree. For
example, an MPI VASP command such as srun -n 128 vasp_std should be paired
with an alf_QM_executor configuration that requests the matching nodes,
tasks, walltime, modules, and launcher behavior. See Parsl And HPC Execution for
practical resource examples.
- Legacy VASP helper
alframework.qm_interfaces.vaspase_interface.VASPGeneratoris deprecated and kept only for older imports. Do not start new configuration files fromvaspase_interface.py. Existing imports may continue to work temporarily, but should be migrated toalframework.qm_interfaces.ase_calculator_interface.VASP_ase_calculator_taskor the genericase_calculator_taskdescribed above.The legacy helper also applies ALF-specific VASP defaults before merging user-provided
vasp_options:VASP setting
Legacy default
xc"pbe"prec"Accurate"ncore1unlessvasp_options["ncore"]is provided.lreal"Auto"nelm120unlessvasp_options["nelm"]is provided.ivdw0unlessvasp_options["ivdw"]is provided.These are compatibility defaults from the old helper, not universal recommendations for VASP calculations. In particular, users should be aware that the legacy path sets
LREAL = Autoby default; review this setting when reproducing old calculations, comparing force labels, or migrating to the ASE calculator interface. The old helper also mapsvasp_options["kpoints"]to ASE’skptsoption and falls back to atomic-number magnetic moments unlessmagmomis provided.
Adding New QM Engines
- Preferred ASE route
Use this path when ASE already provides a calculator for the engine. Configure
ase_calculator_taskas the QM task and include anASE_calculatorimport string in the QM config:{ "QM_task": "alframework.qm_interfaces.ase_calculator_interface.ase_calculator_task", "QM_config_path": "my_qm_config.json", "QM_scratch_dir": "qm_scratch/" }
{ "ASE_calculator": "ase.calculators.mycode.MyCode", "QM_run_command": "mycode_executable", "xc": "PBE", "basis": "def2-SVP" }
The generic task loads the ASE calculator class, creates a molecule-specific scratch directory, runs
calc.calculate(...), storescalc.results, sets the convergence flag fromcalc.converged, and returns the updatedMoleculesObject.- Custom parser route
Use this path when ASE does not support the engine or when ALF needs backend-specific parsing and convergence checks. Define a Parsl task with the ALF QM task signature:
import os from parsl import python_app @python_app(executors=["alf_QM_executor"]) def my_qm_task(molecule_object, QM_config, QM_scratch_dir, properties_list): molecule_id = molecule_object.get_moleculeid() directory = os.path.join(QM_scratch_dir, molecule_id) os.makedirs(directory, exist_ok=False) atoms = molecule_object.get_atoms() requested_properties = list(properties_list.keys()) write_mycode_input(atoms, QM_config, directory, requested_properties) run_mycode(QM_config["QM_run_command"], directory) results = parse_mycode_output(directory, requested_properties) converged = parse_mycode_convergence(directory) molecule_object.store_results(results) molecule_object.set_converged_flag(converged) return molecule_object
The
resultsdictionary should use the same property names requested inproperties_list. Custom tasks should document the units they place inMoleculesObject.resultsso the master configuration can apply the correct HDF5 conversion factor.- Implementation checklist
Before using a new QM backend in production, check that:
The QM task runs on
alf_QM_executorwithout requiring ML/GPU imports.The scratch directory is unique for each
MoleculesObjectid.Requested properties match the keys in
properties_list.Convergence is set explicitly with
set_converged_flag.Failed or incomplete calculations return a non-converged
MoleculesObjector raise an error that ALF can record.The launch command matches the Parsl resource allocation, especially for MPI engines.
QM Interface API Links
You can link from this guide directly to API pages: