Skip to content

Add GPU-resident QM/MM callbacks - #553

Merged
lohedges merged 12 commits into
develfrom
feature_gpu_mlmm
Nov 30, 2026
Merged

lohedges merged 12 commits into
develfrom
feature_gpu_mlmm

Conversation

@lohedges

Copy link
Copy Markdown
Contributor

Adds a GPU-resident QM/MM path for Torch callbacks on the OpenMM CUDA platform, avoiding copies between the GPU and host each step, along with several QM/MM fixes found along the way.

GPU-resident QM/MM

  • New gpu_resident and cuda_graph options for sire.qm.create_engine and sire.qm.emle. Positions, charges and forces stay on the GPU, and the callback can optionally be captured in a CUDA graph. Link atoms use the same charge-shift scheme as the host engines.
  • The CUDA code is built on Linux as a separate library that needs only the CUDA headers and is loaded on demand, so Sire doesn't depend on the NVIDIA driver.
  • Setting SIRE_SHARED_CUDA_CONTEXT=1 before importing Sire makes OpenMM share PyTorch's primary CUDA context, avoiding context switches each step and reducing memory for each extra context.
  • For ANI2xEMLE on alanine dipeptide in water (RTX 5070 Ti, 1 fs), throughput goes from 10.0 ns/day with the default host engine to 67.5 ns/day with the GPU-resident engine, fused EMLE operators, a CUDA graph and the shared context. GPU-resident EMLE requires an emle-engine version that provides emle.models.preprocess.

Fixes

  • The Torch QM/MM engine passed garbage cell vectors to the model.
  • Position restraint anchor particles were treated as MM atoms. QM/MM now raises an error for molecules with virtual sites, which would shift the atom indices.
  • Non-periodic systems are no longer re-imaged into OpenMM's finite box, and callbacks get None as the cell.
  • Link atoms now count as part of the QM region for the cutoff, the switching function and the re-imaging centre, matching EMLE.
  • The QM/MM engines warn once if half the smallest box width is less than the cutoff plus the QM region's radius, when MM atoms can be passed at the wrong periodic image.

Other

  • The CUDA build dependencies are kept out of the conda package's run requirements, and the CUDA compiler and MACE are added to the emle and dev pixi environments for EMLE's fused operators.
  • Documentation for the GPU-resident path in the QM/MM tutorial.

Checklist

  • I confirm that I have merged the latest version of devel into this branch before issuing this pull request (e.g. by running git pull origin devel): [y]
  • I confirm that I have added a test for any new functionality in this pull request: [y]
  • I confirm that I have added documentation (e.g. a new tutorial page or detailed guide) for any new functionality in this pull request: [y]
  • I confirm that I have added a changelog entry to the changelog (we will add a link to this PR as part of the review): [y]
  • I confirm that I have permission to release this code under the MIT license (the Python API) or the LGPLv3+ license (everything else), as described in the LICENSE file: [y]

Prototyped, debugged, and written with the aid of Claude Code (Opus 5.5)

This branch was successfully deployed

No deployments
sire-build — 5339f680 Deployed Nov 30, 2026 by lohedges
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