Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lyuda jan6 #20

Merged
merged 35 commits into from
Jan 7, 2025
Merged
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
9b63a2c
updating skp's torch_branch
osu1191 Jul 10, 2024
829cae9
edited the optimization code
osu1191 Jul 11, 2024
9af610a
added module list
osu1191 Jul 13, 2024
6cc9c4a
removing unwanted files
osu1191 Jul 14, 2024
479686e
getting rid of torch warnings
osu1191 Jul 14, 2024
d23111d
no more warnings
osu1191 Jul 14, 2024
d7e1d3b
added torch_nn variable for choice of model potential
osu1191 Jul 16, 2024
c49287d
debugging... issues in opt_step routine in libopt/
osu1191 Jul 17, 2024
ad82349
debugging and verbose
osu1191 Jul 18, 2024
643d2f3
editing comments for better understanding
osu1191 Jul 18, 2024
3214bda
atom_types fixed, extra calling of torch headers commented out
osu1191 Aug 7, 2024
f8168b4
added setup.sh for environmental variables
osu1191 Aug 26, 2024
8ba1393
added new_README for installation help
osu1191 Aug 26, 2024
23b9352
working on single loading of TorchANI NNPs
osu1191 Aug 27, 2024
0b04b30
parity with lyuda_torch
osu1191 Sep 11, 2024
91475bb
added aev.pt and spec_elpot
osu1191 Oct 8, 2024
688bdaf
removed global_state part
osu1191 Oct 10, 2024
91494ec
added custom path options
osu1191 Oct 17, 2024
7f71ba0
added custom path options
osu1191 Oct 17, 2024
1765e0d
added enable_elpot switch to turn off e_elec and e_qq for custom models
osu1191 Oct 20, 2024
7d668fd
removed duplicate files
osu1191 Oct 20, 2024
c8b361f
switched on OpenMP option in cmake
osu1191 Oct 23, 2024
76a3490
auto + backprop
osu1191 Oct 23, 2024
afa7d53
added torch_switch option for compilation
osu1191 Oct 24, 2024
3ba978b
parity with lyuda_Oct20
osu1191 Oct 27, 2024
19a1fee
parity with lyuda_Oct20
osu1191 Oct 27, 2024
4f780ea
fixed autograd and back prop issues
osu1191 Nov 19, 2024
4f4fad2
cleaning up test files
osu1191 Nov 21, 2024
ead383c
updated torch work
slipchenko Jan 3, 2025
2b54379
small changes in test jobs and printouts
slipchenko Jan 3, 2025
a2ee202
added installed dir and share/libefp/nnlib as asked in README-torch.md
osu1191 Jan 5, 2025
7f90532
added installation option in setup and lib64 to lib
osu1191 Jan 6, 2025
e70b3aa
final fixes torch version
slipchenko Jan 7, 2025
c7ea848
final fixes
slipchenko Jan 7, 2025
978ce1e
Merge branch 'master' into lyuda_Jan6
slipchenko Jan 7, 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
Binary file modified .DS_Store
Binary file not shown.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -24,5 +24,7 @@
/include/
tags
build*/
cmake-build-debug/
/installed/
/cmake-build-debug/
compilation.log

38 changes: 35 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -4,7 +4,23 @@ if (POLICY CMP0135)
endif ()

# extract project version from source

if(NOT DEFINED torch_switch)
if(DEFINED ENV{TORCH_SWITCH})
set(torch_switch $ENV{TORCH_SWITCH})
else()
set(torch_switch OFF)
endif()
endif()

option(torch_switch "Enable Torch library integration" ${TORCH_SWITCH})

if(torch_switch)
add_definitions(-DTORCH_SWITCH)
endif()

file(STRINGS "src/efp.h" _src_efp_h REGEX "LIBEFP_VERSION_STRING")

if (${_src_efp_h} MATCHES "^#define LIBEFP_VERSION_STRING \"(.*)\"$")
set(_libefp_VERSION ${CMAKE_MATCH_1})
endif()
@@ -13,9 +29,17 @@ project(
libefp
# someday when Makefile dropped, configure efp.h.in from cmake
VERSION ${_libefp_VERSION}
LANGUAGES C
LANGUAGES C CXX
)
set(libefp_AUTHORS "Ilya A. Kaliman, Lori A. Burns, Dmitry Morozov, Carlos H. Borca, Yen (Terri) Bui, Yongbin Kim, Lyudmila V. Slipchenko")

#set(CMAKE_INSTALL_PREFIX "${PROJECT_SOURCE_DIR}/installed" CACHE PATH "Installation directory" FORCE)
#set(CMAKE_INSTALL_PREFIX "${LIBEFP_DIR}" CACHE PATH "Installation directory")
set(CMAKE_INSTALL_LIBDIR "lib")

### LVS needs this on MacOS silicon
set(CMAKE_CXX_STANDARD 17)

set(libefp_AUTHORS "Ilya A. Kaliman, Lori A. Burns, Suranjan Paul, Dmitry Morozov, Carlos H. Borca, Yen (Terri) Bui, Yongbin Kim, Lyudmila V. Slipchenko")
set(libefp_DESCRIPTION "Parallel implementation of the Effective Fragment Potential method")
set(libefp_URL "https://github.com/libefp2/libefp")
set(libefp_LICENSE "BSD 2-clause")
@@ -24,6 +48,7 @@ list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)

set(efp libefp) # Namespace


# TODO: Remove when requiring cmake >= 3.21 # from LecrisUT/CMake-Template
if (NOT DEFINED ${efp}_IS_TOP_LEVEL)
if (CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
@@ -54,7 +79,10 @@ option_with_default(BUILD_FPIC "Libraries will be compiled with position indepen
if((${BUILD_SHARED_LIBS}) AND NOT ${BUILD_FPIC})
message(FATAL_ERROR "BUILD_SHARED_LIBS ON and BUILD_FPIC OFF are incompatible, as shared library requires position independent code")
endif()
option_with_print(LIBEFP_ENABLE_OPENMP "Enable OpenMP parallelization. Psi4 wants OFF" OFF)

### This option turns OPENMP ON and OFF!
option_with_print(LIBEFP_ENABLE_OPENMP "Enable OpenMP parallelization. Psi4 wants OFF" ON)

option_with_print(ENABLE_GENERIC "Enable mostly static linking in shared library" OFF)
include(xhost) # defines: option(ENABLE_XHOST "Enable processor-specific optimization" ON)
option_with_print(FRAGLIB_UNDERSCORE_L "DEPRECATED: Installed fragment library has names ending in _L. Psi4 wants OFF" ON)
@@ -132,6 +160,7 @@ set(raw_sources_list
util.c
xr.c
)

set(src_prefix "src/")
string(REGEX REPLACE "([^;]+)" "${src_prefix}\\1" sources_list "${raw_sources_list}")

@@ -203,6 +232,9 @@ install(FILES fraglib/makefp.inp
install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/fraglib
DESTINATION ${CMAKE_INSTALL_DATADIR}/${efp})

install(DIRECTORY ${PROJECT_SOURCE_DIR}/nnlib
DESTINATION ${CMAKE_INSTALL_DATADIR}/${efp})

# headers NOT namespace protected
install(FILES ${src_prefix}/efp.h
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
5 changes: 3 additions & 2 deletions CONTRIBUTORS
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
Libefp was written by Ilya Kaliman.
The following people contributed to libefp. Thanks!

Yen (Terri) Bui
Lori A. Burns
Dmitry Morozov
Carlos H. Borca
Yen (Terri) Bui
Yongbin Kim
Dmitry Morozov
Suranjan Paul
Lyudmila V. Slipchenko

2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -5,6 +5,7 @@ all: efpmd
efpmd: libefp
cd efpmd/libff && CC="$(CC)" CFLAGS="$(MYCFLAGS)" $(MAKE)
cd efpmd/libopt && CC="$(CC)" CFLAGS="$(MYCFLAGS)" FC="$(FC)" FFLAGS="$(MYFFLAGS)" $(MAKE)
cd efpmd/torch && CC="$(CC)" CFLAGS="$(MYCFLAGS)" $(MAKE)
cd efpmd/src && $(MAKE)

libefp:
@@ -15,6 +16,7 @@ clean:
cd tests && $(MAKE) $@
cd efpmd/libff && $(MAKE) $@
cd efpmd/libopt && $(MAKE) $@
cd efpmd/torch && $(MAKE) $@
cd efpmd/src && $(MAKE) $@
rm -rf doxygen_html

56 changes: 56 additions & 0 deletions README-torch.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@

# Installation with LibTorch for ML/EFP models

## Required libraries

- cmake
- lapack math library
- C/C++ compiler (GCC 9 or newer)
- Fortran 77 compiler

An example of working setup at Purdue supercomputers
can be foound in *module.sh* script.

AppleClang 14 works on M2 MacOS Ventura.

## LibTorch library

For ML/EFP models, one needs to use LibTorch library.
Install LibTorch (C++ frontend) of PyTorch. Consult Libtorch/Pytorch
webpages for detail: https://pytorch.org/cppdocs/

You can opt out and configure with EFP-only installation - see the next section.

## Setup environmental variables

*setup.sh* or *setup.csh* are used to set up environmental
variables. The first two are mandatory:

`TORCH_SWITCH` is the variable governing compilation
with or without LibTorch.

`LIBEFP_DIR` is a path to LibEFP directory with source codes.

`INSTALLATION_DIR` is the installation directory.

`TORCH_INSTALLED_DIR` and `LIBTORCH_INCLUDE_DIRS` are paths to the LibTorch
installation and included directories.

## Compilation

Further tuning can be done in `CMakeLists.txt`. Otherwise,
run `./compile.sh` to compile.

Executable `efpmd` will be in `build/efpmd/efpmd` and in

## Running test jobs

Test jobs are contained in `tests` directory.To check the complilation,
do

`cd tests`

`make check`

This will run all the test jobs and report `SUCCESS/FAILURE`. Examine any failed jobs carefully.

42 changes: 6 additions & 36 deletions README.md
Original file line number Diff line number Diff line change
@@ -27,6 +27,10 @@ The latest release can be downloaded

## Installation

**See [README-torch.md](README-torch.md) for the up-to-date installation instructions!
For additional CMake instructions, see [README-cmake.md](README-cmake.md).
The section below is outdated.**

To build LIBEFP from source you need the following:

- C compiler (with C99 standard and OpenMP support)
@@ -65,8 +69,6 @@ Finally, to install everything issue:

make install

For CMake instructions, see [README-cmake.md](README-cmake.md).

## Documentation

For a detailed documentation, tutorials, and EFP bibliography check out
@@ -85,7 +87,7 @@ Fortran bindings to LIBEFP are available in
The EFPMD program is a molecular simulation package based on LIBEFP.
It supports EFP-only molecular simulations such as geometry optimization
and molecular dynamics. EFPMD is a part of the LIBEFP distribution.
See [this](efpmd/README.md) file for more information.
See [EFPMD manual](https://libefp2.github.io/efpmd.html) for more information.

## Parallel scaling

@@ -142,36 +144,4 @@ More information can be found in [How to create EFP parameters](https://libefp2.

## References

1. Fragmentation Methods: A Route to Accurate Calculations on Large Systems.
M.S.Gordon, D.G.Fedorov, S.R.Pruitt, L.V.Slipchenko. Chem. Rev. 112, 632-672
(2012).

2. Effective fragment method for modeling intermolecular hydrogen bonding
effects on quantum mechanical calculations. J.H.Jensen, P.N.Day, M.S.Gordon,
H.Basch, D.Cohen, D.R.Garmer, M.Krauss, W.J.Stevens in "Modeling the
Hydrogen Bond" (D.A. Smith, ed.) ACS Symposium Series 569, 1994, pp
139-151.

3. An effective fragment method for modeling solvent effects in quantum
mechanical calculations. P.N.Day, J.H.Jensen, M.S.Gordon, S.P.Webb,
W.J.Stevens, M.Krauss, D.Garmer, H.Basch, D.Cohen. J.Chem.Phys. 105,
1968-1986 (1996).

4. Solvation of the Menshutkin Reaction: A Rigorous test of the Effective
Fragment Model. S.P.Webb, M.S.Gordon. J.Phys.Chem.A 103, 1265-73 (1999).

5. The Effective Fragment Potential Method: a QM-based MM approach to modeling
environmental effects in chemistry. M.S.Gordon, M.A.Freitag,
P.Bandyopadhyay, J.H.Jensen, V.Kairys, W.J.Stevens. J.Phys.Chem.A 105,
293-307 (2001).

6. The Effective Fragment Potential: a general method for predicting
intermolecular interactions. M.S.Gordon, L.V.Slipchenko, H.Li, J.H.Jensen.
Annual Reports in Computational Chemistry, Volume 3, pp 177-193 (2007).

7. Water-benzene interactions: An effective fragment potential and correlated
quantum chemistry study. L.V.Slipchenko, M.S.Gordon. J.Phys.Chem.A 113,
2092-2102 (2009).

8. Damping functions in the effective fragment potential method. L.V.Slipchenko,
M.S.Gordon. Mol.Phys. 107, 999-1016 (2009).
A complete list of references to the EFP method can be found [here](https://libefp2.github.io/papers.html#).
77 changes: 0 additions & 77 deletions bin/cubegen.pl

This file was deleted.

31 changes: 0 additions & 31 deletions bin/trajectory.pl

This file was deleted.

23 changes: 23 additions & 0 deletions compile.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/bin/csh

rm -rf build
mkdir build

if ( "$TORCH_SWITCH" == "ON" ) then
echo "Building with Torch integration..."
echo "TORCH_DIR = ${TORCH_INSTALLED_DIR}"
cd build
setenv TORCH_CXX_FLAGS "-D_GLIBCXX_USE_CXX11_ABI=0"
cmake -DCMAKE_INSTALL_PREFIX=${INSTALLATION_DIR} -DCMAKE_PREFIX_PATH=${TORCH_INSTALLED_DIR} -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON ..
#cmake -DCMAKE_PREFIX_PATH=${TORCH_INSTALLED_DIR} -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON ..
make VERBOSE=1
make install
else
echo "Building without Torch integration..."
cmake -H. -Bbuild -DCMAKE_INSTALL_PREFIX=${INSTALLATION_DIR}
cd build
make VERBOSE=1
make install
endif

echo "Compilation complete. You can now run test jobs as '${INSTALLATION_DIR}/bin/efpmd input.in' from the tests directory."
Loading