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
79 changes: 0 additions & 79 deletions .github/workflows/build_cmake.yml

This file was deleted.

79 changes: 79 additions & 0 deletions .github/workflows/metatomic-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
name: Metatomic Integration Tests

on:
workflow_dispatch:
inputs:
pixi_envs_branch:
description: "pixi_envs branch for test definitions"
required: false
default: "main"
push:
branches: [metatomic]
pull_request:

jobs:
test:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- mpi: thread-mpi
build_task: gromk-tmpi
gmx_bin: gmx
- mpi: real-mpi
build_task: gromk-mpi
gmx_bin: gmx_mpi

name: metatomic (${{ matrix.mpi }})

steps:
- name: Checkout GROMACS
uses: actions/checkout@v4
with:
path: gromacs

- name: Checkout pixi_envs
uses: actions/checkout@v4
with:
repository: HaoZeke/pixi_envs
ref: ${{ github.event.inputs.pixi_envs_branch || 'main' }}
path: pixi_envs

- name: Place GROMACS inside pixi_envs layout
run: ln -s ${{ github.workspace }}/gromacs pixi_envs/orgs/metatensor/gromacs/gromacs

- name: Install pixi
uses: prefix-dev/setup-pixi@v0.8.1
with:
manifest-path: pixi_envs/orgs/metatensor/gromacs/pixi.toml
environments: metatomic-cpu

- name: Build GROMACS (${{ matrix.mpi }})
working-directory: pixi_envs/orgs/metatensor/gromacs
run: pixi run -e metatomic-cpu ${{ matrix.build_task }} Release

- name: Show cmake error log on failure
if: failure()
working-directory: pixi_envs/orgs/metatensor/gromacs
run: |
for f in gromacs/build-*/CMakeFiles/CMakeError.log; do
echo "=== $f ==="
cat "$f" 2>/dev/null || true
done
for f in gromacs/build-*/CMakeFiles/CMakeOutput.log; do
echo "=== $f (last 100 lines) ==="
tail -100 "$f" 2>/dev/null || true
done

- name: Generate test model
working-directory: pixi_envs/orgs/metatensor/gromacs
run: cd mta_test && pixi run -e metatomic-cpu python create_model.py

- name: Run tests (skip dd8/dd12)
working-directory: pixi_envs/orgs/metatensor/gromacs
env:
GMX_BIN: ${{ matrix.gmx_bin }}
run: |
pixi run -e metatomic-cpu pytest mta_test/ -v \
-m "not dd8 and not dd12"
19 changes: 19 additions & 0 deletions cmake/gmxManageMetatomic.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,25 @@ if(NOT GMX_METATOMIC STREQUAL "OFF")
endif()

set(GMX_TORCH ON)

# Ensure the torch library directory is in RPATH so that libtorch.so,
# libc10.so, etc. can be found at runtime. CMAKE_INSTALL_RPATH_USE_LINK_PATH
# doesn't always extract paths from imported targets, so we add it explicitly.
# Guard prevents duplicate additions if gmxManageNNPot already added it.
if(TORCH_INSTALL_PREFIX AND NOT _torch_rpath_added)
list(APPEND CMAKE_INSTALL_RPATH "${TORCH_INSTALL_PREFIX}/lib")
set(_torch_rpath_added TRUE)

# Use RPATH instead of RUNPATH. Modern linkers default to RUNPATH
# (--enable-new-dtags), but RUNPATH doesn't propagate to transitive
# dependencies: gmx -> libgromacs.so -> libtorch.so -> libc10.so.
include(CheckLinkerFlag)
check_linker_flag(CXX "-Wl,--disable-new-dtags" _linker_supports_disable_new_dtags)
if(_linker_supports_disable_new_dtags)
add_link_options("-Wl,--disable-new-dtags")
endif()
endif()

elseif(GMX_METATOMIC STREQUAL "TORCH")
message(FATAL_ERROR "Torch not found. Please install libtorch and add its installation prefix"
" to CMAKE_PREFIX_PATH or set Torch_DIR to a directory containing "
Expand Down
16 changes: 16 additions & 0 deletions cmake/gmxManageNNPot.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,22 @@ if(NOT GMX_NNPOT STREQUAL "OFF")
endif()

set(GMX_TORCH ON)

# Ensure the torch library directory is in RPATH so that libtorch.so,
# libc10.so, etc. can be found at runtime.
if(TORCH_INSTALL_PREFIX AND NOT _torch_rpath_added)
list(APPEND CMAKE_INSTALL_RPATH "${TORCH_INSTALL_PREFIX}/lib")
set(_torch_rpath_added TRUE)

# Use RPATH instead of RUNPATH. RUNPATH doesn't propagate to
# transitive dependencies (gmx -> libgromacs -> libtorch -> libc10).
include(CheckLinkerFlag)
check_linker_flag(CXX "-Wl,--disable-new-dtags" _linker_supports_disable_new_dtags)
if(_linker_supports_disable_new_dtags)
add_link_options("-Wl,--disable-new-dtags")
endif()
endif()

elseif(GMX_NNPOT STREQUAL "TORCH")
message(FATAL_ERROR "Torch not found. Please install libtorch and add its installation prefix"
" to CMAKE_PREFIX_PATH or set Torch_DIR to a directory containing "
Expand Down
Loading
Loading