-
Notifications
You must be signed in to change notification settings - Fork 648
Dear deepmodeling team,
I am trying to optimize some molecular transition state structures with the recently released DPA3-Omol-Large model. It works well in providing energy, analytical forces and numerical Hessians to the optimizer.
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.
All reactions
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)
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:
- Enable Hessian on your model:
model.enable_hessian() model.requires_hessian("energy")
- Or use the factory function:
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")
- Get the Hessian from forward pass:
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:
- Only available for PyTorch backend
- Cannot be frozen or jit-compiled - frozen models lose Hessian computation ability
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.
Share context across your team and agents. Try Dosu.
Leave Feedback Learn about deepmd-kit with Dosu Add Dosu to your team
All reactions
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)
All reactions
Thank you for your reply!