Skip to content
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

[BUG] PT: rcut cannot be int #3974

Closed
njzjz opened this issue Jul 13, 2024 · 1 comment · Fixed by #4222
Closed

[BUG] PT: rcut cannot be int #3974

njzjz opened this issue Jul 13, 2024 · 1 comment · Fixed by #4222
Assignees
Milestone

Comments

@njzjz
Copy link
Member

njzjz commented Jul 13, 2024

Bug summary

When rcut is an int, an error throws: Expected a value of type 'float' for argument 'rcut' but instead found type 'int'.

DeePMD-kit Version

b86165d

Backend and its version

PyTorch 2.1.2.post300

How did you download the software?

Built from source

Input Files, Running Commands, Error Log, etc.

  File "/home/jz748/codes/deepmd-kit/deepmd/pt/utils/neighbor_stat.py", line 137, in __init__
    self.op = torch.jit.script(op)
  File "/home/jz748/anaconda3/lib/python3.10/site-packages/torch/jit/_script.py", line 1324, in script
    return torch.jit._recursive.create_script_module(
  File "/home/jz748/anaconda3/lib/python3.10/site-packages/torch/jit/_recursive.py", line 559, in create_script_module
    return create_script_module_impl(nn_module, concrete_type, stubs_fn)
  File "/home/jz748/anaconda3/lib/python3.10/site-packages/torch/jit/_recursive.py", line 636, in create_script_module_impl
    create_methods_and_properties_from_stubs(
  File "/home/jz748/anaconda3/lib/python3.10/site-packages/torch/jit/_recursive.py", line 469, in create_methods_and_properties_from_stubs
    concrete_type._create_methods_and_properties(
RuntimeError:

extend_coord_with_ghosts(Tensor coord, Tensor atype, Tensor? cell, float rcut, Tensor? cell_cpu=None) -> ((Tensor, Tensor, Tensor)):
Expected a value of type 'float' for argument 'rcut' but instead found type 'int'.
:
  File "/home/jz748/codes/deepmd-kit/deepmd/pt/utils/neighbor_stat.py", line 79
        nloc = coord.shape[1]
        coord = coord.view(nframes, nloc * 3)
        extend_coord, extend_atype, _ = extend_coord_with_ghosts(
                                        ~~~~~~~~~~~~~~~~~~~~~~~~ <--- HERE
            coord, atype, cell, self.rcut
        )

Steps to Reproduce

cd examples/water/se_e2_a

In input.json, change "rcut": 6.00 to "rcut": 6.

dp --pt train input.json

Further Information, Files, and Links

No response

@njzjz njzjz added the bug label Jul 13, 2024
@njzjz
Copy link
Member Author

njzjz commented Jul 13, 2024

As it looks like a bug from PyTorch, I submit to pytorch/pytorch#130682.

@njzjz njzjz added the upstream label Jul 13, 2024
@iProzd iProzd self-assigned this Sep 26, 2024
@iProzd iProzd moved this to mustfix in DeePMD-kit V3.0.0 RC Sep 26, 2024
@njzjz njzjz added this to the v3.0.0 milestone Sep 26, 2024
@iProzd iProzd linked a pull request Oct 16, 2024 that will close this issue
github-merge-queue bot pushed a commit that referenced this issue Oct 23, 2024
Fix #3974.

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

- **New Features**
- Improved type consistency for neighbor statistics calculations by
ensuring the `rcut` and `rcut_smth` parameters are always floats.
- Enhanced handling of input parameters in various descriptor classes
for better robustness.

- **Bug Fixes**
- Enhanced performance and reliability of neighbor statistics operations
through constructor updates.

- **Documentation**
	- Updated method signatures for clarity and consistency.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
@njzjz njzjz closed this as completed Oct 24, 2024
@github-project-automation github-project-automation bot moved this from mustfix to Done in DeePMD-kit V3.0.0 RC Oct 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Development

Successfully merging a pull request may close this issue.

2 participants