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 .github/workflows/linuxWF.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ jobs:
mdtraj \
MDAnalysis \
"torch>=2.7" \
"metatomic-torch>=0.1.3,<0.2" \
"featomic-torch==0.7.0"
"metatomic-torch>=0.1.5,<0.2" \
"featomic-torch>=0.7.0,<0.8"

# torch 2.7 above is the first one to use cxx11 ABI for the PyPI wheels

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 < 5
#error "this code is only compatible with metatomic-torch >=0.1.5,<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 < 5
#error "this code is only compatible with metatomic-torch >=0.1.5,<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 < 5
#error "this code is only compatible with metatomic-torch >=0.1.5,<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 < 5
#error "this code is only compatible with metatomic-torch >=0.1.5,<0.2"
#endif
int main() {
metatomic_torch::version();
Expand Down
20 changes: 11 additions & 9 deletions src/metatomic/metatomic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ class MetatomicPlumedAction: public ActionAtomistic, public ActionWithValue {
// execute the model for the given system
metatensor_torch::TensorBlock executeModel(metatomic_torch::System system);

torch::jit::Module model_;
metatensor_torch::Module model_;

metatomic_torch::ModelCapabilities capabilities_;

Expand Down Expand Up @@ -233,6 +233,7 @@ MetatomicPlumedAction::MetatomicPlumedAction(const ActionOptions& options):
Action(options),
ActionAtomistic(options),
ActionWithValue(options),
model_(torch::jit::Module()),
device_(torch::kCPU)
{
if (metatomic_torch::version().find("0.1.") != 0) {
Expand Down Expand Up @@ -526,24 +527,23 @@ MetatomicPlumedAction::MetatomicPlumedAction(const ActionOptions& options):

// parse and handle atom sub-selection. This is done AFTER determining the
// output size, since the selection might not be valid for the dummy system
std::vector<int32_t> selected_atoms;
this->parseVector("SELECTED_ATOMS", selected_atoms);
std::vector<AtomNumber> selected_atoms;
this->parseAtomList("SELECTED_ATOMS", selected_atoms);
if (!selected_atoms.empty()) {
auto selection_value = torch::zeros(
{static_cast<int64_t>(selected_atoms.size()), 2},
torch::TensorOptions().dtype(torch::kInt32).device(this->device_)
);

for (unsigned i=0; i<selected_atoms.size(); i++) {
auto n_atoms = static_cast<int32_t>(this->atomic_types_.size(0));
if (selected_atoms[i] <= 0 || selected_atoms[i] > n_atoms) {
auto n_atoms = this->atomic_types_.size(0);
if (selected_atoms[i].index() > n_atoms) {
this->error(
"Values in metatomic's SELECTED_ATOMS should be between 1 "
"and the number of atoms (" + std::to_string(n_atoms) + "), "
"got " + std::to_string(selected_atoms[i]));
"got " + std::to_string(selected_atoms[i].serial()));
}
// PLUMED input uses 1-based indexes, but metatomic wants 0-based
selection_value[i][1] = selected_atoms[i] - 1;
selection_value[i][1] = static_cast<int32_t>(selected_atoms[i].index());
}

evaluations_options_->set_selected_atoms(
Expand Down Expand Up @@ -774,7 +774,9 @@ metatensor_torch::TensorBlock MetatomicPlumedAction::computeNeighbors(

auto neighbor_samples = torch::make_intrusive<metatensor_torch::LabelsHolder>(
std::vector<std::string>{"first_atom", "second_atom", "cell_shift_a", "cell_shift_b", "cell_shift_c"},
pair_samples_values.to(this->device_)
pair_samples_values.to(this->device_),
// vesin should create unique pairs
metatensor::assume_unique{}
);

auto neighbors = torch::make_intrusive<metatensor_torch::TensorBlockHolder>(
Expand Down
Loading