Skip to content

Commit

Permalink
pd: add missing dp.eval() in pd backend (#4488)
Browse files Browse the repository at this point in the history
Switch to eval mode when evaluating model, otherwise `self.training`
will be `True`, backward graph will be created and cause OOM

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

- **New Features**
- Enhanced model evaluation state management to ensure correct behavior
during evaluation.

- **Bug Fixes**
- Improved type consistency in the `normalize_coord` function for better
computational accuracy.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
  • Loading branch information
HydrogenSulfate authored Dec 23, 2024
1 parent 242408d commit 47412da
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
1 change: 1 addition & 0 deletions deepmd/pd/infer/deep_eval.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ def __init__(
else:
# self.dp = paddle.jit.load(self.model_path.split(".json")[0])
raise ValueError(f"Unknown model file format: {self.model_path}!")
self.dp.eval()
self.rcut = self.dp.model["Default"].get_rcut()
self.type_map = self.dp.model["Default"].get_type_map()
if isinstance(auto_batch_size, bool):
Expand Down
2 changes: 1 addition & 1 deletion deepmd/pd/utils/region.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,5 +108,5 @@ def normalize_coord(
"""
icoord = phys2inter(coord, cell)
icoord = paddle.remainder(icoord, paddle.full([], 1.0))
icoord = paddle.remainder(icoord, paddle.full([], 1.0, dtype=icoord.dtype))
return inter2phys(icoord, cell)

0 comments on commit 47412da

Please sign in to comment.