From 7fb793c7f5f970592a5d57a8bafc74fe73464c98 Mon Sep 17 00:00:00 2001 From: hannahbaumann Date: Thu, 5 Mar 2026 14:51:23 +0100 Subject: [PATCH] First go at dummy context cache --- src/openfe/protocols/openmm_septop/base.py | 32 ++++++++++++++-------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/src/openfe/protocols/openmm_septop/base.py b/src/openfe/protocols/openmm_septop/base.py index b3af8a4fd..4a5b15e19 100644 --- a/src/openfe/protocols/openmm_septop/base.py +++ b/src/openfe/protocols/openmm_septop/base.py @@ -985,6 +985,7 @@ def _get_ctx_caches( self, forcefield_settings: OpenMMSystemGeneratorFFSettings, engine_settings: OpenMMEngineSettings, + use_dummy: bool = True, ) -> tuple[openmmtools.cache.ContextCache, openmmtools.cache.ContextCache]: """ Set the context caches based on the chosen platform @@ -993,6 +994,8 @@ def _get_ctx_caches( ---------- forcefield_settings: OpenMMSystemGeneratorFFSettings engine_settings : OpenMMEngineSettings + use_dummy: bool + Whether to use a dummy context cache Returns ------- @@ -1010,17 +1013,22 @@ def _get_ctx_caches( restrict_cpu_count=restrict_cpu, ) - energy_context_cache = openmmtools.cache.ContextCache( - capacity=None, - time_to_live=None, - platform=platform, - ) + if use_dummy: + energy_context_cache = openmmtools.cache.DummyContextCache(platform=platform) + sampler_context_cache = openmmtools.cache.DummyContextCache(platform=platform) - sampler_context_cache = openmmtools.cache.ContextCache( - capacity=None, - time_to_live=None, - platform=platform, - ) + else: + energy_context_cache = openmmtools.cache.ContextCache( + capacity=None, + time_to_live=None, + platform=platform, + ) + + sampler_context_cache = openmmtools.cache.ContextCache( + capacity=None, + time_to_live=None, + platform=platform, + ) return energy_context_cache, sampler_context_cache @@ -1315,7 +1323,9 @@ def run( try: # 5. Get context caches energy_ctx_cache, sampler_ctx_cache = self._get_ctx_caches( - settings["forcefield_settings"], settings["engine_settings"] + settings["forcefield_settings"], + settings["engine_settings"], + use_dummy=True, ) # 6. Get integrator