Skip to content

Add ML potentials for the intramolecular energy of the perturbable molecule - #309

Merged
lohedges merged 18 commits into
develfrom
feature_ml_fep
Dec 3, 2026
Merged

lohedges merged 18 commits into
develfrom
feature_ml_fep

Conversation

@lohedges

@lohedges lohedges commented Dec 3, 2026

Copy link
Copy Markdown
Contributor

This PR adds an ml_model option that replaces the force field with an ML potential for the intramolecular energy of the perturbable molecule, for relative and absolute free energies on the CUDA platform. It uses the end-state interpolation added to Sire in OpenBioSim/sire#559. The energy at λ is (1 − λ) E_ML(A) + λ E_ML(B) + E_MM(λ), where the ML energies of the two end states are evaluated as one batch each step, and the interactions with the environment stay MM, so the existing soft-core potentials and λ schedules are used unchanged.

Options

  • ml_model: one of the following.
    • A standard model: ani2x, mace-off23-small, mace-off23-medium or mace-off23-large.
    • The path to a MACE model file (.model).
    • The path to a TorchScript EMLE model.
    • A factory, file.py:function or module:function, that returns a custom model following the end-state interface documented in the README.
  • ml_emle_model: the EMLE model used by ani2x and MACE models for electrostatic embedding.
  • ml_embedding: mechanical (default) or electrostatic. With electrostatic embedding, stages are added at either end of the λ schedule that switch between mechanical and EMLE embedding, so that the alchemical stages use mechanical embedding. With the annihilate and decouple schedules, only the first stage is added, since the molecule is decoupled at λ = 1. The stages aren't saved in the configured schedule, so restarts and the config file are unaffected.
  • ml_embedding_fraction: the fraction of λ taken by each embedding stage (default 0.1).
  • ml_cutoff, ml_switch_width and ml_cuda_graph: the EMLE cutoff, the width of its switching region, and whether the model is captured in a CUDA graph.

ML models aren't yet supported with GCMC, REST2 or swap_end_states, and these combinations are rejected. Alchemical ions keep their end-state charges through the embedding stages. somd2-view and somd2-summary ignore the embedding settings when pairing vacuum legs with their free legs, since no embedding is applied without water.

Validation

Ethane → methanol relative hydration free energies, and absolute hydration free energies of both molecules, were run with MM, ANI-2x with mechanical embedding and ANI-2x with EMLE embedding, using replica exchange with 11 windows and 1 ns per window.

  • Mechanical embedding agrees with MM in every leg, as expected, since the ML only replaces intramolecular terms that largely cancel.
  • EMLE embedding is about 3.5 kcal/mol more negative, consistent with the free energies of the embedding stages and the known over-solvation of EMLE with fixed-charge LJ and TIP3P water.
  • The EMLE thermodynamic cycle closes (−0.19 ± 0.34 kcal/mol).

@lohedges lohedges added the enhancement New feature or request label Dec 3, 2026
@lohedges
lohedges merged commit 1f92711 into devel Dec 3, 2026
4 checks passed
@lohedges
lohedges deleted the feature_ml_fep branch December 3, 2026 14:27

This branch was previously deployed

1 inactive deployment
somd2-build — 66e1bfe3 Deployed Dec 3, 2026 by lohedges via build (3.13, linux) #167
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant