fix(finetune): warn on descriptor config mismatches - #5549
Conversation
Add shared descriptor configuration comparison helpers for fine-tuning so mismatched settings such as nlayer are reported before selective state dict loading. Reuse the warning path for --use-pretrain-script overwrites and cover PyTorch, Paddle, and pt_expt backends. Authored by OpenClaw (model: custom-chat-jinzhezeng-group/gpt-5.5)
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughTwo new public functions— ChangesDescriptor Mismatch Warning During Fine-Tuning
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Suggested reviewers
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@deepmd/utils/finetune.py`:
- Around line 59-61: The code currently uses None as both a placeholder for
missing keys and for actual None values in configs, causing ambiguity in the
differences list tuples. Create a dedicated sentinel object at the module level
(e.g., _MISSING = object()) and replace all instances where None is used to
represent a missing key with this sentinel instead. This includes the tuple
constructions at lines 59-61 where pretrained_config[key] is None and key is not
in pretrained_config, as well as the similar patterns at lines 69-71 and
104-110, ensuring that actual None config values are distinguished from
genuinely missing keys.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 5d4d3bb8-70ab-4199-93f3-0d086f7f7c73
📒 Files selected for processing (7)
deepmd/pd/train/training.pydeepmd/pd/utils/finetune.pydeepmd/pt/train/training.pydeepmd/pt/utils/finetune.pydeepmd/pt_expt/train/training.pydeepmd/utils/finetune.pysource/tests/common/test_finetune_utils.py
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #5549 +/- ##
==========================================
- Coverage 82.23% 82.20% -0.03%
==========================================
Files 894 898 +4
Lines 102002 103679 +1677
Branches 4276 4435 +159
==========================================
+ Hits 83877 85228 +1351
- Misses 16823 17057 +234
- Partials 1302 1394 +92 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Apply import ordering updates required by pre-commit.ci on PR deepmodeling#5549. Authored by OpenClaw (model: custom-chat-jinzhezeng-group/gpt-5.5)
Use a sentinel for missing descriptor keys so actual None values are reported correctly in finetune configuration mismatch warnings. Add regression coverage for None versus missing values. Authored by OpenClaw (model: custom-chat-jinzhezeng-group/gpt-5.5)
Authored by OpenClaw (model: custom-chat-jinzhezeng-group/gpt-5.5)
njzjz
left a comment
There was a problem hiding this comment.
LGTM — the descriptor-diff logic ignores implicit defaults via normalization with a raw-vs-raw fallback, and the warn calls are guarded by "descriptor" in ... on both sides. Well covered by the new unit tests.
— Opus 4.8
iProzd
left a comment
There was a problem hiding this comment.
LGTM. The latest version addresses the earlier concerns around missing-vs-None handling, symmetric normalization fallback, warning wording, and default-only differences. The shared helper is well scoped and the new tests cover the important descriptor-diff cases.
Summary
--use-pretrain-scriptoverwrites descriptor settings frominput.jsonwith pretrained-model settings.repflow.nlayer/nlayer.This continues the work from the closed Copilot PR #4925, whose source branch has been removed.
Verification
uvx ruff check deepmd/utils/finetune.py deepmd/pt/utils/finetune.py deepmd/pd/utils/finetune.py deepmd/pt/train/training.py deepmd/pd/train/training.py deepmd/pt_expt/train/training.py source/tests/common/test_finetune_utils.pyPYTHONPATH="$PWD" uvx pytest -q source/tests/common/test_finetune_utils.pypython3 -m compileall -q deepmd/utils/finetune.py deepmd/pt/utils/finetune.py deepmd/pd/utils/finetune.py deepmd/pt/train/training.py deepmd/pd/train/training.py deepmd/pt_expt/train/training.py source/tests/common/test_finetune_utils.pyFixes #4848
Authored by OpenClaw (model: custom-chat-jinzhezeng-group/gpt-5.5)
Summary by CodeRabbit
New Features
trainablefield, reporting the relevant nested differences (with normalization when available).Tests
Nonevs missing descriptor fields.