-
Notifications
You must be signed in to change notification settings - Fork 584
perf: change order of element-wise op in edge angle update calculations #4677
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
Conversation
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.
Pull Request Overview
This PR optimizes memory usage and speed by changing the order of element-wise multiplications in the calculation of weighted edge angle updates.
- Reorders multiplication operations so that the larger matrix is multiplied last.
- Applies the change in both PyTorch and NumPy code paths in separate files.
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| deepmd/pt/model/descriptor/repflow_layer.py | Reorders multiplication order to optimize memory usage in PyTorch code. |
| deepmd/dpmodel/descriptor/repflows.py | Reorders multiplication order to optimize memory usage in NumPy code. |
📝 WalkthroughWalkthroughThe modifications reorder the multiplication factors in the computation of Changes
Suggested labels
Suggested reviewers
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (2)
⏰ Context from checks skipped due to timeout of 90000ms (7)
🔇 Additional comments (2)
✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 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 (
|
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## devel #4677 +/- ##
=======================================
Coverage 84.80% 84.80%
=======================================
Files 692 692
Lines 66396 66396
Branches 3539 3538 -1
=======================================
Hits 56306 56306
Misses 8949 8949
Partials 1141 1141 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Similar changes of #4677 Brings +5% speed up compared with #4687 <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **Refactor** - Adjusted the order of operations in update calculations to enhance clarity while maintaining the same functional outcomes. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
This PR changes the order of element-wise multiply when calculating
weighted_edge_angle_update. The largest matrix should be calculated last to avoid saving large intermediate results and unnecessary broadcast.I've tested this PR on OMat with 9 DPA-3 layers and batch size=auto:512.
Since this is an element-wise multiply, changing the order of arguments should not affect the result. The correctness is verified by
torch.allclose.Summary by CodeRabbit