Skip to content
Merged
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
38 changes: 19 additions & 19 deletions .github/workflows/build-wheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ jobs:
rust-target: x86_64-pc-windows-msvc
cibw-arch: AMD64
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v6
with:
fetch-depth: 0

Expand All @@ -63,7 +63,7 @@ jobs:
target: ${{ matrix.rust-target }}

- name: Set up Python
uses: actions/setup-python@v5
uses: actions/setup-python@v6
with:
python-version: "3.13"

Expand All @@ -89,7 +89,7 @@ jobs:
MACOSX_DEPLOYMENT_TARGET=11
FEATOMIC_NO_LOCAL_DEPS=1

- uses: actions/upload-artifact@v4
- uses: actions/upload-artifact@v7
with:
name: wheel-${{ matrix.os }}-${{ matrix.cibw-arch }}
path: ./wheelhouse/*.whl
Expand Down Expand Up @@ -140,7 +140,7 @@ jobs:
- {torch-version: '2.9', cibw-python: 'cp312-*'}
- {torch-version: '2.10', cibw-python: 'cp313-*'}
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v6
with:
fetch-depth: 0

Expand All @@ -151,7 +151,7 @@ jobs:
target: ${{ matrix.rust-target }}

- name: Set up Python
uses: actions/setup-python@v5
uses: actions/setup-python@v6
with:
python-version: "3.13"

Expand Down Expand Up @@ -202,7 +202,7 @@ jobs:
--exclude libc10.so \
-w {dest_dir} {wheel}

- uses: actions/upload-artifact@v4
- uses: actions/upload-artifact@v7
with:
name: torch-single-version-wheel-${{ matrix.torch-version }}-${{ matrix.os }}-${{ matrix.arch }}
path: ./wheelhouse/*.whl
Expand All @@ -227,17 +227,17 @@ jobs:
os: windows-2022
arch: x86_64
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v6

- name: Download wheels
uses: actions/download-artifact@v4
uses: actions/download-artifact@v8
with:
pattern: torch-single-version-wheel-*-${{ matrix.os }}-${{ matrix.arch }}
merge-multiple: false
path: dist

- name: Set up Python
uses: actions/setup-python@v5
uses: actions/setup-python@v6
with:
python-version: "3.13"

Expand Down Expand Up @@ -272,7 +272,7 @@ jobs:
- name: check wheels with twine
run: twine check wheelhouse/*

- uses: actions/upload-artifact@v4
- uses: actions/upload-artifact@v7
with:
name: torch-wheel-${{ matrix.os }}-${{ matrix.arch }}
path: ./wheelhouse/*.whl
Expand All @@ -281,12 +281,12 @@ jobs:
runs-on: ubuntu-24.04
name: sdist
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v6
with:
fetch-depth: 0

- name: Set up Python
uses: actions/setup-python@v5
uses: actions/setup-python@v6
with:
python-version: "3.13"

Expand All @@ -304,7 +304,7 @@ jobs:
./scripts/package-featomic.sh dist/cxx/
./scripts/package-featomic-torch.sh dist/cxx/

- uses: actions/upload-artifact@v4
- uses: actions/upload-artifact@v7
with:
name: sdist
path: |
Expand All @@ -320,27 +320,27 @@ jobs:
pull-requests: write
steps:
- name: Download featomic wheels
uses: actions/download-artifact@v4
uses: actions/download-artifact@v8
with:
path: wheels
pattern: wheel-*
merge-multiple: true

- name: Download featomic-torch wheels
uses: actions/download-artifact@v4
uses: actions/download-artifact@v8
with:
path: wheels
pattern: torch-wheel-*
merge-multiple: true

- name: Download sdists
uses: actions/download-artifact@v4
uses: actions/download-artifact@v8
with:
path: wheels
name: sdist

- name: Re-upload a single wheels artifact
uses: actions/upload-artifact@v4
uses: actions/upload-artifact@v7
with:
name: wheels
path: |
Expand All @@ -356,7 +356,7 @@ jobs:

- name: upload to GitHub release (featomic)
if: startsWith(github.ref, 'refs/tags/featomic-v')
uses: softprops/action-gh-release@v2
uses: softprops/action-gh-release@v3
with:
files: |
wheels/cxx/featomic-cxx-*.tar.gz
Expand All @@ -367,7 +367,7 @@ jobs:

- name: upload to GitHub release (featomic-torch)
if: startsWith(github.ref, 'refs/tags/featomic-torch-v')
uses: softprops/action-gh-release@v2
uses: softprops/action-gh-release@v3
with:
files: |
wheels/cxx/featomic-torch-cxx-*.tar.gz
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ jobs:
- name: free disk space
run: sudo rm -rf /usr/share/dotnet /usr/local/lib/android || true

- uses: actions/checkout@v4
- uses: actions/checkout@v6

- name: setup Python
uses: actions/setup-python@v5
uses: actions/setup-python@v6
with:
python-version: "3.13"

Expand Down Expand Up @@ -76,7 +76,7 @@ jobs:
coverage xml

- name: upload to codecov.io
uses: codecov/codecov-action@v5
uses: codecov/codecov-action@v6
with:
fail_ci_if_error: true
files: target/tarpaulin/cobertura.xml,coverage.xml,coverage.info
6 changes: 3 additions & 3 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ jobs:
- name: free disk space
run: sudo rm -rf /usr/share/dotnet /usr/local/lib/android || true

- uses: actions/checkout@v4
- uses: actions/checkout@v6

- name: setup rust
uses: dtolnay/rust-toolchain@master
with:
toolchain: stable

- name: setup Python
uses: actions/setup-python@v5
uses: actions/setup-python@v6
with:
python-version: "3.13"

Expand All @@ -45,7 +45,7 @@ jobs:
PIP_EXTRA_INDEX_URL: https://download.pytorch.org/whl/cpu

- name: store documentation as github artifact to be downloaded by users
uses: actions/upload-artifact@v4
uses: actions/upload-artifact@v7
with:
name: docs
path: docs/build/html/*
Expand Down
10 changes: 6 additions & 4 deletions .github/workflows/python-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ jobs:
- os: windows-2022
python-version: "3.13"
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v6

- name: setup Python
uses: actions/setup-python@v5
uses: actions/setup-python@v6
with:
python-version: ${{ matrix.python-version }}

Expand Down Expand Up @@ -71,10 +71,12 @@ jobs:
python-version: ['3.10', '3.13']
os: [ubuntu-24.04]
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v6
with:
fetch-depth: 0 # we need the full history to get the git version info

- name: set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
uses: actions/setup-python@v6
with:
python-version: ${{ matrix.python-version }}

Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/rust-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ jobs:
if: matrix.os == 'ubuntu-24.04'
run: sudo rm -rf /usr/share/dotnet /usr/local/lib/android || true

- uses: actions/checkout@v4
- uses: actions/checkout@v6
with:
fetch-depth: 0

Expand All @@ -87,7 +87,7 @@ jobs:
working-directory: /

- name: setup Python
uses: actions/setup-python@v5
uses: actions/setup-python@v6
if: "!matrix.container"
with:
python-version: "3.13"
Expand Down Expand Up @@ -135,7 +135,7 @@ jobs:
runs-on: ubuntu-24.04
name: check examples / benchmarks
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v6

- name: setup rust
uses: dtolnay/rust-toolchain@master
Expand Down Expand Up @@ -172,7 +172,7 @@ jobs:
- rust-version: stable
rust-target: x86_64-unknown-linux-gnu
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v6

- name: setup rust
uses: dtolnay/rust-toolchain@master
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/torch-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ jobs:
apt install -y cmake make gcc g++ git curl python3.10 python3.10-venv
update-alternatives --install /usr/local/bin/python python /usr/bin/python3.10 1

- uses: actions/checkout@v4
- uses: actions/checkout@v6
with:
fetch-depth: 0

Expand All @@ -74,7 +74,7 @@ jobs:
# we get torch from pip to run the C++ test
- name: setup Python
if: matrix.container != 'ubuntu:22.04'
uses: actions/setup-python@v5
uses: actions/setup-python@v6
with:
python-version: ${{ matrix.python-version }}

Expand Down
6 changes: 3 additions & 3 deletions docs/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ 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.4.0,<0.5
metatensor-torch >=0.8.4,<0.9
metatomic-torch >= 0.1.11,<0.2
metatensor-operations >=0.5.0-rc2,<0.6
metatensor-torch >=0.9.0-rc6,<0.10
metatomic-torch >= 0.1.12-rc2,<0.2
torch
chemfiles
matplotlib
Expand Down
10 changes: 5 additions & 5 deletions featomic-torch/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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.8.2")
set(REQUIRED_METATENSOR_TORCH_VERSION "0.8")
set(METATENSOR_TORCH_FETCH_VERSION "0.9.0-rc6")
set(REQUIRED_METATENSOR_TORCH_VERSION "0.9")
if (FEATOMIC_FETCH_METATENSOR_TORCH)
message(STATUS "Fetching metatensor-torch from github")

Expand All @@ -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=0be618d0cdcfca86cd0c25f47d360b6a2410ebb09ece8d21f153e933ce64bb55
URL_HASH SHA256=73afb6795a04e6e31a993d11e35183d3aa3e97b2d30e14b1a4a04c45263a13bc
)

FetchContent_MakeAvailable(metatensor_torch)
Expand All @@ -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.11")
set(METATOMIC_TORCH_FETCH_VERSION "0.1.12-rc2")
set(REQUIRED_METATOMIC_TORCH_VERSION "0.1")
if (FEATOMIC_FETCH_METATENSOR_TORCH)
message(STATUS "Fetching metatomic-torch from github")
Expand All @@ -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=cd500ab1371fb1d284b9ae514e7feaa205eca231437dd2d527fbf3852e673eef
URL_HASH SHA256=38a0de4d9320487405b13ed208013895b829ab74cf9bb774e88c5b628368fc49
)

FetchContent_MakeAvailable(metatomic_torch)
Expand Down
14 changes: 9 additions & 5 deletions featomic-torch/src/autograd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,8 @@ std::vector<torch::Tensor> PositionsGrad<scalar_t>::forward(
auto systems_start = systems_start_ivalue.toIntList();

auto samples = dX_dr->samples();
const auto* sample_ptr = samples->as_metatensor().values().data();
const auto sample_values = samples->as_metatensor().values_cpu();
const auto* sample_ptr = sample_values.data();

always_assert(samples->names().size() == 3);
always_assert(samples->names()[0] == "sample");
Expand Down Expand Up @@ -331,7 +332,8 @@ std::vector<torch::Tensor> PositionsGrad<scalar_t>::backward(
auto dB_d_dA_dr = grad_outputs[0]; // gradient of B w.r.t. dA/dr (output of forward)

auto samples = dX_dr->samples();
const auto* sample_ptr = samples->as_metatensor().values().data();
const auto sample_values = samples->as_metatensor().values_cpu();
const auto* sample_ptr = sample_values.data();

always_assert(samples->names().size() == 3);
always_assert(samples->names()[0] == "sample");
Expand Down Expand Up @@ -436,7 +438,8 @@ std::vector<torch::Tensor> CellGrad<scalar_t>::forward(
always_assert(all_cells.requires_grad());

auto samples = dX_dH->samples();
const auto* sample_ptr = samples->as_metatensor().values().data();
const auto sample_values = samples->as_metatensor().values_cpu();
const auto* sample_ptr = sample_values.data();

always_assert(samples->names().size() == 1);
always_assert(samples->names()[0] == "sample");
Expand Down Expand Up @@ -517,9 +520,10 @@ std::vector<torch::Tensor> CellGrad<scalar_t>::backward(
auto dB_d_dA_dH = grad_outputs[0]; // gradient of B w.r.t. dA/dH (output of forward)

auto samples = dX_dH->samples();
const auto* sample_ptr = samples->as_metatensor().values().data();
always_assert(samples->names().size() == 1);
always_assert(samples->names()[0] == "sample");
const auto samples_values = samples->as_metatensor().values_cpu();
const auto* samples_ptr = samples_values.data();

// ========================= extract pointers =========================== //
// TODO: remove all CPU <=> device data movement by rewriting the VJP
Expand Down Expand Up @@ -571,7 +575,7 @@ std::vector<torch::Tensor> CellGrad<scalar_t>::backward(
// dB_d_dA_dX.shape == [samples, features...]
#pragma omp for
for (int64_t grad_sample_i=0; grad_sample_i<samples->count(); grad_sample_i++) {
auto sample_i = sample_ptr[grad_sample_i];
auto sample_i = samples_ptr[grad_sample_i];
auto system_i = static_cast<int64_t>(systems[sample_i].item<int32_t>());

for (int64_t i=0; i<n_features; i++) {
Expand Down
2 changes: 1 addition & 1 deletion featomic-torch/src/calculator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ static metatensor_torch::TensorBlock block_to_torch(
}

auto torch_values = torch::from_blob(
values.data(),
const_cast<double*>(values.data()),
sizes,
[tensor](void*) mutable {
// this function holds a copy of `tensor`, which will make sure that
Expand Down
Loading
Loading