diff --git a/.github/workflows/linuxWF.yml b/.github/workflows/linuxWF.yml index 02bfecf877..b6dd65183e 100644 --- a/.github/workflows/linuxWF.yml +++ b/.github/workflows/linuxWF.yml @@ -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 diff --git a/configure b/configure index 7041256af6..89cdd7f119 100755 --- a/configure +++ b/configure @@ -10007,8 +10007,8 @@ $as_echo_n "checking libmetatomic without extra libs... " >&6; } #include #include #include - #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(); @@ -10056,8 +10056,8 @@ $as_echo_n "checking libmetatomic with $all_LIBS... " >&6; } #include #include #include - #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(); @@ -10105,8 +10105,8 @@ $as_echo_n "checking libmetatomic with -l$testlib... " >&6; } #include #include #include - #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(); diff --git a/configure.ac b/configure.ac index c4804d91fe..9c922c97ae 100644 --- a/configure.ac +++ b/configure.ac @@ -989,8 +989,8 @@ if test $libmetatomic = true ; then #include #include #include - #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(); diff --git a/src/metatomic/metatomic.cpp b/src/metatomic/metatomic.cpp index 3b27273ca1..14effd71d8 100644 --- a/src/metatomic/metatomic.cpp +++ b/src/metatomic/metatomic.cpp @@ -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_; @@ -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) { @@ -526,8 +527,8 @@ 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 selected_atoms; - this->parseVector("SELECTED_ATOMS", selected_atoms); + std::vector selected_atoms; + this->parseAtomList("SELECTED_ATOMS", selected_atoms); if (!selected_atoms.empty()) { auto selection_value = torch::zeros( {static_cast(selected_atoms.size()), 2}, @@ -535,15 +536,14 @@ MetatomicPlumedAction::MetatomicPlumedAction(const ActionOptions& options): ); for (unsigned i=0; i(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(selected_atoms[i].index()); } evaluations_options_->set_selected_atoms( @@ -774,7 +774,9 @@ metatensor_torch::TensorBlock MetatomicPlumedAction::computeNeighbors( auto neighbor_samples = torch::make_intrusive( std::vector{"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(