Skip to content
Draft
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
12 changes: 6 additions & 6 deletions .github/workflows/build-wheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -353,9 +353,9 @@ jobs:

- name: setup libmetatensor
run: |
curl -L -O https://github.com/metatensor/metatensor/releases/download/metatensor-core-v0.1.19/metatensor-core-cxx-0.1.19.tar.gz
tar xf metatensor-core-cxx-0.1.19.tar.gz
cmake -B build-metatensor -S metatensor-core-cxx-0.1.19 \
curl -L -O https://github.com/metatensor/metatensor/releases/download/metatensor-core-v0.2.0-rc1/metatensor-core-cxx-0.2.0-rc1.tar.gz
tar xf metatensor-core-cxx-0.2.0-rc1.tar.gz
cmake -B build-metatensor -S metatensor-core-cxx-0.2.0-rc1 \
-DMETATENSOR_INSTALL_BOTH_STATIC_SHARED=OFF \
-DCMAKE_INSTALL_PREFIX=$CMAKE_PREFIX_PATH \
-DCMAKE_BUILD_TYPE=Debug
Expand All @@ -364,9 +364,9 @@ jobs:

- name: setup libmetatensor-torch
run: |
curl -L -O https://github.com/metatensor/metatensor/releases/download/metatensor-torch-v0.8.4/metatensor-torch-cxx-0.8.4.tar.gz
tar xf metatensor-torch-cxx-0.8.4.tar.gz
cmake -B build-metatensor-torch -S metatensor-torch-cxx-0.8.4 \
curl -L -O https://github.com/metatensor/metatensor/releases/download/metatensor-torch-v0.9.0-rc2/metatensor-torch-cxx-0.9.0-rc2.tar.gz
tar xf metatensor-torch-cxx-0.9.0-rc2.tar.gz
cmake -B build-metatensor-torch -S metatensor-torch-cxx-0.9.0-rc2 \
-DCMAKE_INSTALL_PREFIX=$CMAKE_PREFIX_PATH \
-DCMAKE_BUILD_TYPE=Debug
cmake --build build-metatensor-torch --config Debug
Expand Down
2 changes: 1 addition & 1 deletion CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## Our Pledge

As members, contributors, and leaders of metatensor we pledge to make
As members, contributors, and leaders of metatomic we pledge to make
participation in our community a harassment-free experience for everyone,
regardless of age, body size, visible or invisible disability, ethnicity, sex
characteristics, gender identity and expression, level of experience,
Expand Down
2 changes: 1 addition & 1 deletion metatomic-torch/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ function(check_compatible_versions _actual_ _requested_)
endfunction()


set(REQUIRED_METATENSOR_TORCH_VERSION "0.8.0")
set(REQUIRED_METATENSOR_TORCH_VERSION "0.9.0")
# Either metatensor is built as part of the same CMake project, or we try to
# find the corresponding CMake package
if (TARGET metatensor_torch)
Expand Down
28 changes: 26 additions & 2 deletions metatomic-torch/src/system.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -759,6 +759,28 @@ System SystemHolder::to_positional(
return this->to(parsed_dtype, parsed_device, non_blocking);
}

static bool check_1d_labels(metatensor_torch::Labels labels, const char* name, torch::Tensor values) {
assert(values.sizes().size() == 1);

if (labels->count() != values.size(0)) {
return false;
}

if (labels->size() != 1) {
return false;
}

if (labels->names()[0] != name) {
return false;
}

auto labels_values = labels->values().reshape(-1);
if (!labels_values.is_meta()) {
return torch::all(labels_values == values.to(labels_values.device())).item<bool>();
}

return true;
}

void SystemHolder::add_neighbor_list(NeighborListOptions options, metatensor_torch::TensorBlock neighbors) {
// check the structure of the NL
Expand All @@ -777,13 +799,15 @@ void SystemHolder::add_neighbor_list(NeighborListOptions options, metatensor_tor
}

auto components = neighbors->components();
if (components.size() != 1 || *components[0] != metatensor::Labels({"xyz"}, {{0}, {1}, {2}})) {
if (components.size() != 1 ||
!(check_1d_labels(components[0], "xyz", torch::tensor({0, 1, 2})))
) {
C10_THROW_ERROR(ValueError,
"invalid components for `neighbors`: there should be a single 'xyz'=[0, 1, 2] component"
);
}

if (*neighbors->properties() != metatensor::Labels({"distance"}, {{0}})) {
if (!check_1d_labels(neighbors->properties(), "distance", torch::tensor({0}))) {
C10_THROW_ERROR(ValueError,
"invalid properties for `neighbors`: there should be a single 'distance'=0 property"
);
Expand Down
1 change: 1 addition & 0 deletions metatomic-torch/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-exit-time-destructors")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-global-constructors")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-poison-system-directories")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-thread-safety-negative")
endif()

file(GLOB ALL_TESTS *.cpp)
Expand Down
2 changes: 1 addition & 1 deletion python/metatomic_torch/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ requires = [
"setuptools >=77",
"packaging >=26",
"cmake",
"metatensor-torch >=0.8.0,<0.9.0",
"metatensor-torch >=0.9.0rc2,<0.10",
# we also add torch to this list in the build backend below
]

Expand Down
4 changes: 2 additions & 2 deletions python/metatomic_torch/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -318,8 +318,8 @@ def create_version_number(version):

install_requires = [
f"torch {torch_version}",
"metatensor-torch >=0.8.0,<0.9",
"metatensor-operations >=0.4.0,<0.5",
"metatensor-torch >=0.9.0rc2,<0.10",
"metatensor-operations >=0.5.0rc2,<0.6",
]

# when packaging a sdist for release, we should never use local dependencies
Expand Down
14 changes: 7 additions & 7 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ setenv =
package = skip
lint_folders = "{toxinidir}/python" "{toxinidir}/setup.py"
build_single_wheel = --no-deps --no-build-isolation --check-build-dependencies
install_lj_tests = pip install {[testenv]build_single_wheel} git+https://github.com/metatensor/lj-test@2f74cf8
install_lj_tests = pip install {[testenv]build_single_wheel} git+https://github.com/metatensor/lj-test@0285a1a

packaging_deps =
setuptools >= 77
Expand All @@ -40,8 +40,8 @@ testing_deps =
pytest-cov

metatensor_deps =
metatensor-torch >=0.8.0,<0.9
metatensor-operations >=0.4.0,<0.5
metatensor-torch >=0.9.0rc2,<0.10
metatensor-operations >=0.5.0rc2,<0.6


################################################################################
Expand All @@ -62,7 +62,7 @@ commands =
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
-DCMAKE_PREFIX_PATH={env_site_packages_dir}/metatensor/;\
{env_site_packages_dir}/torch/;\
{env_site_packages_dir}/metatensor/torch/torch-{env:METATOMIC_TESTS_TORCH_VERSION:2.11}/ \
{env_site_packages_dir}/metatensor_torch/torch-{env:METATOMIC_TESTS_TORCH_VERSION:2.11}/ \
-DMETATOMIC_TORCH_TESTS=ON

# build code with cmake
Expand All @@ -85,7 +85,7 @@ commands =
-DCMAKE_INSTALL_PREFIX={env_dir}/usr/ \
-DCMAKE_PREFIX_PATH={env_site_packages_dir}/metatensor/;\
{env_site_packages_dir}/torch/;\
{env_site_packages_dir}/metatensor/torch/torch-{env:METATOMIC_TESTS_TORCH_VERSION:2.11}/ \
{env_site_packages_dir}/metatensor_torch/torch-{env:METATOMIC_TESTS_TORCH_VERSION:2.11}/ \
-DCMAKE_BUILD_WITH_INSTALL_RPATH=ON \
-DCMAKE_INSTALL_RPATH_USE_LINK_PATH=ON
cmake --build {env_dir}/build-metatomic-torch --config Debug --parallel --target install
Expand All @@ -95,7 +95,7 @@ commands =
-DCMAKE_BUILD_TYPE=Debug \
-DCMAKE_PREFIX_PATH={env_site_packages_dir}/metatensor/;\
{env_site_packages_dir}/torch/;\
{env_site_packages_dir}/metatensor/torch/torch-{env:METATOMIC_TESTS_TORCH_VERSION:2.11}/;\
{env_site_packages_dir}/metatensor_torch/torch-{env:METATOMIC_TESTS_TORCH_VERSION:2.11}/;\
{env_dir}/usr/ \
-DUSE_CMAKE_SUBDIRECTORY=OFF

Expand All @@ -107,7 +107,7 @@ commands =
-DCMAKE_BUILD_TYPE=Debug \
-DCMAKE_PREFIX_PATH={env_site_packages_dir}/metatensor/;\
{env_site_packages_dir}/torch/;\
{env_site_packages_dir}/metatensor/torch/torch-{env:METATOMIC_TESTS_TORCH_VERSION:2.11}/ \
{env_site_packages_dir}/metatensor_torch/torch-{env:METATOMIC_TESTS_TORCH_VERSION:2.11}/ \
-DUSE_CMAKE_SUBDIRECTORY=ON

cmake --build {env_dir}/build-subdirectory --config Debug --parallel
Expand Down
Loading