torchmd-net 2.5.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (63) hide show
  1. torchmd_net-2.5.0/.github/workflows/docs.yml +39 -0
  2. torchmd_net-2.5.0/.github/workflows/publish.yml +74 -0
  3. torchmd_net-2.5.0/.github/workflows/test.yml +44 -0
  4. torchmd_net-2.5.0/.github/workflows/workflow.yml +25 -0
  5. torchmd_net-2.5.0/.gitignore +143 -0
  6. torchmd_net-2.5.0/LICENSE +21 -0
  7. torchmd_net-2.5.0/MANIFEST.in +9 -0
  8. torchmd_net-2.5.0/PKG-INFO +256 -0
  9. torchmd_net-2.5.0/README.md +232 -0
  10. torchmd_net-2.5.0/pyproject.toml +59 -0
  11. torchmd_net-2.5.0/setup.cfg +4 -0
  12. torchmd_net-2.5.0/torchmd_net.egg-info/PKG-INFO +256 -0
  13. torchmd_net-2.5.0/torchmd_net.egg-info/SOURCES.txt +62 -0
  14. torchmd_net-2.5.0/torchmd_net.egg-info/dependency_links.txt +1 -0
  15. torchmd_net-2.5.0/torchmd_net.egg-info/entry_points.txt +2 -0
  16. torchmd_net-2.5.0/torchmd_net.egg-info/requires.txt +13 -0
  17. torchmd_net-2.5.0/torchmd_net.egg-info/top_level.txt +1 -0
  18. torchmd_net-2.5.0/torchmdnet/__init__.py +7 -0
  19. torchmd_net-2.5.0/torchmdnet/calculators.py +295 -0
  20. torchmd_net-2.5.0/torchmdnet/data.py +176 -0
  21. torchmd_net-2.5.0/torchmdnet/datasets/__init__.py +55 -0
  22. torchmd_net-2.5.0/torchmdnet/datasets/ace.py +392 -0
  23. torchmd_net-2.5.0/torchmdnet/datasets/ani.py +339 -0
  24. torchmd_net-2.5.0/torchmdnet/datasets/comp6.py +361 -0
  25. torchmd_net-2.5.0/torchmdnet/datasets/custom.py +192 -0
  26. torchmd_net-2.5.0/torchmdnet/datasets/genentech.py +129 -0
  27. torchmd_net-2.5.0/torchmdnet/datasets/hdf.py +139 -0
  28. torchmd_net-2.5.0/torchmdnet/datasets/maceoff.py +138 -0
  29. torchmd_net-2.5.0/torchmdnet/datasets/md17.py +160 -0
  30. torchmd_net-2.5.0/torchmdnet/datasets/md22.py +98 -0
  31. torchmd_net-2.5.0/torchmdnet/datasets/mdcath.py +272 -0
  32. torchmd_net-2.5.0/torchmdnet/datasets/memdataset.py +269 -0
  33. torchmd_net-2.5.0/torchmdnet/datasets/qm9.py +68 -0
  34. torchmd_net-2.5.0/torchmdnet/datasets/qm9q.py +165 -0
  35. torchmd_net-2.5.0/torchmdnet/datasets/spice.py +189 -0
  36. torchmd_net-2.5.0/torchmdnet/datasets/water.py +111 -0
  37. torchmd_net-2.5.0/torchmdnet/extensions/__init__.py +3 -0
  38. torchmd_net-2.5.0/torchmdnet/extensions/neighbors.py +174 -0
  39. torchmd_net-2.5.0/torchmdnet/extensions/ops.py +124 -0
  40. torchmd_net-2.5.0/torchmdnet/extensions/triton_brute.py +255 -0
  41. torchmd_net-2.5.0/torchmdnet/extensions/triton_cell.py +474 -0
  42. torchmd_net-2.5.0/torchmdnet/extensions/triton_neighbors.py +108 -0
  43. torchmd_net-2.5.0/torchmdnet/loss.py +7 -0
  44. torchmd_net-2.5.0/torchmdnet/models/__init__.py +10 -0
  45. torchmd_net-2.5.0/torchmdnet/models/model.py +563 -0
  46. torchmd_net-2.5.0/torchmdnet/models/output_modules.py +285 -0
  47. torchmd_net-2.5.0/torchmdnet/models/tensornet.py +495 -0
  48. torchmd_net-2.5.0/torchmdnet/models/torchmd_et.py +435 -0
  49. torchmd_net-2.5.0/torchmdnet/models/torchmd_gn.py +340 -0
  50. torchmd_net-2.5.0/torchmdnet/models/torchmd_t.py +342 -0
  51. torchmd_net-2.5.0/torchmdnet/models/utils.py +726 -0
  52. torchmd_net-2.5.0/torchmdnet/models/wrappers.py +67 -0
  53. torchmd_net-2.5.0/torchmdnet/module.py +379 -0
  54. torchmd_net-2.5.0/torchmdnet/optimize.py +93 -0
  55. torchmd_net-2.5.0/torchmdnet/priors/__init__.py +10 -0
  56. torchmd_net-2.5.0/torchmdnet/priors/atomref.py +116 -0
  57. torchmd_net-2.5.0/torchmdnet/priors/base.py +63 -0
  58. torchmd_net-2.5.0/torchmdnet/priors/coulomb.py +125 -0
  59. torchmd_net-2.5.0/torchmdnet/priors/d2.py +201 -0
  60. torchmd_net-2.5.0/torchmdnet/priors/zbl.py +112 -0
  61. torchmd_net-2.5.0/torchmdnet/scripts/__init__.py +0 -0
  62. torchmd_net-2.5.0/torchmdnet/scripts/train.py +284 -0
  63. torchmd_net-2.5.0/torchmdnet/utils.py +417 -0
@@ -0,0 +1,39 @@
1
+ name: Build Documentation
2
+
3
+ on:
4
+ workflow_dispatch:
5
+ workflow_call:
6
+
7
+ jobs:
8
+ build-docs:
9
+ runs-on: ubuntu-latest
10
+
11
+ defaults: # Needed for conda
12
+ run:
13
+ shell: bash -l {0}
14
+
15
+ steps:
16
+ - uses: actions/checkout@v4
17
+
18
+ - uses: conda-incubator/setup-miniconda@v3
19
+ with:
20
+ python-version: "3.10"
21
+ channels: conda-forge
22
+ conda-remove-defaults: "true"
23
+
24
+ - name: Install compiler
25
+ run: conda install gxx --channel conda-forge --override-channels
26
+
27
+ - name: Install docs dependencies
28
+ run: |
29
+ pip install build
30
+ python -m build
31
+ pip install dist/*.whl
32
+ pip install -r docs/requirements.txt
33
+ env:
34
+ ACCELERATOR: "cpu"
35
+
36
+ - name: Build Sphinx Documentation
37
+ run: |
38
+ cd docs
39
+ make html
@@ -0,0 +1,74 @@
1
+ name: Build wheels and publish
2
+
3
+ on:
4
+ workflow_dispatch:
5
+ workflow_call:
6
+
7
+ jobs:
8
+ build:
9
+ name: Create source distribution
10
+ runs-on: ubuntu-latest
11
+
12
+ steps:
13
+ - uses: actions/checkout@v5
14
+
15
+ - uses: actions/setup-python@v6
16
+ with:
17
+ python-version: "3.13"
18
+
19
+ - name: Install cibuildwheel
20
+ run: pip install build
21
+
22
+ - name: Build pypi package
23
+ run: python -m build --sdist
24
+
25
+ - uses: actions/upload-artifact@v4
26
+ with:
27
+ name: source_dist
28
+ path: dist/*.tar.gz
29
+
30
+ publish-to-pypi:
31
+ name: >-
32
+ Publish Python 🐍 distribution 📦 to PyPI
33
+ needs:
34
+ - build
35
+ runs-on: ubuntu-latest
36
+ environment:
37
+ name: pypi
38
+ url: https://pypi.org/p/torchmd-net
39
+ permissions:
40
+ id-token: write # IMPORTANT: mandatory for trusted publishing
41
+
42
+ steps:
43
+ - name: Download all the dists
44
+ uses: actions/download-artifact@v4
45
+ with:
46
+ path: dist/
47
+ merge-multiple: true
48
+
49
+ - name: Publish distribution 📦 to PyPI
50
+ uses: pypa/gh-action-pypi-publish@release/v1
51
+ with:
52
+ password: ${{ secrets.TMDNET_PYPI_API_TOKEN }}
53
+ skip_existing: true
54
+
55
+ github-release:
56
+ name: >-
57
+ Create GitHub Release
58
+ needs:
59
+ - build
60
+ runs-on: ubuntu-latest
61
+
62
+ permissions:
63
+ contents: write # IMPORTANT: mandatory for making GitHub Releases
64
+ id-token: write # IMPORTANT: mandatory for sigstore
65
+
66
+ steps:
67
+ - name: Create GitHub Release
68
+ env:
69
+ GITHUB_TOKEN: ${{ github.token }}
70
+ run: >-
71
+ gh release create
72
+ "$GITHUB_REF_NAME"
73
+ --repo "$GITHUB_REPOSITORY"
74
+ --notes ""
@@ -0,0 +1,44 @@
1
+ name: Test
2
+
3
+ on:
4
+ workflow_dispatch:
5
+ workflow_call:
6
+ schedule:
7
+ - cron: "0 0 * * 0" # Run every Sunday at 0:00
8
+
9
+ jobs:
10
+ test:
11
+ runs-on: ${{ matrix.os }}
12
+
13
+ strategy:
14
+ fail-fast: false
15
+ matrix:
16
+ os:
17
+ ["ubuntu-latest", "ubuntu-22.04-arm", "macos-latest", "windows-2022"]
18
+ python-version: ["3.13"]
19
+
20
+ steps:
21
+ - name: Check out
22
+ uses: actions/checkout@v5
23
+
24
+ - name: Install uv
25
+ uses: astral-sh/setup-uv@v7
26
+ with:
27
+ python-version: ${{ matrix.python-version }}
28
+
29
+ - name: Install the project
30
+ run: uv sync --all-extras --dev
31
+
32
+ - name: Lint with flake8
33
+ run: |
34
+ # stop the build if there are Python syntax errors or undefined names
35
+ uv run flake8 ./torchmdnet --count --select=E9,F63,F7,F82 --show-source --statistics
36
+ # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
37
+ uv run flake8 ./torchmdnet --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
38
+
39
+ - name: Run tests
40
+ # For example, using `pytest`
41
+ run: uv run pytest tests
42
+
43
+ - name: Test torchmd-train utility
44
+ run: uv run torchmd-train --help
@@ -0,0 +1,25 @@
1
+ name: Whole
2
+
3
+ on: [push]
4
+
5
+ jobs:
6
+ test:
7
+ uses: ./.github/workflows/test.yml
8
+ secrets: inherit
9
+
10
+ publish:
11
+ if: startsWith(github.event.ref, 'refs/tags/v')
12
+ needs: test
13
+ uses: ./.github/workflows/publish.yml
14
+ secrets: inherit
15
+
16
+ docs:
17
+ if: startsWith(github.event.ref, 'refs/tags/')
18
+ needs: publish
19
+ uses: ./.github/workflows/docs.yml
20
+ secrets: inherit
21
+
22
+ docs_update:
23
+ if: startsWith(github.event.ref, 'refs/tags/d')
24
+ uses: ./.github/workflows/docs.yml
25
+ secrets: inherit
@@ -0,0 +1,143 @@
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+
6
+ # C extensions
7
+ *.so
8
+
9
+ # Distribution / packaging
10
+ .Python
11
+ build/
12
+ develop-eggs/
13
+ dist/
14
+ downloads/
15
+ eggs/
16
+ .eggs/
17
+ lib/
18
+ lib64/
19
+ parts/
20
+ sdist/
21
+ var/
22
+ wheels/
23
+ pip-wheel-metadata/
24
+ share/python-wheels/
25
+ *.egg-info/
26
+ .installed.cfg
27
+ *.egg
28
+ MANIFEST
29
+
30
+ # PyInstaller
31
+ # Usually these files are written by a python script from a template
32
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
33
+ *.manifest
34
+ *.spec
35
+
36
+ # Installer logs
37
+ pip-log.txt
38
+ pip-delete-this-directory.txt
39
+
40
+ # Unit test / coverage reports
41
+ htmlcov/
42
+ .tox/
43
+ .nox/
44
+ .coverage
45
+ .coverage.*
46
+ .cache
47
+ nosetests.xml
48
+ coverage.xml
49
+ *.cover
50
+ *.py,cover
51
+ .hypothesis/
52
+ .pytest_cache/
53
+
54
+ # Translations
55
+ *.mo
56
+ *.pot
57
+
58
+ # Django stuff:
59
+ *.log
60
+ local_settings.py
61
+ db.sqlite3
62
+ db.sqlite3-journal
63
+
64
+ # Flask stuff:
65
+ instance/
66
+ .webassets-cache
67
+
68
+ # Scrapy stuff:
69
+ .scrapy
70
+
71
+ # Sphinx documentation
72
+ docs/_build/
73
+
74
+ # PyBuilder
75
+ target/
76
+
77
+ # Jupyter Notebook
78
+ .ipynb_checkpoints
79
+
80
+ # IPython
81
+ profile_default/
82
+ ipython_config.py
83
+
84
+ # pyenv
85
+ .python-version
86
+
87
+ # pipenv
88
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
89
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
90
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
91
+ # install all needed dependencies.
92
+ #Pipfile.lock
93
+
94
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow
95
+ __pypackages__/
96
+
97
+ # Celery stuff
98
+ celerybeat-schedule
99
+ celerybeat.pid
100
+
101
+ # SageMath parsed files
102
+ *.sage.py
103
+
104
+ # Environments
105
+ .env
106
+ .venv
107
+ env/
108
+ venv/
109
+ ENV/
110
+ env.bak/
111
+ venv.bak/
112
+
113
+ # Spyder project settings
114
+ .spyderproject
115
+ .spyproject
116
+
117
+ # Rope project settings
118
+ .ropeproject
119
+
120
+ # mkdocs documentation
121
+ /site
122
+
123
+ # mypy
124
+ .mypy_cache/
125
+ .dmypy.json
126
+ dmypy.json
127
+
128
+ # Pyre type checker
129
+ .pyre/
130
+
131
+ # VS Code folder
132
+ .vscode/
133
+
134
+ # temp directories
135
+ logs/
136
+
137
+ # Docs
138
+ docs/build/
139
+ docs/source/generated
140
+
141
+ # Extra
142
+
143
+ *~
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2021-2023 Universitat Pompeu Fabra, https://www.compscience.org
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,9 @@
1
+ prune benchmarks
2
+ prune cibuildwheel_support
3
+ prune docs
4
+ prune examples
5
+ prune scripts
6
+ prune tests
7
+ exclude .readthedocs.yaml
8
+ exclude environment.yml
9
+ exclude Makefile
@@ -0,0 +1,256 @@
1
+ Metadata-Version: 2.4
2
+ Name: torchmd-net
3
+ Version: 2.5.0
4
+ Summary: TorchMD-NET provides state-of-the-art neural networks potentials for biomolecular systems
5
+ Author-email: Acellera <info@acellera.com>
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://github.com/torchmd/torchmd-net
8
+ Project-URL: Bug Tracker, https://github.com/torchmd/torchmd-net/issues
9
+ Classifier: Programming Language :: Python :: 3
10
+ Classifier: Operating System :: POSIX :: Linux
11
+ Requires-Python: >=3.9
12
+ Description-Content-Type: text/markdown
13
+ License-File: LICENSE
14
+ Requires-Dist: h5py
15
+ Requires-Dist: torch
16
+ Requires-Dist: torch_geometric
17
+ Requires-Dist: lightning
18
+ Requires-Dist: tqdm
19
+ Requires-Dist: numpy
20
+ Requires-Dist: triton; sys_platform == "linux" and platform_machine != "aarch64"
21
+ Requires-Dist: triton-windows; sys_platform == "win32"
22
+ Requires-Dist: ase
23
+ Dynamic: license-file
24
+
25
+ [![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
26
+ [![CI](https://github.com/torchmd/torchmd-net/actions/workflows/workflow.yml/badge.svg)](https://github.com/torchmd/torchmd-net/actions/workflows/workflow.yml)
27
+ [![Documentation Status](https://readthedocs.org/projects/torchmd-net/badge/?version=latest)](https://torchmd-net.readthedocs.io/en/latest/?badge=latest)
28
+
29
+ # TorchMD-NET
30
+
31
+ TorchMD-NET provides state-of-the-art neural networks potentials (NNPs) and a mechanism to train them. It offers efficient and fast implementations if several NNPs and it is integrated in GPU-accelerated molecular dynamics code like [ACEMD](https://www.acellera.com/products/molecular-dynamics-software-gpu-acemd/), [OpenMM](https://www.openmm.org) and [TorchMD](https://github.com/torchmd/torchmd). TorchMD-NET exposes its NNPs as [PyTorch](https://pytorch.org) modules.
32
+
33
+
34
+ ## Documentation
35
+
36
+ Documentation is available at https://torchmd-net.readthedocs.io
37
+
38
+ ## Available architectures
39
+
40
+ - [Equivariant Transformer (ET)](https://arxiv.org/abs/2202.02541)
41
+ - [Transformer (T)](https://arxiv.org/abs/2202.02541)
42
+ - [Graph Neural Network (GN)](https://arxiv.org/abs/2212.07492)
43
+ - [TensorNet](https://arxiv.org/abs/2306.06482)
44
+
45
+
46
+
47
+ ## Installation
48
+ TorchMD-Net is available as a pip package as well as in [conda-forge](https://conda-forge.org/)
49
+
50
+ As TorchMD-Net depends on PyTorch we need to add additional index URLs to the installation command as per [pytorch](https://pytorch.org/get-started/locally/)
51
+
52
+ ```sh
53
+ # The following will install TorchMD-Net with PyTorch CUDA 11.8 version
54
+ pip install torchmd-net --extra-index-url https://download.pytorch.org/whl/cu118
55
+ # The following will install TorchMD-Net with PyTorch CUDA 12.4 version
56
+ pip install torchmd-net --extra-index-url https://download.pytorch.org/whl/cu124
57
+ # The following will install TorchMD-Net with PyTorch CPU only version (not recommended)
58
+ pip install torchmd-net --extra-index-url https://download.pytorch.org/whl/cpu
59
+ ```
60
+
61
+ Alternatively it can be installed with conda or mamba with one of the following commands.
62
+ We recommend using [Miniforge](https://github.com/conda-forge/miniforge/) instead of anaconda.
63
+
64
+ ```shell
65
+ mamba install torchmd-net cuda-version=11.8
66
+ mamba install torchmd-net cuda-version=12.4
67
+ ```
68
+
69
+ ### Install from source
70
+
71
+ TorchMD-Net is installed using pip with `pip install -e .` to create an editable install.
72
+
73
+ ## Usage
74
+ Specifying training arguments can either be done via a configuration yaml file or through command line arguments directly. Several examples of architectural and training specifications for some models and datasets can be found in [examples/](https://github.com/torchmd/torchmd-net/tree/main/examples). Note that if a parameter is present both in the yaml file and the command line, the command line version takes precedence.
75
+ GPUs can be selected by setting the `CUDA_VISIBLE_DEVICES` environment variable. Otherwise, the argument `--ngpus` can be used to select the number of GPUs to train on (-1, the default, uses all available GPUs or the ones specified in `CUDA_VISIBLE_DEVICES`). Keep in mind that the [GPU ID reported by nvidia-smi might not be the same as the one `CUDA_VISIBLE_DEVICES` uses](https://stackoverflow.com/questions/26123252/inconsistency-of-ids-between-nvidia-smi-l-and-cudevicegetname).
76
+ For example, to train the Equivariant Transformer on the QM9 dataset with the architectural and training hyperparameters described in the paper, one can run:
77
+ ```shell
78
+ mkdir output
79
+ CUDA_VISIBLE_DEVICES=0 torchmd-train --conf torchmd-net/examples/ET-QM9.yaml --log-dir output/
80
+ ```
81
+ Run `torchmd-train --help` to see all available options and their descriptions.
82
+
83
+ ## Inference with Pretrained models
84
+
85
+ ### AceFF
86
+ Trained [AceFF models](https://huggingface.co/collections/Acellera/aceff-machine-learning-potentials) can be loaded and used for inference.
87
+ please see [here](https://github.com/torchmd/torchmd-net/tree/main/examples/aceff_examples)
88
+
89
+
90
+ To load your own trained models see [here](https://github.com/torchmd/torchmd-net/tree/main/examples#loading-checkpoints) for instructions on how to load pretrained models.
91
+
92
+ ## Creating a new dataset
93
+ If you want to train on custom data, first have a look at `torchmdnet.datasets.Custom`, which provides functionalities for
94
+ loading a NumPy dataset consisting of atom types and coordinates, as well as energies, forces or both as the labels.
95
+ Alternatively, you can implement a custom class according to the torch-geometric way of implementing a dataset. That is,
96
+ derive the `Dataset` or `InMemoryDataset` class and implement the necessary functions (more info [here](https://pytorch-geometric.readthedocs.io/en/latest/notes/create_dataset.html#creating-your-own-datasets)). The dataset must return torch-geometric `Data`
97
+ objects, containing at least the keys `z` (atom types) and `pos` (atomic coordinates), as well as `y` (label), `neg_dy` (negative derivative of the label w.r.t atom coordinates) or both.
98
+
99
+ ### Custom prior models
100
+ In addition to implementing a custom dataset class, it is also possible to add a custom prior model to the model. This can be
101
+ done by implementing a new prior model class in `torchmdnet.priors` and adding the argument `--prior-model <PriorModelName>`.
102
+ As an example, have a look at `torchmdnet.priors.Atomref`.
103
+
104
+ ## Multi-Node Training
105
+
106
+ In order to train models on multiple nodes some environment variables have to be set, which provide all necessary information to PyTorch Lightning. In the following we provide an example bash script to start training on two machines with two GPUs each. The script has to be started once on each node. Once `torchmd-train` is started on all nodes, a network connection between the nodes will be established using NCCL.
107
+
108
+ In addition to the environment variables the argument `--num-nodes` has to be specified with the number of nodes involved during training.
109
+
110
+ ```shell
111
+ export NODE_RANK=0
112
+ export MASTER_ADDR=hostname1
113
+ export MASTER_PORT=12910
114
+
115
+ mkdir -p output
116
+ CUDA_VISIBLE_DEVICES=0,1 torchmd-train --conf torchmd-net/examples/ET-QM9.yaml.yaml --num-nodes 2 --log-dir output/
117
+ ```
118
+
119
+ - `NODE_RANK` : Integer indicating the node index. Must be `0` for the main node and incremented by one for each additional node.
120
+ - `MASTER_ADDR` : Hostname or IP address of the main node. The same for all involved nodes.
121
+ - `MASTER_PORT` : A free network port for communication between nodes. PyTorch Lightning suggests port `12910` as a default.
122
+
123
+
124
+ ### Known Limitations
125
+ - Due to the way PyTorch Lightning calculates the number of required DDP processes, all nodes must use the same number of GPUs. Otherwise training will not start or crash.
126
+ - We observe a 50x decrease in performance when mixing nodes with different GPU architectures (tested with RTX 2080 Ti and RTX 3090).
127
+ - Some CUDA systems might hang during a multi-GPU parallel training. Try `export NCCL_P2P_DISABLE=1`, which disables direct peer to peer GPU communication.
128
+
129
+
130
+ ## Cite
131
+ If you use TorchMD-NET in your research, please cite the following papers:
132
+
133
+ #### Main reference
134
+
135
+ ```
136
+ @misc{pelaez2024torchmdnet,
137
+ title={TorchMD-Net 2.0: Fast Neural Network Potentials for Molecular Simulations},
138
+ author={Raul P. Pelaez and Guillem Simeon and Raimondas Galvelis and Antonio Mirarchi and Peter Eastman and Stefan Doerr and Philipp Thölke and Thomas E. Markland and Gianni De Fabritiis},
139
+ year={2024},
140
+ eprint={2402.17660},
141
+ archivePrefix={arXiv},
142
+ primaryClass={cs.LG}
143
+ }
144
+ ```
145
+
146
+ #### TensorNet
147
+
148
+ ```
149
+ @inproceedings{simeon2023tensornet,
150
+ title={TensorNet: Cartesian Tensor Representations for Efficient Learning of Molecular Potentials},
151
+ author={Guillem Simeon and Gianni De Fabritiis},
152
+ booktitle={Thirty-seventh Conference on Neural Information Processing Systems},
153
+ year={2023},
154
+ url={https://openreview.net/forum?id=BEHlPdBZ2e}
155
+ }
156
+ ```
157
+
158
+ #### Equivariant Transformer
159
+ ```
160
+ @inproceedings{
161
+ tholke2021equivariant,
162
+ title={Equivariant Transformers for Neural Network based Molecular Potentials},
163
+ author={Philipp Th{\"o}lke and Gianni De Fabritiis},
164
+ booktitle={International Conference on Learning Representations},
165
+ year={2022},
166
+ url={https://openreview.net/forum?id=zNHzqZ9wrRB}
167
+ }
168
+ ```
169
+
170
+ #### Graph Network
171
+
172
+ ```
173
+ @article{Majewski2023,
174
+ title = {Machine learning coarse-grained potentials of protein thermodynamics},
175
+ volume = {14},
176
+ ISSN = {2041-1723},
177
+ url = {http://dx.doi.org/10.1038/s41467-023-41343-1},
178
+ DOI = {10.1038/s41467-023-41343-1},
179
+ number = {1},
180
+ journal = {Nature Communications},
181
+ publisher = {Springer Science and Business Media LLC},
182
+ author = {Majewski, Maciej and Pérez, Adrià and Th\"{o}lke, Philipp and Doerr, Stefan and Charron, Nicholas E. and Giorgino, Toni and Husic, Brooke E. and Clementi, Cecilia and Noé, Frank and De Fabritiis, Gianni},
183
+ year = {2023},
184
+ month = sep
185
+ }
186
+ ```
187
+
188
+ ## Developer guide
189
+
190
+ ### Implementing a new architecture
191
+
192
+ To implement a new architecture, you need to follow these steps:
193
+ **1.** Create a new class in `torchmdnet.models` that inherits from `torch.nn.Model`. Follow TorchMD_ET as a template. This is a minimum implementation of a model:
194
+ ```python
195
+ class MyModule(nn.Module):
196
+ def __init__(self, parameter1, parameter2):
197
+ super(MyModule, self).__init__()
198
+ # Define your model here
199
+ self.layer1 = nn.Linear(10, 10)
200
+ ...
201
+ # Initialize your model parameters here
202
+ self.reset_parameters()
203
+
204
+ def reset_parameters(self):
205
+ # Initialize your model parameters here
206
+ nn.init.xavier_uniform_(self.layer1.weight)
207
+ ...
208
+
209
+ def forward(self,
210
+ z: Tensor, # Atomic numbers, shape (n_atoms, 1)
211
+ pos: Tensor, # Atomic positions, shape (n_atoms, 3)
212
+ batch: Tensor, # Batch vector, shape (n_atoms, 1). All atoms in the same molecule have the same value and are contiguous.
213
+ q: Optional[Tensor] = None, # Atomic charges, shape (n_atoms, 1)
214
+ s: Optional[Tensor] = None, # Atomic spins, shape (n_atoms, 1)
215
+ ) -> Tuple[Tensor, Tensor, Tensor, Tensor, Tensor]:
216
+ # Define your forward pass here
217
+ scalar_features = ...
218
+ vector_features = ...
219
+ # Return the scalar and vector features, as well as the atomic numbers, positions and batch vector
220
+ return scalar_features, vector_features, z, pos, batch
221
+ ```
222
+ **2.** Add the model to the `__all__` list in `torchmdnet.models.__init__.py`. This will make the tests pick your model up.
223
+ **3.** Tell models.model.create_model how to initialize your module by adding a new entry, for instance:
224
+ ```python
225
+ elif args["model"] == "mymodule":
226
+ from torchmdnet.models.torchmd_mymodule import MyModule
227
+ is_equivariant = False # Set to True if your model is equivariant
228
+ representation_model = MyModule(
229
+ parameter1=args["parameter1"],
230
+ parameter2=args["parameter2"],
231
+ **shared_args, # Arguments typically shared by all models
232
+ )
233
+ ```
234
+
235
+ **4.** Add any new parameters required to initialize your module to scripts.train.get_args. For instance:
236
+ ```python
237
+ parser.add_argument('--parameter1', type=int, default=32, help='Parameter1 required by MyModule')
238
+ ...
239
+ ```
240
+ **5.** Add an example configuration file to `torchmd-net/examples` that uses your model.
241
+ **6.** Make tests use your configuration file by adding a case to tests.utils.load_example_args. For instance:
242
+ ```python
243
+ if model_name == "mymodule":
244
+ config_file = join(dirname(dirname(__file__)), "examples", "MyModule-QM9.yaml")
245
+ ```
246
+
247
+ At this point, if your module is missing some feature the tests will let you know, and you can add it. If you add a new feature to the package, please add a test for it.
248
+
249
+ ### Code style
250
+
251
+ We use [black](https://https://black.readthedocs.io/en/stable/). Please run `black` on your modified files before committing.
252
+
253
+ ### Testing
254
+
255
+ To run the tests, install the package and run `pytest` in the root directory of the repository. Tests are a good source of knowledge on how to use the different components of the package.
256
+