Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 57 additions & 0 deletions examples/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# Running the example configurations

Run `dpgen2 submit` from the directory containing the chosen input file. Training
and other file paths are relative to the process working directory. For example:

```sh
cd examples/water
dpgen2 submit input_dpgen.json
```

The training templates are shipped next to their inputs and their `model.type_map`
matches the corresponding `inputs.type_map`, including element order. DPA-2
examples use the DeePMD-kit 3.x PyTorch backend and its nested `repinit` /
`repformer` descriptor schema. The water multitask template defines both
`water_1` and `water_2` in `model.model_dict`, `loss_dict`, and
`training.data_dict`; new iteration data is added only to `water_1`.
`input_distill.json` keeps the TensorFlow backend and uses a compatible
`se_atten` template. These are training-input examples, not bundled datasets or
pretrained models: replace the initial-data, model, potential, executor, and
machine paths/settings for your deployment before submission.

## Methane distillation student

`ch4/input_dist.json` uses TensorFlow and initializes one student from
`student_model.pb`. Its small `student_train.json` uses a `se_e2_a` descriptor,
64-wide fitting layers, and the type map `["H", "C"]`. The frozen student must be
built from that same model definition; an unrelated `.pb` or a PyTorch `.pt`
model is not interchangeable. After providing the initial labeled methane data
at the paths in the template, generate the matching student with DeePMD-kit's
TensorFlow backend:

```sh
cd examples/ch4
dp --tf train student_train.json
dp --tf freeze -o student_model.pb
dpgen2 submit input_dist.json
```

Supply a separately trained `teacher_model.pb` and configure the remaining
example paths before the final command. If using an existing frozen student,
replace the student template with the architecture and type map used to train
that exact student. The workflow forces the distillation model count to one.

## Template checks

The test extra includes the DeePMD-kit input-schema validator without requiring
a TensorFlow/PyTorch training runtime. Run:

```sh
pip install -e '.[test]'
PYTHONPATH=.:tests python -m unittest -v tests.test_check_examples
```

These checks load paths from each example directory, prepare the actual number
of training tasks, inject initial and iteration data, exercise fresh and
initialized training rewrites, and validate the resulting DeePMD-kit schemas.
They do not execute full model training or external simulation/labeling jobs.
209 changes: 148 additions & 61 deletions examples/calypso/dpa2_train.json
Original file line number Diff line number Diff line change
@@ -1,43 +1,28 @@
{
"_comment": "that's all",
"model": {
"type_map": [
"Mg",
"Al"
],
"descriptor": {
"type": "dpa2",
"tebd_dim": 8,
"repinit_rcut": 9.0,
"repinit_rcut_smth": 8.0,
"repinit_nsel": 120,
"repformer_rcut": 4.0,
"repformer_rcut_smth": 3.5,
"repformer_nsel": 40,
"repinit_neuron": [
25,
50,
100
],
"repinit_axis_neuron": 12,
"repinit_activation": "tanh",
"repformer_nlayers": 12,
"repformer_g1_dim": 128,
"repformer_g2_dim": 32,
"repformer_attn2_hidden": 32,
"repformer_attn2_nhead": 4,
"repformer_attn1_hidden": 128,
"repformer_attn1_nhead": 4,
"repformer_axis_dim": 4,
"repformer_update_h2": false,
"repformer_update_g1_has_conv": true,
"repformer_update_g1_has_grrg": true,
"repformer_update_g1_has_drrd": true,
"repformer_update_g1_has_attn": true,
"repformer_update_g2_has_g1g1": true,
"repformer_update_g2_has_attn": true,
"repformer_attn2_has_gate": true,
"repformer_add_type_ebd_to_seq": false
"repinit": {
"rcut": 6.0,
"rcut_smth": 0.5,
"nsel": 120,
"neuron": [
25,
50,
100
],
"axis_neuron": 12,
"tebd_dim": 8
},
"repformer": {
"rcut": 4.0,
"rcut_smth": 3.5,
"nsel": 40,
"nlayers": 3,
"g1_dim": 128,
"g2_dim": 32
},
"seed": 1
},
"fitting_net": {
"neuron": [
Expand All @@ -46,17 +31,134 @@
240
],
"resnet_dt": true,
"seed": 1,
"_comment": " that's all"
"seed": 1
},
"_comment": " that's all"
"type_map": [
"H",
"He",
"Li",
"Be",
"B",
"C",
"N",
"O",
"F",
"Ne",
"Na",
"Mg",
"Al",
"Si",
"P",
"S",
"Cl",
"Ar",
"K",
"Ca",
"Sc",
"Ti",
"V",
"Cr",
"Mn",
"Fe",
"Co",
"Ni",
"Cu",
"Zn",
"Ga",
"Ge",
"As",
"Se",
"Br",
"Kr",
"Rb",
"Sr",
"Y",
"Zr",
"Nb",
"Mo",
"Tc",
"Ru",
"Rh",
"Pd",
"Ag",
"Cd",
"In",
"Sn",
"Sb",
"Te",
"I",
"Xe",
"Cs",
"Ba",
"La",
"Ce",
"Pr",
"Nd",
"Pm",
"Sm",
"Eu",
"Gd",
"Tb",
"Dy",
"Ho",
"Er",
"Tm",
"Yb",
"Lu",
"Hf",
"Ta",
"W",
"Re",
"Os",
"Ir",
"Pt",
"Au",
"Hg",
"Tl",
"Pb",
"Bi",
"Po",
"At",
"Rn",
"Fr",
"Ra",
"Ac",
"Th",
"Pa",
"U",
"Np",
"Pu",
"Am",
"Cm",
"Bk",
"Cf",
"Es",
"Fm",
"Md",
"No",
"Lr",
"Rf",
"Db",
"Sg",
"Bh",
"Hs",
"Mt",
"Ds",
"Rg",
"Cn",
"Nh",
"Fl",
"Mc",
"Lv",
"Ts",
"Og"
]
},
"learning_rate": {
"type": "exp",
"decay_steps": 5000,
"start_lr": 0.0002,
"stop_lr": 3.51e-08,
"_comment": "that's all"
"stop_lr": 3.51e-08
},
"loss": {
"type": "ener",
Expand All @@ -65,32 +167,17 @@
"start_pref_f": 1000,
"limit_pref_f": 1,
"start_pref_v": 0,
"limit_pref_v": 0,
"_comment": " that's all"
"limit_pref_v": 0
},
"training": {
"stat_file": "./dpa2",
"training_data": {
"systems": [
"/personal/workplace/DP/dpgen2/Mg12Al8/deepmd"
],
"batch_size": 1,
"_comment": "that's all"
},
"_validation_data": {
"systems": [
"/personal/workplace/DP/dpgen2/Mg12Al8/deepmd"
],
"batch_size": 1,
"_comment": "that's all"
"systems": [],
"batch_size": "auto"
},
"numb_steps": 20,
"warmup_steps": 0,
"gradient_max_norm": 5.0,
"numb_steps": 1000,
"seed": 10,
"disp_file": "lcurve.out",
"disp_freq": 100,
"save_freq": 200,
"_comment": "that's all"
"save_freq": 1000
}
}
2 changes: 1 addition & 1 deletion examples/calypso/input.test.json
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@
"init_model_start_pref_f": 100,
"_comment": "all"
},
"template_script": "train.json",
"template_script": "dpa2_train.json",
"_comment": "all"
},
"fp": {
Expand Down
3 changes: 2 additions & 1 deletion examples/ch4/input_dist.json
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@
"student_model_path": "student_model.pb",
"type": "dp-dist",
"config": {
"impl": "tensorflow",
"init_model_policy": "yes",
"init_model_old_ratio": 0.5,
"init_model_numb_steps": 200000,
Expand All @@ -129,7 +130,7 @@
"init_model_start_pref_f": 100,
"_comment": "all"
},
"template_script": "train.json",
"template_script": "student_train.json",
"_comment": "all"
},
"fp" : {
Expand Down
61 changes: 61 additions & 0 deletions examples/ch4/student_train.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
{
"model": {
"descriptor": {
"type": "se_e2_a",
"sel": [
16,
8
],
"rcut": 6.0,
"rcut_smth": 0.5,
"neuron": [
10,
20,
40
],
"axis_neuron": 4,
"seed": 1
},
"fitting_net": {
"neuron": [
64,
64,
64
],
"resnet_dt": true,
"seed": 1
},
"type_map": [
"H",
"C"
]
},
"learning_rate": {
"type": "exp",
"decay_steps": 5000,
"start_lr": 0.0002,
"stop_lr": 3.51e-08
},
"loss": {
"type": "ener",
"start_pref_e": 0.02,
"limit_pref_e": 1,
"start_pref_f": 1000,
"limit_pref_f": 1,
"start_pref_v": 0,
"limit_pref_v": 0
},
"training": {
"training_data": {
"systems": [
"CH4.POSCAR.01x01x01/02.md/sys-0004-0001/deepmd"
],
"batch_size": "auto"
},
"numb_steps": 1000,
"seed": 10,
"disp_file": "lcurve.out",
"disp_freq": 100,
"save_freq": 1000
}
}
1 change: 0 additions & 1 deletion examples/chno/dpa_manyi.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@
"seed": 922,
"disp_file": "lcurve.out",
"disp_freq": 2000,
"numb_test": 5,
"save_freq": 10000,
"save_ckpt": "model.ckpt",
"disp_training": true,
Expand Down
Loading
Loading