Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
77 commits
Select commit Hold shift + click to select a range
ec2e031
implement pytorch-exportable for se_e2_a descriptor
Feb 5, 2026
b8a48ff
better type for xp.zeros
Feb 5, 2026
1cc001f
implement env, base_descriptor and exclude_mask, remove the dependenc…
Feb 6, 2026
f2fbe88
mv to_torch_tensor to common
Feb 6, 2026
e2afbe9
simplify __init__ of the NaiveLayer
Feb 6, 2026
4ba511a
fix bug
Feb 6, 2026
fb9598a
fix bug
Feb 6, 2026
fa03351
simplify init method of se_e2_a descriptor. fig bug in consistent UT
Feb 6, 2026
09b33f1
restructure the test folders. add test_common.
Feb 6, 2026
67f2e54
add test_exclusion_mask.py
Feb 6, 2026
f7d83dd
fix poitential import issue in test.
Feb 6, 2026
0c96bb6
correct __call__(). fix bug
Feb 6, 2026
9dca912
fix registration issue
Feb 6, 2026
17f0a5d
fix pt-expt file extension
Feb 6, 2026
8ce93ba
fix(pt): expansion of get_default_nthreads()
Feb 6, 2026
3091988
fix bug of intra-inter
Feb 6, 2026
85f0583
fix bug of default dp inter value
Feb 6, 2026
d33324d
fix cicd
Feb 6, 2026
4de9a56
feat: add support for se_r
Feb 6, 2026
f4dc0af
fix device of xp array
Feb 6, 2026
2384835
fix device of xp array
Feb 6, 2026
9646d71
revert extend_coord_with_ghosts
Feb 6, 2026
f270069
raise error for non-implemented methods
Feb 6, 2026
57433d3
restore import torch
Feb 6, 2026
eedcbaf
fix(pt,pt-expt): guard thread setters
Feb 6, 2026
d8b2cf4
make exclusion mask modules
Feb 6, 2026
aeef15a
fix(pt-expt): clear params on None
Feb 6, 2026
8bdb1f8
fix bug
Feb 7, 2026
d3b01da
utility to handel dpmodel -> pt_expt conversion
Feb 8, 2026
3452a2a
fix to_numpy_array device
Feb 8, 2026
ba8e7ab
chore(dpmodel,pt_expt): refactorize the implementation of embedding net
Feb 8, 2026
621c7cc
feat: se_t and se_t_tebd descriptors for the pytroch exportable backend.
Feb 8, 2026
faa4026
fix bug
Feb 8, 2026
e263270
refact: fitting net
Feb 8, 2026
ea61141
fix bug
Feb 8, 2026
de8f156
merge master
Feb 8, 2026
ad83d98
Merge branch 'refact-auto-setattr' into refact-fitting-net
Feb 8, 2026
9311ed5
feat(pt_expt): add fitting
Feb 9, 2026
9472af7
merge master
Feb 10, 2026
6ef9cd8
merge with master
Feb 11, 2026
165d1df
fix the API consistency issue in descriptors
Feb 11, 2026
e76b702
feat: add stat for dpmodel's atomic model. implement atomic model for…
Feb 11, 2026
03974dd
merge master
Feb 12, 2026
4ae2726
feat: full energy model (but not exportable)
Feb 12, 2026
fb08ffc
add missing file
Feb 12, 2026
ed460a5
add missing file
Feb 12, 2026
f5171f2
merge master
Feb 12, 2026
a59c18d
fix test
Feb 12, 2026
d057ca1
fix test
Feb 12, 2026
b3d22da
fix test
Feb 12, 2026
d2e4faa
Merge branch 'feat-fitting' into feat-atomic-model
Feb 12, 2026
d094d21
merge with updated feat-atomic-model
Feb 12, 2026
a920ef6
use torch_module to simplify the def of modules.
Feb 12, 2026
56cbe2d
simplify three autograd to one by vmap, which was made inpossible by jit
Feb 12, 2026
bcb4008
export forward_lower, but not successful
Feb 12, 2026
4437146
Merge remote-tracking branch 'upstream/master' into feat-atomic-model
Feb 13, 2026
33a9db3
Merge branch 'feat-atomic-model' into feat-full-model
Feb 13, 2026
d0e22d2
make forward_lower exportable
Feb 13, 2026
1f7bb6c
implement all EnergyModel APIs in pt but not in dpmodel. add a compre…
Feb 13, 2026
4be000c
Merge branch 'master' into feat-atomic-model
wanghan-iapcm Feb 13, 2026
2ea6b74
simplify the code
Feb 14, 2026
459afa2
Merge remote-tracking branch 'origin/feat-atomic-model' into feat-ato…
Feb 14, 2026
21077bc
fix bug
Feb 14, 2026
bdd015c
fix issues
Feb 14, 2026
1c1ea90
Merge branch 'feat-atomic-model' into feat-full-model
Feb 14, 2026
77609c1
more careful check on the compute_or_load_stat
Feb 14, 2026
1fa1eb2
merge master
Feb 14, 2026
b67accc
add guard for eval_descriptor and eval_fitting_last_layer
Feb 15, 2026
19df985
fix issues
Feb 15, 2026
fc0be62
remove eval_ hooks
Feb 15, 2026
c15212d
rm eval_return_middle_output
Feb 15, 2026
1ef67ec
make output of energy model compatible among backends
Feb 15, 2026
79fa7ce
fix bugs
Feb 16, 2026
9eae3cd
fix bugs
Feb 16, 2026
f6a695f
implement rename for all models
Feb 16, 2026
ecc411e
fixes
Feb 16, 2026
53a7e7f
fix bugs
Feb 16, 2026
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
4 changes: 3 additions & 1 deletion deepmd/dpmodel/fitting/general_fitting.py
Original file line number Diff line number Diff line change
Expand Up @@ -584,6 +584,7 @@ def _call_common(
)

# calculate the prediction
results: dict[str, Array] = {}
if not self.mixed_types:
outs = xp.zeros(
[nf, nloc, net_dim_out],
Expand Down Expand Up @@ -622,4 +623,5 @@ def _call_common(
exclude_mask = xp.astype(exclude_mask, xp.bool)
# nf x nloc x nod
outs = xp.where(exclude_mask[:, :, None], outs, xp.zeros_like(outs))
return {self.var_name: outs}
results[self.var_name] = outs
return results
4 changes: 1 addition & 3 deletions deepmd/dpmodel/infer/deep_eval.py
Original file line number Diff line number Diff line change
Expand Up @@ -358,9 +358,7 @@ def _eval_model(

results = []
for odef in request_defs:
# it seems not doing conversion
# dp_name = self._OUTDEF_DP2BACKEND[odef.name]
dp_name = odef.name
dp_name = self._OUTDEF_DP2BACKEND[odef.name]
if dp_name in batch_output:
shape = self._get_output_shape(odef, nframes, natoms)
if batch_output[dp_name] is not None:
Expand Down
90 changes: 90 additions & 0 deletions deepmd/dpmodel/model/dipole_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
Any,
)

from deepmd.dpmodel.array_api import (
Array,
)
from deepmd.dpmodel.atomic_model import (
DPDipoleAtomicModel,
)
Expand Down Expand Up @@ -31,3 +34,90 @@
) -> None:
DPModelCommon.__init__(self)
DPDipoleModel_.__init__(self, *args, **kwargs)

def translated_output_def(self) -> dict[str, Any]:
out_def_data = self.model_output_def().get_data()
output_def = {
"dipole": out_def_data["dipole"],
"global_dipole": out_def_data["dipole_redu"],
}
if self.do_grad_r("dipole"):
output_def["force"] = out_def_data["dipole_derv_r"]
output_def["force"].squeeze(-2)
if self.do_grad_c("dipole"):
output_def["virial"] = out_def_data["dipole_derv_c_redu"]
output_def["virial"].squeeze(-2)
output_def["atom_virial"] = out_def_data["dipole_derv_c"]
output_def["atom_virial"].squeeze(-2)
if "mask" in out_def_data:
output_def["mask"] = out_def_data["mask"]
return output_def

def call(
self,
coord: Array,
atype: Array,
box: Array | None = None,
fparam: Array | None = None,
aparam: Array | None = None,
do_atomic_virial: bool = False,
) -> dict[str, Array]:
Comment on lines +56 to +64

Check warning

Code scanning / CodeQL

Signature mismatch in overriding method Warning

This method does not accept arbitrary keyword arguments, which overridden
NativeOP.call
does.
This call
correctly calls the base method, but does not match the signature of the overriding method.
This method requires at most 7 positional arguments, whereas overridden
NativeOP.call
may be called with arbitrarily many.
This call
correctly calls the base method, but does not match the signature of the overriding method.
This method requires at least 3 positional arguments, whereas overridden
NativeOP.call
may be called with 1.
This call
correctly calls the base method, but does not match the signature of the overriding method.
model_ret = self.call_common(
coord,
atype,
box,
fparam=fparam,
aparam=aparam,
do_atomic_virial=do_atomic_virial,
)
if self.get_fitting_net() is not None:
model_predict = {}
model_predict["dipole"] = model_ret["dipole"]
model_predict["global_dipole"] = model_ret["dipole_redu"]
if self.do_grad_r("dipole"):
model_predict["force"] = model_ret.get("dipole_derv_r")
if self.do_grad_c("dipole"):
model_predict["virial"] = model_ret.get("dipole_derv_c_redu")
if do_atomic_virial:
model_predict["atom_virial"] = model_ret.get("dipole_derv_c")
if "mask" in model_ret:
model_predict["mask"] = model_ret["mask"]
else:
model_predict = model_ret
model_predict["updated_coord"] += coord
return model_predict

def call_lower(
self,
extended_coord: Array,
extended_atype: Array,
nlist: Array,
mapping: Array | None = None,
fparam: Array | None = None,
aparam: Array | None = None,
do_atomic_virial: bool = False,
) -> dict[str, Array]:
model_ret = self.call_common_lower(
extended_coord,
extended_atype,
nlist,
mapping,
fparam=fparam,
aparam=aparam,
do_atomic_virial=do_atomic_virial,
)
if self.get_fitting_net() is not None:
model_predict = {}
model_predict["dipole"] = model_ret["dipole"]
model_predict["global_dipole"] = model_ret["dipole_redu"]
if self.do_grad_r("dipole"):
model_predict["extended_force"] = model_ret.get("dipole_derv_r")
if self.do_grad_c("dipole"):
model_predict["virial"] = model_ret.get("dipole_derv_c_redu")
if do_atomic_virial:
model_predict["extended_virial"] = model_ret.get("dipole_derv_c")
else:
model_predict = model_ret
return model_predict

forward_lower = call_lower
70 changes: 70 additions & 0 deletions deepmd/dpmodel/model/dos_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
Any,
)

from deepmd.dpmodel.array_api import (
Array,
)
from deepmd.dpmodel.atomic_model import (
DPDOSAtomicModel,
)
Expand Down Expand Up @@ -31,3 +34,70 @@
) -> None:
DPModelCommon.__init__(self)
DPDOSModel_.__init__(self, *args, **kwargs)

def translated_output_def(self) -> dict[str, Any]:
out_def_data = self.model_output_def().get_data()
output_def = {
"atom_dos": out_def_data["dos"],
"dos": out_def_data["dos_redu"],
}
if "mask" in out_def_data:
output_def["mask"] = out_def_data["mask"]
return output_def

def call(
self,
coord: Array,
atype: Array,
box: Array | None = None,
fparam: Array | None = None,
aparam: Array | None = None,
do_atomic_virial: bool = False,
) -> dict[str, Array]:
Comment on lines +48 to +56

Check warning

Code scanning / CodeQL

Signature mismatch in overriding method Warning

This method does not accept arbitrary keyword arguments, which overridden
NativeOP.call
does.
This call
correctly calls the base method, but does not match the signature of the overriding method.
This method requires at most 7 positional arguments, whereas overridden
NativeOP.call
may be called with arbitrarily many.
This call
correctly calls the base method, but does not match the signature of the overriding method.
This method requires at least 3 positional arguments, whereas overridden
NativeOP.call
may be called with 1.
This call
correctly calls the base method, but does not match the signature of the overriding method.
model_ret = self.call_common(
coord,
atype,
box,
fparam=fparam,
aparam=aparam,
do_atomic_virial=do_atomic_virial,
)
if self.get_fitting_net() is not None:
model_predict = {}
model_predict["atom_dos"] = model_ret["dos"]
model_predict["dos"] = model_ret["dos_redu"]
if "mask" in model_ret:
model_predict["mask"] = model_ret["mask"]
else:
model_predict = model_ret
model_predict["updated_coord"] += coord
return model_predict

def call_lower(
self,
extended_coord: Array,
extended_atype: Array,
nlist: Array,
mapping: Array | None = None,
fparam: Array | None = None,
aparam: Array | None = None,
do_atomic_virial: bool = False,
) -> dict[str, Array]:
model_ret = self.call_common_lower(
extended_coord,
extended_atype,
nlist,
mapping,
fparam=fparam,
aparam=aparam,
do_atomic_virial=do_atomic_virial,
)
if self.get_fitting_net() is not None:
model_predict = {}
model_predict["atom_dos"] = model_ret["dos"]
model_predict["dos"] = model_ret["dos_redu"]
else:
model_predict = model_ret
return model_predict

forward_lower = call_lower
4 changes: 4 additions & 0 deletions deepmd/dpmodel/model/dp_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,7 @@ def update_sel(
def get_fitting_net(self) -> BaseFitting:
"""Get the fitting network."""
return self.atomic_model.fitting

def get_descriptor(self) -> BaseDescriptor:
"""Get the descriptor."""
return self.atomic_model.descriptor
111 changes: 111 additions & 0 deletions deepmd/dpmodel/model/dp_zbl_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
Any,
)

from deepmd.dpmodel.array_api import (
Array,
)
from deepmd.dpmodel.atomic_model.linear_atomic_model import (
DPZBLLinearEnergyAtomicModel,
)
Expand Down Expand Up @@ -34,6 +37,114 @@
) -> None:
super().__init__(*args, **kwargs)

def translated_output_def(self) -> dict[str, Any]:
out_def_data = self.model_output_def().get_data()
output_def = {
"atom_energy": out_def_data["energy"],
"energy": out_def_data["energy_redu"],
}
if self.do_grad_r("energy"):
output_def["force"] = out_def_data["energy_derv_r"]
output_def["force"].squeeze(-2)
if self.do_grad_c("energy"):
output_def["virial"] = out_def_data["energy_derv_c_redu"]
output_def["virial"].squeeze(-2)
output_def["atom_virial"] = out_def_data["energy_derv_c"]
output_def["atom_virial"].squeeze(-2)
if "mask" in out_def_data:
output_def["mask"] = out_def_data["mask"]
return output_def

def call(
self,
coord: Array,
atype: Array,
box: Array | None = None,
fparam: Array | None = None,
aparam: Array | None = None,
do_atomic_virial: bool = False,
) -> dict[str, Array]:
Comment on lines +58 to +66

Check warning

Code scanning / CodeQL

Signature mismatch in overriding method Warning

This method does not accept arbitrary keyword arguments, which overridden
NativeOP.call
does.
This call
correctly calls the base method, but does not match the signature of the overriding method.
This method requires at most 7 positional arguments, whereas overridden
NativeOP.call
may be called with arbitrarily many.
This call
correctly calls the base method, but does not match the signature of the overriding method.
This method requires at least 3 positional arguments, whereas overridden
NativeOP.call
may be called with 1.
This call
correctly calls the base method, but does not match the signature of the overriding method.
model_ret = self.call_common(
coord,
atype,
box,
fparam=fparam,
aparam=aparam,
do_atomic_virial=do_atomic_virial,
)
model_predict = {}
model_predict["atom_energy"] = model_ret["energy"]
model_predict["energy"] = model_ret["energy_redu"]
if self.do_grad_r("energy"):
if model_ret.get("energy_derv_r") is not None:
model_predict["force"] = model_ret["energy_derv_r"].squeeze(-2)
else:
model_predict["force"] = model_ret.get("energy_derv_r")
if self.do_grad_c("energy"):
derv_c_redu = model_ret.get("energy_derv_c_redu")
if derv_c_redu is not None:
model_predict["virial"] = derv_c_redu.squeeze(-2)
else:
model_predict["virial"] = derv_c_redu
if do_atomic_virial:
derv_c = model_ret.get("energy_derv_c")
if derv_c is not None:
model_predict["atom_virial"] = derv_c.squeeze(-2)
else:
model_predict["atom_virial"] = derv_c
else:
if model_ret.get("dforce") is not None:
model_predict["force"] = model_ret["dforce"]
if "mask" in model_ret:
model_predict["mask"] = model_ret["mask"]
return model_predict

def call_lower(
self,
extended_coord: Array,
extended_atype: Array,
nlist: Array,
mapping: Array | None = None,
fparam: Array | None = None,
aparam: Array | None = None,
do_atomic_virial: bool = False,
) -> dict[str, Array]:
model_ret = self.call_common_lower(
extended_coord,
extended_atype,
nlist,
mapping,
fparam=fparam,
aparam=aparam,
do_atomic_virial=do_atomic_virial,
)
model_predict = {}
model_predict["atom_energy"] = model_ret["energy"]
model_predict["energy"] = model_ret["energy_redu"]
if self.do_grad_r("energy"):
if model_ret.get("energy_derv_r") is not None:
model_predict["extended_force"] = model_ret["energy_derv_r"].squeeze(-2)
else:
model_predict["extended_force"] = model_ret.get("energy_derv_r")
if self.do_grad_c("energy"):
derv_c_redu = model_ret.get("energy_derv_c_redu")
if derv_c_redu is not None:
model_predict["virial"] = derv_c_redu.squeeze(-2)
else:
model_predict["virial"] = derv_c_redu
if do_atomic_virial:
derv_c = model_ret.get("energy_derv_c")
if derv_c is not None:
model_predict["extended_virial"] = derv_c.squeeze(-2)
else:
model_predict["extended_virial"] = derv_c
else:
if model_ret.get("dforce") is not None:
model_predict["dforce"] = model_ret["dforce"]
return model_predict

forward_lower = call_lower

@classmethod
def update_sel(
cls,
Expand Down
Loading