-
Notifications
You must be signed in to change notification settings - Fork 525
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
[WIP] Add dpa1 + lammps inference #4556
base: devel
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,6 +19,7 @@ | |
prod_env_mat, | ||
) | ||
from deepmd.pd.utils import ( | ||
decomp, | ||
env, | ||
) | ||
from deepmd.pd.utils.env import ( | ||
|
@@ -615,8 +616,14 @@ def compute_input_stats( | |
self.stats = env_mat_stat.stats | ||
mean, stddev = env_mat_stat() | ||
if not self.set_davg_zero: | ||
paddle.assign(paddle.to_tensor(mean).to(device=env.DEVICE), self.mean) # pylint: disable=no-explicit-dtype | ||
paddle.assign(paddle.to_tensor(stddev).to(device=env.DEVICE), self.stddev) # pylint: disable=no-explicit-dtype | ||
paddle.assign( | ||
paddle.to_tensor(mean, dtype=self.mean.dtype).to(device=env.DEVICE), | ||
self.mean, | ||
) # pylint: disable=no-explicit-dtype | ||
paddle.assign( | ||
paddle.to_tensor(stddev, dtype=self.stddev.dtype).to(device=env.DEVICE), | ||
self.stddev, | ||
) # pylint: disable=no-explicit-dtype | ||
|
||
def get_stats(self) -> dict[str, StatItem]: | ||
"""Get the statistics of the descriptor.""" | ||
|
@@ -744,7 +751,7 @@ def forward( | |
"Compressed environment is not implemented yet." | ||
) | ||
else: | ||
if rr.numel() > 0: | ||
if decomp.numel(rr) > 0: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💡 Codebase verification Revert to using direct tensor.numel() method The
🔗 Analysis chainVerify behavior of decomp.numel matches tensor.numel. The change from 🏁 Scripts executedThe following scripts were executed for the analysis: Script: #!/bin/bash
# Description: Verify the behavior of decomp.numel
# Search for other usages of numel to ensure consistency
# Check implementation of decomp.numel
rg -A 5 "def numel" "deepmd/pd/utils/decomp.py"
# Check other usages of numel in the codebase
rg "\.numel\(\)" "deepmd/pd/"
Length of output: 555 |
||
rr = rr * mm.unsqueeze(2).astype(rr.dtype) | ||
ss = rr[:, :, :1] | ||
if self.compress: | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -131,7 +131,8 @@ | |
if paddle.in_dynamic_mode(): | ||
return np.prod(x.shape) | ||
|
||
return paddle.numel(x) | ||
return True | ||
# return paddle.numel(x) | ||
Comment on lines
+134
to
+135
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Critical: The The function now returns
Consider this alternative implementation: def numel(x: paddle.Tensor) -> int:
if paddle.in_dynamic_mode():
return np.prod(x.shape)
- return True
+ return paddle.numel(x)
|
||
|
||
|
||
# alias for decomposed functions for convinience | ||
|
Original file line number | Diff line number | Diff line change | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -7,6 +7,7 @@ | |||||||||||||||||
import paddle | ||||||||||||||||||
|
||||||||||||||||||
from deepmd.pd.utils import ( | ||||||||||||||||||
decomp, | ||||||||||||||||||
env, | ||||||||||||||||||
) | ||||||||||||||||||
from deepmd.pd.utils.region import ( | ||||||||||||||||||
|
@@ -97,7 +98,7 @@ def build_neighbor_list( | |||||||||||||||||
nall = coord.shape[1] // 3 | ||||||||||||||||||
# fill virtual atoms with large coords so they are not neighbors of any | ||||||||||||||||||
# real atom. | ||||||||||||||||||
if coord.numel() > 0: | ||||||||||||||||||
if decomp.numel(coord) > 0: | ||||||||||||||||||
xmax = paddle.max(coord) + 2.0 * rcut | ||||||||||||||||||
else: | ||||||||||||||||||
xmax = paddle.zeros([], dtype=coord.dtype).to(device=coord.place) + 2.0 * rcut | ||||||||||||||||||
Comment on lines
+101
to
104
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Bug: Condition will always evaluate to True. Due to changes in Use direct tensor size check: - if decomp.numel(coord) > 0:
+ if coord.shape[1] > 0:
xmax = paddle.max(coord) + 2.0 * rcut
else:
xmax = paddle.zeros([], dtype=coord.dtype).to(device=coord.place) + 2.0 * rcut 📝 Committable suggestion
Suggested change
|
||||||||||||||||||
|
@@ -240,7 +241,7 @@ def build_directional_neighbor_list( | |||||||||||||||||
nall_neig = coord_neig.shape[1] // 3 | ||||||||||||||||||
# fill virtual atoms with large coords so they are not neighbors of any | ||||||||||||||||||
# real atom. | ||||||||||||||||||
if coord_neig.numel() > 0: | ||||||||||||||||||
if decomp.numel(coord_neig) > 0: | ||||||||||||||||||
xmax = paddle.max(coord_cntl) + 2.0 * rcut | ||||||||||||||||||
else: | ||||||||||||||||||
xmax = ( | ||||||||||||||||||
|
Large diffs are not rendered by default.
Large diffs are not rendered by default.
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.
🛠️ Refactor suggestion
Remove commented-out debug code.
Debug code should not be committed to production, even if commented out.