-
Notifications
You must be signed in to change notification settings - Fork 510
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
<!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Introduced a new descriptor class `DescrptSeT` for enhanced compatibility with array APIs. - Added support for JAX as a backend option for the `"se_e3"` descriptor. - **Bug Fixes** - Improved array handling in the `clear` method of the `NN` class to ensure compatibility across different array implementations. - **Documentation** - Updated the module exports to include the new `DescrptSeT` class. - Expanded documentation to reflect JAX as a supported backend for the `"se_e3"` descriptor. - **Tests** - Enhanced the test suite to support additional computational backends and added new evaluation methods. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Signed-off-by: Jinzhe Zeng <[email protected]>
- Loading branch information
Showing
7 changed files
with
144 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
# SPDX-License-Identifier: LGPL-3.0-or-later | ||
from typing import ( | ||
Any, | ||
) | ||
|
||
from deepmd.dpmodel.descriptor.se_t import DescrptSeT as DescrptSeTDP | ||
from deepmd.jax.common import ( | ||
ArrayAPIVariable, | ||
flax_module, | ||
to_jax_array, | ||
) | ||
from deepmd.jax.descriptor.base_descriptor import ( | ||
BaseDescriptor, | ||
) | ||
from deepmd.jax.utils.exclude_mask import ( | ||
PairExcludeMask, | ||
) | ||
from deepmd.jax.utils.network import ( | ||
NetworkCollection, | ||
) | ||
|
||
|
||
@BaseDescriptor.register("se_e3") | ||
@BaseDescriptor.register("se_at") | ||
@BaseDescriptor.register("se_a_3be") | ||
@flax_module | ||
class DescrptSeT(DescrptSeTDP): | ||
def __setattr__(self, name: str, value: Any) -> None: | ||
if name in {"dstd", "davg"}: | ||
value = to_jax_array(value) | ||
if value is not None: | ||
value = ArrayAPIVariable(value) | ||
elif name in {"embeddings"}: | ||
if value is not None: | ||
value = NetworkCollection.deserialize(value.serialize()) | ||
elif name == "env_mat": | ||
# env_mat doesn't store any value | ||
pass | ||
elif name == "emask": | ||
value = PairExcludeMask(value.ntypes, value.exclude_types) | ||
|
||
return super().__setattr__(name, value) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# SPDX-License-Identifier: LGPL-3.0-or-later | ||
from typing import ( | ||
Any, | ||
) | ||
|
||
from deepmd.dpmodel.descriptor.se_t import DescrptSeT as DescrptSeTDP | ||
|
||
from ..common import ( | ||
to_array_api_strict_array, | ||
) | ||
from ..utils.exclude_mask import ( | ||
PairExcludeMask, | ||
) | ||
from ..utils.network import ( | ||
NetworkCollection, | ||
) | ||
|
||
|
||
class DescrptSeT(DescrptSeTDP): | ||
def __setattr__(self, name: str, value: Any) -> None: | ||
if name in {"dstd", "davg"}: | ||
value = to_array_api_strict_array(value) | ||
elif name in {"embeddings"}: | ||
if value is not None: | ||
value = NetworkCollection.deserialize(value.serialize()) | ||
elif name == "env_mat": | ||
# env_mat doesn't store any value | ||
pass | ||
elif name == "emask": | ||
value = PairExcludeMask(value.ntypes, value.exclude_types) | ||
|
||
return super().__setattr__(name, value) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters