Skip to content

Pass only the nearest MM atoms to GPU-resident models - #562

Merged
lohedges merged 2 commits into
develfrom
feature_gpu_resident_mm_subset
Dec 4, 2026
Merged

lohedges merged 2 commits into
develfrom
feature_gpu_resident_mm_subset

Conversation

@lohedges

@lohedges lohedges commented Dec 4, 2026

Copy link
Copy Markdown
Contributor

GPU-resident callbacks with electrostatic embedding were passed every MM atom, so that the shapes stay fixed for CUDA graphs, even though the switched charges of atoms beyond the cutoff are zero. For large systems the model then processes tens of thousands of atoms that contribute nothing.

This PR passes only the max_mm_atoms MM atoms nearest the QM region, selected on the GPU with torch.topk so that the shapes stay fixed. The MM1 and MM2 link-atom atoms and the virtual point charges are always included.

  • max_mm_atoms is a new option of sire.qm.create_engine and sire.qm.emle. It requires gpu_resident and electrostatic embedding.
  • By default it is set after the first call, which passes all atoms, to 1.25 × the number within the cutoff. The most within the cutoff so far is tracked on the device, also inside the CUDA graph. Every 100 calls it is read back, and if it is close to the limit, the limit is increased and the CUDA graph is recaptured.
  • The subtracted Coulomb energy is computed for the same atoms that are passed to the model. Any atoms within the cutoff that don't fit are left to the MM force until the limit is increased, and a warning is raised.

For chorismate in chorismate mutase (50,193 atoms, ANI2xEMLE with dense_aev, a 16 Å cutoff, a CUDA graph and a shared CUDA context), this goes from 4.05 to 3.18 ms/step, i.e. 42.6 to 54.3 ns/day at 2 fs.

  • 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]

@lohedges
lohedges merged commit 5ed8368 into devel Dec 4, 2026
4 of 5 checks passed
@lohedges
lohedges deleted the feature_gpu_resident_mm_subset branch December 4, 2026 21:07

This branch had an error being deployed

1 failed deployment
sire-build — 3219d951 Deployed Dec 4, 2026 by lohedges via build (3.14, windows) #492
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