Skip to content

Conversation

@anyangml
Copy link
Collaborator

@anyangml anyangml commented Dec 1, 2025

Summary by CodeRabbit

Release Notes

  • Bug Fixes
    • Improved model type detection to recognize additional model configurations, including polarizability-based variants. This expands compatibility with a broader range of supported models during inference operations.

✏️ 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

The model type detection logic in the deep evaluation module is modified to expand the conditions for selecting the DeepPolar model. The detection now triggers when the model output type contains either "polar" or "polarizability", whereas previously it only checked for "polar".

Changes

Cohort / File(s) Summary
Model type detection expansion
deepmd/pt/infer/deep_eval.py
Updated DeepPolar model selection condition to recognize both "polar" and "polarizability" in the model output type identifier

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

  • Single file modification with a straightforward condition expansion
  • No new logic density or control flow changes
  • Localized, self-evident change requiring minimal context

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 'Fix: model_output_type unify name' directly addresses the main change: expanding model type detection to handle both 'polar' and 'polarizability' variants, which is a unification of naming conventions for the model_output_type.
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 34f03fc and 44cf67f.

📒 Files selected for processing (1)
  • deepmd/pt/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/pt/infer/deep_eval.py
⏰ 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). (31)
  • GitHub Check: CodeQL analysis (python)
  • GitHub Check: Agent
  • GitHub Check: Test Python (5, 3.9)
  • GitHub Check: Test Python (1, 3.12)
  • GitHub Check: Test Python (5, 3.12)
  • GitHub Check: Test Python (6, 3.12)
  • GitHub Check: Test Python (6, 3.9)
  • GitHub Check: Test Python (1, 3.9)
  • GitHub Check: Test Python (4, 3.9)
  • GitHub Check: Test Python (3, 3.9)
  • GitHub Check: Test Python (4, 3.12)
  • GitHub Check: Test Python (3, 3.12)
  • GitHub Check: Test Python (2, 3.9)
  • GitHub Check: Test Python (2, 3.12)
  • GitHub Check: Analyze (python)
  • GitHub Check: Build C++ (rocm, rocm)
  • GitHub Check: Analyze (c-cpp)
  • GitHub Check: Build C++ (clang, clang)
  • GitHub Check: Build C++ (cpu, cpu)
  • GitHub Check: Build C++ (cuda120, cuda)
  • GitHub Check: Build C++ (cuda, cuda)
  • GitHub Check: Build C library (2.14, >=2.5.0,<2.15, libdeepmd_c_cu11.tar.gz)
  • GitHub Check: Build wheels for cp311-macosx_arm64
  • GitHub Check: Build C library (2.18, libdeepmd_c.tar.gz)
  • GitHub Check: Build wheels for cp311-macosx_x86_64
  • GitHub Check: Build wheels for cp311-manylinux_x86_64
  • GitHub Check: Test C++ (true)
  • GitHub Check: Test C++ (false)
  • GitHub Check: Build wheels for cp311-win_amd64
  • GitHub Check: Build wheels for cp310-manylinux_aarch64
  • GitHub Check: Build wheels for cp311-manylinux_x86_64
🔇 Additional comments (1)
deepmd/pt/infer/deep_eval.py (1)

242-260: The concerns raised about redundancy and ordering bugs are not applicable.

The model_output_type() method returns a List[str], not a string. This means the in operator checks for list membership, not substring matching. Therefore:

  1. The explicit check for "polarizability" alongside "polar" is necessary and correct—they are distinct strings in the output type list that can both exist.
  2. There is no ordering bug with "global_polar" since substring matching does not occur with list membership checks.

The code change is valid: both "polar" and "polarizability" output types should map to DeepPolar.

Likely an incorrect or invalid review comment.


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

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 84.33%. Comparing base (bfa6245) to head (44cf67f).
⚠️ Report is 38 commits behind head on devel.

Additional details and impacted files
@@            Coverage Diff             @@
##            devel    #5069      +/-   ##
==========================================
+ Coverage   84.28%   84.33%   +0.04%     
==========================================
  Files         708      709       +1     
  Lines       69911    70445     +534     
  Branches     3608     3619      +11     
==========================================
+ Hits        58923    59407     +484     
- Misses       9832     9871      +39     
- 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.

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.

1 participant