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.


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
$ git clone
$ cd tensordict
$ python develop
$ cd ../rl
$ python 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!






Knowledge Base

Indices and tables


Access comprehensive developer documentation for PyTorch

View Docs


Get in-depth tutorials for beginners and advanced developers

View Tutorials


Find development resources and get your questions answered

View Resources