Repository navigation
fix(pt): omit absent charge-spin inputs for legacy scripted models - #6052
Zhang-pchao wants to merge 2 commits into
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configuration
📒 Files selected for processing (1)
Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review. 📝 WalkthroughWalkthroughDeepEval and ModelWrapper omit ChangesOptional
Priority: ⬇️ Low Estimated code review effort: 2 (Simple) | ~10 minutes Change: Bug fix Merge Risk: ⚪ Minimal · up to No concrete merge-blocking risk introduced by this change was established. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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 |
njzjz-bot
left a comment
There was a problem hiding this comment.
Agent: dot
Reviewed exact head ae9f255, including the full three-file patch, the native and external-neighbor-list dispatch, the modern model signatures, the energy-loss call path, and existing wrapper tests. No blocking correctness finding.
The compatibility change is consistent across the call sites: ModelWrapper omits only an absent charge_spin value, and both extended-coordinate and edge-schema lower calls do the same. A supplied tensor is retained. The modern EnergyModel/make_model and SeZM signatures default this argument to None, so omission preserves their existing missing-input/default behavior. The legacy fixture regression exercises both native wrapper dispatch and the Vesin lower path and compares energy, force and virial.
Nonblocking test suggestion: separate the native/wrapper compatibility assertion from the Vesin availability mark. Currently, without the optional Vesin dependency the whole new regression is skipped, including the native path. A small wrapper contract test using a legacy scripted signature, plus a modern toy model that asserts it receives the exact supplied charge_spin tensor, would protect both halves of this contract without the optional neighbor-list dependency. The existing wrapper toy accepts charge_spin but discards it, so it does not cover the forwarding guarantee.
Validation limit: this was a source review through the connector; I did not independently execute pytest or reproduce the PR's reported 12 passing tests. At review time the exact-head GitHub Actions runs reported action_required, pre-commit passed, and Read the Docs reported failure.
|
Added a scripted toy model without a |
njzjz-bot
left a comment
There was a problem hiding this comment.
Agent: dot
Reviewed delta ae9f255 → 285932e. No new blocking finding.
The added tests address my earlier suggestion: a TorchScript-compiled legacy model lacks charge_spin and runs through inference, skip-loss, and loss-mediated dispatch without Vesin. The modern toy asserts object identity of the supplied tensor in all three modes. Production code is unchanged.
Validation: full test-file/wrapper source review and Python syntax parsing. PyTorch is unavailable in this review environment, so these tests were not independently executed. Exact-head pre-commit passes, RTD fails, and seven Actions workflows remain action_required.
Summary
Do not pass charge_spin=None to scripted model methods that predate that optional argument. Preserve the keyword when a charge/spin tensor is supplied. Apply the same rule in inference and the model wrapper.
The regression loads the repository's legacy scripted fixture and compares native versus external (vesin) neighbor-list evaluation for energy, forces and virial.
Validation
Based on current master (7a9510d).
pytest -q source/tests/pt/model/test_nlist_backend.py: 12 passed, 7 conditional GPU/backend skips. The new legacy-model regression executed and passed with vesin.Tests used the proposed Python source with the existing compatible PyTorch 2.11 native operators. This is a Python schema-compatibility fix; a full native-backend rebuild was not required for that focused test.
Summary by CodeRabbit
CI follow-up (2026-10-07)
The exact-head Read the Docs build fails while installing
doc/requirements.txt, before Sphinx runs: the selected PyTorch headers require C++20, while the current target baseline selects C++17. The same build-standard mismatch appears on all five related contribution heads (#6051 through #6055). Existing issue #6048 and PR #6049 already address this compatibility problem; this PR leaves that repair in its independent upstream review. The Read the Docs check remains failed until that dependency is resolved and the build is rerun. The exact-head pre-commit.ci check passes; GitHub Actions still require maintainer approval.