-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feat: pairtab model pytorch #174
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you please provide UT for the atomic model?
- check the output energy is as expected. e.g. in the case you have a few atoms in the system you can manually calculate the energy and check if it is consistent with your code.
- check if you code is jitable. see for example
deepmd-pytorch/tests/test_se_e2_a.py
Line 142 in 05c3f9d
def test_jit(
optimized the for loop implementation, checked the calculation locally, going to figure out jit and unittests tomorrow. |
I tested jit with the following code, no error msg
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What would be the behavior of your model
- if the r-range of the input table is smaller than the cut-off distance? is the interaction between the pairs beyond upper bound of the table and smaller than rcut zero?
- if the r-range of the input table is larger than the cut-off distance?
deepmd_pt/model/model/pair_tab.py
Outdated
|
||
atomic_energy = 0.5 * torch.sum(torch.where(nlist != -1, raw_atomic_energy, torch.zeros_like(raw_atomic_energy)) ,dim=-1) | ||
|
||
return {"atomic_energy": atomic_energy} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the key should be "energy", please check your output def.
you may want to use this decorator to ensure the correctness of your atomic model output
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated the key. Not sure about the decorator, this atomic model has no Fitting
|
Migrated from this [PR](dptech-corp/deepmd-pytorch#174). This is to reimplement the PairTab Model in Pytorch. Notes: 1. Different from the tensorflow version, the pytorch version abstracts away all the post energy conversion operations (force, virial). 2. Added extrapolation when `rcut` > `rmax`. The pytorch version overwrite energy beyond extrapolation endpoint to `0`. These features are not available in the tensorflow version. The extrapolation uses a cubic spline form, the 1st order derivation for the starting point is estimated using the last two rows in the user defined table. See example below: ![img_v3_027k_b50c690d-dc2d-4803-bd2c-2e73aa3c73fg](https://github.com/deepmodeling/deepmd-kit/assets/137014849/f3efa4d3-795e-4ff8-acdc-642227f0e19c) ![img_v3_027k_8de38597-ef4e-4e5b-989e-dbd13cc93fag](https://github.com/deepmodeling/deepmd-kit/assets/137014849/493da26d-f01d-4dd0-8520-ea2d84e7b548) ![img_v3_027k_f8268564-3f5d-49e6-91d6-169a61d9347g](https://github.com/deepmodeling/deepmd-kit/assets/137014849/b8ad4d4d-a4a4-40f0-94d1-810006e7175b) ![img_v3_027k_3966ef67-dd5e-4f48-992e-c2763311451g](https://github.com/deepmodeling/deepmd-kit/assets/137014849/27f31e79-13c8-4ce8-9911-b4cc0ac8188c) --------- Co-authored-by: Anyang Peng <aisi_ap@Anyangs-Laptop.local> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
The goal of this PR is to migrate the PairTabModel from TF to PT:
input.json
Notes: