You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This pull request updates the `build_neighbor_list` function in
`deepmd/pt/utils/nlist.py` to improve its performance and correctness
when selecting neighbors. The key change involves replacing `torch.sort`
with `torch.topk` to optimize the selection of the nearest neighbors.
<details><summary>Details</summary>
<p>
Before: 16.4ms
<img width="495" alt="image"
src="https://github.com/user-attachments/assets/e6b0c091-b11b-491a-b2fd-e0aadc6c35ba"
/>
After: 3.4ms
<img width="303" alt="image"
src="https://github.com/user-attachments/assets/81931c76-60eb-46a5-9934-0d837b954df9"
/>
Step time goes from 212.5ms to 200.5ms, ~5% speed-up.
</p>
</details>
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit
- **Refactor**
- Enhanced efficiency and clarity in neighbor selection, improving
performance in identifying closest neighbors while maintaining the same
user experience.
- **Tests**
- Improved reliability of neighbor list tests by validating neighbor
sets regardless of order.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
---------
Signed-off-by: Chun Cai <[email protected]>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Copilot <[email protected]>
0 commit comments