deepmodeling / deepmd-kit

A deep learning package for many-body potential energy representation and molecular dynamics
https://docs.deepmodeling.com/projects/deepmd/
GNU Lesser General Public License v3.0
1.41k stars 486 forks source link

[BUG] _Python API Prediction Issue_ #3884

Closed ZhihaoXu0313 closed 2 weeks ago

ZhihaoXu0313 commented 2 weeks ago

Bug summary

After finetunning a DP model, I used "dp --pt test" command to test the performance of the model,. It works well.

But when I use the same model with Python API (dp = DeePot("model.pt"); e, f, v = dp.eval(coord, cell, atype)), I cannot get the accurate prediction, even if I use the same data from the dataset.

DeePMD-kit Version

DeePMD-kit v3.0.0a0

Backend and its version

PyTorch

How did you download the software?

Offline packages

Input Files, Running Commands, Error Log, etc.

See above

Steps to Reproduce

See above

Further Information, Files, and Links

No response

njzjz commented 2 weeks ago

dp test is based on DeepPot.eval, so this behavior seems impossible, or you didn't input the correct data.

https://github.com/deepmodeling/deepmd-kit/blob/ec32340389f614b9a90f1bc07e6b157c8f39b3a6/deepmd/entrypoints/test.py#L329-L338

ZhihaoXu0313 commented 2 weeks ago

Hi! Thanks for your information! I finally find the issue, that is when I do the inference with python, the atype directly read from the dataset is not match with the type_map in input.json for finetunning.

njzjz commented 2 weeks ago

Glad to hear you resolved it and that it is not a bug. It seems to be the same issue as #3020.