Skip to content

Commit 271b3a5

Browse files
committed
add type_embed_num_features arg to NequIPGNNModel
1 parent b6c7780 commit 271b3a5

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ Most recent change on the top.
1010

1111

1212
### Added
13-
- Users can specify having irreps of different multiplicites in `NequIPGNNModel` by providing `num_features` that is a list of `l_max + 1` features. E.g. for `l_max=2` and `parity=False`, `num_features=[5, 2, 7]` refers to `5x0e`, `2x1o` and `7x2e` features (see `configs/tutorial.yaml` for an example)
13+
- users can specify having irreps of different multiplicites in `NequIPGNNModel` by providing `num_features` that is a list of `l_max + 1` features. E.g. for `l_max=2` and `parity=False`, `num_features=[5, 2, 7]` refers to `5x0e`, `2x1o` and `7x2e` features (see `configs/tutorial.yaml` for an example)
14+
- users can specify `type_embed_num_features` as a separate hyperparameter to control the number of features in the type embedding layer (defaults to `num_features[0]`)
1415
- batched AOTI inference
1516
- per-edge-type cutoff can now lead to cost reduction in the LAMMPS ML-IAP interface
1617
- optional `--constant-fold` acceleration argument for `nequip-compile --mode aotinductor` that can provide small speed ups for PyTorch >= 2.8 (may fail with some models, please open issues if that such instances are encountered)

nequip/model/nequip_models.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ def NequIPGNNModel(
3434
l_max: int = 1,
3535
parity: bool = True,
3636
num_features: Union[int, List[int]] = 32,
37+
type_embed_num_features: Optional[int] = None,
3738
radial_mlp_depth: int = 2,
3839
radial_mlp_width: int = 64,
3940
**kwargs,
@@ -50,6 +51,7 @@ def NequIPGNNModel(
5051
l_max (int): the maximum rotation order for the network's features, ``1`` is a good default, ``2`` is more accurate but slower (default ``1``)
5152
parity (bool): whether to include features with odd mirror parity -- often turning parity off gives equally good results but faster networks, so it's worth testing (default ``True``)
5253
num_features (int/List[int]): multiplicity of the features, smaller is faster (default ``32``); it is also possible to provide the multiplicity for each irrep, e.g. for ``l_max=2`` and ``parity=False``, ``num_features=[5, 2, 7]`` refers to ``5x0e``, ``2x1o`` and ``7x2e`` features
54+
type_embed_num_features (int): number of features for the type embedding layer; if not provided, defaults to ``num_features[0]`` (default ``None``)
5355
radial_mlp_depth (int): number of radial layers, usually 1-3 works best, smaller is faster (default ``2``)
5456
radial_mlp_width (int): number of hidden neurons in radial function, smaller is faster (default ``64``)
5557
num_bessels (int): number of Bessel basis functions (default ``8``)
@@ -80,6 +82,13 @@ def NequIPGNNModel(
8082
f"`num_features` should be of length `l_max + 1` ({l_max + 1}), but found `num_features={num_features}` with {len(num_features)} entries."
8183
)
8284

85+
# === type embedding ===
86+
type_embed_num_features = (
87+
type_embed_num_features
88+
if type_embed_num_features is not None
89+
else num_features[0]
90+
)
91+
8392
# === convnet ===
8493
# convert a single set of parameters uniformly for every layer
8594
feature_irreps_hidden = repr(
@@ -101,7 +110,7 @@ def NequIPGNNModel(
101110
# === build model ===
102111
model = FullNequIPGNNModel(
103112
irreps_edge_sh=irreps_edge_sh,
104-
type_embed_num_features=num_features[0],
113+
type_embed_num_features=type_embed_num_features,
105114
feature_irreps_hidden=feature_irreps_hidden_list,
106115
radial_mlp_depth=radial_mlp_depth_list,
107116
radial_mlp_width=radial_mlp_width_list,

0 commit comments

Comments
 (0)