Skip to main content

DeePMD-kit plugin for graph neural network models.

Project description

DeePMD-kit plugin for various graph neural network models

DOI:10.1021/acs.jcim.4c02441 Citations conda install PyPI - Version

deepmd-gnn is a DeePMD-kit plugin for various graph neural network (GNN) models, which connects DeePMD-kit and atomistic GNN packages by enabling GNN models in DeePMD-kit.

Supported packages and models include:

After installing the plugin, you can train the GNN models using DeePMD-kit, run active learning cycles for the GNN models using DP-GEN, perform simulations with the MACE model using molecular dynamic packages supported by DeePMD-kit, such as LAMMPS and AMBER. You can follow DeePMD-kit documentation to train the GNN models using its PyTorch backend, after using the specific model parameters.

Credits

If you use this software, please cite the following paper:

  • Jinzhe Zeng, Timothy J. Giese, Duo Zhang, Han Wang, Darrin M. York, DeePMD-GNN: A DeePMD-kit Plugin for External Graph Neural Network Potentials, J. Chem. Inf. Model., 2025, 65, 7, 3154-3160, DOI: 10.1021/acs.jcim.4c02441. Citations

Installation

Install via conda

If you are in a conda environment where DeePMD-kit is already installed from the conda-forge channel, you can use conda to install the DeePMD-GNN plugin:

conda install deepmd-gnn -c conda-forge

Build from source

First, clone this repository:

git clone https://gitlab.com/RutgersLBSR/deepmd-gnn
cd deepmd-gnn

Python interface plugin

Python 3.9 or above is required. A C++ compiler that supports C++ 14 (for PyTorch 2.0) or C++ 17 (for PyTorch 2.1 or above) is required.

Assume you have installed DeePMD-kit (v3.0.0b2 or above) and PyTorch in an environment, then execute

# expose PyTorch CMake modules
export CMAKE_PREFIX_PATH=$(python -c "import torch;print(torch.utils.cmake_prefix_path)")

pip install .

C++ interface plugin

DeePMD-kit version should be v3.0.0b4 or later.

Follow DeePMD-kit documentation to install DeePMD-kit C++ interface with PyTorch backend support and other related MD packages. After that, you can build the plugin

# Assume libtorch has been contained in CMAKE_PREFIX_PATH
mkdir -p build
cd build
cmake .. -D CMAKE_INSTALL_PREFIX=/prefix/to/install
cmake --build . -j8
cmake --install .

libdeepmd_gnn.so will be installed into the directory you assign. When using any DeePMD-kit C++ interface, set the following environment variable in advance:

export DP_PLUGIN_PATH=/prefix/to/install/lib/libdeepmd_gnn.so

Usage

Follow Parameters section to prepare a DeePMD-kit input file.

dp --pt train input.json
dp --pt freeze

A frozen model file named frozen_model.pth will be generated. You can use it in the MD packages or other interfaces. For details, follow DeePMD-kit documentation.

Running LAMMPS + MACE with period boundary conditions

GNN models use message passing neural networks, so the neighbor list built with traditional cutoff radius will not work, since the ghost atoms also need to build neighbor list. By default, the model requests the neighbor list with a cutoff radius of $r_c \times N_{L}$, where $r_c$ is set by r_max and $N_L$ is set by num_interactions (MACE) / num_layers (NequIP), and rebuilds the neighbor list for ghost atoms. However, this approach is very inefficient.

The alternative approach for the MACE model (note: NequIP doesn't support such approach) is to use the mapping passed from LAMMPS, which does not support MPI. One needs to set DP_GNN_USE_MAPPING when freezing the models,

DP_GNN_USE_MAPPING=1 dp --pt freeze

and request the mapping when using LAMMPS (also requires DeePMD-kit v3.0.0rc0 or above). By using the mapping, the ghost atoms will be mapped to the real atoms, so the regular neighbor list with a cutoff radius of $r_c$ can be used.

atom_modify map array

In the future, we will explore utilizing the MPI to communicate the neighbor list, while this approach requires a deep hack for external packages.

Parameters

MACE

To use the MACE model, set "type": "mace" in the model section of the training script. Below is default values for the MACE model, most of which follows default values in the MACE package:

"model": {
  "type": "mace",
  "type_map": [
    "O",
    "H"
  ],
  "r_max": 5.0,
  "sel": "auto",
  "num_radial_basis": 8,
  "num_cutoff_basis": 5,
  "max_ell": 3,
  "interaction": "RealAgnosticResidualInteractionBlock",
  "num_interactions": 2,
  "hidden_irreps": "128x0e + 128x1o",
  "pair_repulsion": false,
  "distance_transform": "None",
  "correlation": 3,
  "gate": "silu",
  "MLP_irreps": "16x0e",
  "radial_type": "bessel",
  "radial_MLP": [64, 64, 64],
  "std": 1.0,
  "precision": "float32"
}

NequIP

"model": {
  "type": "nequip",
  "type_map": [
    "O",
    "H"
  ],
  "r_max": 5.0,
  "sel": "auto",
  "num_layers": 4,
  "l_max": 2,
  "num_features": 32,
  "nonlinearity_type": "gate",
  "parity": true,
  "num_basis": 8,
  "BesselBasis_trainable": true,
  "PolynomialCutoff_p": 6,
  "invariant_layers": 2,
  "invariant_neurons": 64,
  "use_sc": true,
  "irreps_edge_sh": "0e + 1e",
  "feature_irreps_hidden": "32x0o + 32x0e + 32x1o + 32x1e",
  "chemical_embedding_irreps_out": "32x0e",
  "conv_to_output_hidden_irreps_out": "16x0e",
  "precision": "float32"
}

DPRc support

In deepmd-gnn, the GNN model can be used in a DPRc way. Type maps that starts with m (such as mH) or OW or HW will be recognized as MM types. Two MM atoms will not build edges with each other. Such GNN+DPRc model can be directly used in AmberTools24.

Examples

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

deepmd_gnn-0.1.3.tar.gz (2.1 MB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

deepmd_gnn-0.1.3-py2.py3-none-win_amd64.whl (73.3 kB view details)

Uploaded Python 2Python 3Windows x86-64

deepmd_gnn-0.1.3-py2.py3-none-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl (47.9 kB view details)

Uploaded Python 2Python 3manylinux: glibc 2.24+ x86-64manylinux: glibc 2.28+ x86-64

deepmd_gnn-0.1.3-py2.py3-none-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl (48.0 kB view details)

Uploaded Python 2Python 3manylinux: glibc 2.24+ ARM64manylinux: glibc 2.28+ ARM64

deepmd_gnn-0.1.3-py2.py3-none-macosx_11_0_arm64.whl (47.3 kB view details)

Uploaded Python 2Python 3macOS 11.0+ ARM64

deepmd_gnn-0.1.3-py2.py3-none-macosx_10_13_x86_64.whl (46.8 kB view details)

Uploaded Python 2Python 3macOS 10.13+ x86-64

File details

Details for the file deepmd_gnn-0.1.3.tar.gz.

File metadata

  • Download URL: deepmd_gnn-0.1.3.tar.gz
  • Upload date:
  • Size: 2.1 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for deepmd_gnn-0.1.3.tar.gz
Algorithm Hash digest
SHA256 e8e4e6d5b1d63750fedeb0f75b15902449a276da025333e40f18c4f54fae1db0
MD5 78fd8c33649f9e82feab2837a4e05088
BLAKE2b-256 dc4d3b165e9e55efc089397ff5eccc914a348aeee5c5885c1139301ea2fbd88f

See more details on using hashes here.

Provenance

The following attestation bundles were made for deepmd_gnn-0.1.3.tar.gz:

Publisher: release.yaml on deepmodeling/deepmd-gnn

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file deepmd_gnn-0.1.3-py2.py3-none-win_amd64.whl.

File metadata

  • Download URL: deepmd_gnn-0.1.3-py2.py3-none-win_amd64.whl
  • Upload date:
  • Size: 73.3 kB
  • Tags: Python 2, Python 3, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for deepmd_gnn-0.1.3-py2.py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 6782856934662242a0612d9b3cf1de14dc04b6c1fe80a3ab65af628cebd91f27
MD5 2f10a612fd0bd023e73b11e59a383678
BLAKE2b-256 ad6627732cad865b07f25002a8bc08f8491ff3257e33983602fdde7c9fb64dce

See more details on using hashes here.

Provenance

The following attestation bundles were made for deepmd_gnn-0.1.3-py2.py3-none-win_amd64.whl:

Publisher: release.yaml on deepmodeling/deepmd-gnn

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file deepmd_gnn-0.1.3-py2.py3-none-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for deepmd_gnn-0.1.3-py2.py3-none-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 b8fd3cc731b0429ad6edd98328cfba6d3474ba0ab1170ec8fa63f29712a6d306
MD5 65689f934b1d183b0526600a768927a1
BLAKE2b-256 82f1c6be462e4bac87f7bab5f9f097151dac092be44232781361e45f9e153817

See more details on using hashes here.

Provenance

The following attestation bundles were made for deepmd_gnn-0.1.3-py2.py3-none-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl:

Publisher: release.yaml on deepmodeling/deepmd-gnn

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file deepmd_gnn-0.1.3-py2.py3-none-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for deepmd_gnn-0.1.3-py2.py3-none-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 b0d853d993a32f9b57d79b8a6910109e5f92cdd1c53c0c9033f9b6159b5850de
MD5 e8edbc86092a205c719274def3eff55f
BLAKE2b-256 ef9cd1ce4a05cc4bbac7cbb86f6d5191b40ba07576160256b3e00b87b48ea8db

See more details on using hashes here.

Provenance

The following attestation bundles were made for deepmd_gnn-0.1.3-py2.py3-none-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl:

Publisher: release.yaml on deepmodeling/deepmd-gnn

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file deepmd_gnn-0.1.3-py2.py3-none-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for deepmd_gnn-0.1.3-py2.py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 dc0dec70cf310883daf3d1c26b43716efb7469cd4ac98010db1fc0740051a5f0
MD5 5fe65b1b472bf3147b7357d7a00bd716
BLAKE2b-256 9cf22546f5ceb063d941803af2affb31fa5280992ea3b2ce798fa9695d84924e

See more details on using hashes here.

Provenance

The following attestation bundles were made for deepmd_gnn-0.1.3-py2.py3-none-macosx_11_0_arm64.whl:

Publisher: release.yaml on deepmodeling/deepmd-gnn

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file deepmd_gnn-0.1.3-py2.py3-none-macosx_10_13_x86_64.whl.

File metadata

File hashes

Hashes for deepmd_gnn-0.1.3-py2.py3-none-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 636e29c8657990f81c7146945d2f41fc18fde8f4dcc7b5bf3323b2c23246b3c5
MD5 6e20340afd0ef7a5091b0bb6d24f41b3
BLAKE2b-256 a58722d3d8d106d614c9d8cf5c32afab2d4e239e11cd0ff8c41295e39cdad3d0

See more details on using hashes here.

Provenance

The following attestation bundles were made for deepmd_gnn-0.1.3-py2.py3-none-macosx_10_13_x86_64.whl:

Publisher: release.yaml on deepmodeling/deepmd-gnn

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page