Skip to content

Commit

Permalink
update dpa-2 compression status
Browse files Browse the repository at this point in the history
Signed-off-by: Jinzhe Zeng <[email protected]>
  • Loading branch information
njzjz committed Nov 12, 2024
1 parent f774be7 commit c341571
Show file tree
Hide file tree
Showing 4 changed files with 119 additions and 2 deletions.
5 changes: 3 additions & 2 deletions doc/model/dpa2.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,6 @@ Type embedding is within this descriptor with the {ref}`tebd_dim <model[standard

## Model compression

Model compression is supported, but only the `repinit` part is compressed.
The effect is limited.
Model compression is supported when {ref}`repinit/tebd_input_mode <model[standard]/descriptor[dpa2]/repinit/tebd_input_mode>` is `strip`, but only the `repinit` part is compressed.
An example is given in `examples/water/dpa2/input_torch_compressible.json`.
The performance improvement will be limited if other parts are more expensive.
2 changes: 2 additions & 0 deletions examples/water/dpa2/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,5 @@ For detailed differences in their configurations, please refer to the table belo
| `input_torch_small.json` | 3 |||| Smallest DPA-2 model, optimized for speed. |
| `input_torch_medium.json` | 6 |||| Recommended well-performing DPA-2 model, balancing efficiency and precision. |
| `input_torch_large.json` | 12 |||| Most complex model with the highest precision. |

`input_torch_compressible.json` is derived from `input_torch_small.json` and makes the `repinit` part compressible.
113 changes: 113 additions & 0 deletions examples/water/dpa2/input_torch_compressible.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
{
"_comment": "that's all",
"model": {
"type_map": [
"O",
"H"
],
"descriptor": {
"type": "dpa2",
"repinit": {
"tebd_dim": 8,
"rcut": 6.0,
"rcut_smth": 0.5,
"nsel": 120,
"neuron": [
25,
50,
100
],
"axis_neuron": 12,
"activation_function": "tanh",
"three_body_sel": 48,
"three_body_rcut": 4.0,
"three_body_rcut_smth": 3.5,
"use_three_body": true,
"tebd_input_mode": "strip"
},
"repformer": {
"rcut": 4.0,
"rcut_smth": 3.5,
"nsel": 48,
"nlayers": 3,
"g1_dim": 128,
"g2_dim": 32,
"attn2_hidden": 32,
"attn2_nhead": 4,
"attn1_hidden": 128,
"attn1_nhead": 4,
"axis_neuron": 4,
"update_h2": false,
"update_g1_has_conv": true,
"update_g1_has_grrg": true,
"update_g1_has_drrd": true,
"update_g1_has_attn": false,
"update_g2_has_g1g1": false,
"update_g2_has_attn": false,
"update_style": "res_residual",
"update_residual": 0.01,
"update_residual_init": "norm",
"attn2_has_gate": true,
"use_sqrt_nnei": true,
"g1_out_conv": true,
"g1_out_mlp": true
},
"add_tebd_to_repinit_out": false
},
"fitting_net": {
"neuron": [
240,
240,
240
],
"resnet_dt": true,
"seed": 1,
"_comment": " that's all"
},
"_comment": " that's all"
},
"learning_rate": {
"type": "exp",
"decay_steps": 5000,
"start_lr": 0.001,
"stop_lr": 3.51e-08,
"_comment": "that's all"
},
"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,
"_comment": " that's all"
},
"training": {
"stat_file": "./dpa2.hdf5",
"training_data": {
"systems": [
"../data/data_0",
"../data/data_1",
"../data/data_2"
],
"batch_size": 1,
"_comment": "that's all"
},
"validation_data": {
"systems": [
"../data/data_3"
],
"batch_size": 1,
"_comment": "that's all"
},
"numb_steps": 1000000,
"warmup_steps": 0,
"gradient_max_norm": 5.0,
"seed": 10,
"disp_file": "lcurve.out",
"disp_freq": 100,
"save_freq": 2000,
"_comment": "that's all"
}
}
1 change: 1 addition & 0 deletions source/tests/common/test_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
p_examples / "water" / "dpa2" / "input_torch_small.json",
p_examples / "water" / "dpa2" / "input_torch_medium.json",
p_examples / "water" / "dpa2" / "input_torch_large.json",
p_examples / "water" / "dpa2" / "input_torch_compressible.json",
p_examples / "property" / "train" / "input_torch.json",
p_examples / "water" / "se_e3_tebd" / "input_torch.json",
)
Expand Down

0 comments on commit c341571

Please sign in to comment.