{"id":16694597,"url":"https://github.com/deepmodeling/deepmd-gnn","last_synced_at":"2025-07-12T12:33:42.624Z","repository":{"id":254377329,"uuid":"845743328","full_name":"deepmodeling/deepmd-gnn","owner":"deepmodeling","description":"DeePMD-kit plugin for various graph neural network models","archived":false,"fork":false,"pushed_at":"2025-07-07T20:14:36.000Z","size":1806,"stargazers_count":47,"open_issues_count":6,"forks_count":7,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-07-07T22:38:29.731Z","etag":null,"topics":["deepmd","deepmd-kit","mace","nequip","python","pytorch"],"latest_commit_sha":null,"homepage":"https://docs.deepmodeling.com/projects/deepmd-gnn/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"lgpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/deepmodeling.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2024-08-21T21:01:06.000Z","updated_at":"2025-06-23T11:36:11.000Z","dependencies_parsed_at":"2024-08-23T04:24:52.876Z","dependency_job_id":"64c07135-3df1-4062-bf00-e78501891d07","html_url":"https://github.com/deepmodeling/deepmd-gnn","commit_stats":null,"previous_names":["njzjz/deepmd-mace","njzjz/deepmd-gnn","deepmodeling/deepmd-gnn"],"tags_count":2,"template":false,"template_full_name":"njzjz/python-template","purl":"pkg:github/deepmodeling/deepmd-gnn","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deepmodeling%2Fdeepmd-gnn","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deepmodeling%2Fdeepmd-gnn/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deepmodeling%2Fdeepmd-gnn/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deepmodeling%2Fdeepmd-gnn/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/deepmodeling","download_url":"https://codeload.github.com/deepmodeling/deepmd-gnn/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deepmodeling%2Fdeepmd-gnn/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264990641,"owners_count":23694465,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["deepmd","deepmd-kit","mace","nequip","python","pytorch"],"created_at":"2024-10-12T16:47:15.710Z","updated_at":"2025-07-12T12:33:42.612Z","avatar_url":"https://github.com/deepmodeling.png","language":"Python","funding_links":[],"categories":["Interatomic Potentials (ML-IAP)"],"sub_categories":[],"readme":"# DeePMD-kit plugin for various graph neural network models\n\n[![DOI:10.1021/acs.jcim.4c02441](https://img.shields.io/badge/DOI-10.1021%2Facs.jcim.4c02441-blue)](https://doi.org/10.1021/acs.jcim.4c02441)\n[![Citations](https://citations.njzjz.win/10.1021/acs.jcim.4c02441)](https://doi.org/10.1021/acs.jcim.4c02441)\n[![conda install](https://img.shields.io/conda/dn/conda-forge/deepmd-gnn?label=conda%20install)](https://anaconda.org/conda-forge/deepmd-gnn)\n[![PyPI - Version](https://img.shields.io/pypi/v/deepmd-gnn)](https://pypi.org/p/deepmd-gnn)\n\n`deepmd-gnn` is a [DeePMD-kit](https://github.com/deepmodeling/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.\n\nSupported packages and models include:\n\n- [MACE](https://github.com/ACEsuit/mace) (PyTorch version)\n- [NequIP](https://github.com/mir-group/nequip) (PyTorch version)\n\nAfter [installing the plugin](#installation), you can train the GNN models using DeePMD-kit, run active learning cycles for the GNN models using [DP-GEN](https://github.com/deepmodeling/dpgen), perform simulations with the MACE model using molecular dynamic packages supported by DeePMD-kit, such as [LAMMPS](https://github.com/lammps/lammps) and [AMBER](https://ambermd.org/).\nYou can follow [DeePMD-kit documentation](https://docs.deepmodeling.com/projects/deepmd/en/latest/) to train the GNN models using its PyTorch backend, after using the specific [model parameters](#parameters).\n\n## Credits\n\nIf you use this software, please cite the following paper:\n\n- 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](https://doi.org/10.1021/acs.jcim.4c02441). [![Citations](https://citations.njzjz.win/10.1021/acs.jcim.4c02441)](https://badge.dimensions.ai/details/doi/10.1021/acs.jcim.4c02441)\n\n## Installation\n\n### Install via conda\n\nIf you are in a [conda environment](https://docs.deepmodeling.com/faq/conda.html) where DeePMD-kit is already installed from the conda-forge channel,\nyou can use `conda` to install the DeePMD-GNN plugin:\n\n```sh\nconda install deepmd-gnn -c conda-forge\n```\n\n### Build from source\n\nFirst, clone this repository:\n\n```sh\ngit clone https://gitlab.com/RutgersLBSR/deepmd-gnn\ncd deepmd-gnn\n```\n\n#### Python interface plugin\n\nPython 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.\n\nAssume you have installed [DeePMD-kit](https://github.com/deepmodeling/deepmd-kit) (v3.0.0b2 or above) and [PyTorch](https://github.com/pytorch/pytorch) in an environment, then execute\n\n```sh\n# expose PyTorch CMake modules\nexport CMAKE_PREFIX_PATH=$(python -c \"import torch;print(torch.utils.cmake_prefix_path)\")\n\npip install .\n```\n\n#### C++ interface plugin\n\nDeePMD-kit version should be v3.0.0b4 or later.\n\nFollow [DeePMD-kit documentation](https://docs.deepmodeling.com/projects/deepmd/en/latest/install/install-from-source.html#install-the-c-interface) to install DeePMD-kit C++ interface with PyTorch backend support and other related MD packages.\nAfter that, you can build the plugin\n\n```sh\n# Assume libtorch has been contained in CMAKE_PREFIX_PATH\nmkdir -p build\ncd build\ncmake .. -D CMAKE_INSTALL_PREFIX=/prefix/to/install\ncmake --build . -j8\ncmake --install .\n```\n\n`libdeepmd_gnn.so` will be installed into the directory you assign.\nWhen using any DeePMD-kit C++ interface, set the following environment variable in advance:\n\n```sh\nexport DP_PLUGIN_PATH=/prefix/to/install/lib/libdeepmd_gnn.so\n```\n\n## Usage\n\nFollow [Parameters section](#parameters) to prepare a DeePMD-kit input file.\n\n```sh\ndp --pt train input.json\ndp --pt freeze\n```\n\nA frozen model file named `frozen_model.pth` will be generated. You can use it in the MD packages or other interfaces.\nFor details, follow [DeePMD-kit documentation](https://docs.deepmodeling.com/projects/deepmd/en/latest/).\n\n### Running LAMMPS + MACE with period boundary conditions\n\nGNN models use message passing neural networks,\nso the neighbor list built with traditional cutoff radius will not work,\nsince the ghost atoms also need to build neighbor list.\nBy default, the model requests the neighbor list with a cutoff radius of $r_c \\times N_{L}$,\nwhere $r_c$ is set by `r_max` and $N_L$ is set by `num_interactions` (MACE) / `num_layers` (NequIP),\nand rebuilds the neighbor list for ghost atoms.\nHowever, this approach is very inefficient.\n\nThe 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.\nOne needs to set `DP_GNN_USE_MAPPING` when freezing the models,\n\n```sh\nDP_GNN_USE_MAPPING=1 dp --pt freeze\n```\n\nand request the mapping when using LAMMPS (also requires DeePMD-kit v3.0.0rc0 or above).\nBy using the mapping, the ghost atoms will be mapped to the real atoms,\nso the regular neighbor list with a cutoff radius of $r_c$ can be used.\n\n```lammps\natom_modify map array\n```\n\nIn the future, we will explore utilizing the MPI to communicate the neighbor list,\nwhile this approach requires a deep hack for external packages.\n\n## Parameters\n\n### MACE\n\nTo use the MACE model, set `\"type\": \"mace\"` in the `model` section of the training script.\nBelow is default values for the MACE model, most of which follows default values in the MACE package:\n\n```json\n\"model\": {\n  \"type\": \"mace\",\n  \"type_map\": [\n    \"O\",\n    \"H\"\n  ],\n  \"r_max\": 5.0,\n  \"sel\": \"auto\",\n  \"num_radial_basis\": 8,\n  \"num_cutoff_basis\": 5,\n  \"max_ell\": 3,\n  \"interaction\": \"RealAgnosticResidualInteractionBlock\",\n  \"num_interactions\": 2,\n  \"hidden_irreps\": \"128x0e + 128x1o\",\n  \"pair_repulsion\": false,\n  \"distance_transform\": \"None\",\n  \"correlation\": 3,\n  \"gate\": \"silu\",\n  \"MLP_irreps\": \"16x0e\",\n  \"radial_type\": \"bessel\",\n  \"radial_MLP\": [64, 64, 64],\n  \"std\": 1.0,\n  \"precision\": \"float32\"\n}\n```\n\n### NequIP\n\n```json\n\"model\": {\n  \"type\": \"nequip\",\n  \"type_map\": [\n    \"O\",\n    \"H\"\n  ],\n  \"r_max\": 5.0,\n  \"sel\": \"auto\",\n  \"num_layers\": 4,\n  \"l_max\": 2,\n  \"num_features\": 32,\n  \"nonlinearity_type\": \"gate\",\n  \"parity\": true,\n  \"num_basis\": 8,\n  \"BesselBasis_trainable\": true,\n  \"PolynomialCutoff_p\": 6,\n  \"invariant_layers\": 2,\n  \"invariant_neurons\": 64,\n  \"use_sc\": true,\n  \"irreps_edge_sh\": \"0e + 1e\",\n  \"feature_irreps_hidden\": \"32x0o + 32x0e + 32x1o + 32x1e\",\n  \"chemical_embedding_irreps_out\": \"32x0e\",\n  \"conv_to_output_hidden_irreps_out\": \"16x0e\",\n  \"precision\": \"float32\"\n}\n```\n\n## DPRc support\n\nIn `deepmd-gnn`, the GNN model can be used in a [DPRc](https://docs.deepmodeling.com/projects/deepmd/en/latest/model/dprc.html) way.\nType maps that starts with `m` (such as `mH`) or `OW` or `HW` will be recognized as MM types.\nTwo MM atoms will not build edges with each other.\nSuch GNN+DPRc model can be directly used in AmberTools24.\n\n## Examples\n\n- [examples/water](examples/water)\n- [examples/dprc](examples/dprc)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdeepmodeling%2Fdeepmd-gnn","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdeepmodeling%2Fdeepmd-gnn","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdeepmodeling%2Fdeepmd-gnn/lists"}