-
Notifications
You must be signed in to change notification settings - Fork 516
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
fix(pt): use eval mode in the Python interface #4404
Conversation
Same as deepmodeling#4402 Signed-off-by: Jinzhe Zeng <[email protected]>
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.
Copilot reviewed 1 out of 1 changed files in this pull request and generated no suggestions.
📝 WalkthroughWalkthroughThe changes in this pull request involve a modification to the Changes
Possibly related PRs
Suggested labels
Suggested reviewers
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
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.
Actionable comments posted: 0
🧹 Outside diff range and nitpick comments (1)
deepmd/pt/infer/deep_eval.py (1)
146-146
: LGTM! Consider adding a comment explaining eval mode.The addition of
self.dp.eval()
is correct and well-placed. This ensures the model is in evaluation mode which is crucial for inference as it disables training-specific behaviors like dropout and batch normalization updates.Consider adding a comment to explain why eval mode is necessary:
+ # Set model to evaluation mode to disable dropout and batch norm updates self.dp.eval()
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (1)
deepmd/pt/infer/deep_eval.py
(1 hunks)
🔇 Additional comments (1)
deepmd/pt/infer/deep_eval.py (1)
Line range hint 67-146
: Verify eval mode is set consistently across all model loading paths.
The model can be loaded either from .pt
or .pth
files. Let's verify that both paths properly handle evaluation mode.
✅ Verification successful
Based on the search results, I can generate the final response as we have sufficient information to verify the eval mode consistency:
Eval mode is set consistently across both model loading paths
The code correctly sets eval mode after model loading for both .pt
and .pth
files. This is evidenced by:
- The final
self.dp.eval()
call is made after both loading paths - The call is made at the same indentation level, ensuring it's executed regardless of which path is taken
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Description: Check if eval() is consistently called after model loading across the codebase
# Search for model loading patterns followed by eval calls
echo "Checking model loading patterns:"
rg -A 5 "torch\.(?:jit\.)?load.*map_location.*DEVICE"
# Search for potential inconsistencies in eval mode usage
echo -e "\nChecking eval mode patterns:"
rg "\.eval\(\)"
Length of output: 3926
Same as #4402
Summary by CodeRabbit
New Features
Bug Fixes