openmmtools icon indicating copy to clipboard operation
openmmtools copied to clipboard

Example for running MPI for ReplicaExchangeSampler?

Open mrshirts opened this issue 4 years ago • 4 comments

Is there a good example for a script that parallelizes the runs generated by ReplicaExchangeSampler over cores via MPI (or other means)? Note that are systems are small enough (<100 particles) that we don't appear to be getting that much performance benefit of GPU over CPU. We are having a hard time getting this work, and we didn't find anything in the official documentation.

Thanks!

mrshirts avatar May 28 '20 21:05 mrshirts

ReplicaExchangeSampler should have automatic detection of MPI and it should parallelize the replicas over MPI processes accordingly. So it should be possible to just run mpirun [mpirun_options] my_script_with_rex.py.

To make it run over CPU rather than GPU, you should be able t set the platform in the ContextCache object used to generate the OpenMM Contexts. By default, ReplicaExchange uses a global context cache that you configure at the beginning of your script like this

from openmmtools.cache import global_context_cache
global_context_cache.platform = openmm.getPlatform('CPU')

Note however this bug: #449. This is giving us a hard time, and I am short on dev time right now, unfortunately.

andrrizzi avatar May 29 '20 11:05 andrrizzi

Thanks so much for the info! I suspect we will either be running on 1 GPU at a time, or parallelized on CPU's, so we hopefully will be OK.

mrshirts avatar May 29 '20 14:05 mrshirts

Parallelizing over CPU might indeed work since I don't think we have tested the bug on CPUs. So far, however, the problem seems to be with MPI rather than the GPU platform in particular.

andrrizzi avatar Jun 01 '20 10:06 andrrizzi

BTW, it's working, but we are still sorting out how to optimize what it does.

mrshirts avatar Jul 06 '20 19:07 mrshirts