deepmodeling / abacus-develop

An electronic structure package based on either plane wave basis or numerical atomic orbitals.
http://abacus.ustc.edu.cn
GNU Lesser General Public License v3.0
174 stars 136 forks source link

Can model.ptg trained by deepks be used in another system that is different from training system? #4130

Closed yycx1111 closed 6 months ago

yycx1111 commented 6 months ago

Details

  1. I used the model.ptg trained in the water molecule system in the SCF calculation of GaN and the following error was reported.
  2. Is it true that the model trained by deepks can only be used in the same system?
  3. What is the generalisation ability of deepks model? Can the trained model be used in systems with the same atom types but more atoms or in systems with different atom types?

error message: terminate called after throwing an instance of 'std::runtime_error' what(): The following operation failed in the TorchScript interpreter. Traceback of TorchScript, serialized code (most recent call last): File "code/torch/deepks/model/model.py", line 19, in forward _3 = self.linear _4 = self.input_scale input = torch.div(torch.sub(x, self.input_shift), torch.add(_4, CONSTANTS.c0))


    _5 = (_3).forward(input, )
    _6 = torch.div((_2).forward(input, ), _1)

Traceback of TorchScript, original code (most recent call last):
/opt/miniconda3/lib/python3.9/site-packages/deepks/model/model.py(268): forward
/opt/miniconda3/lib/python3.9/site-packages/torch/nn/modules/module.py(1039): _slow_forward
/opt/miniconda3/lib/python3.9/site-packages/torch/nn/modules/module.py(1051): _call_impl
/opt/miniconda3/lib/python3.9/site-packages/torch/jit/_trace.py(952): trace_module
/opt/miniconda3/lib/python3.9/site-packages/torch/jit/_trace.py(752): trace
/opt/miniconda3/lib/python3.9/site-packages/deepks/model/model.py(314): compile
/opt/miniconda3/lib/python3.9/site-packages/deepks/model/model.py(322): compile_save
/opt/miniconda3/lib/python3.9/site-packages/deepks/iterate/template_abacus.py(139): convert_data
/opt/miniconda3/lib/python3.9/site-packages/deepks/task/task.py(126): execute
/opt/miniconda3/lib/python3.9/site-packages/deepks/task/task.py(88): run
/opt/miniconda3/lib/python3.9/site-packages/deepks/task/workflow.py(49): run
/opt/miniconda3/lib/python3.9/site-packages/deepks/task/workflow.py(49): run
/opt/miniconda3/lib/python3.9/site-packages/deepks/task/workflow.py(49): run
/opt/miniconda3/lib/python3.9/site-packages/deepks/task/workflow.py(87): restart
/opt/miniconda3/lib/python3.9/site-packages/deepks/iterate/iterate.py(349): main
/opt/miniconda3/lib/python3.9/site-packages/deepks/main.py(259): iter_cli
/opt/miniconda3/lib/python3.9/site-packages/deepks/main.py(37): main_cli
/opt/miniconda3/lib/pyt

### Have you read FAQ on the online manual http://abacus.deepmodeling.com/en/latest/community/faq.html

- [X] Yes, I have read the FAQ part on online manual.

### Task list for Issue attackers (only for developers)

- [ ] Understand the problem or question described by the user.
- [ ] Check if the issue is a known problem or has been addressed in the documentation.
- [ ] Test the issue or problem on a similar system or environment, if possible.
- [ ] Identify the root cause or provide clarification on the user's question.
- [ ] Provide a step-by-step guide, including any necessary resources, to resolve the issue or answer the question.
- [ ] If the issue is related to documentation, update the documentation to prevent future confusion (optional).
- [ ] If the issue is related to code, consider implementing a fix or improvement (optional).
- [ ] Review and incorporate any relevant feedback from users or developers.
- [ ] Ensure the user's issue is resolved or their question is answered and close the ticket.
WHUweiqingzhou commented 6 months ago

@ouqi0711 could you have a look?

ouqi0711 commented 6 months ago

In principle, the trained DeePKS model can be applied to systems differ from the training set, as long as they share the same projector file. For point#3, the trained model can be used in systems with the same atom types but more atoms See, for example, https://pubs.acs.org/doi/10.1021/acs.jpcc.3c04703. However, applying the model to systems with different atom types may not yield desired accuracy. Also, as mentioned above, systems that applying the model have to share the same projector file as the training set does.

Note that you may also raise issue about DeePKS at https://github.com/deepmodeling/deepks-kit.

yycx1111 commented 6 months ago

In principle, the trained DeePKS model can be applied to systems differ from the training set, as long as they share the same projector file. For point#3, the trained model can be used in systems with the same atom types but more atoms See, for example, https://pubs.acs.org/doi/10.1021/acs.jpcc.3c04703. However, applying the model to systems with different atom types may not yield desired accuracy. Also, as mentioned above, systems that applying the model have to share the same projector file as the training set does.

Note that you may also raise issue about DeePKS at https://github.com/deepmodeling/deepks-kit.

Thank you very much for your answer.