Skip to content

Conversation

@anyangml
Copy link
Collaborator

@anyangml anyangml commented Dec 1, 2025

Summary by CodeRabbit

  • Bug Fixes
    • Improved model type detection to also recognize "polarizability" as equivalent to "polar", ensuring models that report polarizability are correctly handled during inference and expanding compatibility with additional model variants.

✏️ Tip: You can customize this high-level summary in your review settings.

Copilot AI review requested due to automatic review settings December 1, 2025 06:45
@github-actions github-actions bot added the Python label Dec 1, 2025
Copilot finished reviewing on behalf of anyangml December 1, 2025 06:48
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes a bug in the PyTorch backend's model type detection by adding support for the "polarizability" output type name. The atomic model returns "polarizability" in its model_output_type(), but the inference code was only checking for "polar", causing polar models to fail type detection.

Key Changes:

  • Updated the model type detection logic to recognize both "polar" and "polarizability" as indicators of a polar model

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review for a chance to win a $100 gift card. Take the survey.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 1, 2025

📝 Walkthrough

Walkthrough

Expanded model-output-type detection to treat strings containing either "polar" or "polarizability" as DeepPolar across three deep evaluation modules.

Changes

Cohort / File(s) Summary
Model type detection expansion
deepmd/pt/infer/deep_eval.py, deepmd/dpmodel/infer/deep_eval.py, deepmd/jax/infer/deep_eval.py
Updated conditional logic so that model output types containing either "polar" or "polarizability" map to the DeepPolar evaluator; no other logic changed.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

  • Same small conditional change applied in three locations — review for consistent string matching and any downstream assumptions.
  • Files to spot-check: the three updated deep_eval.py modules and any tests or callers that pass model_output_type.

Suggested reviewers

  • njzjz
  • wanghan-iapcm

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title references 'model_output_type unify name' which directly matches the core change: unifying handling of 'polarizability' with 'polar' in model type detection across three files.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 44cf67f and 2cf38ea.

📒 Files selected for processing (2)
  • deepmd/dpmodel/infer/deep_eval.py (1 hunks)
  • deepmd/jax/infer/deep_eval.py (1 hunks)
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2024-09-19T04:25:12.408Z
Learnt from: njzjz
Repo: deepmodeling/deepmd-kit PR: 4144
File: source/api_cc/tests/test_deeppot_dpa_pt.cc:166-246
Timestamp: 2024-09-19T04:25:12.408Z
Learning: Refactoring between test classes `TestInferDeepPotDpaPt` and `TestInferDeepPotDpaPtNopbc` is addressed in PR #3905.

Applied to files:

  • deepmd/dpmodel/infer/deep_eval.py
🧬 Code graph analysis (2)
deepmd/jax/infer/deep_eval.py (4)
deepmd/jax/jax2tf/tfmodel.py (1)
  • model_output_type (238-240)
deepmd/jax/jax2tf/serialization.py (1)
  • model_output_type (285-286)
deepmd/jax/model/hlo.py (1)
  • model_output_type (234-236)
deepmd/dpmodel/model/make_model.py (1)
  • model_output_type (184-193)
deepmd/dpmodel/infer/deep_eval.py (4)
deepmd/dpmodel/model/base_model.py (1)
  • model_output_type (99-100)
deepmd/dpmodel/model/spin_model.py (1)
  • model_output_type (271-273)
deepmd/dpmodel/model/make_model.py (1)
  • model_output_type (184-193)
deepmd/pt/model/model/make_model.py (1)
  • model_output_type (90-101)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (29)
  • GitHub Check: Build C++ (rocm, rocm)
  • GitHub Check: Build C library (2.18, libdeepmd_c.tar.gz)
  • GitHub Check: Build C++ (cuda120, cuda)
  • GitHub Check: Build C++ (cuda, cuda)
  • GitHub Check: Build C++ (cpu, cpu)
  • GitHub Check: Build C++ (clang, clang)
  • GitHub Check: Build C library (2.14, >=2.5.0,<2.15, libdeepmd_c_cu11.tar.gz)
  • GitHub Check: Test Python (6, 3.12)
  • GitHub Check: Test Python (5, 3.12)
  • GitHub Check: Test Python (6, 3.9)
  • GitHub Check: Test Python (4, 3.9)
  • GitHub Check: Test Python (1, 3.9)
  • GitHub Check: Test Python (1, 3.12)
  • GitHub Check: Test Python (3, 3.12)
  • GitHub Check: Test Python (5, 3.9)
  • GitHub Check: Test Python (2, 3.12)
  • GitHub Check: Test Python (3, 3.9)
  • GitHub Check: Test Python (4, 3.12)
  • GitHub Check: Test Python (2, 3.9)
  • GitHub Check: Build wheels for cp311-manylinux_x86_64
  • GitHub Check: Build wheels for cp311-manylinux_x86_64
  • GitHub Check: Build wheels for cp311-win_amd64
  • GitHub Check: Build wheels for cp310-manylinux_aarch64
  • GitHub Check: Analyze (python)
  • GitHub Check: Build wheels for cp311-macosx_x86_64
  • GitHub Check: Build wheels for cp311-macosx_arm64
  • GitHub Check: Test C++ (true)
  • GitHub Check: Analyze (c-cpp)
  • GitHub Check: Test C++ (false)
🔇 Additional comments (2)
deepmd/dpmodel/infer/deep_eval.py (1)

130-145: DeepPolar dispatch now correctly covers polarizability outputs

Extending the branch to check for "polarizability" in model_output_type aligns this backend with the others and prevents "Unknown model type" for models whose OUT variable is named "polarizability" instead of "polar". The logic and ordering of the conditions remain consistent and correct.

deepmd/jax/infer/deep_eval.py (1)

151-166: JAX backend model_type resolution is now consistent for polarizability

The added "polarizability" membership alongside "polar" ensures JAX DeepEval routes polarizability models to DeepPolar, matching the dpmodel/pt backends and avoiding spurious "Unknown model type" for these outputs.


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 and usage tips.

@anyangml anyangml requested a review from iProzd December 1, 2025 07:18
@codecov
Copy link

codecov bot commented Dec 1, 2025

Codecov Report

❌ Patch coverage is 33.33333% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 84.28%. Comparing base (bfa6245) to head (2cf38ea).
⚠️ Report is 46 commits behind head on devel.

Files with missing lines Patch % Lines
deepmd/dpmodel/infer/deep_eval.py 0.00% 1 Missing ⚠️
deepmd/jax/infer/deep_eval.py 0.00% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff            @@
##            devel    #5069    +/-   ##
========================================
  Coverage   84.28%   84.28%            
========================================
  Files         708      709     +1     
  Lines       69911    70561   +650     
  Branches     3608     3619    +11     
========================================
+ Hits        58923    59471   +548     
- Misses       9832     9923    +91     
- Partials     1156     1167    +11     

☔ View full report in Codecov by Sentry.
📢 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.

@iProzd
Copy link
Collaborator

iProzd commented Dec 2, 2025

Under what situation will this occur? And are dpmodel and jax also relevant?

@iProzd iProzd added this pull request to the merge queue Dec 3, 2025
Merged via the queue into deepmodeling:devel with commit 2d5fa3c Dec 3, 2025
61 of 64 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants