Skip to content

Commit e94d93c

Browse files
Merge branch 'v2.10'
2 parents df08667 + 0926471 commit e94d93c

14 files changed

Lines changed: 875 additions & 460 deletions

File tree

.ci/pytorch/requirements.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# The extra url makes pip grap the torch fersion we want to use in the regtests
22
--extra-index-url=https://download.pytorch.org/whl/cpu
33
torch>=2.7
4-
metatomic-torch>=0.1.3,<0.2
5-
featomic-torch==0.7.0
4+
metatomic-torch>=0.1.13,<0.2
5+
featomic-torch>=0.7.4,<0.8

configure

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10235,8 +10235,8 @@ $as_echo_n "checking libmetatomic without extra libs... " >&6; }
1023510235
#include <metatensor.hpp>
1023610236
#include <metatensor/torch.hpp>
1023710237
#include <metatomic/torch.hpp>
10238-
#if METATOMIC_TORCH_VERSION_MAJOR != 0 || METATOMIC_TORCH_VERSION_MINOR != 1
10239-
#error "this code is only compatible with metatomic-torch >=0.1,<0.2"
10238+
#if METATOMIC_TORCH_VERSION_MAJOR != 0 || METATOMIC_TORCH_VERSION_MINOR != 1 || METATOMIC_TORCH_VERSION_PATCH < 12
10239+
#error "this code is only compatible with metatomic-torch >=0.1.12,<0.2"
1024010240
#endif
1024110241
int main() {
1024210242
metatomic_torch::version();
@@ -10284,8 +10284,8 @@ $as_echo_n "checking libmetatomic with $all_LIBS... " >&6; }
1028410284
#include <metatensor.hpp>
1028510285
#include <metatensor/torch.hpp>
1028610286
#include <metatomic/torch.hpp>
10287-
#if METATOMIC_TORCH_VERSION_MAJOR != 0 || METATOMIC_TORCH_VERSION_MINOR != 1
10288-
#error "this code is only compatible with metatomic-torch >=0.1,<0.2"
10287+
#if METATOMIC_TORCH_VERSION_MAJOR != 0 || METATOMIC_TORCH_VERSION_MINOR != 1 || METATOMIC_TORCH_VERSION_PATCH < 12
10288+
#error "this code is only compatible with metatomic-torch >=0.1.12,<0.2"
1028910289
#endif
1029010290
int main() {
1029110291
metatomic_torch::version();
@@ -10333,8 +10333,8 @@ $as_echo_n "checking libmetatomic with -l$testlib... " >&6; }
1033310333
#include <metatensor.hpp>
1033410334
#include <metatensor/torch.hpp>
1033510335
#include <metatomic/torch.hpp>
10336-
#if METATOMIC_TORCH_VERSION_MAJOR != 0 || METATOMIC_TORCH_VERSION_MINOR != 1
10337-
#error "this code is only compatible with metatomic-torch >=0.1,<0.2"
10336+
#if METATOMIC_TORCH_VERSION_MAJOR != 0 || METATOMIC_TORCH_VERSION_MINOR != 1 || METATOMIC_TORCH_VERSION_PATCH < 12
10337+
#error "this code is only compatible with metatomic-torch >=0.1.12,<0.2"
1033810338
#endif
1033910339
int main() {
1034010340
metatomic_torch::version();

configure.ac

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1021,8 +1021,8 @@ if test $libmetatomic = true ; then
10211021
#include <metatensor.hpp>
10221022
#include <metatensor/torch.hpp>
10231023
#include <metatomic/torch.hpp>
1024-
#if METATOMIC_TORCH_VERSION_MAJOR != 0 || METATOMIC_TORCH_VERSION_MINOR != 1
1025-
#error "this code is only compatible with metatomic-torch >=0.1,<0.2"
1024+
#if METATOMIC_TORCH_VERSION_MAJOR != 0 || METATOMIC_TORCH_VERSION_MINOR != 1 || METATOMIC_TORCH_VERSION_PATCH < 12
1025+
#error "this code is only compatible with metatomic-torch >=0.1.12,<0.2"
10261026
#endif
10271027
int main() {
10281028
metatomic_torch::version();

regtest/metatomic/rt-basic/cv.py

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -32,30 +32,31 @@ class TestCollectiveVariable(torch.nn.Module):
3232
CV^2 are returned.
3333
"""
3434

35-
def __init__(self, cutoff, multiple_properties):
35+
def __init__(self, cutoff, multiple_properties, feature_key="feature"):
3636
super().__init__()
3737

3838
self._nl_request = NeighborListOptions(
3939
cutoff=cutoff, full_list=True, strict=True
4040
)
4141
self._multiple_properties = multiple_properties
42+
self._feature_key = feature_key
4243

4344
def forward(
4445
self,
4546
systems: List[System],
4647
outputs: Dict[str, ModelOutput],
4748
selected_atoms: Optional[Labels],
4849
) -> Dict[str, TensorMap]:
49-
if "features" not in outputs:
50+
if self._feature_key not in outputs:
5051
return {}
5152

5253
device = torch.device("cpu")
5354
if len(systems) > 0:
5455
device = systems[0].positions.device
5556

56-
output = outputs["features"]
57+
output = outputs[self._feature_key]
5758

58-
if output.per_atom:
59+
if output.sample_kind == "atom":
5960
samples_list: List[List[int]] = []
6061
for s, system in enumerate(systems):
6162
for i in range(len(system)):
@@ -67,6 +68,7 @@ def forward(
6768
sample_values.reshape(-1, 2),
6869
)
6970
else:
71+
assert output.sample_kind == "system"
7072
samples = Labels(
7173
"system", torch.arange(len(systems), device=device).reshape(-1, 1)
7274
)
@@ -89,14 +91,14 @@ def forward(
8991
distances = torch.linalg.vector_norm(neighbors.values.reshape(-1, 3), dim=1)
9092
inv_dist = 1.0 / distances
9193

92-
if output.per_atom:
94+
if output.sample_kind == "atom":
9395
sliced = values[system_start:system_stop, 0]
9496
sliced += sliced.index_add(0, atom_index, inv_dist)
9597
else:
9698
values[system_i, 0] += inv_dist.sum()
9799

98100
if self._multiple_properties:
99-
if output.per_atom:
101+
if output.sample_kind == "atom":
100102
sliced = values[system_start:system_stop, 1]
101103
sliced += sliced.index_add(0, atom_index, inv_dist**2)
102104
else:
@@ -116,14 +118,14 @@ def forward(
116118
)
117119

118120
if selected_atoms is not None:
119-
if output.per_atom:
121+
if output.sample_kind == "atom":
120122
cv = mts.slice(cv, axis="samples", selection=selected_atoms)
121123
else:
122124
raise ValueError(
123125
"selected atoms is only supported with per-atom output"
124126
)
125127

126-
return {"features": cv}
128+
return {self._feature_key: cv}
127129

128130
def requested_neighbor_lists(self) -> List[NeighborListOptions]:
129131
return [self._nl_request]
@@ -132,7 +134,7 @@ def requested_neighbor_lists(self) -> List[NeighborListOptions]:
132134
CUTOFF = 3.5
133135

134136
capabilities = ModelCapabilities(
135-
outputs={"features": ModelOutput(per_atom=True)},
137+
outputs={"feature": ModelOutput(sample_kind="atom")},
136138
interaction_range=CUTOFF,
137139
supported_devices=["cpu", "mps", "cuda"],
138140
length_unit="A",
@@ -152,7 +154,7 @@ def requested_neighbor_lists(self) -> List[NeighborListOptions]:
152154
model.save("vector-per-atom.pt")
153155

154156
capabilities = ModelCapabilities(
155-
outputs={"features": ModelOutput(per_atom=False)},
157+
outputs={"feature": ModelOutput(sample_kind="system")},
156158
interaction_range=CUTOFF,
157159
supported_devices=["cpu", "mps", "cuda"],
158160
length_unit="A",
@@ -169,3 +171,12 @@ def requested_neighbor_lists(self) -> List[NeighborListOptions]:
169171
cv.eval()
170172
model = AtomisticModel(cv, ModelMetadata(), capabilities)
171173
model.save("vector-global.pt")
174+
175+
176+
cv = TestCollectiveVariable(
177+
cutoff=CUTOFF, multiple_properties=False, feature_key="feature/variant"
178+
)
179+
capabilities.outputs = {"feature/variant": ModelOutput(sample_kind="system")}
180+
cv.eval()
181+
model = AtomisticModel(cv, ModelMetadata(), capabilities)
182+
model.save("variant-global.pt")
Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
9
2-
-4795.88 -5679.30 -5054.72
3-
X 147.18 -79.30 -178.34
4-
X -174.21 -55.39 124.40
5-
X -214.90 78.13 151.48
6-
X -424.19 203.64 276.74
7-
X 71.31 -44.07 35.23
8-
X 230.71 -150.74 -438.92
9-
X 140.70 -55.57 -67.27
10-
X 208.55 -18.70 211.20
11-
X 14.85 122.00 -114.51
2+
-4822.75 -5711.13 -5083.06
3+
X 148.00 -79.74 -179.33
4+
X -175.19 -55.70 125.09
5+
X -216.11 78.57 152.33
6+
X -426.55 204.77 278.27
7+
X 71.71 -44.32 35.43
8+
X 231.98 -151.58 -441.35
9+
X 141.49 -55.88 -67.65
10+
X 209.72 -18.80 212.37
11+
X 14.94 122.68 -115.16

regtest/metatomic/rt-basic/plumed.dat

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,15 +55,28 @@ vector_per_atom: METATOMIC ...
5555

5656
PRINT ARG=vector_per_atom FILE=vector_per_atom FMT=%8.2f
5757

58+
variant: METATOMIC ...
59+
MODEL=variant-global.pt
60+
VARIANT=variant
61+
DEVICE=cpu
62+
63+
SPECIES1=1,4,7
64+
SPECIES2=2,3,5,6,8,9
65+
SPECIES_TO_TYPES=6,8
66+
...
67+
68+
PRINT ARG=variant FILE=variant FMT=%8.2f
69+
5870

5971
scalar_per_atom_sum: SUM ARG=scalar_per_atom PERIODIC=NO
6072
vector_global_sum: SUM ARG=vector_global PERIODIC=NO
6173
vector_per_atom_sum: SUM ARG=vector_per_atom PERIODIC=NO
74+
variant_sum: SUM ARG=variant PERIODIC=NO
6275

6376
summed: CUSTOM ...
64-
ARG=scalar_global,scalar_per_atom_sum,vector_global_sum,vector_per_atom_sum
65-
VAR=x,y,z,t
66-
FUNC=x+y+z+t
77+
ARG=scalar_global,scalar_per_atom_sum,vector_global_sum,vector_per_atom_sum,variant_sum
78+
VAR=a,b,c,d,e
79+
FUNC=a+b+c+d+e
6780
PERIODIC=NO
6881
...
6982

regtest/metatomic/rt-perovskite/BaTiO3-CV.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ def forward(
4545
outputs: Dict[str, ModelOutput],
4646
selected_atoms: Optional[Labels],
4747
) -> Dict[str, TensorMap]:
48-
if "features" not in outputs:
48+
if "feature" not in outputs:
4949
return {}
5050

5151
spherical_expansion = self.calculator(
@@ -71,14 +71,14 @@ def forward(
7171
blocks=[block],
7272
)
7373

74-
return {"features": cv}
74+
return {"feature": cv}
7575

7676

7777
cv = BaTiO3_CV()
7878
cv.eval()
7979

8080
capabilities = ModelCapabilities(
81-
outputs={"features": ModelOutput(per_atom=False)},
81+
outputs={"feature": ModelOutput(sample_kind="system")},
8282
interaction_range=3.0,
8383
supported_devices=["cpu"],
8484
length_unit="A",

regtest/metatomic/rt-soap/soap_cv.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,11 @@ def forward(
4444
outputs: Dict[str, ModelOutput],
4545
selected_atoms: Optional[Labels],
4646
) -> Dict[str, TensorMap]:
47-
if "features" not in outputs:
47+
if "feature" not in outputs:
4848
return {}
4949

50-
if not outputs["features"].per_atom:
51-
raise ValueError("per_atom=False is not supported")
50+
if outputs["feature"].sample_kind != "atom":
51+
raise ValueError("only per-atom output is supported")
5252

5353
if len(systems[0]) == 0:
5454
# PLUMED is trying to determine the size of the output
@@ -75,15 +75,15 @@ def forward(
7575
blocks=[block],
7676
)
7777

78-
return {"features": cv}
78+
return {"feature": cv}
7979

8080

8181
cv = SOAP_CV(species=[1, 6, 7, 8])
8282
cv.eval()
8383

8484

8585
capabilities = ModelCapabilities(
86-
outputs={"features": ModelOutput(per_atom=True)},
86+
outputs={"feature": ModelOutput(sample_kind="atom")},
8787
interaction_range=4.0,
8888
supported_devices=["cpu"],
8989
length_unit="nm",

src/maketools/codecheck

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ fi
118118
-U__PLUMED_HAS_ASMJIT \
119119
-D__PLUMED_WRAPPER_CXX_EXPLICIT=explicit \
120120
--config-exclude=small_vector/ \
121+
-i vesin.cpp \
121122
--template='[{file}:{line}] ({severity}) :{id}: {message}' \
122123
--enable=all --suppress=missingIncludeSystem --inline-suppr --force \
123124
"$@"
Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,19 @@
11
#!/usr/bin/env bash
22

3-
path=$1
3+
version=$1
44

55
if (($# != 1)) ; then
6-
echo "usage: $0 /path/to/vesin"
7-
echo
8-
echo "All the commands to run:"
9-
echo " cd /some/dir/"
10-
echo " git clone https://github.com/luthaf/vesin"
11-
echo " cd /your/plumed2/src/metatomic"
12-
echo " ./import.sh /some/dir/vesin"
13-
exit 0
6+
echo "usage: $0 <vesin-version>"
7+
exit 1
148
fi
159

16-
bash -c "$path/create-single-cpp.py > /dev/null"
10+
rm -f vesin-single-build-v*.tar.gz
11+
wget https://github.com/Luthaf/vesin/releases/download/v$version/vesin-single-build-v$version.tar.gz
1712

18-
cp $path/vesin/include/vesin.h vesin.h
19-
mv vesin-single-build.cpp vesin.cpp
13+
tar xf vesin-single-build-v$version.tar.gz
14+
15+
mv vesin-single-build-nocuda.cpp vesin.cpp
16+
rm -f vesin-single-build.cpp
2017

2118
# Patch files to follow PLUMED linter
2219
sed 's|#define VESIN_H|#define VESIN_H\n/*INDENT-OFF*/\n|

0 commit comments

Comments
 (0)