Skip to content

fix(dpmodel): preserve virtual atom types in data utilities#5837

Open
njzjz-bot wants to merge 1 commit into
deepmodeling:masterfrom
njzjz-bot:fix/dpmodel-lmdb-virtual-types-5633
Open

fix(dpmodel): preserve virtual atom types in data utilities#5837
njzjz-bot wants to merge 1 commit into
deepmodeling:masterfrom
njzjz-bot:fix/dpmodel-lmdb-virtual-types-5633

Conversation

@njzjz-bot

Copy link
Copy Markdown
Contributor

Fixes #5633

Summary

  • ignore negative virtual atom sentinels when collecting observed species
  • count only configured real types in LMDB natoms vectors while retaining every coordinate slot in nloc
  • share one atom-type remapping helper between training and test readers so negative sentinels survive type-map changes
  • retain explicit NumPy bounds errors for malformed positive atom types

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.py
  • source/tests/common/dpmodel/test_lmdb_data.py
  • 79 tests passed
  • ruff format .
  • ruff check .

Coding agent: Codex
Codex version: codex-cli 0.144.4
Model: gpt-5.6-sol
Reasoning effort: xhigh

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
@dosubot dosubot Bot added the bug label Jul 16, 2026
@coderabbitai

coderabbitai Bot commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

@njzjz-bot, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 3 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: fa4734a6-e90c-4e79-8aeb-1a4c59e35b0d

📥 Commits

Reviewing files that changed from the base of the PR and between 6c3b985 and b4d47b8.

📒 Files selected for processing (4)
  • deepmd/dpmodel/utils/lmdb_data.py
  • deepmd/dpmodel/utils/stat.py
  • source/tests/common/dpmodel/test_lmdb_data.py
  • source/tests/common/dpmodel/test_observed_type.py
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@njzjz

njzjz commented Jul 18, 2026

Copy link
Copy Markdown
Member

Possible reviewers based on changed lines, exact file history, and exact-file review history:

  • @wanghan-iapcm — 4 commits on changed files; 4 reviews on exact changed files (deepmd/dpmodel/utils/lmdb_data.py, deepmd/dpmodel/utils/stat.py, source/tests/common/dpmodel/test_lmdb_data.py).
  • @iProzd — 6 commits on changed files (deepmd/dpmodel/utils/lmdb_data.py, deepmd/dpmodel/utils/stat.py, source/tests/common/dpmodel/test_lmdb_data.py, source/tests/common/dpmodel/test_observed_type.py).

No review request was made automatically.

Coding agent: Codex
Codex version: codex-cli 0.144.4
Model: gpt-5.6-sol
Reasoning effort: xhigh

@njzjz
njzjz requested review from iProzd and wanghan-iapcm July 18, 2026 07:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Code scan] Preserve virtual atom types in dpmodel stat and LMDB utilities

2 participants