Skip to content

fix(pt-expt): add key remapping for cross-backend checkpoint compatibility#5422

Closed
Copilot wants to merge 3 commits intomasterfrom
copilot/debug-checkpoint-key-issues
Closed

fix(pt-expt): add key remapping for cross-backend checkpoint compatibility#5422
Copilot wants to merge 3 commits intomasterfrom
copilot/debug-checkpoint-key-issues

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 26, 2026

  • Investigate the key mismatch issue with pt_expt checkpoints
  • Add complete key remapping for pt_expt → PT conversion in _remap_state_dict_keys_for_pt
    • Add .w.matrix remapping
    • Add .b.bias remapping for all layer types
  • Add complete key remapping for PT → pt_expt conversion in ModelWrapper.load_state_dict
    • Add .matrix.w remapping
    • Add .bias.b remapping for all layer types
  • Run linting
  • Address code review feedback
    • Move import re to module level
    • Remove unused _PT_TO_PT_EXPT_KEY_MAP class variable
    • Remove unused ClassVar import

Fix checkpoint key mismatches between pt and pt_expt backends during
dptest. The backends use different naming conventions for some buffers:
- pt uses "min_nbor_dist"
- pt_expt uses "_min_nbor_dist"

Add key remapping in both directions:
- pt_expt/train/wrapper.py: remap PT keys to pt_expt format
- pt/infer/deep_eval.py: remap pt_expt keys to PT format

Also add logging of missing/unexpected keys to pt_expt wrapper
for better debugging.

Agent-Logs-Url: https://github.com/deepmodeling/deepmd-kit/sessions/ee9417b6-69d2-497c-81d7-a9afff7c7d6c

Co-authored-by: anyangml <137014849+anyangml@users.noreply.github.com>
Copilot AI and others added 2 commits April 26, 2026 05:18
…mpatibility

Add complete key remapping between PT and pt_expt backends:
- PT uses .matrix/.bias, pt_expt uses .w/.b for layer weights/biases
- PT uses .min_nbor_dist, pt_expt uses ._min_nbor_dist

This allows loading pt_expt checkpoints (.pt files) in PT backend and vice versa.

Agent-Logs-Url: https://github.com/deepmodeling/deepmd-kit/sessions/287e8580-f3ed-4b4e-b31f-1c25935791fd

Co-authored-by: anyangml <137014849+anyangml@users.noreply.github.com>
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 26, 2026

Codecov Report

❌ Patch coverage is 93.33333% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 82.36%. Comparing base (d14233e) to head (22e3535).

Files with missing lines Patch % Lines
deepmd/pt_expt/train/wrapper.py 88.23% 2 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##           master    #5422   +/-   ##
=======================================
  Coverage   82.36%   82.36%           
=======================================
  Files         824      824           
  Lines       87109    87140   +31     
  Branches     4197     4197           
=======================================
+ Hits        71743    71771   +28     
- Misses      14091    14094    +3     
  Partials     1275     1275           

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

@anyangml anyangml closed this Apr 26, 2026
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