Skip to content

Commit b9303c7

Browse files
authored
docs: move arg docs from Variant to sub Arguments (#4369)
See deepmodeling/dargs#82 <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **Documentation** - Enhanced documentation for various descriptor arguments and fitting configurations, improving clarity and usability. - Added detailed descriptions for descriptors related to the smooth edition of Deep Potential. - Updated registration of descriptor arguments to include new documentation strings for better guidance on functionality and expected parameters. <!-- end of auto-generated comment: release notes by coderabbit.ai --> Signed-off-by: Jinzhe Zeng <jinzhe.zeng@rutgers.edu>
1 parent f879b48 commit b9303c7

File tree

1 file changed

+39
-42
lines changed

1 file changed

+39
-42
lines changed

deepmd/utils/argcheck.py

Lines changed: 39 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,21 @@
4040

4141
doc_only_tf_supported = "(Supported Backend: TensorFlow) "
4242
doc_only_pt_supported = "(Supported Backend: PyTorch) "
43+
# descriptors
44+
doc_loc_frame = "Defines a local frame at each atom, and the compute the descriptor as local coordinates under this frame."
45+
doc_se_e2_a = "Used by the smooth edition of Deep Potential. The full relative coordinates are used to construct the descriptor."
46+
doc_se_e2_r = "Used by the smooth edition of Deep Potential. Only the distance between atoms is used to construct the descriptor."
47+
doc_se_e3 = "Used by the smooth edition of Deep Potential. The full relative coordinates are used to construct the descriptor. Three-body embedding will be used by this descriptor."
48+
doc_se_a_tpe = "Used by the smooth edition of Deep Potential. The full relative coordinates are used to construct the descriptor. Type embedding will be used by this descriptor."
49+
doc_se_atten = "Used by the smooth edition of Deep Potential. The full relative coordinates are used to construct the descriptor. Attention mechanism will be used by this descriptor."
50+
doc_se_atten_v2 = "Used by the smooth edition of Deep Potential. The full relative coordinates are used to construct the descriptor. Attention mechanism with new modifications will be used by this descriptor."
51+
doc_se_a_mask = "Used by the smooth edition of Deep Potential. It can accept a variable number of atoms in a frame (Non-PBC system). *aparam* are required as an indicator matrix for the real/virtual sign of input atoms."
52+
doc_hybrid = "Concatenate of a list of descriptors as a new descriptor."
53+
# fitting
54+
doc_ener = "Fit an energy model (potential energy surface)."
55+
doc_dos = "Fit a density of states model. The total density of states / site-projected density of states labels should be provided by `dos.npy` or `atom_dos.npy` in each data system. The file has number of frames lines and number of energy grid columns (times number of atoms in `atom_dos.npy`). See `loss` parameter."
56+
doc_dipole = "Fit an atomic dipole model. Global dipole labels or atomic dipole labels for all the selected atoms (see `sel_type`) should be provided by `dipole.npy` in each data system. The file either has number of frames lines and 3 times of number of selected atoms columns, or has number of frames lines and 3 columns. See `loss` parameter."
57+
doc_polar = "Fit an atomic polarizability model. Global polarizazbility labels or atomic polarizability labels for all the selected atoms (see `sel_type`) should be provided by `polarizability.npy` in each data system. The file with has number of frames lines and 9 times of number of selected atoms columns, or has number of frames lines and 9 columns. See `loss` parameter."
4358

4459

4560
def list_to_doc(xx):
@@ -229,7 +244,7 @@ def get_all_argument(self, exclude_hybrid: bool = False) -> list[Argument]:
229244
descrpt_args_plugin = ArgsPlugin()
230245

231246

232-
@descrpt_args_plugin.register("loc_frame", doc=doc_only_tf_supported)
247+
@descrpt_args_plugin.register("loc_frame", doc=doc_only_tf_supported + doc_loc_frame)
233248
def descrpt_local_frame_args():
234249
doc_sel_a = "A list of integers. The length of the list should be the same as the number of atom types in the system. `sel_a[i]` gives the selected number of type-i neighbors. The full relative coordinates of the neighbors are used by the descriptor."
235250
doc_sel_r = "A list of integers. The length of the list should be the same as the number of atom types in the system. `sel_r[i]` gives the selected number of type-i neighbors. Only relative distance of the neighbors are used by the descriptor. sel_a[i] + sel_r[i] is recommended to be larger than the maximally possible number of type-i neighbors in the cut-off radius."
@@ -250,7 +265,7 @@ def descrpt_local_frame_args():
250265
]
251266

252267

253-
@descrpt_args_plugin.register("se_e2_a", alias=["se_a"])
268+
@descrpt_args_plugin.register("se_e2_a", alias=["se_a"], doc=doc_se_e2_a)
254269
def descrpt_se_a_args():
255270
doc_sel = 'This parameter set the number of selected neighbors for each type of atom. It can be:\n\n\
256271
- `list[int]`. The length of the list should be the same as the number of atom types in the system. `sel[i]` gives the selected number of type-i neighbors. `sel[i]` is recommended to be larger than the maximally possible number of type-i neighbors in the cut-off radius. It is noted that the total sel value must be less than 4096 in a GPU environment.\n\n\
@@ -318,7 +333,9 @@ def descrpt_se_a_args():
318333
]
319334

320335

321-
@descrpt_args_plugin.register("se_e3", alias=["se_at", "se_a_3be", "se_t"])
336+
@descrpt_args_plugin.register(
337+
"se_e3", alias=["se_at", "se_a_3be", "se_t"], doc=doc_se_e3
338+
)
322339
def descrpt_se_t_args():
323340
doc_sel = 'This parameter set the number of selected neighbors for each type of atom. It can be:\n\n\
324341
- `list[int]`. The length of the list should be the same as the number of atom types in the system. `sel[i]` gives the selected number of type-i neighbors. `sel[i]` is recommended to be larger than the maximally possible number of type-i neighbors in the cut-off radius. It is noted that the total sel value must be less than 4096 in a GPU environment.\n\n\
@@ -373,7 +390,9 @@ def descrpt_se_t_args():
373390
]
374391

375392

376-
@descrpt_args_plugin.register("se_a_tpe", alias=["se_a_ebd"], doc=doc_only_tf_supported)
393+
@descrpt_args_plugin.register(
394+
"se_a_tpe", alias=["se_a_ebd"], doc=doc_only_tf_supported + doc_se_a_tpe
395+
)
377396
def descrpt_se_a_tpe_args():
378397
doc_type_nchanl = "number of channels for type embedding"
379398
doc_type_nlayer = "number of hidden layers of type embedding net"
@@ -387,7 +406,7 @@ def descrpt_se_a_tpe_args():
387406
]
388407

389408

390-
@descrpt_args_plugin.register("se_e2_r", alias=["se_r"])
409+
@descrpt_args_plugin.register("se_e2_r", alias=["se_r"], doc=doc_se_e2_r)
391410
def descrpt_se_r_args():
392411
doc_sel = 'This parameter set the number of selected neighbors for each type of atom. It can be:\n\n\
393412
- `list[int]`. The length of the list should be the same as the number of atom types in the system. `sel[i]` gives the selected number of type-i neighbors. `sel[i]` is recommended to be larger than the maximally possible number of type-i neighbors in the cut-off radius. It is noted that the total sel value must be less than 4096 in a GPU environment.\n\n\
@@ -446,7 +465,7 @@ def descrpt_se_r_args():
446465
]
447466

448467

449-
@descrpt_args_plugin.register("hybrid")
468+
@descrpt_args_plugin.register("hybrid", doc=doc_hybrid)
450469
def descrpt_hybrid_args():
451470
doc_list = "A list of descriptor definitions"
452471

@@ -538,7 +557,7 @@ def descrpt_se_atten_common_args():
538557
]
539558

540559

541-
@descrpt_args_plugin.register("se_atten", alias=["dpa1"])
560+
@descrpt_args_plugin.register("se_atten", alias=["dpa1"], doc=doc_se_atten)
542561
def descrpt_se_atten_args():
543562
doc_smooth_type_embedding = f"Whether to use smooth process in attention weights calculation. {doc_only_tf_supported} When using stripped type embedding, whether to dot smooth factor on the network output of type embedding to keep the network smooth, instead of setting `set_davg_zero` to be True."
544563
doc_set_davg_zero = "Set the normalization average to zero. This option should be set when `se_atten` descriptor or `atom_ener` in the energy fitting is used"
@@ -774,7 +793,7 @@ def descrpt_se_e3_tebd_args():
774793
]
775794

776795

777-
@descrpt_args_plugin.register("se_atten_v2")
796+
@descrpt_args_plugin.register("se_atten_v2", doc=doc_se_atten_v2)
778797
def descrpt_se_atten_v2_args():
779798
doc_set_davg_zero = "Set the normalization average to zero. This option should be set when `se_atten` descriptor or `atom_ener` in the energy fitting is used"
780799
doc_trainable_ln = (
@@ -1343,7 +1362,7 @@ def descrpt_se_a_ebd_v2_args():
13431362
return descrpt_se_a_args()
13441363

13451364

1346-
@descrpt_args_plugin.register("se_a_mask", doc=doc_only_tf_supported)
1365+
@descrpt_args_plugin.register("se_a_mask", doc=doc_only_tf_supported + doc_se_a_mask)
13471366
def descrpt_se_a_mask_args():
13481367
doc_sel = 'This parameter sets the number of selected neighbors for each type of atom. It can be:\n\n\
13491368
- `list[int]`. The length of the list should be the same as the number of atom types in the system. `sel[i]` gives the selected number of type-i neighbors. `sel[i]` is recommended to be larger than the maximally possible number of type-i neighbors in the cut-off radius. It is noted that the total sel value must be less than 4096 in a GPU environment.\n\n\
@@ -1397,27 +1416,7 @@ def descrpt_se_a_mask_args():
13971416

13981417

13991418
def descrpt_variant_type_args(exclude_hybrid: bool = False) -> Variant:
1400-
link_lf = make_link("loc_frame", "model[standard]/descriptor[loc_frame]")
1401-
link_se_e2_a = make_link("se_e2_a", "model[standard]/descriptor[se_e2_a]")
1402-
link_se_e2_r = make_link("se_e2_r", "model[standard]/descriptor[se_e2_r]")
1403-
link_se_e3 = make_link("se_e3", "model[standard]/descriptor[se_e3]")
1404-
link_se_a_tpe = make_link("se_a_tpe", "model[standard]/descriptor[se_a_tpe]")
1405-
link_hybrid = make_link("hybrid", "model[standard]/descriptor[hybrid]")
1406-
link_se_atten = make_link("se_atten", "model[standard]/descriptor[se_atten]")
1407-
link_se_atten_v2 = make_link(
1408-
"se_atten_v2", "model[standard]/descriptor[se_atten_v2]"
1409-
)
1410-
link_se_a_mask = make_link("se_a_mask", "model[standard]/descriptor[se_a_mask]")
1411-
doc_descrpt_type = f"The type of the descriptor. See explanation below. \n\n\
1412-
- {link_lf}: Defines a local frame at each atom, and the compute the descriptor as local coordinates under this frame.\n\n\
1413-
- {link_se_e2_a}: Used by the smooth edition of Deep Potential. The full relative coordinates are used to construct the descriptor.\n\n\
1414-
- {link_se_e2_r}: Used by the smooth edition of Deep Potential. Only the distance between atoms is used to construct the descriptor.\n\n\
1415-
- {link_se_e3}: Used by the smooth edition of Deep Potential. The full relative coordinates are used to construct the descriptor. Three-body embedding will be used by this descriptor.\n\n\
1416-
- {link_se_a_tpe}: Used by the smooth edition of Deep Potential. The full relative coordinates are used to construct the descriptor. Type embedding will be used by this descriptor.\n\n\
1417-
- {link_se_atten}: Used by the smooth edition of Deep Potential. The full relative coordinates are used to construct the descriptor. Attention mechanism will be used by this descriptor.\n\n\
1418-
- {link_se_atten_v2}: Used by the smooth edition of Deep Potential. The full relative coordinates are used to construct the descriptor. Attention mechanism with new modifications will be used by this descriptor.\n\n\
1419-
- {link_se_a_mask}: Used by the smooth edition of Deep Potential. It can accept a variable number of atoms in a frame (Non-PBC system). *aparam* are required as an indicator matrix for the real/virtual sign of input atoms. \n\n\
1420-
- {link_hybrid}: Concatenate of a list of descriptors as a new descriptor."
1419+
doc_descrpt_type = "The type of the descriptor."
14211420

14221421
return Variant(
14231422
"type",
@@ -1430,7 +1429,7 @@ def descrpt_variant_type_args(exclude_hybrid: bool = False) -> Variant:
14301429
fitting_args_plugin = ArgsPlugin()
14311430

14321431

1433-
@fitting_args_plugin.register("ener")
1432+
@fitting_args_plugin.register("ener", doc=doc_ener)
14341433
def fitting_ener():
14351434
doc_numb_fparam = "The dimension of the frame parameter. If set to >0, file `fparam.npy` should be included to provided the input fparams."
14361435
doc_numb_aparam = "The dimension of the atomic parameter. If set to >0, file `aparam.npy` should be included to provided the input aparams."
@@ -1506,7 +1505,7 @@ def fitting_ener():
15061505
]
15071506

15081507

1509-
@fitting_args_plugin.register("dos")
1508+
@fitting_args_plugin.register("dos", doc=doc_dos)
15101509
def fitting_dos():
15111510
doc_numb_fparam = "The dimension of the frame parameter. If set to >0, file `fparam.npy` should be included to provided the input fparams."
15121511
doc_numb_aparam = "The dimension of the atomic parameter. If set to >0, file `aparam.npy` should be included to provided the input aparams."
@@ -1594,7 +1593,7 @@ def fitting_property():
15941593
]
15951594

15961595

1597-
@fitting_args_plugin.register("polar")
1596+
@fitting_args_plugin.register("polar", doc=doc_polar)
15981597
def fitting_polar():
15991598
doc_neuron = "The number of neurons in each hidden layers of the fitting net. When two hidden layers are of the same size, a skip connection is built."
16001599
doc_activation_function = f'The activation function in the fitting net. Supported activation functions are {list_to_doc(ACTIVATION_FN_DICT.keys())} Note that "gelu" denotes the custom operator version, and "gelu_tf" denotes the TF standard version. If you set "None" or "none" here, no activation function will be used.'
@@ -1648,7 +1647,7 @@ def fitting_polar():
16481647
# return fitting_polar()
16491648

16501649

1651-
@fitting_args_plugin.register("dipole")
1650+
@fitting_args_plugin.register("dipole", doc=doc_dipole)
16521651
def fitting_dipole():
16531652
doc_neuron = "The number of neurons in each hidden layers of the fitting net. When two hidden layers are of the same size, a skip connection is built."
16541653
doc_activation_function = f'The activation function in the fitting net. Supported activation functions are {list_to_doc(ACTIVATION_FN_DICT.keys())} Note that "gelu" denotes the custom operator version, and "gelu_tf" denotes the TF standard version. If you set "None" or "none" here, no activation function will be used.'
@@ -1687,11 +1686,7 @@ def fitting_dipole():
16871686

16881687
# YWolfeee: Delete global polar mode, merge it into polar mode and use loss setting to support.
16891688
def fitting_variant_type_args():
1690-
doc_descrpt_type = "The type of the fitting. See explanation below. \n\n\
1691-
- `ener`: Fit an energy model (potential energy surface).\n\n\
1692-
- `dos` : Fit a density of states model. The total density of states / site-projected density of states labels should be provided by `dos.npy` or `atom_dos.npy` in each data system. The file has number of frames lines and number of energy grid columns (times number of atoms in `atom_dos.npy`). See `loss` parameter. \n\n\
1693-
- `dipole`: Fit an atomic dipole model. Global dipole labels or atomic dipole labels for all the selected atoms (see `sel_type`) should be provided by `dipole.npy` in each data system. The file either has number of frames lines and 3 times of number of selected atoms columns, or has number of frames lines and 3 columns. See `loss` parameter.\n\n\
1694-
- `polar`: Fit an atomic polarizability model. Global polarizazbility labels or atomic polarizability labels for all the selected atoms (see `sel_type`) should be provided by `polarizability.npy` in each data system. The file with has number of frames lines and 9 times of number of selected atoms columns, or has number of frames lines and 9 columns. See `loss` parameter.\n\n"
1689+
doc_descrpt_type = "The type of the fitting."
16951690

16961691
return Variant(
16971692
"type",
@@ -1722,12 +1717,14 @@ def modifier_dipole_charge():
17221717

17231718

17241719
def modifier_variant_type_args():
1725-
doc_modifier_type = "The type of modifier. See explanation below.\n\n\
1726-
-`dipole_charge`: Use WFCC to model the electronic structure of the system. Correct the long-range interaction"
1720+
doc_modifier_type = "The type of modifier."
1721+
doc_dipole_charge = "Use WFCC to model the electronic structure of the system. Correct the long-range interaction."
17271722
return Variant(
17281723
"type",
17291724
[
1730-
Argument("dipole_charge", dict, modifier_dipole_charge()),
1725+
Argument(
1726+
"dipole_charge", dict, modifier_dipole_charge(), doc=doc_dipole_charge
1727+
),
17311728
],
17321729
optional=False,
17331730
doc=doc_modifier_type,

0 commit comments

Comments
 (0)