-
|
Dear deepmodeling team, I am trying to optimize some molecular transition state structures with the recently released I noticed that PR #5287 introduced support for calculating the analytical Hessians. However, I couldn't find any related discussion or documentation on how to actually use this feature. Could you please clarify how to invoke the analytical Hessian functionality? Any guidance or pointers to relevant docs/examples would be greatly appreciated. Thank you for your work on DeepMD. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
|
Hi @RA-zoL! I'm Dosu and I’m helping the deepmd-kit team. The analytical Hessian feature is documented here: Fit energy Hessian. To use it with the PyTorch backend:
model.enable_hessian()
model.requires_hessian("energy")
from deepmd.pt.model.model import make_hessian_model
model_hess = make_hessian_model(EnergyModel)(descriptor, fitting, type_map=type_map)
model_hess.requires_hessian("energy")
ret_dict = model_hess.forward_common(coord, atype, box=cell)
ana_hess = ret_dict["hessian"] # or "energy_derv_r_derv_r"There's also a complete test example showing usage. Important limitations:
Regarding DPA3-Omol-Large: The Hessian implementation is descriptor-agnostic and uses PyTorch's automatic differentiation at the model level, so it should theoretically work with DPA3 models. However, I didn't find explicit tests or documentation confirming DPA3 + Hessian compatibility, so you may want to test this or check with the maintainers. To reply, just mention @dosu. How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other |
Beta Was this translation helpful? Give feedback.
-
|
I fixed a bug in #5351. After patching that PR, you could obtain the Hessian with the following script from deepmd.infer import DeepPot
import numpy as np
dp=DeepPot("/home/jzzeng/.cache/deepmd/pretrained/models/DPA3-Omol-Large.pt", no_jit=True)
dp.get_model().enable_hessian()
dp.deep_eval._has_hessian=True
coord = np.array([[1, 0, 0], [0, 0, 1.5], [1, 0, 3]]).reshape([1, -1])
atype = [1, 0, 1]
e, f, v, h = dp.eval(coord, None, atype)
print(h) |
Beta Was this translation helpful? Give feedback.
I fixed a bug in #5351. After patching that PR, you could obtain the Hessian with the following script