Skip to content

Commit

Permalink
fix(pt): build nlist faster with torch.amax (#3826)
Browse files Browse the repository at this point in the history
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

- **Performance Improvements**
- Enhanced the performance of coordinate extension in neighbor lists by
optimizing internal computations.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
  • Loading branch information
iProzd authored May 28, 2024
1 parent 3f6e511 commit eb1dd1d
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion deepmd/pt/utils/nlist.py
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ def extend_coord_with_ghosts(
# +1: central cell
nbuff = torch.ceil(rcut / to_face).to(torch.long)
# 3
nbuff = torch.max(nbuff, dim=0, keepdim=False).values
nbuff = torch.amax(nbuff, dim=0) # faster than torch.max
nbuff_cpu = nbuff.cpu()
xi = torch.arange(-nbuff_cpu[0], nbuff_cpu[0] + 1, 1, device="cpu")
yi = torch.arange(-nbuff_cpu[1], nbuff_cpu[1] + 1, 1, device="cpu")
Expand Down

0 comments on commit eb1dd1d

Please sign in to comment.