n2p2 - Improved link to HPC MD software¶
This module documents efforts to improve the interaction of n2p2 with existing HPC software, in particular the molecular dynamics (MD) software package LAMMPS.
Purpose of Module¶
Although n2p2 was already shipped with source files for patching LAMMPS before, the build process required manual intervention of users. To avoid this in future versions of LAMMPS a pull request was created to include the n2p2/LAMMPS interface by default as a user package. In order to conform with LAMMPS contribution guidelines multiple issues were resolved, triggering these changes/additions to LAMMPS and n2p2:
- Modify the traditional build process (via makefiles) to include n2p2
- Modify the CMake build process to search and include n2p2
- Create additional documentation about the build settings
- Adapt documentation of the LAMMPS
pair_style nnp
command - Create a suitable example which can be shipped with LAMMPS
- Change n2p2 to conform with LAMMPS
bigbig
settings (see here) - Change the source files
pair_nnp.(cpp/h)
to conform with the LAMMPS coding style
Furthermore, the n2p2 build system was adapted to allow for multiple
interfaces to other software packages, with an option to select only
those of interest to the user. This can be achieved by providing the
INTERFACES
variable in the build stage, e.g. use
make libnnpif INTERFACES="LAMMPS CabanaMD"
to build both the LAMMPS
and the CabanaMD
interface and include it in
the libnnpif
library.
As a first application, the user contributed CabanaMD interface was integrated in the new build process. CabanaMD is an ECP proxy application which makes use of the Kokkos performance portability library and n2p2 to port neural network potentials in MD simulations to GPUs and other HPC hardware.
Background Information¶
This module is based on n2p2, a C++ code for generation and application of neural network potentials used in molecular dynamics simulations. The source code and documentation are located here:
- n2p2 documentation: http://compphysvienna.github.io/n2p2/
- n2p2 source code: http://github.com/CompPhysVienna/n2p2
In addition the source files for the LAMMPS patch are based on LAMMPS, a C++ code for massively parallelized molecular dynamics simulations. The source code and documentation are located here:
- LAMMPS documentation: https://lammps.sandia.gov/
- LAMMPS source code: http://github.com/lammps/lammps
Building and Testing¶
Important
By the time of reading these instructions the packages were most likely
developed further and it cannot be guaranteed that the procedures given below
will give the desired results. To retrieve the state of each software at the
time of writing these lines please uncomment and use the lines with git
checkout <commit-hash>
.
LAMMPS user package¶
To test whether the LAMMPS user package USER-NNP
works together with
n2p2 as expected we have to download LAMMPS from the pair-style-nnp
feature branch and use the current master
version of n2p2. First, to get
and compile n2p2:
git clone https://github.com/CompPhysVienna/n2p2
cd n2p2/src
# git checkout 428db3ee61f9943feaeedfaaeb5e096289983d46
make libnnpif -j
cd ../..
Next we retrieve the LAMMPS feature branch:
git clone -b pair-style-nnp --single-branch https://github.com/singraber/lammps
cd lammps
# git checkout ed53e2bbff2465dd05ba015a05843b2bb328360c
and compile the code with the USER-NNP
package enabled using the CMake
build approach:
mkdir build
cd build
cmake -D PKG_USER-NNP=yes -D N2P2_DIR=<path-to-n2p2> ../cmake
make -j
Alternatively, we could also use the traditional build process using makefiles:
cd src
make yes-user-nnp
make N2P2_DIR=<path-to-n2p2> mpi -j
In either case the LAMMPS binary should be created (lammps/build/lmp
or
lammps/src/lmp_mpi
) and we can test if it works correctly with the provided
example:
cd ../examples/USER/nnp
# Binary from CMake build process:
mpirun -np 4 ../../../build/lmp -in in.nnp
# or from the traditional build process:
# mpirun -np 4 ../../../src/lmp_mpi -in in.nnp
CabanaMD interface¶
While the n2p2 build process for the CabanaMD interface is trivial (it requires only the collection of some header files) the compilation steps on the CabanaMD side are not trivial. Furthermore, testing requires a suitable GPU with a compatible compiler environment. Hence it is not feasible to provide general build instructions for testing here. However, the n2p2 documentation offers an example build procedure for a specific hardware setup here.
Source Code¶
Changes in LAMMPS¶
The easiest way to view the source code changes in LAMMPS covered by this module is to use the GitHub pull request page. There, use the Files changed tab to review all changes.
Changes in n2p2¶
The following commits collect all changes required to follow the LAMMPS contribution guidelines:
- Updated makefiles for new LAMMPS build process
- Add flag information when n2p2 runs
- Changed build flags prefix from NNP_ to N2P2_
- Changed Atom::(Neighbor::)tag to int64_t
The commits which restructured the makefiles to allow multiple selectable interface library parts can be found here (they are part of the CabanaMD pull request):
The CabanaMD example build instructions were added to the n2p2 documentation in this commit: