TorchRL¶
TorchRL is an open-source Reinforcement Learning (RL) library for PyTorch.
You can install TorchRL directly from PyPI (see more about installation instructions in the dedicated section below):
$ pip install torchrl
TorchRL provides pytorch and python-first, low and high level abstractions for RL that are intended to be efficient, modular, documented and properly tested. The code is aimed at supporting research in RL. Most of it is written in python in a highly modular way, such that researchers can easily swap components, transform them or write new ones with little effort.
This repo attempts to align with the existing pytorch ecosystem libraries in that it has a “dataset pillar” (environments), transforms, models, data utilities (e.g. collectors and containers), etc. TorchRL aims at having as few dependencies as possible (python standard library, numpy and pytorch). Common environment libraries (e.g. OpenAI gym) are only optional.
On the low-level end, torchrl comes with a set of highly re-usable functionals for cost functions, returns and data processing.
TorchRL aims at a high modularity and good runtime performance.
To read more about TorchRL philosophy and capabilities beyond this API reference, check the TorchRL paper.
Installation¶
TorchRL releases are synced with PyTorch, so make sure you always enjoy the latest features of the library with the most recent version of PyTorch (although core features are guaranteed to be backward compatible with pytorch>=1.13). Nightly releases can be installed via
$ pip install tensordict-nightly
$ pip install torchrl-nightly
or via a git clone
if you’re willing to contribute to the library:
$ cd path/to/root
$ git clone https://github.com/pytorch/tensordict
$ git clone https://github.com/pytorch/rl
$ cd tensordict
$ python setup.py develop
$ cd ../rl
$ python setup.py develop
Getting started¶
A series of quick tutorials to get ramped up with the basic features of the library. If you’re in a hurry, you can start by the last item of the series and navigate to the previous ones whenever you want to learn more!