Simulation / Modeling / Design

Accelerate Molecular Dynamics Simulations with Accurate, Flexible Primitives Using NVIDIA cuPotential

AI-Generated Summary

  • NVIDIA cuPotential provides modular C API primitives that accelerate molecular dynamics simulations by optimizing long-range interaction evaluation under periodic boundary conditions.
  • The library integrates with OpenMM through a plugin that replaces the nonbonded force, Langevin integrator, and Monte Carlo barostat with drop-in replacements requiring minimal code changes.
  • Benchmarks across GPU architectures from T4 to RTX PRO 6000 Blackwell show end-to-end speedups of 2x to over 3x for systems ranging from 24,000 to 400,000 atoms under NPT conditions.
  • New C2 continuous splitting and spreading functions developed with D. E. Shaw Research and the Flatiron Institute achieve target accuracy at lower grid resolutions and reduced cutoffs compared to standard Ewald and u-series methods.
  • Energy drift measurements over 10 ns show cuPotential reduces drift by several hundred fold versus default PME settings, exceeding typical biomolecular simulation requirements.
  • Beyond electrostatics, the library improves dispersion energy accuracy by several thousand fold while maintaining comparable force errors at lower computational cost.

Next Steps

Powered by NVIDIA Nemotron. AI-generated content may summarize information incompletely. Verify important information. Learn more

Molecular dynamics (MD) is an indispensable tool across physics, chemistry, biology, and materials science. Owing to its arithmetic structure, particularly the parallel evaluation of many atom-pair interactions, MD codes were among the first to be ported to run on GPUs. However, as GPUs evolve, optimizing kernels and ensuring compatibility across heterogeneous hardware have become more difficult than ever for many MD engine developers.

Specifically, in simulations run with classical forcefields, the evaluation of long-range interactions under periodic boundary conditions, such as electrostatics and dispersion, remains the major computational and engineering bottleneck.

NVIDIA cuPotential, a focused library designed for molecular dynamics, addresses these challenges. By offering modular primitives with a C API, cuPotential empowers developers and users to select specific components from multiple layers of the stack to accelerate workloads (Figure 1).

cuPotential provides direct space and reciprocal space utilities such as cutoff-based interaction evaluators and charge spreading functions. This release also provides a plugin specifically for OpenMM given its popularity in the developer ecosystem as an example. The goal is seamless drop-in replacements with minimal changes to the user’s code.

This post explains how to integrate the plugin into OpenMM, evaluate accuracy against high-accuracy references, and measure simulation throughput. It also introduces two examples for developers who need control over parameter representation and updates. Finally, it briefly discusses the science and error analysis behind the new splitting and spreading methods. This rigorous attention to accuracy and energy drift in simulation allows developers to integrate and benefit from the acceleration provided by cuPotential kernels without affecting simulation results.

Building the cuPotential runtime and plugin for OpenMM

cuPotential is composed of two parts: a core methods library and a plugin for OpenMM that consumes the primitives that can be built directly in a conda environment on Linux. The following tutorial walks through building the runtime and plugin, installing the Python wheel, and running the supplied molecular dynamics sample.

Prerequisites

  • Linux x86-64 with a supported NVIDIA GPU
  • An installed NVIDIA driver compatible with CUDA 13.1
  • Conda or Micromamba installed and initialized for your shell
  • A clone of the cuPotential repository from the NVIDIA/cuPotential GitHub repo

The environment supplies the CUDA toolkit and compilers; a separate system-wide CUDA toolkit installation is not required. The GPU driver must already be installed on the host.

Step 1: Create and activate the environment

Using Conda, create and activate the environment:

conda create -y -n cupotential-build -c conda-forge \
  python=3.12 openmm=8.4.0 \
  cuda-version=13.1 cuda-toolkit=13.1 \
  cmake make gcc_linux-64=13 gxx_linux-64=13 \
  swig pip setuptools wheel numpy

conda activate cupotential-build

Alternatively, you can use Micromamba:

micromamba create -y -n cupotential-build -c conda-forge \
  python=3.12 openmm=8.4.0 \
  cuda-version=13.1 cuda-toolkit=13.1 \
  cmake make gcc_linux-64=13 gxx_linux-64=13 \
  swig pip setuptools wheel numpy

micromamba activate cupotential-build

Next, install the Python build dependencies:

python -m pip install "pybind11>=2.12" nvidia-mathdx

The cuda-toolkit package supplies the CUDA compiler and development tools. Setting cuda-version alone does not install those tools.

Step 2: Point the build helper to the active environment

In plugins/openmm/run_build, replace:

OPENMM=/opt/openmm

with:

OPENMM="${CONDA_PREFIX:?Activate the conda environment first}"

Both Conda and Micromamba set CONDA_PREFIX when an environment is activated.

Step 3: Build and install

Use the cuPotential repository root, with the environment active:

export CUDACXX="$CONDA_PREFIX/bin/nvcc"
export CUDAHOSTCXX="$CXX"

./plugins/openmm/run_build
python -m pip wheel \
  --no-deps --no-build-isolation \
  --wheel-dir plugins/openmm/dist \
  ./plugins/openmm
python -m pip install plugins/openmm/dist/*.whl

The build helper compiles the cuPotential runtime if it’s not already present, then builds the OpenMM plugin. The final installation command also installs the wheel’s declared pip CUDA dependencies.

Step 4: Verify the installation

Run the supplied sample directly:

cd plugins/openmm/samples
./solvated_systems/run

The sample evaluates DHFR (Dihydrofolate reductase), BACE (Beta-secretase 1), and ApoA1 (Apolipoprotein A1), under both NVT and NPT conditions. The DHFR and ApoA1 systems are from the OpenMM benchmark suite, while BACE is from the OpenFE benchmark set. A successful run ends with:

PASS

The samples use AMBER14/TIP3P force field, a 0.9 nm nonbonded interaction cutoff length, a 5 x 10⁻⁴ electrostatic accuracy target, and mixed precision. Its 4 fs timestep is paired with constrained hydrogen bonds, rigid water, and hydrogen mass repartitioning to 1.5 amu.

These runs measure accuracy and performance separately. For electrostatics, it compares both implementations with a double-precision reference, using twice the cutoff length for the short range part and twice the mesh resolution in each dimension for the long range part, with the Ewald splitting parameter held fixed. For truncated Lennard-Jones interactions, it uses a double-precision reference at the same cutoff, preserving the interaction model being tested.

For throughput, each implementation runs 500 warm-up steps followed by 3,000 timed steps. The cuPotential arm uses its own force and integrator, plus its barostat for NPT. The reported speedup therefore describes that integrated configuration.

Using cuPotential with OpenMM

The cuPotential OpenMM plugin provides replacements for the OpenMM nonbonded force, Langevin integrator, and Monte Carlo barostat. In your production MD simulations, the key steps to integrate cuPotential into OpenMM are:

  1. Replace the system’s OpenMM nonbonded force before creating the simulation context
  2. Use integrator and optionally barostat from cuPotential
import openmm as mm
import openmm.unit as unit
import nv_openmm_plugin as nv

temperature = 300 * unit.kelvin      # Temperature, 300 K
timestep = 0.004 * unit.picoseconds  # Timestep, 4 fs
friction_coeff = 1.0 / unit.picoseconds   # Friction coefficient in Langevin thermostat
pressure = 1.0 * unit.bar            # Pressure if using barostat for NPT

# Prepare the system using OpenMM. Replace with your system.
pdb = app.PDBFile("solvated.pdb")
forcefield = app.ForceField("amber14-all.xml", "amber14/tip3p.xml")

system = forcefield.createSystem(
    pdb.topology,
    nonbondedMethod=app.PME,
    nonbondedCutoff=0.9 * unit.nanometers,
    ewaldErrorTolerance=5e-4,
    constraints=app.HBonds,
    rigidWater=True,
    hydrogenMass=1.5 * unit.amu,
)

# replace OpenMM NonbondedForce instance with the plugin's NonbondedForce
for index, force in enumerate(system.getForces()):
    if isinstance(force, mm.NonbondedForce):
        system.addForce(nv.NonbondedForce(force))
        system.removeForce(index)
        break

# The cuPotential integrator handles center-of-mass motion removal.
for index, force in enumerate(system.getForces()):
    if isinstance(force, mm.CMMotionRemover):
        system.removeForce(index)
        break

integrator = nv.LangevinMiddleIntegrator(
    temperature,
    friction_coeff,
    timestep,
)
# Optionally, add cuPotential barostat for NPT simulations
system.addForce(nv.MonteCarloBarostat(
    pressure,           # Pressure
    temperature,        # Match the integrator temperature.
    frequency=25,       # Attempt a volume change every 25 steps.
))

# Create the simulation after configuring all forces.
simulation = app.Simulation(
    pdb.topology,
    system,
    integrator,
    mm.Platform.getPlatformByName("CUDA"),
    {"Precision": "mixed"},
)
simulation.context.setPositions(pdb.positions)
simulation.minimizeEnergy() # OpenMM 8.4 only
simulation.context.setVelocitiesToTemperature(temperature)

simulation.step(1000)

This excerpt shows that the integration changes. The complete sample includes system construction, CUDA context creation, accuracy checks, and timing. For NPT simulations, it also uses nv.MonteCarloBarostat.

The current plugin targets solvated, approximately uniform-density systems in rectangular periodic boxes, which is typical in biomolecular simulations. It accepts PME source forces; LJPME, triclinic boxes, and OpenMM particle or exception parameter offsets are not supported. Consult the plugin README before adapting an existing simulation.

Benchmarking cuPotential in OpenMM

When cuPotential is integrated into OpenMM using the built-in plugin, performance is significantly enhanced across a wide range of GPU architectures for system sizes in the range of 24,000 to 400,000 atoms, namely DHFR, TYK2 (Tyrosine Kinase 2 from OpenFE benchmarks), BACE, ApoA1, Water with 100,000 atoms, and cellulose.

Figure 2 shows a collection of speedup measures under the NPT condition for a range of GPUs. Newer generation GPUs, including NVIDIA RTX PRO 6000 Blackwell Workstation Edition and NVIDIA RTX PRO 6000 Blackwell Server Edition, achieve over 3x end-to-end speedups in selected benchmarks. Other tested GPUs (NVIDIA B200, H100, A100, L40S, A10, L4 and T4) also benefit, with gains often around 2x or more. Note that the performance numbers are measured with standard, non-alchemical systems.

Improving accuracy and efficiency through new splitting and spreading methods

Ewald splitting, specifically the Particle Mesh Ewald (PME) variant, has been the de facto method for the past 30 years in the simulation field. Recently, new techniques such as the u-series, midtown splines and prolates have been proposed but not widely adopted by the simulation community given their high technical requirement and sophistication. The NVIDIA team has been collaborating with D. E. Shaw Research and the Flatiron Institute to develop a new set of C2 continuous splitting and spreading functions that are broadly applicable, highly accurate, and performant.

Figure 3 shows detailed error benchmark analyses across various grid resolutions and cutoff distances, highlighting the accuracy profile of the cuPotential approach relative to Ewald and u-series. These analyses are done with the 100K-atom water system under NPT conditions, with statistics computed over 25 frames. Ewald alpha-parameters were tuned to asymptotically reach the desired force tolerance.

Our team’s approach enables reducing the real-space cutoff and/or the reciprocal space grid-size, with no loss in accuracy (compared to the near-exact regime), defined as the L2 Force RMSE at default settings specified by OpenMM. We note up-front that the u-series was not optimized for the force error, but rather the ensemble error, and we simply chose the parameters to attain the desired force error in order to be consistent with OpenMM.

Beyond electrostatics, splitting and spreading kernels for lattice dispersion interactions through cuPotential enables highly nonpolar and membrane systems to be modelled more accurately. Conventional homogeneous analytical corrections can lead to severe simulation artifacts.

cuPotential is able to significantly improve the accuracy in the dispersion energy by several thousand fold compared to conventional methods, while maintaining comparable force errors at significantly reduced computational cost (Figure 4). The u-series is omitted because the original paper from DESRES only covered electrostatics. In practice, reducing cutoff to 6A still poses enormous challenges due to complexities introduced by NBFix as well as combining rules.

Accuracy and energy drift analysis

For long-time scale simulations, measuring energy drift is an important validation step to ensure that leakage is minimized. Although there are many potential sources of error, in addition to splitting, it’s important that the library is not the dominant cause of the drift. Compared to standard OpenMM with a smooth switching function for truncated Lennard-Jones interactions, it’s possible to measure the effect of cutoff truncation attributed to the residual in direct space under kernel splitting.

cuPotential significantly reduces drift by several hundred fold compared to default settings in PME, and far exceeds the typical requirements of the biomolecular simulation community. Figure 5 shows energy drift over the course of 10 ns for a 10,000-molecule rigid water system, with a 9 Å cutoff for cuPotential and standard OpenMM, while a 20 Å cutoff is used for converged PME. We used 2 fs timesteps and 300 K simulation temperature. For drift estimation, energy drift ΔE = E(t) – E(20ps) normalized over 60,000 degrees of freedom.

Get started accelerating MD simulations with cuPotential

NVIDIA cuPotential accelerates molecular dynamics simulations while offering modular flexibility and high numerical accuracy. To get started and learn more, visit the NVIDIA/cuPotential GitHub repo, where you’ll find additional examples, benchmarks, and code to integrate these accelerated primitives in your own MD simulations.

Acknowledgments

We thank our collaborators at D. E. Shaw Research and the Flatiron Institute’s Center for Computational Mathematics for their scientific and mathematical contributions, discussions, and guidance on the error analysis behind the new splitting and spreading methods.

Discuss (0)

Tags