Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Aug 28, 2025

Fix #3672.

Fixes backend conversion issues for dipole models when using the sel_type parameter. The dp convert-backend command was failing due to missing serialization support for None networks and incomplete dipole fitting serialization.

  • Fix NetworkCollection serialization to handle None networks
  • Add missing @variables dictionary for DipoleFittingSeA PyTorch compatibility
  • Include sel_type in serialized data for proper backend conversion
  • Fix TF fitting deserialization to skip None networks
  • Add comprehensive tests for sel_type parameter
  • Remove duplicate test classes and merge parameterized tests
  • Clean up accidentally committed test output files
  • Refactor additional_data property to return dictionary directly
  • Resolve merge conflicts in .gitignore after rebase

All tests pass and the dp convert-backend command now works for dipole models with sel_type parameter. The branch has been successfully rebased against the latest devel branch with all conflicts resolved.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Co-authored-by: njzjz <9496702+njzjz@users.noreply.github.com>
@njzjz
Copy link
Member

njzjz commented Aug 28, 2025

@copilot continue your work.

Copilot AI and others added 2 commits August 28, 2025 18:31
- Fixed NetworkCollection serialization to handle None networks properly
- Added missing @variables and sel_type to DipoleFittingSeA serialization
- All tests pass and backend conversion works successfully
- Fixes #3672

Co-authored-by: njzjz <9496702+njzjz@users.noreply.github.com>
Co-authored-by: njzjz <9496702+njzjz@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Aug 28, 2025

@copilot continue your work.

Work completed! Successfully fixed the dipole model backend conversion issue. The changes handle None networks in NetworkCollection serialization and add missing fields to DipoleFittingSeA. All tests pass and the dp convert-backend command now works for dipole models with sel_type parameter. Commit c392871

Copilot AI changed the title [WIP] [BUG] Cannot convert dipole model from TF to PT fix: handle None networks in dipole model backend conversion Aug 28, 2025
Copilot AI and others added 2 commits August 28, 2025 18:43
Co-authored-by: njzjz <9496702+njzjz@users.noreply.github.com>
Co-authored-by: njzjz <9496702+njzjz@users.noreply.github.com>
Copilot AI requested a review from njzjz August 28, 2025 18:45
@njzjz
Copy link
Member

njzjz commented Aug 30, 2025

@copilot please add tests for sel_type to tests/consistent/fitting/test_dipole.py. Make sure the tests can be passed.

- Add TestDipoleSelType class for cross-backend consistency testing with sel_type=[0,1]
- Add TestDipoleSelTypeBehavior class with specific sel_type functionality tests:
  * test_tf_sel_type_all_types: verify TF dipole fitting with all types selected
  * test_tf_sel_type_partial: verify TF dipole fitting with partial type selection
  * test_dp_exclude_types_behavior: verify DP dipole fitting exclude_types behavior
  * test_serialization_with_excluded_types: verify sel_type is properly stored
  * test_network_collection_none_handling: verify NetworkCollection handles None networks
- Fix TF fitting.py to handle None networks in deserialization (skip instead of assert)
- All tests pass and verify the sel_type bug fix works correctly

Co-authored-by: njzjz <9496702+njzjz@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Aug 30, 2025

@copilot please add tests for sel_type to tests/consistent/fitting/test_dipole.py. Make sure the tests can be passed.

Added comprehensive tests for sel_type parameter in tests/consistent/fitting/test_dipole.py:

  • TestDipoleSelType class: Cross-backend consistency testing with sel_type=[0,1]
  • TestDipoleSelTypeBehavior class: Specific sel_type functionality tests including:
    • TF dipole fitting with all/partial type selection
    • DP dipole fitting exclude_types behavior verification
    • NetworkCollection None handling
    • Serialization behavior with excluded types

All tests pass and verify the sel_type bug fix works correctly. Also fixed TF fitting deserialization to properly handle None networks. Commit b9e5bed

Copilot AI changed the title fix: handle None networks in dipole model backend conversion fix: handle None networks in dipole model backend conversion and add comprehensive tests Aug 30, 2025
… sel_type

Co-authored-by: njzjz <9496702+njzjz@users.noreply.github.com>
Copilot AI requested a review from njzjz August 30, 2025 15:00
@njzjz njzjz marked this pull request as ready for review August 30, 2025 18:02
Copilot AI review requested due to automatic review settings August 30, 2025 18:02
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 backend conversion issues for dipole models when using the sel_type parameter, addressing issue #3672. The dp convert-backend command was failing due to incomplete serialization support for dipole fitting configurations.

  • Enhances NetworkCollection to handle None networks in serialization and deserialization
  • Adds missing serialization components to DipoleFittingSeA for PyTorch compatibility
  • Implements proper handling of selective type fitting during backend conversion

Reviewed Changes

Copilot reviewed 4 out of 5 changed files in this pull request and generated 4 comments.

File Description
deepmd/dpmodel/utils/network.py Enhanced NetworkCollection to serialize None networks and skip completeness checks when networks contain None values
deepmd/tf/fit/dipole.py Added missing @variables dictionary and sel_type serialization for proper backend conversion
deepmd/tf/fit/fitting.py Modified deserialization to skip None networks instead of asserting failure
source/tests/consistent/fitting/test_dipole.py Added parameterized testing for sel_type parameter and custom test method for TF consistency

@codecov
Copy link

codecov bot commented Aug 30, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 84.28%. Comparing base (581bcb6) to head (76bac9a).
⚠️ Report is 65 commits behind head on devel.

Additional details and impacted files
@@           Coverage Diff           @@
##            devel    #4934   +/-   ##
=======================================
  Coverage   84.28%   84.28%           
=======================================
  Files         705      705           
  Lines       69058    69064    +6     
  Branches     3573     3573           
=======================================
+ Hits        58204    58211    +7     
+ Misses       9714     9713    -1     
  Partials     1140     1140           

☔ 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.

Co-authored-by: njzjz <9496702+njzjz@users.noreply.github.com>
Copilot AI requested a review from njzjz August 31, 2025 06:03
@njzjz njzjz requested a review from anyangml September 2, 2025 08:41
@njzjz
Copy link
Member

njzjz commented Sep 2, 2025

@copilot resolve conflicts.

Copy link
Contributor Author

Copilot AI commented Sep 2, 2025

@copilot resolve conflicts.

Conflicts resolved! Successfully rebased the branch against the latest devel branch. The merge conflict in .gitignore has been fixed by properly combining both the test output file patterns and training/model output file patterns. The branch is now up-to-date and ready for merging. (Commit 4963430)

Copilot AI requested a review from njzjz September 2, 2025 08:52
Signed-off-by: Jinzhe Zeng <jinzhe.zeng@ustc.edu.cn>
@njzjz njzjz enabled auto-merge September 2, 2025 09:20
@njzjz njzjz added this pull request to the merge queue Sep 2, 2025
Merged via the queue into devel with commit ea7f828 Sep 2, 2025
60 checks passed
@njzjz njzjz deleted the copilot/fix-3672 branch September 2, 2025 14:28
ChiahsinChu pushed a commit to ChiahsinChu/deepmd-kit that referenced this pull request Dec 17, 2025
…ing#4934)

Fix deepmodeling#3672.

Fixes backend conversion issues for dipole models when using the
`sel_type` parameter. The `dp convert-backend` command was failing due
to missing serialization support for `None` networks and incomplete
dipole fitting serialization.

- [x] Fix NetworkCollection serialization to handle `None` networks
- [x] Add missing `@variables` dictionary for DipoleFittingSeA PyTorch
compatibility
- [x] Include `sel_type` in serialized data for proper backend
conversion
- [x] Fix TF fitting deserialization to skip `None` networks
- [x] Add comprehensive tests for `sel_type` parameter
- [x] Remove duplicate test classes and merge parameterized tests
- [x] Clean up accidentally committed test output files
- [x] Refactor additional_data property to return dictionary directly
- [x] Resolve merge conflicts in .gitignore after rebase

All tests pass and the `dp convert-backend` command now works for dipole
models with `sel_type` parameter. The branch has been successfully
rebased against the latest devel branch with all conflicts resolved.

<!-- START COPILOT CODING AGENT TIPS -->
---

✨ Let Copilot coding agent [set things up for
you](https://github.com/deepmodeling/deepmd-kit/issues/new?title=✨+Set+up+Copilot+instructions&body=Configure%20instructions%20for%20this%20repository%20as%20documented%20in%20%5BBest%20practices%20for%20Copilot%20coding%20agent%20in%20your%20repository%5D%28https://gh.io/copilot-coding-agent-tips%29%2E%0A%0A%3COnboard%20this%20repo%3E&assignees=copilot)
— coding agent works faster and does higher quality work when set up for
your repo.

---------

Signed-off-by: Jinzhe Zeng <jinzhe.zeng@ustc.edu.cn>
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: njzjz <9496702+njzjz@users.noreply.github.com>
Co-authored-by: Jinzhe Zeng <jinzhe.zeng@ustc.edu.cn>
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.

[BUG] Cannot convert dipole model from TF to PT

5 participants