Skip to content

docs(skills): add structured DPA4 workflow support - #5961

Open
SchrodingersCattt wants to merge 38 commits into
deepmodeling:masterfrom
SchrodingersCattt:docs/add-deepmd-dpa4-skill
Open

SchrodingersCattt wants to merge 38 commits into
deepmodeling:masterfrom
SchrodingersCattt:docs/add-deepmd-dpa4-skill

Conversation

@SchrodingersCattt

@SchrodingersCattt SchrodingersCattt commented Aug 7, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • add a dedicated deepmd-finetune-dpa4 skill while preserving deepmd-finetune-dpa3
  • add progressive DPA4/SeZM and DPA4C guidance to deepmd-train
  • document .pt, .pt2, .pth, and .pb inference artifact routing
  • add model deployment, freeze-time policy, same-node export, and explicit atom-type mapping guidance to lammps-deepmd
  • update the Agent Skills index and focused regression tests

Design

The skills remain organized by user workflow rather than adding one umbrella DPA4 skill. Checkpoint routing is based on stored model metadata instead of filenames. DPA4/SeZM guidance covers PyTorch training and fine-tuning, LoRA, held-out evaluation, .pt2 export, Python inference, and LAMMPS deployment. DPA4C guidance covers the public PyTorch Exportable training, freeze, compression, export-time inference policy, and LAMMPS deployment contracts.

The changed skills contain no MatMaster, Bohrium, private image, private library path, or platform-specific helper dependency.

Validation

  • python -m pytest -q -p no:cacheprovider source/tests/common/test_agent_skills.py: 15 passed, 1 skipped; the skipped normalization test requires a built DeePMD checkout
  • python -m black --check source/tests/common/test_agent_skills.py
  • git diff --check
  • focused tests cross-check DPA4C export variables against doc/model/dpa4c.md, reject the invalid --pt_expt spelling, and preserve the same-node export contract

@dosubot dosubot Bot added the Docs label Aug 7, 2026
@coderabbitai

coderabbitai Bot commented Aug 7, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

The PR adds DPA4/SeZM skills for training, fine-tuning, Python inference, and LAMMPS deployment. It documents .pt2 workflows, checkpoint inspection, LoRA training, artifact validation, and atom-type mapping.

Changes

DPA4/SeZM skill workflows

Layer / File(s) Summary
Checkpoint routing and skill index
doc/agent-skills.md, skills/deepmd-finetune-dpa4/SKILL.md
Adds the fine-tuning skill and documents checkpoint routing, compatibility checks, and verification.
DPA4 training workflow
skills/deepmd-train/SKILL.md, skills/deepmd-train/models/dpa4.md
Adds DPA4/SeZM model selection, configuration, PyTorch training, .pt2 export, testing, and readiness checks.
DPA4 fine-tuning workflow
skills/deepmd-finetune-dpa4/SKILL.md
Documents standard and LoRA fine-tuning, multi-task branch selection, monitoring, validation, export, and testing.
Inference artifact workflows
skills/deepmd-python-inference/SKILL.md, skills/deepmd-python-inference/references/model-artifacts.md
Documents artifact identification, backend selection, DPA4 loading, descriptor and embedding support, and runtime validation.
LAMMPS deployment guidance
skills/lammps-deepmd/SKILL.md, skills/lammps-deepmd/references/commands-and-workflow.md, skills/lammps-deepmd/references/model-deployment.md
Adds deployment artifact guidance, pinned tool versions, export requirements, atom mapping, and production validation.

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

Possibly related PRs

Suggested reviewers: iprozd

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: adding structured DPA4 workflow documentation and support across Agent Skills.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

SchrodingersCattt and others added 2 commits August 7, 2026 22:36
Updated the description for the deepmd-finetune-dpa4 skill to simplify language and remove references to SeZM.

Signed-off-by: Ming-Yu Guo <guomy26@mail2.sysu.edu.cn>

@coderabbitai coderabbitai 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.

Actionable comments posted: 4

🤖 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 `@skills/deepmd-finetune-dpa4/SKILL.md`:
- Around line 92-95: Update the LoRA example reference in the training
instructions to use ../../examples/water/dpa4/lora_ft.json, ensuring it resolves
from the skill directory to the repository-level example while preserving the
existing command guidance.
- Around line 27-36: Update skills/deepmd-finetune-dpa4/SKILL.md at lines 27-36,
49-63, and 104-115, skills/deepmd-train/models/dpa4.md at lines 73-84,
skills/deepmd-python-inference/references/model-artifacts.md at lines 63-70, and
skills/lammps-deepmd/references/model-deployment.md at lines 9-15 and 27-36 so
the selected multi-task branch is propagated through training and freezing
workflows, using --model-branch SELECTED_BRANCH for training and --head
SELECTED_BRANCH for freezing or export commands.

In `@skills/deepmd-python-inference/SKILL.md`:
- Around line 31-35: Restrict .pt2 guidance to inference commands and APIs
verified as supported by integration tests. In
skills/deepmd-python-inference/SKILL.md at lines 31-35, 58-60, and 292-293, and
references/model-artifacts.md at lines 17-22, 39-44, and 57-60, remove or revise
any universal .pt2 loading claims and update dp test or dp eval-desc examples to
supported frozen formats or explicit backend flags when .pt2 is unsupported.
Ensure all documented .pt2 paths are consistent with the installed-version
capabilities.

In `@skills/lammps-deepmd/SKILL.md`:
- Line 6: Update the online execution command in the compatibility metadata to
pin both LAMMPS and DeePMD-kit to the tested compatible versions, and apply the
same pins consistently to every command that invokes them.
🪄 Autofix

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 Plus

Run ID: 5f040ef9-3491-40d7-a8a4-f8142ef6b61f

📥 Commits

Reviewing files that changed from the base of the PR and between a3195b0 and 979ba46.

📒 Files selected for processing (10)
  • doc/agent-skills.md
  • skills/deepmd-finetune-dpa3/SKILL.md
  • skills/deepmd-finetune-dpa4/SKILL.md
  • skills/deepmd-python-inference/SKILL.md
  • skills/deepmd-python-inference/references/model-artifacts.md
  • skills/deepmd-train/SKILL.md
  • skills/deepmd-train/models/dpa4.md
  • skills/lammps-deepmd/SKILL.md
  • skills/lammps-deepmd/references/commands-and-workflow.md
  • skills/lammps-deepmd/references/model-deployment.md

Comment thread skills/deepmd-finetune-dpa4/SKILL.md
Comment thread skills/deepmd-finetune-dpa4/SKILL.md Outdated
Comment thread skills/deepmd-python-inference/SKILL.md
Comment thread skills/lammps-deepmd/SKILL.md Outdated
@SchrodingersCattt

Copy link
Copy Markdown
Contributor Author

Addressed the review findings in four focused commits:

  • 6e27dc22: clarify .pt2 inference limits; retain verified DeepPot.eval/dp test, remove the unsupported metadata-only .pt2 eval-desc recipe, and state that DPA4 dp embed supports .pt but not .pt2.
  • dc8ec953: fix the LoRA example path and propagate selected multi-task heads through fine-tuning (--model-branch) and export (--head) without changing single-task commands.
  • 92476d3d: distinguish DPA4 edge_vec and NeighborGraph .pt2 contracts, require with-comm metadata/artifact for multi-rank LAMMPS, and document device/toolchain compatibility.
  • 0e24272f: pin all online uvx commands consistently to the published DPA4-capable pair deepmd-kit[gpu,torch,lmp]==3.2.0b0 and lammps==2025.7.22.2.0.

Validation: relative links and JSON examples checked, unsupported .pt2 eval-desc command absent, git diff --check passes, and skills/deepmd-finetune-dpa3/SKILL.md still matches upstream exactly.

@coderabbitai coderabbitai 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.

Actionable comments posted: 3

🤖 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 `@skills/deepmd-python-inference/references/model-artifacts.md`:
- Around line 71-77: Update the `dp embed` example to pass `--head
SELECTED_BRANCH` when extracting embeddings from multi-task pretrained
checkpoints, preserving the intended fitting head; alternatively, explicitly
document that the example is single-head-only.
- Around line 54-57: Update the DeepPot.eval and dp test coverage statement in
model-artifacts.md to clarify that atomic virial is available only when the
archive was exported with --atomic-virial, rather than implying it is always
supported; keep the other covered outputs unchanged.

In `@skills/lammps-deepmd/SKILL.md`:
- Around line 48-52: Update the local command-line help instruction in SKILL.md
by removing the `tee /dev/tty` pipeline from the `lmp -h` command, so it writes
directly to standard output and works without a controlling terminal.
🪄 Autofix

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 Plus

Run ID: de465679-0ebf-4de7-a9c3-863538ed52fd

📥 Commits

Reviewing files that changed from the base of the PR and between 979ba46 and c41e68a.

📒 Files selected for processing (6)
  • skills/deepmd-finetune-dpa4/SKILL.md
  • skills/deepmd-python-inference/SKILL.md
  • skills/deepmd-python-inference/references/model-artifacts.md
  • skills/deepmd-train/models/dpa4.md
  • skills/lammps-deepmd/SKILL.md
  • skills/lammps-deepmd/references/model-deployment.md
🚧 Files skipped from review as they are similar to previous changes (2)
  • skills/deepmd-train/models/dpa4.md
  • skills/deepmd-python-inference/SKILL.md

Comment thread skills/deepmd-python-inference/references/model-artifacts.md Outdated
Comment thread skills/deepmd-python-inference/references/model-artifacts.md
Comment thread skills/lammps-deepmd/SKILL.md Outdated
@SchrodingersCattt

Copy link
Copy Markdown
Contributor Author

Addressed the latest review comments in two focused commits:

  • adc86165: qualify atomic virial by the archive's do_atomic_virial metadata and add --head SELECTED_BRANCH to the multi-task DPA4 embedding example. The wording reflects current source behavior: ordinary non-spin dp --pt freeze exports atomic virial by default, while specialized spin/conversion routes may not.
  • 263c3408: remove both tee /dev/tty pipelines so pinned lmp -h commands write directly to stdout in non-interactive environments.

Validation: git diff --check, focused assertions for the metadata/head/help changes, editor diagnostics, and confirmation that skills/deepmd-finetune-dpa3/SKILL.md still matches upstream.

@codecov

codecov Bot commented Aug 7, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 77.50%. Comparing base (5b9fe07) to head (336d718).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #5961      +/-   ##
==========================================
- Coverage   77.74%   77.50%   -0.25%     
==========================================
  Files        1155     1155              
  Lines      139649   139649              
  Branches     5056     5056              
==========================================
- Hits       108573   108230     -343     
- Misses      29191    29535     +344     
+ Partials     1885     1884       -1     

☔ View full report in Codecov by Harness.
📢 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.

@njzjz
njzjz requested a review from iProzd August 7, 2026 17:36
Document how to obtain and verify compatible DPA4 checkpoints, decide between standard fine-tuning and LoRA, inspect active adapter state, distinguish merged best checkpoints, and avoid the incompatible bundled checkpoint/example pairing.
@SchrodingersCattt
SchrodingersCattt marked this pull request as draft August 8, 2026 00:10

@coderabbitai coderabbitai 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.

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 `@skills/deepmd-finetune-dpa4/SKILL.md`:
- Around line 104-111: Update the checker around model_dict, lora, and the
use_lora diagnostic to inspect each dictionary in multi-task branches for a lora
setting. Treat LoRA as enabled when either the top-level model.lora or any
branch-level lora is present, report that combined status, and reject multi-task
configurations whenever branch-level or top-level LoRA is detected.
🪄 Autofix

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 Plus

Run ID: 9c666cc7-3e45-49bc-9ca7-08963dd0c3b3

📥 Commits

Reviewing files that changed from the base of the PR and between 263c340 and 588023c.

📒 Files selected for processing (1)
  • skills/deepmd-finetune-dpa4/SKILL.md

Comment thread skills/deepmd-finetune-dpa4/SKILL.md Outdated
Remove smoke-model-specific discussion and detailed checkpoint inspection scripts, retaining concise general requirements for checkpoint selection and LoRA usage.
@SchrodingersCattt
SchrodingersCattt marked this pull request as ready for review August 8, 2026 06:02
Signed-off-by: weiqichen77 <weiqchen@hku.hk>
@weiqichen77
weiqichen77 force-pushed the docs/add-deepmd-dpa4-skill branch from e188dd4 to f42fdde Compare August 9, 2026 00:54
@iProzd iProzd added the P2 Non-blocking DPA4/DPA4C release follow-up. label Aug 10, 2026
@njzjz njzjz added this to the v3.2.0 milestone Aug 10, 2026
@SchrodingersCattt

Copy link
Copy Markdown
Contributor Author

Added DPA4C training guidance in 783ff88d after merging current upstream master:

  • route DPA4C requests from deepmd-train to a dedicated progressive-disclosure reference
  • state the required dp --pt-expt backend
  • distinguish DPA4's model.use_compile / model.enable_tf32 from DPA4C's training.enable_compile / training.enable_tf32
  • include a complete accelerated DPA4C template, deployment commands, and a checklist
  • add a regression test that pins these backend-specific paths

Validation: source/tests/common/test_agent_skills.py -> 14 passed, 1 skipped (the existing normalization test skips without a built extension).

@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 cbff85a3df36c9e21a22704801f909ffba2ddc5f. The LoRA command now preserves the selected multi-task source branch, and the MatMaster submission/audit scripts involved in my previous findings are no longer part of this PR. I checked the current artifact routing, minimal DPA4 configuration, held-out evaluation commands, freeze policy, and LAMMPS template against the repository interfaces. source/tests/common/test_agent_skills.py: 16 passed. No remaining blocking finding in the current documentation/workflow changes; this validation did not launch training or molecular dynamics.

Coding agent: Codex
Codex version: codex-cli 0.154.0
Model: gpt-6-astra
Reasoning effort: xhigh

@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 this exact head because review was explicitly re-requested. The head is unchanged from my prior full review; I re-checked the complete 14-file diff, current resolved review threads, repository guidance, and exact-head CI. The previously identified workflow/correctness issues remain addressed, including multi-task branch/head propagation, LoRA source-head preservation, held-out type-map and completeness checks, DPA4/DPA4C export routing and freeze-time policy, and auditable LAMMPS type mapping/deployment guidance. Exact-head CodeQL, Python, C++, CUDA, C-library build, C++ build, and PyPI workflows are all green. I found no new high-confidence blocking issue.

Agent: ChatGPT
Model: GPT-5.6 Sol
GitHub account: njzjz-bot
Reviewed head: cbff85a
Trigger: scheduled all-PR monitoring

@OutisLi OutisLi left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Please fix the retained-evaluation output naming before merging. I also found an incomplete configuration example.

  1. [P1] Use per-system output prefixes that survive suffix replacement. In skills/deepmd-python-inference/references/held-out-evaluation.md:30-36, prefixes such as system.000 and system.001 both become system.e.out, system.e_peratom.out, and system.f.out, because the actual energy detail writer uses Path.with_suffix(...) (deepmd/infer/model_test/ener.py:163-188). Each separate dp test invocation starts without append mode, so the second system silently overwrites the first system's evidence.

I reproduced this using the exact-head production writer with reference energies 10 and 11: after writing both systems, only three detail files remained, all containing the second system's data. Please use suffix-free identifiers such as system_000/system_001, or separate per-system directories. The fake-dp test at source/tests/common/test_agent_skills.py:159-171 appends extensions and therefore does not match the real writer. Add a two-system regression using the real naming/writing behavior and verify that both outputs survive.

  1. [P2] Make the DPA4C JSON complete, or explicitly label it as a fragment. The fenced configuration in skills/deepmd-train/models/dpa4c.md:23-60 omits learning_rate. It normalizes successfully but fails with KeyError: 'learning_rate' at deepmd/pt_expt/train/training.py:1850. I reproduced this through deepmd.main.main(['--pt-expt', 'train', 'input.json']), changing only the dataset path and bounding the step count. The prose links to a maintained complete example, so an explicit instruction to merge this fragment into that example would also resolve the ambiguity; otherwise include the required section. An executable trainer-initialization check would catch this better than substring assertions.

All 16 focused tests passed, and 11 documented CLI forms parsed successfully. The earlier review fixes are present; these findings concern the remaining output-name collision and configuration-example ambiguity. No new runtime performance concern was found in this documentation/skills change.

OutisLi commented Oct 3, 2026

Copy link
Copy Markdown
Collaborator

Please rebase onto or merge the latest master first to pick up model.preset support, then make presets the recommended/default path for new DPA4 and DPA4C training configurations. Use the v20260911 presets for both families: dpa4--v20260911 and dpa4c--v20260911.

The main workflow should be choosing the family/grade and using its preset, rather than manually reconstructing the architecture through a list of descriptor and fitting-network parameters. Replace the first examples accordingly, point the DPA4 workflow to examples/water/dpa4/input_preset.json, and move manual architecture overrides to an advanced section. Explicit descriptor/fitting_net keys override the preset, so simply adding preset while retaining the old full architecture blocks would defeat this change.

Apart from the dataset's type_map, the usual model-side additions should be limited to task-specific settings such as descriptor.seed/use_amp, fitting_net.seed/vacuum_ref, and optional descriptor.add_chg_spin_ebd/default_chg_spin. Keep the required data, learning-rate and training configuration outside that model-architecture simplification.

Please document the vacuum-reference dependency: enabling fitting_net.vacuum_ref also requires an assigned energy bias via model.preset_out_bias.energy, using isolated-atom energies consistent with the training reference calculation and aligned with type_map. Without an assigned bias, vacuum_ref is disabled. Vacuum referencing and charge/spin conditioning should remain explicit modeling choices; they are not interchangeable with execution flags. For fine-tuning, preserve compatibility with the checkpoint rather than blindly replacing its architecture with a newer preset.

Update the example regressions to exercise preset expansion followed by validation for both families, retaining the trainer-initialization check. Validate on the updated branch or merge result containing v20260911 support.

@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 the new workflow/documentation delta, examples, regression tests and Read the Docs configuration against the current implementation, starting from cbff85a. No new blocking findings.

The earlier issues are addressed: held-out evaluation now uses suffix-free output prefixes, with a production-writer regression ensuring both systems' retained energy outputs survive. DPA4C snippets are explicitly model sections, with complete training inputs supplied by the maintained example and a trainer-initialization regression. DPA4/DPA4C v20260911 preset names, override semantics and vacuum-reference requirements match implementation; fine-tuning guidance preserves the checkpoint architecture.

Python shard 12 shows all 18 test_agent_skills tests passing (https://github.com/deepmodeling/deepmd-kit/actions/runs/37169987191/job/111340854331). This ran on merge commit f66daf8, containing the reviewed head. Python/C++/CUDA workflow summaries, library/package builds, CodeQL, pre-commit and Read the Docs report success; workflow success alone is not a claim that every label-gated GPU job executed.

Verification was source inspection and existing CI evidence; no independent training, export, molecular-dynamics or documentation build was run. Scope is the branch-owned delta and relevant integration points, not unrelated upstream-merge changes.

Agent: dot
Reviewed head: 336d718
Baseline: cbff85a

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

Docs Examples P2 Non-blocking DPA4/DPA4C release follow-up. Python

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.

7 participants