From 72b61d4f9ebf2c7627ec7e9547d366bc440fe6be Mon Sep 17 00:00:00 2001 From: Guillaume Fraux Date: Thu, 25 Jun 2026 16:18:01 +0200 Subject: [PATCH 1/2] Update to metatensor-torch v0.10.0 --- docs/requirements.txt | 4 ++-- featomic-torch/CHANGELOG.md | 4 ++++ featomic-torch/CMakeLists.txt | 10 +++++----- featomic/CMakeLists.txt | 4 ++-- featomic/include/featomic.hpp | 4 ++-- python/featomic/build-backend/backend.py | 2 +- .../featomic/clebsch_gordan/_backend.py | 2 -- .../featomic/clebsch_gordan/_coefficients.py | 18 +++++++----------- python/featomic/pyproject.toml | 2 +- python/featomic_torch/build-backend/backend.py | 4 ++-- .../featomic/torch/clebsch_gordan.py | 2 -- python/featomic_torch/setup.py | 4 ++-- tox.ini | 6 +++--- 13 files changed, 31 insertions(+), 35 deletions(-) diff --git a/docs/requirements.txt b/docs/requirements.txt index 3ecc5dbdc..4ec14439c 100644 --- a/docs/requirements.txt +++ b/docs/requirements.txt @@ -11,8 +11,8 @@ myst-parser # markdown => rst translation, used in extensions/featomic_json_ # dependencies for the tutorials --extra-index-url https://download.pytorch.org/whl/cpu metatensor-operations >=0.5.0,<0.6 -metatensor-torch >=0.9.0,<0.10 -metatomic-torch >= 0.1.12,<0.2 +metatensor-torch >=0.10.0,<0.11 +metatomic-torch >= 0.1.15,<0.2 torch chemfiles matplotlib diff --git a/featomic-torch/CHANGELOG.md b/featomic-torch/CHANGELOG.md index c592ea4a3..9b174d235 100644 --- a/featomic-torch/CHANGELOG.md +++ b/featomic-torch/CHANGELOG.md @@ -17,6 +17,10 @@ a changelog](https://keepachangelog.com/en/1.1.0/) format. This project follows ### Removed --> +### Changed + +- The code is now compatible with metatensor-torch v0.10 + ## [Version 0.7.4](https://github.com/metatensor/featomic/releases/tag/featomic-torch-v0.7.4) - 2026-05-15 ### Changed diff --git a/featomic-torch/CMakeLists.txt b/featomic-torch/CMakeLists.txt index 1140f8e3b..0c6c619cb 100644 --- a/featomic-torch/CMakeLists.txt +++ b/featomic-torch/CMakeLists.txt @@ -122,8 +122,8 @@ find_package(Torch 2.3 REQUIRED) # # When updating METATENSOR_TORCH_FETCH_VERSION, you will also have to update the # SHA256 sum of the file in `FetchContent_Declare`. -set(METATENSOR_TORCH_FETCH_VERSION "0.9.0") -set(REQUIRED_METATENSOR_TORCH_VERSION "0.9") +set(METATENSOR_TORCH_FETCH_VERSION "0.10.0") +set(REQUIRED_METATENSOR_TORCH_VERSION "0.10") if (FEATOMIC_FETCH_METATENSOR_TORCH) message(STATUS "Fetching metatensor-torch from github") @@ -132,7 +132,7 @@ if (FEATOMIC_FETCH_METATENSOR_TORCH) FetchContent_Declare( metatensor_torch URL ${URL_ROOT}/metatensor-torch-v${METATENSOR_TORCH_FETCH_VERSION}/metatensor-torch-cxx-${METATENSOR_TORCH_FETCH_VERSION}.tar.gz - URL_HASH SHA256=4e31c235447b6bc14c7703c640e2f35409813c2f159a32b8d23386ad4a5abd57 + URL_HASH SHA256=a0a25e061ae4fbf2a563e9fcceed68ac79b4d857e4c9803a1614d301dc3fdfcd ) FetchContent_MakeAvailable(metatensor_torch) @@ -150,7 +150,7 @@ endif() # # When updating METATOMIC_TORCH_FETCH_VERSION, you will also have to update the # SHA256 sum of the file in `FetchContent_Declare`. -set(METATOMIC_TORCH_FETCH_VERSION "0.1.12") +set(METATOMIC_TORCH_FETCH_VERSION "0.1.15") set(REQUIRED_METATOMIC_TORCH_VERSION "0.1") if (FEATOMIC_FETCH_METATENSOR_TORCH) message(STATUS "Fetching metatomic-torch from github") @@ -160,7 +160,7 @@ if (FEATOMIC_FETCH_METATENSOR_TORCH) FetchContent_Declare( metatomic_torch URL ${URL_ROOT}/metatomic-torch-v${METATOMIC_TORCH_FETCH_VERSION}/metatomic-torch-cxx-${METATOMIC_TORCH_FETCH_VERSION}.tar.gz - URL_HASH SHA256=d9e587c7ce3d9d6338ed5f6da119e2a3b29698381886f36a53603523c0499542 + URL_HASH SHA256=2fa4c94144164168834a90ff195ed7d788959c9d9ffd3ea4a85e2f470925c708 ) FetchContent_MakeAvailable(metatomic_torch) diff --git a/featomic/CMakeLists.txt b/featomic/CMakeLists.txt index 62ffa2a09..0a68813a0 100644 --- a/featomic/CMakeLists.txt +++ b/featomic/CMakeLists.txt @@ -246,7 +246,7 @@ endif() # # When updating METATENSOR_FETCH_VERSION, you will also have to update the # SHA256 sum of the file in `FetchContent_Declare`. -set(METATENSOR_FETCH_VERSION "0.2.0") +set(METATENSOR_FETCH_VERSION "0.2.2") set(METATENSOR_REQUIRED_VERSION "0.2") if (FEATOMIC_FETCH_METATENSOR) message(STATUS "Fetching metatensor-core from github") @@ -256,7 +256,7 @@ if (FEATOMIC_FETCH_METATENSOR) FetchContent_Declare( metatensor URL ${URL_ROOT}/metatensor-core-v${METATENSOR_FETCH_VERSION}/metatensor-core-cxx-${METATENSOR_FETCH_VERSION}.tar.gz - URL_HASH SHA256=809a799b1c8d58b7ede3868d6ebe4123924ba31e4637481f9ca5c8a0ed14be17 + URL_HASH SHA256=a104512516c8761080075e3ba7c023fcc1bb3430df7c67b25bded359a729e2ff ) FetchContent_MakeAvailable(metatensor) diff --git a/featomic/include/featomic.hpp b/featomic/include/featomic.hpp index 9f45bce3e..eacd7a0dc 100644 --- a/featomic/include/featomic.hpp +++ b/featomic/include/featomic.hpp @@ -635,7 +635,7 @@ class Calculator { options.as_featomic_calculation_options_t() )); - return metatensor::TensorMap(descriptor); + return metatensor::TensorMap::unsafe_from_ptr(descriptor); } /// Runs a calculation for multiple `systems` @@ -669,7 +669,7 @@ class Calculator { options.as_featomic_calculation_options_t() )); - return metatensor::TensorMap(descriptor); + return metatensor::TensorMap::unsafe_from_ptr(descriptor); } /// Get the underlying pointer to a `featomic_calculator_t`. diff --git a/python/featomic/build-backend/backend.py b/python/featomic/build-backend/backend.py index 9c8a5d2f5..5c118bf90 100644 --- a/python/featomic/build-backend/backend.py +++ b/python/featomic/build-backend/backend.py @@ -11,5 +11,5 @@ def get_requires_for_build_wheel(config_settings=None): defaults = build_meta.get_requires_for_build_wheel(config_settings) return defaults + [ "cmake", - "metatensor-core >=0.2.0,<0.3", + "metatensor-core >=0.2.2,<0.3", ] diff --git a/python/featomic/featomic/clebsch_gordan/_backend.py b/python/featomic/featomic/clebsch_gordan/_backend.py index f289aaf63..dda0a7941 100644 --- a/python/featomic/featomic/clebsch_gordan/_backend.py +++ b/python/featomic/featomic/clebsch_gordan/_backend.py @@ -53,5 +53,3 @@ class TorchDType: Array = Union[np.ndarray, TorchTensor] DType = Union[np.dtype, TorchDType] Device = Union[str, TorchDevice] - -BACKEND_IS_METATENSOR_TORCH = False diff --git a/python/featomic/featomic/clebsch_gordan/_coefficients.py b/python/featomic/featomic/clebsch_gordan/_coefficients.py index 6661d96b4..18d666a16 100644 --- a/python/featomic/featomic/clebsch_gordan/_coefficients.py +++ b/python/featomic/featomic/clebsch_gordan/_coefficients.py @@ -11,7 +11,6 @@ from . import _dispatch from ._backend import ( - BACKEND_IS_METATENSOR_TORCH, Array, Device, DType, @@ -84,11 +83,7 @@ def calculate_cg_coefficients( complex_like = torch.empty(0, dtype=complex_dtype, device=device) real_like = torch.empty(0, dtype=dtype, device=device) - if BACKEND_IS_METATENSOR_TORCH: - labels_values_like = torch.empty(0, dtype=torch.int32, device=device) - else: - # we are using metatensor-core with torch arrays - labels_values_like = np.empty(0, dtype=np.int32) + labels_values_like = torch.empty(0, dtype=torch.int32, device=device) else: assert arrays_backend == "numpy" if dtype == np.float32: @@ -110,7 +105,6 @@ def calculate_cg_coefficients( cg_coeff_dict = _build_dense_cg_coeff_dict( lambda_max, complex_like, - labels_values_like, arrays_backend=arrays_backend, dtype=dtype, device=device, @@ -137,7 +131,6 @@ def calculate_cg_coefficients( def _build_dense_cg_coeff_dict( lambda_max: int, complex_like: Array, - labels_values_like: Array, arrays_backend: str, dtype: DType, device: Device, @@ -575,9 +568,12 @@ def _cg_couple_dense( l1 = (array.shape[1] - 1) // 2 l2 = (array.shape[2] - 1) // 2 - cg_l1l2lam = (-1) ** (l1 + l2 + o3_lambda) * cg_coefficients.block( - {"l1": l1, "l2": l2, "lambda": o3_lambda} - ).values + key = Labels( + ["l1", "l2", "lambda"], + _dispatch.int_array_like([[l1, l2, o3_lambda]], cg_coefficients.keys.values), + ) + + cg_l1l2lam = (-1) ** (l1 + l2 + o3_lambda) * cg_coefficients.block(key).values return _dispatch.tensordot(array, cg_l1l2lam[0, ..., 0], axes=([2, 1], [1, 0])) diff --git a/python/featomic/pyproject.toml b/python/featomic/pyproject.toml index d83039d44..c9ba47675 100644 --- a/python/featomic/pyproject.toml +++ b/python/featomic/pyproject.toml @@ -25,7 +25,7 @@ classifiers = [ ] dependencies = [ - "metatensor-core >=0.2.0,<0.3", + "metatensor-core >=0.2.2,<0.3", "metatensor-operations >=0.5.0,<0.6", "wigners", ] diff --git a/python/featomic_torch/build-backend/backend.py b/python/featomic_torch/build-backend/backend.py index 9b502951b..2329eab55 100644 --- a/python/featomic_torch/build-backend/backend.py +++ b/python/featomic_torch/build-backend/backend.py @@ -43,7 +43,7 @@ def get_requires_for_build_wheel(config_settings=None): return defaults + [ "cmake", TORCH_DEP, - "metatensor-torch >=0.9.0,<0.10", - "metatomic-torch >=0.1.12,<0.2", + "metatensor-torch >=0.10.0,<0.11", + "metatomic-torch >=0.1.15,<0.2", FEATOMIC_DEP, ] diff --git a/python/featomic_torch/featomic/torch/clebsch_gordan.py b/python/featomic_torch/featomic/torch/clebsch_gordan.py index d282ec8a3..90d426185 100644 --- a/python/featomic_torch/featomic/torch/clebsch_gordan.py +++ b/python/featomic_torch/featomic/torch/clebsch_gordan.py @@ -23,8 +23,6 @@ # This module only exposes a handful of things, defined here. Any changes here MUST also # be made to the `featomic/clebsch_gordan/_backend.py` file, which is used in # non-TorchScript mode. -module.__dict__["BACKEND_IS_METATENSOR_TORCH"] = True - module.__dict__["Labels"] = metatensor.torch.Labels module.__dict__["TensorBlock"] = metatensor.torch.TensorBlock module.__dict__["TensorMap"] = metatensor.torch.TensorMap diff --git a/python/featomic_torch/setup.py b/python/featomic_torch/setup.py index a39bf64d6..87769a010 100644 --- a/python/featomic_torch/setup.py +++ b/python/featomic_torch/setup.py @@ -346,8 +346,8 @@ def create_version_number(version): install_requires = [ f"torch {torch_version}", - "metatensor-torch >=0.9.0,<0.10", - "metatomic-torch >=0.1.12,<0.2", + "metatensor-torch >=0.10.0,<0.11", + "metatomic-torch >=0.1.15,<0.2", ] # when packaging a sdist for release, we should never use local dependencies diff --git a/tox.ini b/tox.ini index 2fdbb0735..2464fa501 100644 --- a/tox.ini +++ b/tox.ini @@ -21,11 +21,11 @@ lint-folders = "{toxinidir}/python" "{toxinidir}/setup.py" # we need to manually install dependencies for featomic, since tox will install # the fresh wheel with `--no-deps` after building it. metatensor-core-requirement = - metatensor-core >=0.2.0,<0.3 + metatensor-core >=0.2.2,<0.3 metatensor-torch-requirement = - metatensor-torch >=0.9.0,<0.10 - metatomic-torch >=0.1.12,<0.2 + metatensor-torch >=0.10.0,<0.11 + metatomic-torch >=0.1.15,<0.2 build-single-wheel = --no-deps --no-build-isolation --check-build-dependencies warning_options = From bf8e9bd12cc8e1b0256522f2c21a60d31818d18f Mon Sep 17 00:00:00 2001 From: Guillaume Fraux Date: Thu, 25 Jun 2026 17:34:16 +0200 Subject: [PATCH 2/2] Release featomic v0.6.7 and featomic-torch v0.7.5 --- featomic-torch/CHANGELOG.md | 2 ++ featomic-torch/CMakeLists.txt | 2 +- featomic-torch/VERSION | 2 +- featomic-torch/tests/cmake-project/CMakeLists.txt | 2 +- featomic/CHANGELOG.md | 7 +++++++ featomic/Cargo.toml | 2 +- featomic/tests/cmake-project/CMakeLists.txt | 2 +- python/featomic_torch/build-backend/backend.py | 2 +- 8 files changed, 15 insertions(+), 6 deletions(-) diff --git a/featomic-torch/CHANGELOG.md b/featomic-torch/CHANGELOG.md index 9b174d235..bdee90aa5 100644 --- a/featomic-torch/CHANGELOG.md +++ b/featomic-torch/CHANGELOG.md @@ -17,6 +17,8 @@ a changelog](https://keepachangelog.com/en/1.1.0/) format. This project follows ### Removed --> +## [Version 0.7.5](https://github.com/metatensor/featomic/releases/tag/featomic-torch-v0.7.5) - 2026-06-25 + ### Changed - The code is now compatible with metatensor-torch v0.10 diff --git a/featomic-torch/CMakeLists.txt b/featomic-torch/CMakeLists.txt index 0c6c619cb..aa7311a1d 100644 --- a/featomic-torch/CMakeLists.txt +++ b/featomic-torch/CMakeLists.txt @@ -81,7 +81,7 @@ function(check_compatible_versions _dependency_ _actual_ _requested_) endfunction() -set(REQUIRED_FEATOMIC_VERSION "0.6.6") +set(REQUIRED_FEATOMIC_VERSION "0.6.7") if (NOT "$ENV{FEATOMIC_NO_LOCAL_DEPS}" STREQUAL "1") # If building a dev version, we also need to update the # REQUIRED_FEATOMIC_VERSION in the same way we update the diff --git a/featomic-torch/VERSION b/featomic-torch/VERSION index 0a1ffad4b..8bd6ba8c5 100644 --- a/featomic-torch/VERSION +++ b/featomic-torch/VERSION @@ -1 +1 @@ -0.7.4 +0.7.5 diff --git a/featomic-torch/tests/cmake-project/CMakeLists.txt b/featomic-torch/tests/cmake-project/CMakeLists.txt index c1ec2ab86..e798e3836 100644 --- a/featomic-torch/tests/cmake-project/CMakeLists.txt +++ b/featomic-torch/tests/cmake-project/CMakeLists.txt @@ -6,7 +6,7 @@ project(featomic-torch-test-cmake-project CXX) # We need to update the REQUIRED_FEATOMIC_VERSION in the same way we update the # featomic version for dev builds include(../../cmake/dev-versions.cmake) -set(REQUIRED_FEATOMIC_TORCH_VERSION "0.7.4") +set(REQUIRED_FEATOMIC_TORCH_VERSION "0.7.5") create_development_version("${REQUIRED_FEATOMIC_TORCH_VERSION}" FEATOMIC_TORCH_FULL_VERSION "featomic-torch-v") string(REGEX REPLACE "([0-9]*)\\.([0-9]*).*" "\\1.\\2" REQUIRED_FEATOMIC_TORCH_VERSION ${FEATOMIC_TORCH_FULL_VERSION}) find_package(featomic_torch ${REQUIRED_FEATOMIC_TORCH_VERSION} REQUIRED) diff --git a/featomic/CHANGELOG.md b/featomic/CHANGELOG.md index 5b00562cc..29ce873cc 100644 --- a/featomic/CHANGELOG.md +++ b/featomic/CHANGELOG.md @@ -17,6 +17,13 @@ a changelog](https://keepachangelog.com/en/1.1.0/) format. This project follows ### Removed --> +## [Version 0.6.7](https://github.com/metatensor/featomic/releases/tag/featomic-v0.6.7) - 2026-06-25 + +### Added + +- `spherical_to_cartesian` python function, doing the inverse of + `cartesian_to_spherical`. + ## [Version 0.6.6](https://github.com/metatensor/featomic/releases/tag/featomic-v0.6.6) - 2026-05-15 ### Changed diff --git a/featomic/Cargo.toml b/featomic/Cargo.toml index 1459a559d..16f885440 100644 --- a/featomic/Cargo.toml +++ b/featomic/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "featomic" -version = "0.6.6" +version = "0.6.7" authors = ["Guillaume Fraux "] edition = "2021" rust-version = "1.74" diff --git a/featomic/tests/cmake-project/CMakeLists.txt b/featomic/tests/cmake-project/CMakeLists.txt index b9216174c..4cf68235b 100644 --- a/featomic/tests/cmake-project/CMakeLists.txt +++ b/featomic/tests/cmake-project/CMakeLists.txt @@ -5,7 +5,7 @@ project(featomic-test-cmake-project C CXX) # We need to update the REQUIRED_FEATOMIC_VERSION in the same way we update the # featomic version for dev builds include(../../cmake/dev-versions.cmake) -set(REQUIRED_FEATOMIC_VERSION "0.6.6") +set(REQUIRED_FEATOMIC_VERSION "0.6.7") create_development_version("${REQUIRED_FEATOMIC_VERSION}" FEATOMIC_FULL_VERSION "featomic-v") string(REGEX REPLACE "([0-9]*)\\.([0-9]*).*" "\\1.\\2" REQUIRED_FEATOMIC_VERSION ${FEATOMIC_FULL_VERSION}) find_package(featomic ${REQUIRED_FEATOMIC_VERSION} REQUIRED) diff --git a/python/featomic_torch/build-backend/backend.py b/python/featomic_torch/build-backend/backend.py index 2329eab55..966d713df 100644 --- a/python/featomic_torch/build-backend/backend.py +++ b/python/featomic_torch/build-backend/backend.py @@ -23,7 +23,7 @@ FEATOMIC_DEP = f"featomic @ {FEATOMIC_SRC.as_uri()}" else: # we are building from a sdist - FEATOMIC_DEP = "featomic >=0.6.6,<0.7" + FEATOMIC_DEP = "featomic >=0.6.7,<0.7" FORCED_TORCH_VERSION = os.environ.get("FEATOMIC_TORCH_BUILD_WITH_TORCH_VERSION") if FORCED_TORCH_VERSION is not None: