Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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: 2 additions & 2 deletions .ci/pytorch/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# The extra url makes pip grap the torch fersion we want to use in the regtests
--extra-index-url=https://download.pytorch.org/whl/cpu
torch>=2.7
metatomic-torch>=0.1.3,<0.2
featomic-torch==0.7.0
metatomic-torch>=0.1.8,<0.2
featomic-torch>=0.7.0,<0.8
16 changes: 15 additions & 1 deletion .github/workflows/linuxWF.yml
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,21 @@ jobs:
MDAnalysis
pip install --user -r ./.ci/pytorch/requirements.txt

# torch 2.7 above is the first one to use cxx11 ABI for the PyPI wheels
python -c "import featomic.torch; print('featomic.torch.__file__:', featomic.torch.__file__)"

echo "ls /home/runner/.local/lib/python3.10/site-packages/featomic/torch/"
ls /home/runner/.local/lib/python3.10/site-packages/featomic/torch/

echo "ls /home/runner/.local/lib/python3.10/site-packages/featomic_torch.libs/"
ls /home/runner/.local/lib/python3.10/site-packages/featomic_torch.libs/

python -c "import featomic.torch; import metatomic.torch; print(metatomic.torch._extensions._collect_extensions('/tmp/ext-test'))"

python -c "import site; print('getsitepackages:', site.getsitepackages())"
python -c "import site; print('getusersitepackages:', site.getusersitepackages())"

exit 1


- name: Configure libmetatomic & libtorch
if: ${{ ! contains( matrix.variant, '-debug-' ) }} # the libraries on PyPI are not compiled with GLIBCXX_DEBUG
Expand Down
12 changes: 6 additions & 6 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -10007,8 +10007,8 @@ $as_echo_n "checking libmetatomic without extra libs... " >&6; }
#include <metatensor.hpp>
#include <metatensor/torch.hpp>
#include <metatomic/torch.hpp>
#if METATOMIC_TORCH_VERSION_MAJOR != 0 || METATOMIC_TORCH_VERSION_MINOR != 1
#error "this code is only compatible with metatomic-torch >=0.1,<0.2"
#if METATOMIC_TORCH_VERSION_MAJOR != 0 || METATOMIC_TORCH_VERSION_MINOR != 1 || METATOMIC_TORCH_VERSION_PATCH < 8
#error "this code is only compatible with metatomic-torch >=0.1.8,<0.2"
#endif
int main() {
metatomic_torch::version();
Expand Down Expand Up @@ -10056,8 +10056,8 @@ $as_echo_n "checking libmetatomic with $all_LIBS... " >&6; }
#include <metatensor.hpp>
#include <metatensor/torch.hpp>
#include <metatomic/torch.hpp>
#if METATOMIC_TORCH_VERSION_MAJOR != 0 || METATOMIC_TORCH_VERSION_MINOR != 1
#error "this code is only compatible with metatomic-torch >=0.1,<0.2"
#if METATOMIC_TORCH_VERSION_MAJOR != 0 || METATOMIC_TORCH_VERSION_MINOR != 1 || METATOMIC_TORCH_VERSION_PATCH < 8
#error "this code is only compatible with metatomic-torch >=0.1.8,<0.2"
#endif
int main() {
metatomic_torch::version();
Expand Down Expand Up @@ -10105,8 +10105,8 @@ $as_echo_n "checking libmetatomic with -l$testlib... " >&6; }
#include <metatensor.hpp>
#include <metatensor/torch.hpp>
#include <metatomic/torch.hpp>
#if METATOMIC_TORCH_VERSION_MAJOR != 0 || METATOMIC_TORCH_VERSION_MINOR != 1
#error "this code is only compatible with metatomic-torch >=0.1,<0.2"
#if METATOMIC_TORCH_VERSION_MAJOR != 0 || METATOMIC_TORCH_VERSION_MINOR != 1 || METATOMIC_TORCH_VERSION_PATCH < 8
#error "this code is only compatible with metatomic-torch >=0.1.8,<0.2"
#endif
int main() {
metatomic_torch::version();
Expand Down
4 changes: 2 additions & 2 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -989,8 +989,8 @@ if test $libmetatomic = true ; then
#include <metatensor.hpp>
#include <metatensor/torch.hpp>
#include <metatomic/torch.hpp>
#if METATOMIC_TORCH_VERSION_MAJOR != 0 || METATOMIC_TORCH_VERSION_MINOR != 1
#error "this code is only compatible with metatomic-torch >=0.1,<0.2"
#if METATOMIC_TORCH_VERSION_MAJOR != 0 || METATOMIC_TORCH_VERSION_MINOR != 1 || METATOMIC_TORCH_VERSION_PATCH < 8
#error "this code is only compatible with metatomic-torch >=0.1.8,<0.2"
#endif
int main() {
metatomic_torch::version();
Expand Down
18 changes: 14 additions & 4 deletions regtest/metatomic/rt-basic/cv.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,28 +32,29 @@ class TestCollectiveVariable(torch.nn.Module):
CV^2 are returned.
"""

def __init__(self, cutoff, multiple_properties):
def __init__(self, cutoff, multiple_properties, features_key="features"):
super().__init__()

self._nl_request = NeighborListOptions(
cutoff=cutoff, full_list=True, strict=True
)
self._multiple_properties = multiple_properties
self._features_key = features_key

def forward(
self,
systems: List[System],
outputs: Dict[str, ModelOutput],
selected_atoms: Optional[Labels],
) -> Dict[str, TensorMap]:
if "features" not in outputs:
if self._features_key not in outputs:
return {}

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

output = outputs["features"]
output = outputs[self._features_key]

if output.per_atom:
samples_list: List[List[int]] = []
Expand Down Expand Up @@ -123,7 +124,7 @@ def forward(
"selected atoms is only supported with per-atom output"
)

return {"features": cv}
return {self._features_key: cv}

def requested_neighbor_lists(self) -> List[NeighborListOptions]:
return [self._nl_request]
Expand Down Expand Up @@ -169,3 +170,12 @@ def requested_neighbor_lists(self) -> List[NeighborListOptions]:
cv.eval()
model = AtomisticModel(cv, ModelMetadata(), capabilities)
model.save("vector-global.pt")


cv = TestCollectiveVariable(
cutoff=CUTOFF, multiple_properties=False, features_key="features/variant"
)
capabilities.outputs = {"features/variant": ModelOutput(per_atom=False)}
cv.eval()
model = AtomisticModel(cv, ModelMetadata(), capabilities)
model.save("variant-global.pt")
20 changes: 10 additions & 10 deletions regtest/metatomic/rt-basic/forces.reference
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
9
-4795.88 -5679.30 -5054.72
X 147.18 -79.30 -178.34
X -174.21 -55.39 124.40
X -214.90 78.13 151.48
X -424.19 203.64 276.74
X 71.31 -44.07 35.23
X 230.71 -150.74 -438.92
X 140.70 -55.57 -67.27
X 208.55 -18.70 211.20
X 14.85 122.00 -114.51
-4822.75 -5711.13 -5083.06
X 148.00 -79.74 -179.33
X -175.19 -55.70 125.09
X -216.11 78.57 152.33
X -426.55 204.77 278.27
X 71.71 -44.32 35.43
X 231.98 -151.58 -441.35
X 141.49 -55.88 -67.65
X 209.72 -18.80 212.37
X 14.94 122.68 -115.16
19 changes: 16 additions & 3 deletions regtest/metatomic/rt-basic/plumed.dat
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,28 @@ vector_per_atom: METATOMIC ...

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

variant: METATOMIC ...
MODEL=variant-global.pt
VARIANT=variant
DEVICE=cpu

SPECIES1=1,4,7
SPECIES2=2,3,5,6,8,9
SPECIES_TO_TYPES=6,8
...

PRINT ARG=variant FILE=variant FMT=%8.2f


scalar_per_atom_sum: SUM ARG=scalar_per_atom PERIODIC=NO
vector_global_sum: SUM ARG=vector_global PERIODIC=NO
vector_per_atom_sum: SUM ARG=vector_per_atom PERIODIC=NO
variant_sum: SUM ARG=variant PERIODIC=NO

summed: CUSTOM ...
ARG=scalar_global,scalar_per_atom_sum,vector_global_sum,vector_per_atom_sum
VAR=x,y,z,t
FUNC=x+y+z+t
ARG=scalar_global,scalar_per_atom_sum,vector_global_sum,vector_per_atom_sum,variant_sum
VAR=a,b,c,d,e
FUNC=a+b+c+d+e
PERIODIC=NO
...

Expand Down
1 change: 1 addition & 0 deletions src/maketools/codecheck
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ fi
-U__PLUMED_HAS_ASMJIT \
-D__PLUMED_WRAPPER_CXX_EXPLICIT=explicit \
--config-exclude=small_vector/ \
-i vesin.cpp \
--template='[{file}:{line}] ({severity}) :{id}: {message}' \
--enable=all --suppress=missingIncludeSystem --inline-suppr --force \
$files
Expand Down
22 changes: 10 additions & 12 deletions src/metatomic/import.sh → src/metatomic/import-vesin.sh
Original file line number Diff line number Diff line change
@@ -1,21 +1,19 @@
#!/usr/bin/env bash

path=$1
version=$1

if (($# != 1)) ; then
echo "usage: $0 /path/to/vesin"
echo
echo "All the commands to run:"
echo " cd /some/dir/"
echo " git clone https://github.com/luthaf/vesin"
echo " cd /your/plumed2/src/metatomic"
echo " ./import.sh /some/dir/vesin"
exit 0
echo "usage: $0 <vesin-version>"
exit 1
fi

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

cp $path/vesin/include/vesin.h vesin.h
tar xf vesin-single-build-v$version.tar.gz
# bash -c "$path/create-single-cpp.py > /dev/null"

# cp $path/vesin/include/vesin.h vesin.h
mv vesin-single-build.cpp vesin.cpp

# Patch files to follow PLUMED linter
Expand All @@ -28,7 +26,7 @@ sed 's|#define VESIN_H|#define VESIN_H\n/*INDENT-OFF*/\n|
' vesin.h > tmp
mv tmp vesin.h

sed '1 s|^|/*INDENT-OFF*/\n#include "vesin.h"\n|
sed '1 s|^|/*INDENT-OFF*/\n|
s|<stddef.h>|<cstddef>|
s|<stdint.h>|<cstdint>|
s|vesin::|PLMD::metatomic::vesin::|
Expand Down
Loading
Loading