LAMMPS: PyTorch#
Requirements#
LAMMPS version of
stable_2Aug2023_update3CUDA-aware OpenMPIfor faster parallel MD (optional)
CUDA-aware OpenMPI is optional but recommended for parallel MD. If it is not available, GPUs will communicate via the CPU when running in parallel mode. It is still faster than using only one GPU, but its efficiency is lower.
Note
CUDA-aware OpenMPI does not support NVIDIA gaming GPUs. Since the software is closely tied to hardware specifications, please consult your server administrator if CUDA-aware OpenMPI is unavailable.
Build#
Ensure the LAMMPS version is stable_2Aug2023_update3. You can easily switch the version using Git. After switching the version, run sevenn patch_lammps with the LAMMPS directory path as an argument.
git clone https://github.com/lammps/lammps.git lammps_sevenn --branch stable_2Aug2023_update3 --depth=1
sevenn patch_lammps ./lammps_sevenn {--flashTP} {--d3}
You can refer to sevenn/pair_e3gnn/patch_lammps.sh for details of the patch process.
Tip
(Optional) Add --flashTP option to accelerate SevenNet for LAMMPS using flashTP. You must preinstall flashTP before building LAMMPS with flashTP.
(Optional) Build with GPU-D3 pair style#
Add --d3 option to install GPU-accelerated Grimme’s D3 method pair style. You can manually select the target capability using the TORCH_CUDA_ARCH_LIST environment variable. For example, you can use: export TORCH_CUDA_ARCH_LIST="6.1;7.0;8.0;8.6;8.9;9.0". For additional details, see the CUDA-accelerated Grimme’s D3.
Then build the LAMMPS binary:
cd ./lammps_sevenn
mkdir build
cd build
cmake ../cmake -DCMAKE_PREFIX_PATH=`python -c 'import torch;print(torch.utils.cmake_prefix_path)'`
make -j4
If the error MKL_INCLUDE_DIR NOT-FOUND occurs, you can use a dummy directory.
-DMKL_INCLUDE_DIR=/tmp
“Undefined reference” errors can be caused by missing linked libraries, incorrect link order, ABI mismatches, or missing dependent shared libraries. If the missing symbol lives in a shared library, ensure the library’s location is included in $LD_LIBRARY_PATH or CMake RPATH settings.
For other error cases, solution can be found in the pair-nequip repository, as we share the same architecture.
If the compilation is successful, the executable lmp can be found at {path_to_lammps_dir}/build.
To use this binary easily, create a soft link to your bin directory, which should be included in your $PATH.
ln -s {absolute_path_to_lammps_directory}/build/lmp $HOME/.local/bin/lmp
This allows you to run the binary using lmp -in my_lammps_script.lmp.
Usage#
Potential deployment#
To deploy LAMMPS models from checkpoints for both serial and parallel execution, use sevenn get_model.
Single-GPU MD#
For single-GPU MD simulations, the e3gnn pair_style should be used. A minimal input script is provided below:
units metal
atom_style atomic
pair_style e3gnn
pair_coeff * * {path to serial model} {space separated chemical species}
Note
If the LAMMPS is built with GPU-D3 pair style, you can combine SevenNet with D3 through the pair/hybrid command as the example below. For detailed instruction about parameters, supporting functionals and damping types, refer to CUDA-accelerated Grimme’s D3.
pair_style hybrid/overlay e3gnn d3 9000 1600 damp_bj pbe
pair_coeff * * e3gnn {path to serial model} {space separated chemical species}
pair_coeff * * d3 {space separated chemical species}
Multi-GPU MD#
For multi-GPU MD simulations, the e3gnn/parallel pair_style should be used. A minimal input script is provided below:
units metal
atom_style atomic
pair_style e3gnn/parallel
pair_coeff * * {number of message-passing layers} {directory of parallel model} {space separated chemical species}
For example,
pair_style e3gnn/parallel
pair_coeff * * 4 ./deployed_parallel Hf O
The number of message-passing layers corresponds to the number of *.pt files in the ./deployed_parallel directory.
It is expected that there is one GPU per MPI process. If the number of available GPUs is less than the number of MPI processes, the simulation may run inefficiently.
Caution
Currently, the parallel version encounters an error when one of the subdomain cells contains no atoms. This issue can be addressed using the processors command and, more effectively, the fix balance command in LAMMPS. A patch for this issue will be released in a future update.
Caution
Currently, our D3 algorithm is not supported by multi-GPU.