Commit 78b8f01
authored
perf: change order of element-wise op in edge angle update calculations (#4677)
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.
| Metric | Before | After | Improvement |
|------------------------|----------|----------|-------------|
| Peak Memory | 25.0G | 21.4G | -15% |
| Speed (per 100 steps) | 31.27s | 28.9s | +7.7% |
Since this is an element-wise multiply, changing the order of arguments
should not affect the result. The correctness is verified by
`torch.allclose`.
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit
- **Refactor**
- Improved internal calculation order for weighted updates to enhance
code clarity and maintainability, while ensuring the functionality
remains consistent.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->1 parent 0918b22 commit 78b8f01
File tree
2 files changed
+4
-4
lines changed- deepmd
- dpmodel/descriptor
- pt/model/descriptor
2 files changed
+4
-4
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1117 | 1117 | | |
1118 | 1118 | | |
1119 | 1119 | | |
1120 | | - | |
1121 | | - | |
| 1120 | + | |
1122 | 1121 | | |
| 1122 | + | |
1123 | 1123 | | |
1124 | 1124 | | |
1125 | 1125 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
698 | 698 | | |
699 | 699 | | |
700 | 700 | | |
701 | | - | |
702 | | - | |
| 701 | + | |
703 | 702 | | |
| 703 | + | |
704 | 704 | | |
705 | 705 | | |
706 | 706 | | |
| |||
0 commit comments