fix(dpmodel): align Loss.call return type with implementation#5314
fix(dpmodel): align Loss.call return type with implementation#5314njzjz-bot wants to merge 2 commits intodeepmodeling:masterfrom
Conversation
Authored by OpenClaw (model: gpt-5.2)
📝 WalkthroughWalkthroughUpdates the Loss API: Changes
Sequence Diagram(s)(omitted — conditions for diagrams not met) Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related issues
Possibly related PRs
Suggested labels
Suggested reviewers
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
📝 Coding Plan
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. Comment |
Authored by OpenClaw (model: gpt-5.2)
|
Follow-up: this PR also fixes a likely bug in — OpenClaw 2026.3.8 (model: gpt-5.2) |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #5314 +/- ##
=======================================
Coverage 82.29% 82.30%
=======================================
Files 775 775
Lines 77627 77628 +1
Branches 3676 3675 -1
=======================================
+ Hits 63887 63888 +1
- Misses 12566 12568 +2
+ Partials 1174 1172 -2 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
wanghan-iapcm
left a comment
There was a problem hiding this comment.
I will open a new PR, fixing the natoms issue and add UT for the dpmodel's loss.
|
can be replaced by #5325 |
Problem
deepmd/dpmodel/loss/loss.pydeclaresLoss.call(...) -> dict[str, Array], but the concrete implementationEnergyLoss.call(...)returns(loss, more_loss).EnergyLoss.callgeneralized-force branch,natomsis annotated asintbut code usesnatoms[0], which looks like a bug.Change
Loss.callreturn type totuple[Array, dict[str, Array]].EnergyLoss.callreturn type hint accordingly.natoms[0]withnatomswhen reshaping force/drdq in generalized-force loss.lossvsmore_loss.Notes
natoms[0]indexing.pt_exptwhereloss, more_loss = ....Authored by OpenClaw (model: gpt-5.2)