Developer Installation

You can install TorchSim with pip or from source.

Install using pip

You can install the basic functionality of torch-sim using pip:

pip install torch-sim-atomistic

Install from source

To install torch-sim from source, clone the repository from github

git clone https://github.com/Radical-AI/torch-sim
cd torch-sim
pip install . -e

Installing pre-commit

If you’re planning on contributing to the torch-sim source, you should also install the developer requirements with:

pip install -e .
pre-commit install
pre-commit run --all-files

The pre-commit command will ensure that changes to the source code match the torch-sim style guidelines by running code linters such as black and ruff automatically with each commit.

Running unit tests

Unit tests can be run from the source folder using pytest. First, the requirements to run tests must be installed:

pip install .[test]

And the tests run using:

pytest

Building the documentation

The torch-sim documentation can be built using the sphinx package. First, install the requirements:

pip install .[docs]

Next, the docs can be built to the docs_build directory:

sphinx-build docs docs_build

And launched with:

python -m http.server -d docs_build

To locally generate the tutorials, they must be copied to the docs folder, converted to .ipynb files, and executed. Then the .py files and any generated trajectory files must be cleaned up.

cp -r examples/tutorials docs/ && \
jupytext --set-formats "py:percent,ipynb" docs/tutorials/*.py && \
jupytext --set-kernel python3 docs/tutorials/*.py && \
jupytext --to notebook --execute docs/tutorials/*.py && \
rm docs/tutorials/*.py && \
rm docs/tutorials/*.h5* && \
rm docs/tutorials/*.traj*

Documentation structure based on Alex Ganose (@utf) exceptional atomate2 package.