Skip to content

fix(dpmodel): preserve virtual spin atom types#5854

Open
njzjz-bot wants to merge 2 commits into
deepmodeling:masterfrom
njzjz-bot:fix/spinmodel-virtual-types-5663
Open

fix(dpmodel): preserve virtual spin atom types#5854
njzjz-bot wants to merge 2 commits into
deepmodeling:masterfrom
njzjz-bot:fix/spinmodel-virtual-types-5663

Conversation

@njzjz-bot

Copy link
Copy Markdown
Contributor

Closes #5663.

Summary

  • preserve negative placeholder types when creating dense and lower-interface spin partners
  • use one array-API-safe lookup that maps virtual atom types to zero instead of applying Python negative indexing
  • zero placeholder spin displacements, virial corrections, magnetic outputs, and magnetic masks
  • add dense, lower, end-to-end invariance, and Array API strict regressions

Why existing tests missed this

Existing spin consistency tests use only nonnegative real atom types, including their lower-interface ghost atoms. Negative-type tests cover base atomic models and neighbor-list builders, where masking happens before type-dependent work, but not SpinModel preprocessing, which runs earlier. Cross-backend spin tests therefore never supplied a nonzero padded spin or asserted that both the real placeholder and its generated spin partner remained negative.

Validation

  • pytest source/tests/common/dpmodel/test_spin_model_virtual_types.py source/tests/common/dpmodel/test_finetune_spin.py source/tests/common/dpmodel/test_spin_model_legacy_routing.py -q (12 passed)
  • ruff format . (1664 files unchanged on final pass)
  • ruff check . (passed)
  • git diff --check (passed)

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

Keep negative placeholder types and their spin partners virtual through dense
and lower input expansion. Mask type-dependent spin scales and outputs for
placeholders, with NumPy and Array API regression coverage.

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
@codecov

codecov Bot commented Jul 17, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 78.31%. Comparing base (6c3b985) to head (f28b33c).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #5854      +/-   ##
==========================================
- Coverage   78.58%   78.31%   -0.27%     
==========================================
  Files        1050     1050              
  Lines      120637   120641       +4     
  Branches     4356     4354       -2     
==========================================
- Hits        94801    94482     -319     
- Misses      24278    24592     +314     
- Partials     1558     1567       +9     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@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 — 7 commits on changed files; 42 reviews on exact changed files (deepmd/dpmodel/model/spin_model.py).
  • @iProzd — 4 commits on changed files (deepmd/dpmodel/model/spin_model.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 and removed request for iProzd and wanghan-iapcm July 18, 2026 07:26
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 when expanding SpinModel inputs

2 participants