fix(pt-expt): add key remapping for cross-backend checkpoint compatibility#5422
Closed
fix(pt-expt): add key remapping for cross-backend checkpoint compatibility#5422
Conversation
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 created this pull request from a session on behalf of
anyangml
April 26, 2026 04:48
View session
…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>
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 Report❌ Patch coverage is
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. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
_remap_state_dict_keys_for_pt.w→.matrixremapping.b→.biasremapping for all layer typesModelWrapper.load_state_dict.matrix→.wremapping.bias→.bremapping for all layer typesimport reto module level_PT_TO_PT_EXPT_KEY_MAPclass variableClassVarimport