Skip to content

feat(skills): add DPA-4c distillation workflow - #227

Merged
Fillianore merged 3 commits into
AI4MS:develfrom
Fillianore:distill-dpa4c
Aug 14, 2026
Merged

feat(skills): add DPA-4c distillation workflow#227
Fillianore merged 3 commits into
AI4MS:develfrom
Fillianore:distill-dpa4c

Conversation

@Fillianore

Copy link
Copy Markdown
Contributor

Add concept-level and deepmd-skill support for distilling a DPA-4c student model from a fine-tuned DPA-4 teacher:

  • mlff concept SKILL: rewrite the distillation procedure into explicit Phase A (teacher NPT MD) -> Phase B (teacher inference labeling) -> Phase C (student training + two-level evaluation), with strict phase ordering gates and seed/training-set provenance checks.
  • deepmd SKILL + supported models reference: document DPA-4c CLI usage (--pt-expt, never --finetune due to OOM for sel=[999999]), the --skip-neighbor-stat requirement, and the recommended Bohrium image (dpa4-mlip-340e01f9) on a 5090 GPU.
  • deepmd_prepare.py: fix epoch-key alias handling so exactly one epoch key remains in the training dict (avoids dargs strict-schema failure).
  • references/dpa4c_distill_input.json: verified input template from a completed 1M-step DPA-4c distillation run.

Add concept-level and deepmd-skill support for distilling a DPA-4c student
model from a fine-tuned DPA-4 teacher:

- mlff concept SKILL: rewrite the distillation procedure into explicit
  Phase A (teacher NPT MD) -> Phase B (teacher inference labeling) ->
  Phase C (student training + two-level evaluation), with strict phase
  ordering gates and seed/training-set provenance checks.
- deepmd SKILL + supported models reference: document DPA-4c CLI usage
  (--pt-expt, never --finetune due to OOM for sel=[999999]), the
  --skip-neighbor-stat requirement, and the recommended Bohrium image
  (dpa4-mlip-340e01f9) on a 5090 GPU.
- deepmd_prepare.py: fix epoch-key alias handling so exactly one epoch key
  remains in the training dict (avoids dargs strict-schema failure).
- references/dpa4c_distill_input.json: verified input template from a
  completed 1M-step DPA-4c distillation run.

## Recommended Procedure — Generate a force field via distillation

> **Strict phase ordering — Phase A → Phase B → Phase C.**

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.

Maybe better call each step "stages" instead of "phases" in case LLM confuse stages in pipeline with crystalline phases.

>
> **If you believe a phase can be skipped or shortened for your particular structure,
> that belief is precisely the error this rule exists to prevent.** Skipping Phase A
> (teacher MD) or Phase B (proper labeling) and jumping straight to Phase C (student

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.

Not precise enough. Maybe say: "Skipping generating and labeling new samples by running MD with teacher model is not allowed. Specifically, do not simply relabel existing DFT structures with the teacher model and use these structures in training the student model, as xxx."

A valid **teacher model** must satisfy BOTH conditions:

1. It is a **fine-tuned** model on the target system, i.e., it has already gone through the
fine-tuning procedure above on DFT-labeled data of that system.

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.

Add "DO NOT use pretrained models"


1. It is a **fine-tuned** model on the target system, i.e., it has already gone through the
fine-tuning procedure above on DFT-labeled data of that system.
2. It is a **single-task** model (dedicated to the target system).

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.

For a model that supports multi-task training (such as DPA-3), a teacher model must be a single task model specifically fine-tuned in the target system.

DFT-labeled test set from the corresponding fine-tuning workflow. If that is not available, then
consider choosing an appropriate subset of the distillation testing set and re-compute them with DFT
(subset number of frames times number of atoms in each frame should not exceed 10000 total atoms).
The distillation workflow mirrors the fine-tuning workflow phase by phase, except that the labels are

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.

Distillation contents are quite long. Maybe separate "fine-tuning.md" and a "distillation.md" from the main concept skill?

exactly as in fine-tuning Phase A.

The only systematic difference is the sampling scale: because the student is trained from scratch,
distillation needs roughly **20 times** the number of frames used in fine-tuning.

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.

Much more. Maybe change to 50 times at least. Distillation won't cost much.

> **(1) NPT ensemble** — mandatory for strain diversity; never switch to NVT/NVE without
> explicit user approval. **(2) Entropy-based structure selection** — mandatory after
> MD sampling and before labeling. **(3) ~100× frame scale** — distillation needs
> roughly 100× the frames of fine-tuning (≥ 20000 for simple systems).

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.

100x conflicts with 20x mentioned before.


### Phase B — Teacher inference labeling (replaces DFT)

Label the entropy-selected structures by **teacher model inference** (single-point energy, force and

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.

By inferencing with the teacher model to obtain xxx, xxx, xxx

> 2. The total labeled frame count is **≥ ~20000** (simple systems) / **≥ ~40000**
> (complex systems) / **≥ ~100000** (very complex systems), consistent with the
> Phase A output recommendation above.
> 3. The frames span a **diverse configuration space** (different cell shapes, strains,

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.

Different cell shapes may cause confusion. Do you mean that all structures may be sampled from the same supercell matrix while allowing lattice vectors to vary during NPT sampling? Or you must have different supercell matrices?

all teacher-labeled frames.

2. Train the DPA-4c student model **from scratch** (no pretrained initialization). Because the student
starts from scratch, training is much longer than fine-tuning: use about **1,000,000 (1M) training

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.

Stop instructing agent with traning steps. Now that num_epochs keyword is supported, always let the agent use num_epochs.

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.

Use 1000 epochs, if possible.

5. Also, do not use nvidia GPUs older than V100 as they no longer support the triton AOT induction route of
modern pytorch, which is compulsory for deepmd-kit>=3.2.0.

## DPA-4c distillation student (dpa4c descriptor)

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.

DPA-4c ("dpa4c" descriptor, only used as student models during distillation)

dp --pt-expt train input.json --init-model <pretrain.pt> --skip-neighbor-stat
```

- `--finetune` is **prohibited** for DPA-4c: its bias-adjustment dense forward pass

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.

--finetune keyword is prohibited for DPA-4c. Always use only dp --pt-expt train input.json --skip-neighbor-stat to train from scratch.

architecture** (dpa2, dpa3, dpa4/SeZM, se_atten_v2, ...).

**[For bohrium submission] Image and machine:** recommended image
`registry.dp.tech/dptech/dpa-calculator:dpa4-mlip-340e01f9` on a **5090** GPU machine.

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.

I recommend just add a table of models and their correponding images in the previous machine section

@qchempku2017 qchempku2017 Aug 13, 2026

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.

By the way, are 5090 nodes available now? Are they no longer busy? Why L20_48g nodes cannot be used?


---

# DPA-4c distillation (student model training)

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.

Maybe no need to duplicate here as you have already mentioned in supported_deepmd_models.md

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

Good work overall, but I have a few suggestions.

@ruoyuwang1995nya

Copy link
Copy Markdown
Collaborator

@Fillianore Maybe you can check the suggestion first?

…#227)

Concept skill split (qchempku2017):
- Extract the fine-tuning and distillation procedures from the main
  concept SKILL.md into references/fine-tuning.md and
  references/distillation.md. SKILL.md now stays a concise overview that
  points to the two reference files (365 -> 97 lines).

Wording & correctness fixes per review:
- Rename "Phase" -> "Stage" throughout (avoid confusion with crystalline
  phases).
- Distillation: strengthen the seed-vs-training-set rule to explicitly
  forbid relabeling existing DFT structures with the teacher.
- Distillation Stage Zero gate: "DO NOT use pretrained models"; clarify
  that multi-task-capable models (e.g. DPA-3) must be single-task
  fine-tuned on the target system to qualify as a teacher.
- Unify the distillation frame multiplier to ~100x (was inconsistent
  20x/100x).
- Stage B: rephrase labeling as "inferencing with the teacher model to
  obtain energy, forces and virial".
- Clarify the configuration-diversity check (NPT lattice-vector
  fluctuation on the same supercell), and classify systems whose initial
  structures span multiple distinct cell types as complex.
- Use ~1000 epochs (num_epochs keyword) instead of training steps.

deepmd skill:
- Remove the duplicated DPA-4c distillation block from SKILL.md; keep a
  short pointer to supported_deepmd_models.md. Keep the --init-model
  flag; make the --finetune prohibition wording stricter.
- supported_deepmd_models.md: rename the DPA-4c section heading.
…pochs)

- distillation.md: 1000 epochs -> 50 epochs.
- dpa4c_distill_input.json: replace numb_steps=1000000 with num_epochs=50,
  consistent with the num_epochs keyword recommended since deepmd 3.2.0.
@Fillianore
Fillianore merged commit 10088de into AI4MS:devel Aug 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants