Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
43e0fe7
Intitial scaffolding of metatensor interface
Luthaf Oct 4, 2024
a3fc5c9
[MAINT] Fix merge cruft
HaoZeke Sep 12, 2025
9fbf93f
chore(metatensor): orchestrate vesin design
HaoZeke Sep 15, 2025
8932089
chore(build): try to find metatensor
HaoZeke Sep 15, 2025
11f4ff2
chore(metatomic): trace nnpot through the code
HaoZeke Sep 15, 2025
2f9b51d
chore(metatomic): register as an energy output
HaoZeke Sep 15, 2025
1ac6b17
chore(metatomic): rename for the new ecosystem
HaoZeke Sep 15, 2025
e0d7995
chore(metatomic): regex rename for metatomic
HaoZeke Sep 15, 2025
8d58263
chore(metatomic): add topology processing
HaoZeke Sep 15, 2025
f6837a5
maint(metatomic): docstring update and formatting
HaoZeke Sep 15, 2025
799454d
maint(params): use the right variables
HaoZeke Sep 15, 2025
18a2a95
doc(metatomic): add a note wrt tpr
HaoZeke Sep 15, 2025
0138afc
chore(metatomic): rework cmake dependencies
HaoZeke Sep 15, 2025
3d964d5
chore(metatomic): try to use more git and fallback
HaoZeke Sep 15, 2025
bbbff69
chore(metatomic): kang from LAMMPS
HaoZeke Sep 15, 2025
6a69669
chore(openmp): fix for cuda compilers
HaoZeke Sep 15, 2025
c23f94a
chore(metatomic): resolve more compilation errors
HaoZeke Sep 15, 2025
58bea16
chore(metatomic): try to fix compilers
HaoZeke Sep 15, 2025
9212e26
chore(metatomic): grab vesin through cmake
HaoZeke Sep 16, 2025
b6e3d9e
chore(metatomic): remove caffe2 mkl workaround
HaoZeke Sep 16, 2025
e24d9a0
chore(metatomic): easier imports
HaoZeke Sep 16, 2025
d0bc34c
chore(metatomic): Forgotten include
HaoZeke Sep 16, 2025
a1fbc30
chore(metatomic): forgotten cmake
HaoZeke Sep 16, 2025
5fe4b03
feat(mta): rework a ton for compilation
HaoZeke Nov 5, 2025
4906acc
feat(mta): update vesin to 0.4.1
HaoZeke Nov 6, 2025
67b5fac
feat(mta): compile without errors
HaoZeke Nov 6, 2025
25ee141
feat(mta): compile AND link correctly
HaoZeke Nov 6, 2025
4ee2d02
chore(mtaopt): rework in the style of nnpot
HaoZeke Nov 6, 2025
899126d
chore(mdmta): register everywhere
HaoZeke Nov 6, 2025
1744fa6
tst(mtaopt): add reference tests for options
HaoZeke Nov 6, 2025
15438cd
bug(mtaforce): ensure compatible extensions
HaoZeke Nov 6, 2025
ecb1b31
bug(mtaforce): fix vesin calling conventions
HaoZeke Nov 6, 2025
51c945e
chore(mtaforce): use the model dtype
HaoZeke Nov 6, 2025
4c71a0d
chore(mtaforce): cleanup debugging
HaoZeke Nov 6, 2025
5d78bf3
chore(mtapot): update for mpi usage and efficiency
HaoZeke Nov 7, 2025
71a85e6
chore(mtaforce): defensively handle dtypes
HaoZeke Nov 7, 2025
26583ee
feat(mtapot): use more internal helpers
HaoZeke Nov 7, 2025
dbe5379
chore(mtapot): cleanup a bit
HaoZeke Nov 7, 2025
82c786d
chore(typo): fixup
HaoZeke Nov 7, 2025
fcd9e5f
chore(cmake): rework for older versions and clean
HaoZeke Nov 12, 2025
f4b0bb7
chore(cpp): more cleanup
HaoZeke Nov 12, 2025
c619614
Update src/gromacs/applied_forces/metatomic/metatomic_forceprovider.h
HaoZeke Nov 13, 2025
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
9 changes: 7 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -579,6 +579,11 @@ include(gmxManageCP2K)
########################################################################
include(gmxManageNNPot)

########################################################################
# Process metatomic settings
########################################################################
include(gmxManageMetatomic)

########################################################################
#Process shared/static library settings
########################################################################
Expand Down Expand Up @@ -630,7 +635,7 @@ if (GMX_HWLOC)
if (HWLOC_FIND_QUIETLY_AFTER_FIRST_RUN)
set(HWLOC_FIND_QUIETLY TRUE)
endif()
find_package(HWLOC 1.5)
find_package(HWLOC 1.5)

if (HWLOC_FOUND)
if (HWLOC_LIBRARIES MATCHES ".a$")
Expand Down Expand Up @@ -716,7 +721,7 @@ if(GMX_GPU)
elseif(${_gmx_gpu_uppercase} STREQUAL "HIP")
include(gmxManageHip)
elseif(${_gmx_gpu_uppercase} STREQUAL "OPENCL")
message(STATUS "GPU support with OpenCL is deprecated. It is still fully supported (and "
message(STATUS "GPU support with OpenCL is deprecated. It is still fully supported (and "
"recommended for Apple GPUs). Please use CUDA for running on NVIDIA GPUs and "
"SYCL for running on Intel and AMD GPUs.")
include(gmxManageOpenCL)
Expand Down
1 change: 1 addition & 0 deletions api/legacy/include/gromacs/topology/ifunc.h
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ enum
F_DENSITYFITTING,
F_EQM,
F_ENNPOT,
F_EMETATOMICPOT,
F_EPOT,
F_EKIN,
F_ETOT,
Expand Down
1 change: 1 addition & 0 deletions api/nblib/listed_forces/conversionscommon.h
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ using GmxToNblibMapping =
Unimplemented, // F_DENSITYFITTING,
Unimplemented, // F_EQM,
Unimplemented, // F_ENNPOT,
Unimplemented, // F_EMETATOMICPOT,
Unimplemented, // F_EPOT,
Unimplemented, // F_EKIN,
Unimplemented, // F_ETOT,
Expand Down
144 changes: 144 additions & 0 deletions cmake/gmxManageMetatomic.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
#
# This file is part of the GROMACS molecular simulation package.
#
# Copyright 2024- The GROMACS Authors
# and the project initiators Erik Lindahl, Berk Hess and David van der Spoel.
# Consult the AUTHORS/COPYING files and https://www.gromacs.org for details.
#
# GROMACS is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public License
# as published by the Free Software Foundation; either version 2.1
# of the License, or (at your option) any later version.
#
# GROMACS is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with GROMACS; if not, see
# https://www.gnu.org/licenses, or write to the Free Software Foundation,
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
# If you want to redistribute modifications to GROMACS, please
# consider that scientific software is very special. Version
# control is crucial - bugs must be traceable. We will be happy to
# consider code for inclusion in the official distribution, but
# derived work must not be called official GROMACS. Details are found
# in the README & COPYING files - if they are missing, get the
# official version at https://www.gromacs.org.
#
# To help us fund GROMACS development, we humbly ask that you cite
# the research papers on the package. Check out https://www.gromacs.org.


option(GMX_METATOMIC "Enable interface to metatomic atomistic models" OFF)

# if(TORCH_ALREADY_SEARCHED)
# set(FIND_TORCH_QUIETLY ON)
# endif()

if(GMX_METATOMIC)
# Bring the `torch` target in scope to allow evaluation
# of cmake generator expression from `metatensor_torch`
find_package(Torch REQUIRED)

################ definition of metatensor and metatomic targets ################

set(METATENSOR_CORE_VERSION "0.1.17")
set(METATENSOR_CORE_SHA256 "42119e11908239915ccc187d7ca65449b461f1d4b5af4d6df1fb613d687da76a")

set(METATENSOR_TORCH_VERSION "0.8.0")
set(METATENSOR_TORCH_SHA256 "61d383ce958deafe0e3916088185527680c9118588722b17ec5c39cfbaa6da55")

set(METATOMIC_TORCH_VERSION "0.1.4")
set(METATOMIC_TORCH_SHA256 "385ec8b8515d674b6a9f093f724792b2469e7ea2365ca596f574b64e38494f94")

set(VESIN_VERSION "0.4.1")
set(VESIN_GIT_TAG "87dcad999fec47b29ab21be9662ef283edc7530b")

set(DOWNLOAD_VESIN_DEFAULT ON)
find_package(vesin ${VESIN_VERSION} QUIET)
if (vesin_FOUND)
set(DOWNLOAD_VESIN_DEFAULT OFF)
endif()

set(DOWNLOAD_METATENSOR_DEFAULT ON)
find_package(metatensor_torch ${METATENSOR_TORCH_VERSION} QUIET)
if (metatensor_torch_FOUND)
set(DOWNLOAD_METATENSOR_DEFAULT OFF)
endif()

set(DOWNLOAD_METATOMIC_DEFAULT ON)
find_package(metatomic_torch ${METATOMIC_TORCH_VERSION} QUIET)
if (metatomic_torch_FOUND)
set(DOWNLOAD_METATOMIC_DEFAULT OFF)
endif()


option(DOWNLOAD_METATENSOR "Download metatensor package instead of using an already installed one" ${DOWNLOAD_METATENSOR_DEFAULT})
option(DOWNLOAD_METATOMIC "Download metatomic package instead of using an already installed one" ${DOWNLOAD_METATOMIC_DEFAULT})

if (DOWNLOAD_METATENSOR)
include(FetchContent)

set(URL_BASE "https://github.com/metatensor/metatensor/releases/download")
FetchContent_Declare(metatensor
URL ${URL_BASE}/metatensor-core-v${METATENSOR_CORE_VERSION}/metatensor-core-cxx-${METATENSOR_CORE_VERSION}.tar.gz
URL_HASH SHA256=${METATENSOR_CORE_SHA256}
)

message(STATUS "Fetching metatensor v${METATENSOR_CORE_VERSION} from github")
FetchContent_MakeAvailable(metatensor)

FetchContent_Declare(metatensor-torch
URL ${URL_BASE}/metatensor-torch-v${METATENSOR_TORCH_VERSION}/metatensor-torch-cxx-${METATENSOR_TORCH_VERSION}.tar.gz
URL_HASH SHA256=${METATENSOR_TORCH_SHA256}
)

message(STATUS "Fetching metatensor-torch v${METATENSOR_TORCH_VERSION} from github")
FetchContent_MakeAvailable(metatensor-torch)
else()
# make sure to fail the configuration if cmake can not find metatensor-torch
find_package(metatensor_torch REQUIRED ${METATENSOR_TORCH_VERSION})
endif()

if (DOWNLOAD_METATOMIC)
include(FetchContent)

set(URL_BASE "https://github.com/metatensor/metatomic/releases/download")
FetchContent_Declare(metatomic-torch
URL ${URL_BASE}/metatomic-torch-v${METATOMIC_TORCH_VERSION}/metatomic-torch-cxx-${METATOMIC_TORCH_VERSION}.tar.gz
URL_HASH SHA256=${METATOMIC_TORCH_SHA256}
)

message(STATUS "Fetching metatomic-torch v${METATOMIC_TORCH_VERSION} from github")
FetchContent_MakeAvailable(metatomic-torch)
else()
# make sure to fail the configuration if cmake can not find metatomic-torch
find_package(metatomic_torch REQUIRED ${METATOMIC_TORCH_VERSION})
endif()

if (DOWNLOAD_VESIN)
include(FetchContent)

FetchContent_Declare(
vesin
GIT_REPOSITORY https://github.com/Luthaf/vesin.git
GIT_TAG ${VESIN_GIT_TAG}
)

FetchContent_MakeAvailable(vesin)
else()
# make sure to fail the configuration if cmake can not find vesin
find_package(vesin REQUIRED ${VESIN_VERSION})
endif()

list(APPEND GMX_COMMON_LIBRARIES
vesin
metatensor
metatomic_torch
metatensor_torch
)

endif()
2 changes: 1 addition & 1 deletion cmake/gmxManageOpenMP.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
if(GMX_OPENMP)
# We should do OpenMP detection if we get here
# OpenMP check must come before other CFLAGS!
find_package(OpenMP)
find_package(OpenMP REQUIRED C CXX)
if(NOT OPENMP_FOUND)
if(CMAKE_CXX_COMPILER_ID MATCHES "AppleClang")
message(FATAL_ERROR "The compiler you are using does not support OpenMP parallelism, "
Expand Down
3 changes: 3 additions & 0 deletions src/config.h.cmakein
Original file line number Diff line number Diff line change
Expand Up @@ -482,6 +482,9 @@
/* Define if we are building with an external FMM implementation */
#cmakedefine01 GMX_USE_EXT_FMM

/* Define if we are building with Metatomic */
#cmakedefine01 GMX_METATOMIC

/* Build using clang analyzer */
#cmakedefine01 GMX_CLANG_ANALYZER

Expand Down
2 changes: 1 addition & 1 deletion src/external/muparser/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ option(ENABLE_WIDE_CHAR "Enable wide character support" OFF)
option(BUILD_SHARED_LIBS "Build shared/static libs" ON)

if(ENABLE_OPENMP)
find_package(OpenMP REQUIRED)
find_package(OpenMP REQUIRED C CXX)
endif()

# Credit: https://stackoverflow.com/questions/2368811/how-to-set-warning-level-in-cmake/3818084
Expand Down
2 changes: 1 addition & 1 deletion src/external/tng_io/src/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ if(TNG_BUILD_TEST)
endif()

if(TNG_BUILD_EXAMPLES)
find_package(OpenMP)
find_package(OpenMP REQUIRED C CXX)
if(OPENMP_FOUND)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_EXE_LINKER_FLAGS}")
Expand Down
1 change: 1 addition & 0 deletions src/gromacs/applied_forces/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ add_subdirectory(qmmm)
add_subdirectory(colvars)
add_subdirectory(plumed)
add_subdirectory(nnpot)
add_subdirectory(metatomic)

if (BUILD_TESTING)
add_subdirectory(tests)
Expand Down
52 changes: 52 additions & 0 deletions src/gromacs/applied_forces/metatomic/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#
# This file is part of the GROMACS molecular simulation package.
#
# Copyright 2024- The GROMACS Authors
# and the project initiators Erik Lindahl, Berk Hess and David van der Spoel.
# Consult the AUTHORS/COPYING files and https://www.gromacs.org for details.
#
# GROMACS is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public License
# as published by the Free Software Foundation; either version 2.1
# of the License, or (at your option) any later version.
#
# GROMACS is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with GROMACS; if not, see
# https://www.gnu.org/licenses, or write to the Free Software Foundation,
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
# If you want to redistribute modifications to GROMACS, please
# consider that scientific software is very special. Version
# control is crucial - bugs must be traceable. We will be happy to
# consider code for inclusion in the official distribution, but
# derived work must not be called official GROMACS. Details are found
# in the README & COPYING files - if they are missing, get the
# official version at https://www.gromacs.org.
#
# To help us fund GROMACS development, we humbly ask that you cite
# the research papers on the package. Check out https://www.gromacs.org.

gmx_add_libgromacs_sources(
metatomic_options.cpp
metatomic_mdmodule.cpp
metatomic_topologypreprocessor.cpp
)

if (GMX_METATOMIC)
gmx_add_libgromacs_sources(
metatomic_forceprovider.cpp
)
else()
gmx_add_libgromacs_sources(
metatomic_forceprovider_stub.cpp
)
endif()

if (BUILD_TESTING)
add_subdirectory(tests)
endif()
Loading