deepmd.pt.model.descriptor.dpa3#
Classes#
The DPA3 descriptor[Rfbfb621257be-1]_. |
Module Contents#
- class deepmd.pt.model.descriptor.dpa3.DescrptDPA3(ntypes: int, repflow: deepmd.dpmodel.descriptor.dpa3.RepFlowArgs | dict, concat_output_tebd: bool = False, activation_function: str = 'silu', precision: str = 'float64', exclude_types: list[tuple[int, int]] = [], env_protection: float = 0.0, trainable: bool = True, seed: int | list[int] | None = None, use_econf_tebd: bool = False, use_tebd_bias: bool = False, use_loc_mapping: bool = True, type_map: list[str] | None = None)[source]#
Bases:
deepmd.pt.model.descriptor.base_descriptor.BaseDescriptor,torch.nn.ModuleThe DPA3 descriptor[Rfbfb621257be-1]_.
- Parameters:
- repflow
Union[RepFlowArgs,dict] The arguments used to initialize the repflow block, see docstr in RepFlowArgs for details information.
- concat_output_tebdbool,
optional Whether to concat type embedding at the output of the descriptor.
- activation_function
str,optional The activation function in the embedding net.
- precision
str,optional The precision of the embedding net parameters.
- exclude_types
list[list[int]],optional The excluded pairs of types which have no interaction with each other. For example, [[0, 1]] means no interaction between type 0 and type 1.
- env_protection
float,optional Protection parameter to prevent division by zero errors during environment matrix calculations. For example, when using paddings, there may be zero distances of neighbors, which may make division by zero error during environment matrix calculations without protection.
- trainablebool,
optional If the parameters are trainable.
- seed
int,optional Random seed for parameter initialization.
- use_econf_tebdbool,
Optional Whether to use electronic configuration type embedding.
- use_tebd_biasbool,
Optional Whether to use bias in the type embedding layer.
- use_loc_mappingbool,
Optional Whether to use local atom index mapping in training or non-parallel inference. When True, local indexing and mapping are applied to neighbor lists and embeddings during descriptor computation.
- type_map
list[str],Optional A list of strings. Give the name to each type of atoms.
- repflow
References
[1]Zhang, D., Peng, A., Cai, C. et al. Graph neural network model for the era of large atomistic models. arXiv preprint arXiv:2506.01686 (2025).
- get_rcut_smth() float[source]#
Returns the radius where the neighbor information starts to smoothly decay to 0.
- mixed_types() bool[source]#
If true, the descriptor 1. assumes total number of atoms aligned across frames; 2. requires a neighbor list that does not distinguish different atomic types.
If false, the descriptor 1. assumes total number of atoms of each atom type aligned across frames; 2. requires a neighbor list that distinguishes different atomic types.
- need_sorted_nlist_for_lower() bool[source]#
Returns whether the descriptor needs sorted nlist when using forward_lower.
Share the parameters of self to the base_class with shared_level during multitask training. If not start from checkpoint (resume is False), some separated parameters (e.g. mean and stddev) will be re-calculated across different classes.
- change_type_map(type_map: list[str], model_with_new_type_stat=None) None[source]#
Change the type related params to new ones, according to type_map and the original one in the model. If there are new types in type_map, statistics will be updated accordingly to model_with_new_type_stat for these new types.
- compute_input_stats(merged: Callable[[], list[dict]] | list[dict], path: deepmd.utils.path.DPPath | None = None) None[source]#
Compute the input statistics (e.g. mean and stddev) for the descriptors from packed data.
- Parameters:
- merged
Union[Callable[[],list[dict]],list[dict]] - list[dict]: A list of data samples from various data systems.
Each element, merged[i], is a data dictionary containing keys: torch.Tensor originating from the i-th data system.
- Callable[[], list[dict]]: A lazy function that returns data samples in the above format
only when needed. Since the sampling process can be slow and memory-intensive, the lazy function helps by only sampling once.
- path
Optional[DPPath] The path to the stat file.
- merged
- set_stat_mean_and_stddev(mean: list[torch.Tensor], stddev: list[torch.Tensor]) None[source]#
Update mean and stddev for descriptor.
- get_stat_mean_and_stddev() tuple[list[torch.Tensor], list[torch.Tensor]][source]#
Get mean and stddev for descriptor.
- classmethod deserialize(data: dict) DescrptDPA3[source]#
Deserialize the model.
- Parameters:
- data
dict The serialized data
- data
- Returns:
BDThe deserialized descriptor
- forward(extended_coord: torch.Tensor, extended_atype: torch.Tensor, nlist: torch.Tensor, mapping: torch.Tensor | None = None, comm_dict: dict[str, torch.Tensor] | None = None)[source]#
Compute the descriptor.
- Parameters:
- extended_coord
The extended coordinates of atoms. shape: nf x (nallx3)
- extended_atype
The extended aotm types. shape: nf x nall
- nlist
The neighbor list. shape: nf x nloc x nnei
- mapping
The index mapping, mapps extended region index to local region.
- comm_dict
The data needed for communication for parallel inference.
- Returns:
node_ebdThe output descriptor. shape: nf x nloc x n_dim (or n_dim + tebd_dim)
rot_matThe rotationally equivariant and permutationally invariant single particle representation. shape: nf x nloc x e_dim x 3
edge_ebdThe edge embedding. shape: nf x nloc x nnei x e_dim
h2The rotationally equivariant pair-partical representation. shape: nf x nloc x nnei x 3
swThe smooth switch function. shape: nf x nloc x nnei
- classmethod update_sel(train_data: deepmd.utils.data_system.DeepmdDataSystem, type_map: list[str] | None, local_jdata: dict) tuple[dict, float | None][source]#
Update the selection and perform neighbor statistics.
- abstractmethod enable_compression(min_nbor_dist: float, table_extrapolate: float = 5, table_stride_1: float = 0.01, table_stride_2: float = 0.1, check_frequency: int = -1) None[source]#
Receive the statistics (distance, max_nbor_size and env_mat_range) of the training data.
- Parameters:
- min_nbor_dist
The nearest distance between atoms
- table_extrapolate
The scale of model extrapolation
- table_stride_1
The uniform stride of the first table
- table_stride_2
The uniform stride of the second table
- check_frequency
The overflow check frequency