diff --git a/deepmd/pd/infer/deep_eval.py b/deepmd/pd/infer/deep_eval.py index a2f8510f28..d03509da50 100644 --- a/deepmd/pd/infer/deep_eval.py +++ b/deepmd/pd/infer/deep_eval.py @@ -354,6 +354,12 @@ def _eval_model( request_defs: list[OutputVariableDef], ): model = self.dp.to(DEVICE) + + # convert to eval mode + is_training = model.training + if is_training: + model.eval() + prec = NP_PRECISION_DICT[RESERVED_PRECISON_DICT[GLOBAL_PD_FLOAT_PRECISION]] nframes = coords.shape[0] @@ -419,6 +425,11 @@ def _eval_model( results.append( np.full(np.abs(shape), np.nan, dtype=prec) ) # this is kinda hacky + + # restore to training mode if previously enabled + if is_training: + model.train() + return tuple(results) def _eval_model_spin(