fix(dpmodel): preserve virtual atom types in data utilities#5837
Conversation
Ignore negative virtual sentinels when collecting observed species and computing per-type LMDB counts. Remap only real atom types so training and test readers retain virtual entries. Add regressions for observed-type statistics, LMDB remapping, atom counts, and malformed positive indices. Coding-Agent: Codex Codex-Version: codex-cli 0.144.4 Model: gpt-5.6-sol Reasoning-Effort: xhigh
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (4)
📝 WalkthroughWalkthroughLMDB atom-type remapping now preserves negative virtual sentinels and validates positive indices. Atom counts and observed-type collection ignore invalid types, with regression tests covering both behaviors. ChangesVirtual atom type handling
Estimated code review effort: 3 (Moderate) | ~20 minutes Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 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 |
|
Possible reviewers based on changed lines, exact file history, and exact-file review history:
No review request was made automatically. Coding agent: Codex |
wanghan-iapcm
left a comment
There was a problem hiding this comment.
LGTM. Correctly preserves negative virtual sentinels through the type remap (previously type_remap[-1] aliased them to the last real species) and avoids the np.bincount crash on negatives, with both LMDB readers now sharing _remap_atom_types. The new tests genuinely fail on pre-fix code (virtual type aliased / included), so they're real regression tests. One minor docstring nit inline.
Coding-Agent: Codex Codex-Version: codex-cli 0.144.6 Model: gpt-5.6-sol Reasoning-Effort: xhigh
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #5837 +/- ##
==========================================
+ Coverage 78.58% 78.62% +0.04%
==========================================
Files 1050 1054 +4
Lines 120637 121762 +1125
Branches 4356 4404 +48
==========================================
+ Hits 94801 95738 +937
- Misses 24278 24456 +178
- Partials 1558 1568 +10 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Fixes #5633
Summary
Why existing tests missed this
The observed-type tests covered valid types and a positive out-of-range index, but never a negative value. That omitted Python negative-index semantics, where
type_map[-1]silently aliases the final real species.The LMDB fixtures generated only type 0 and type 1 atoms. Existing reversed and superset type-map tests therefore exercised remapping without a virtual sentinel, and natoms-vector tests never passed a negative value to
np.bincount. The dpmodel/PyTorch consistency coverage also uses the same LMDB reader on both sides, so it could only confirm a shared result rather than expose this shared bug. Existing virtual-atom model tests construct virtual atoms in memory instead of serializing them through these LMDB/stat utility paths.Validation
source/tests/common/dpmodel/test_observed_type.pysource/tests/common/dpmodel/test_lmdb_data.pyruff format .ruff check .Coding agent: Codex
Codex version: codex-cli 0.144.4
Model: gpt-5.6-sol
Reasoning effort: xhigh
Summary by CodeRabbit