Skip to content

Load cuPotential support on demand - #561

Merged
lohedges merged 5 commits into
develfrom
feature_optional_cuPotential
Dec 4, 2026
Merged

lohedges merged 5 commits into
develfrom
feature_optional_cuPotential

Conversation

@lohedges

@lohedges lohedges commented Dec 4, 2026

Copy link
Copy Markdown
Contributor

Previously, building Sire with SIRE_CUPOTENTIAL_DIR compiled cuPotential support into _SireOpenMM and linked it to libOpenMMNvidia, so that build of Sire couldn't be loaded without that exact plugin library present, even if cuPotential was never used.

The cuPotential-specific code now lives in a separate library, libSireOpenMMNvidia, built only when the cuPotential headers are found and installed next to _SireOpenMM. _SireOpenMM talks to it through a small interface (cupotential.h) and loads it with dlopen only when use_cupotential is requested, or when the lambda lever meets a cuPotential force. _SireOpenMM no longer links any cuPotential library, so the same Sire build works with or without the plugin installed.

If the support can't be loaded, use_cupotential raises a clear error: either that Sire was built without cuPotential support, or the underlying load error. Failed loads aren't cached, so they can be retried.

Tested with a patched cuPotential 0.3.5 build: the converted force is used, lambda-lever updates match stock OpenMM across lambda windows with and without REST2, context reinitialisation is exact, and NVT/NPT dynamics run as before. New tests cover the error when cuPotential is unavailable and the lambda dependence of the energy when it is available.

  • 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: [n/a]
  • 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 added the enhancement New feature or request label Dec 4, 2026
@lohedges
lohedges merged commit 6d018bf into devel Dec 4, 2026
2 of 5 checks passed
@lohedges
lohedges deleted the feature_optional_cuPotential branch December 4, 2026 15:17

This branch had an error being deployed

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