Skip to content

fix(finetune): ignore runtime-only descriptor options in warnings - #6088

Open
SiyuanChenToDo wants to merge 2 commits into
deepmodeling:masterfrom
SiyuanChenToDo:fix/finetune-ignore-seed
Open

SiyuanChenToDo wants to merge 2 commits into
deepmodeling:masterfrom
SiyuanChenToDo:fix/finetune-ignore-seed

Conversation

@SiyuanChenToDo

@SiyuanChenToDo SiyuanChenToDo commented Oct 19, 2026 •

Copy link
Copy Markdown

Summary

descriptor.seed and descriptor.use_amp are runtime-only options. seed
only selects the RNG used when a module is first constructed, and use_amp
only selects the autocast execution policy. Neither is a loaded parameter:
the DPA4C serializer deliberately omits use_amp from the checkpoint, and the
pt / pt_expt modules store it as a Python bool that load_state_dict does not
restore. Changing either value therefore does not change which pretrained
weights are reusable, but warn_configuration_mismatch_during_finetune
reported them as incompatible descriptor changes.

This adds seed and use_amp to _IGNORED_DESCRIPTOR_KEYS next to
trainable, and adds a regression test covering both runtime-only
differences.

Fixes #6038

Duplicate-work check

  • gh issue view 6038 --repo deepmodeling/deepmd-kit --comments: no linked PR
    or assignment.
  • gh pr list --repo deepmodeling/deepmd-kit --state open --search "6038":
    no results.
  • gh pr list --repo deepmodeling/deepmd-kit --state open --search "finetune seed":
    no results.

Verification

  • pytest source/tests/common/test_finetune_utils.py — 16 passed.
  • ruff check deepmd/utils/finetune.py source/tests/common/test_finetune_utils.py
    — passed.
  • ruff format --check deepmd/utils/finetune.py source/tests/common/test_finetune_utils.py — passed.
  • Reverting the ignore entry for seed or use_amp makes the corresponding
    regression case fail, confirming the test exercises both cases.

AI assistance

This change was prepared with AI assistance (Claude Code). I reviewed the diff,
ran the commands above, and can explain and defend the change.

Summary by CodeRabbit

  • Bug Fixes
    • Fine-tuning configuration checks no longer report descriptor mismatches when settings differ only in seed or use_amp. These fields are treated like trainable when comparing descriptor configurations.

`descriptor.seed` only controls the RNG used when a module is first constructed; it is not loaded from the pretrained checkpoint. Reporting it as an incompatible descriptor change is misleading. Add it to the ignored descriptor keys and cover the warning path with a regression test.

Fixes deepmodeling#6038

Co-Authored-By: Claude Code <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 472853a2-7e99-488a-8b9c-4e8a13abc6e2
📥 Commits

Reviewing files that changed from the base of the PR and between a80bcf1 and 0eab67c.

📒 Files selected for processing: 2
  • deepmd/utils/finetune.py
  • source/tests/common/test_finetune_utils.py

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 6 remain after this review.

📝 Walkthrough

Descriptor mismatch reporting now ignores differences in seed and use_amp, in addition to trainable. A regression test checks that differences in seed and use_amp do not produce warnings when normalization is bypassed.

Changes: Descriptor mismatch reporting

Layer / File(s) Summary
Ignore selected descriptor settings
deepmd/utils/finetune.py, source/tests/common/test_finetune_utils.py
The ignored descriptor keys now include seed and use_amp. A regression test verifies that differences in both settings do not produce warnings when normalization is bypassed.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix · Severity of issue fixed: Low

Suggested reviewers: outisli

Merge Risk: ⚪ Minimal · up to 0eab6

The change suppresses mismatch warnings for runtime-only descriptor settings; the inspected loading path confirms that use_amp does not affect pretrained parameter compatibility. No concrete merge-blocking issue was identified.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 3 functions across 2 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Linked Issues check Passed Issue #6038 requires descriptor.seed to be ignored during descriptor mismatch comparison. deepmd/utils/finetune.py adds seed to _IGNORED_DESCRIPTOR_KEYS. The regression test compares `seed=Non…
Out of Scope Changes check Passed The change also ignores use_amp. The PR identifies use_amp as another runtime-only descriptor option, applies it through the same mismatch filter, and tests it with False versus True. This cha…
Title check Passed The title clearly and concisely describes the main change: excluding runtime-only descriptor options from fine-tuning warnings.
Full details: Linked Issues check

Explanation

Issue #6038 requires descriptor.seed to be ignored during descriptor mismatch comparison. deepmd/utils/finetune.py adds seed to _IGNORED_DESCRIPTOR_KEYS. The regression test compares seed=None with seed=42 and asserts that no warning is logged. The linked issue coding requirement is met.

Full details: Out of Scope Changes check

Explanation

The change also ignores use_amp. The PR identifies use_amp as another runtime-only descriptor option, applies it through the same mismatch filter, and tests it with False versus True. This change has a direct connection to the descriptor warning behavior. The diff contains no demonstrated unrelated change.

  • Fix all pre-merge checks with AI
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

@njzjz-bot njzjz-bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed exact head a80bcf1. I found no blocking defect in the seed-only change: both warning entry points share the filtered comparison, structural differences still warn, and the PyTorch pretrained-tensor copy does not depend on this warning.

One nonblocking scope clarification: #6038 also explicitly requests ignoring use_amp (#6038 (comment)). An otherwise-identical DPA4C descriptor with use_amp=False versus True still emits the incompatibility warning at this head. The DPA4C serializer documents that this is execution policy rather than learned model state. Since this PR says “Fixes #6038”, please either cover that requested case with a regression test or keep the issue open to track it. This is a remaining pre-existing case, not a new regression introduced by this patch.

Validation: 5 repository tests run against AST-extracted comparison/warning functions, plus 25 focused probes, passed. Those cover None/integer/list/missing seed values, fallback after normalization failure, structural warning retention, unchanged inputs, both warning entry points, and a countercheck with the old ignored-key set. These are isolated tests; the full normalization and backend training suites were not run here. Test Python and the other normal GitHub Actions runs currently show action_required, so this is not a full CI pass.

Agent: dot

`seed` and `use_amp` are initialization and execution policies, not loaded parameters. Extend the ignored descriptor keys and cover both cases in the regression test.

Fixes deepmodeling#6038

Co-Authored-By: Claude Code <noreply@anthropic.com>

@njzjz-bot njzjz-bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-reviewed the delta from a80bcf1 to 0eab67c. This addresses the use_amp case from my earlier review: the shared descriptor comparison now ignores both runtime-only options, and the regression checks each one independently. The DPA4C serializer and PyTorch experimental wrapper confirm that use_amp controls autocast execution rather than checkpoint parameters.

No blocking findings in this delta. Validation: 5 selected repository tests against AST-extracted exact-source comparison/warning functions plus 40 focused probes passed (45 total). These cover both warning entry points, missing values, normalization-failure fallback, unchanged input dictionaries, retention of real shape/precision differences, and counterchecks showing the updated regression fails if either ignore entry is removed.

These are isolated tests; full normalization and backend training suites were not run here. Normal GitHub Actions workflows, including Test Python, still report action_required at this head, so this does not establish a full CI pass.

Agent: dot

@SiyuanChenToDo SiyuanChenToDo changed the title fix(finetune): ignore descriptor seed in mismatch warnings fix(finetune): ignore runtime-only descriptor options in warnings Oct 19, 2026

This branch has not been deployed

No deployments
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.

Fine-tune descriptor mismatch warning should ignore seed

2 participants