← Open Source
astooke

rlpyt

Reinforcement Learning in PyTorch.

Model DevelopmentReinforcement LearningPython
Open on GitHub
Momentum
+0stars in 24 hours0.0%
2.28k
Stars
326
Forks
+1
This week
16
Contributors
Created 2019-04-28 · Updated 2026-10-13 · #8782 today
Top developers
astookeAlexanderKoch-Kochjuliusfrost

astooke/rlpyt is ranked 8,782 with 2,278 stars.

Same-category comparison

astooke/rlpyt is ranked 8,782 among these 8 peers; salesforce/TransmogrifAI is ranked 8,783.

Same-category comparison
NameRankMetrics
benedekrozemberczki/karateclub8,762
Language:
Python
Stars:
2,291
Forks:
253
Description:
Karate Club: An API Oriented Open-source Python Framework for Unsupervised Learning on Graphs (CIKM 2020).
jsbroks/coco-annotator8,768
Language:
Vue
Stars:
2,286
Forks:
475
Description:
:pencil2: Web-based image segmentation tool for object detection, localization, and keypoints.
Sumandora/remove-refusals-with-transformers8,771
Language:
Python
Stars:
2,284
Forks:
339
Description:
Implements harmful/harmless refusal removal using pure HF Transformers.
Liuziyu77/Visual-RFT8,779
Language:
Jupyter Notebook
Stars:
2,280
Forks:
110
Description:
Official repository of 'Visual-RFT: Visual Reinforcement Fine-Tuning' & 'Visual-ARFT: Visual Agentic Reinforcement Fine-Tuning'’.
salesforce/TransmogrifAI8,783
Language:
Scala
Stars:
2,278
Forks:
398
Description:
TransmogrifAI (pronounced trăns-mŏgˈrə-fī) is an AutoML library for building modular, reusable, strongly typed machine learning workflows on Apache Spark with minimal hand-tuning.
rsennrich/subword-nmt8,785
Language:
Python
Stars:
2,276
Forks:
470
Description:
Unsupervised Word Segmentation for Neural Machine Translation and Text Generation.
MineDojo/MineDojo8,789
Language:
Java
Stars:
2,271
Forks:
195
Description:
Building Open-Ended Embodied Agents with Internet-Scale Knowledge.
ndrplz/ConvLSTM_pytorch8,794
Language:
Python
Stars:
2,268
Forks:
441
Description:
Implementation of Convolutional LSTM in PyTorch.
Key parameters and specifications
Key parameters and specifications
ParameterValue
LanguagePython
CategoryModel Development
SubcategoryReinforcement Learning
KeywordsDistributed training, RL
Stars2,278
Forks326
Contributors16
Created date2019-04-28
Updated date2026-10-13
Stars in 1 day0
Stars in 7 days1
Rank8,782
Previous rank8,842
Rank change60
7-day stars rank9,425
Previous 7-day stars rank9,472
7-day stars rank change47
Total stars rank5,703
Previous total stars rank5,699
Total stars rank change-4
CountryUSA
README summary

rlpyt Deep Reinforcement Learning in PyTorch *NEW: extended documentation available at (as of 27 Jan 2020)* *View the Change Log* Modular, optimized implementations of common deep RL algorithms in PyTorch, with unified infrastructure supporting all three major families of model-free algorithms: policy gradient, deep-q learning, and q-function policy gradient. Intended to be a high-throughput code-base for small- to medium-scale research (large-scale meaning like OpenAI Dota with 100's GPUs). Key capabilities/features include: Run

experiments in serial mode (helpful for debugging during development, or maybe sufficient for experiments). Run experiments fully parallelized, with options for parallel sampling and/or multi-GPU optimization. Multi-GPU optimization uses PyTorch's DistributedDataParallel, which supports gradient reduction concurrent with backprop. Use CPU or GPU for training and/or batched action selection during environment sampling. Sampling and optimization synchronous or asynchronous (via replay buffer). Training data always organized with leading indexes as . Online or offline evaluation of agent diagnostics during

training. Launching utilities for stacking/queueing sets of experiments in parallel on given **local** hardware resources (e. run 40 experiments on an 8-GPU machine with 1 experiment per GPU at a time). Compatible with the OpenAI Gym environment interface. 1 Modularity for easy modification / re-use of existing components. Implemented Algorithms **Policy Gradient** A2C, PPO. **Replay Buffers** (supporting both DQN + QPG) non-sequence and sequence (for recurrent) replay, n-step returns, uniform or prioritized replay, full-observation or frame

-based buffer (e. for Atari, stores only unique frames to save memory, reconstructs multi-frame observations). **Deep Q-Learning** DQN + variants: Double, Dueling, Categorical (up to Rainbow minus Noisy Nets), Recurrent (R2D2-style). *Coming soon*: Implicit Quantile Networks? **Q-Function Policy Gradient** DDPG, TD3, SAC. Getting Started Follow the installation instructions below, and then get started in the examples folder. Example scripts are ordered by increasing complexity. For newcomers to deep RL, it may be better to get familiar with

the algorithms using a different resource, such as the excellent OpenAI Spinning Up: docs, code. New data structure: Rlpyt introduces new object classes for easier organization of collections of numpy arrays / torch tensors. A is essentially a which exposes indexed or sliced read/writes into the structure. This is also intended to support environments with multi-modal observations or actions. For example, rather than flattening joint-angle and camera-image observations into one observation vector, the environment can store them

as-is into a for the observation, and in the forward method of the model, and can be fed into the desired layers. Intermediate infrastructure code doesn’t change. Overall the code is stable, but might still develop, changes may occur. Visualization This package does not include its own visualization, as the logged data is compatible with previous editions (see below). Clone this repository to the local machine. Install the anaconda environment appropriate for the machine. Either A) Edit the

PYTHONPATH to include the rlpyt directory, or 4. Install any packages / files pertaining to desired environments (e. Hint: for easy

Frequently asked questions

How many stars and forks are recorded?

astooke/rlpyt has 2,278 stars and 326 forks.

What is the repository rank?

astooke/rlpyt is ranked 8,782.

What language and category are recorded?

astooke/rlpyt has 2,278 stars, uses Python and belongs to Model Development.

Which repository is closest in rank?

astooke/rlpyt is compared with salesforce/TransmogrifAI, ranked 8,783 with 2,278 stars.

README

rlpyt

Deep Reinforcement Learning in PyTorch

NEW: extended documentation available at https://rlpyt.readthedocs.io (as of 27 Jan 2020)

View the Change Log

Modular, optimized implementations of common deep RL algorithms in PyTorch, with unified infrastructure supporting all three major families of model-free algorithms: policy gradient, deep-q learning, and q-function policy gradient. Intended to be a high-throughput code-base for small- to medium-scale research (large-scale meaning like OpenAI Dota with 100's GPUs). Key capabilities/features include:

  • Run experiments in serial mode (helpful for debugging during development, or maybe sufficient for experiments).
  • Run experiments fully parallelized, with options for parallel sampling and/or multi-GPU optimization.
    • Multi-GPU optimization uses PyTorch's DistributedDataParallel, which supports gradient reduction concurrent with backprop.
  • Use CPU or GPU for training and/or batched action selection during environment sampling.
  • Sampling and optimization synchronous or asynchronous (via replay buffer).
  • Full support for recurrent agents.
    • All agents receive observation, prev_action, prev_reward.
    • Training data always organized with leading indexes as [Time, Batch].
  • Online or offline evaluation of agent diagnostics during training.
  • Launching utilities for stacking/queueing sets of experiments in parallel on given local hardware resources (e.g. run 40 experiments on an 8-GPU machine with 1 experiment per GPU at a time).
  • Compatible with the OpenAI Gym environment interface.1
  • Modularity for easy modification / re-use of existing components.

Implemented Algorithms

Policy Gradient A2C, PPO.

Replay Buffers (supporting both DQN + QPG) non-sequence and sequence (for recurrent) replay, n-step returns, uniform or prioritized replay, full-observation or frame-based buffer (e.g. for Atari, stores only unique frames to save memory, reconstructs multi-frame observations).

Deep Q-Learning DQN + variants: Double, Dueling, Categorical (up to Rainbow minus Noisy Nets), Recurrent (R2D2-style). Coming soon: Implicit Quantile Networks?

Q-Function Policy Gradient DDPG, TD3, SAC. Coming soon: Distributional DDPG?

Getting Started

Follow the installation instructions below, and then get started in the examples folder. Example scripts are ordered by increasing complexity.

For newcomers to deep RL, it may be better to get familiar with the algorithms using a different resource, such as the excellent OpenAI Spinning Up: docs, code.

New data structure: namedarraytuple

Rlpyt introduces new object classes namedarraytuple for easier organization of collections of numpy arrays / torch tensors. (see rlpyt/utils/collections.py). A namedarraytuple is essentially a namedtuple which exposes indexed or sliced read/writes into the structure. For example, consider writing into a (possibly nested) dictionary of arrays:

for k, v in src.items():
  if isinstance(dest[k], dict):
    ..recurse..
  dest[k][slice_or_indexes] = v

This code is replaced by the following:

dest[slice_or_indexes] = src

Importantly, this syntax looks the same whether dest and src are indiviual numpy arrays or arbitrarily-structured collections of arrays (the structures of dest and src must match, or src can be a single value, or None is an empty placeholder). Rlpyt uses this data structure extensively--different elements of training data are organized with the same leading dimensions, making it easy to interact with desired time- or batch-dimensions.

This is also intended to support environments with multi-modal observations or actions. For example, rather than flattening joint-angle and camera-image observations into one observation vector, the environment can store them as-is into a namedarraytuple for the observation, and in the forward method of the model, observation.joint and observation.image can be fed into the desired layers. Intermediate infrastructure code doesn’t change.

Future Developments.

Overall the code is stable, but might still develop, changes may occur. Open to suggestions/contributions for other established algorithms to add or other developments to support more use cases--please see our simple contribution guidelines.

Visualization

This package does not include its own visualization, as the logged data is compatible with previous editions (see below). For more features, use https://github.com/vitchyr/viskit.

Installation

  1. Clone this repository to the local machine.

  2. Install the anaconda environment appropriate for the machine.

conda env create -f linux_[cpu|cuda9|cuda10].yml
source activate rlpyt
  1. Either A) Edit the PYTHONPATH to include the rlpyt directory, or B) Install as editable python package
#A
export PYTHONPATH=path_to_rlpyt:$PYTHONPATH

#B
pip install -e .
  1. Install any packages / files pertaining to desired environments (e.g. gym, mujoco). Atari is included.

Hint: for easy access, add the following to your ~/.bashrc (might substitute conda for source).

alias rlpyt="source activate rlpyt; cd path_to_rlpyt"

Extended Notes

For more discussion, please see the white paper on Arxiv. If you use this repository in your work or otherwise wish to cite it, please make reference to the white paper.

Code Organization

The class types perform the following roles:

  • Runner - Connects the sampler, agent, and algorithm; manages the training loop and logging of diagnostics.
    • Sampler - Manages agent / environment interaction to collect training data, can initialize parallel workers.
      • Collector - Steps environments (and maybe operates agent) and records samples, attached to sampler.
        • Environment - The task to be learned.
          • Observation Space/Action Space - Interface specifications from environment to agent.
        • TrajectoryInfo - Diagnostics logged on a per-trajectory basis.
    • Agent - Chooses control action to the environment in sampler; trained by the algorithm. Interface to model.
      • Model - Torch neural network module, attached to the agent.
      • Distribution - Samples actions for stochastic agents and defines related formulas for use in loss function, attached to the agent.
    • Algorithm - Uses gathered samples to train the agent (e.g. defines a loss function and performs gradient descent).
      • Optimizer - Training update rule (e.g. Adam), attached to the algorithm.
      • OptimizationInfo - Diagnostics logged on a per-training batch basis.

Historical, Scaling, Interfaces

This code is a revision and extension of accel_rl, which explored scaling RL in the Atari domain using Theano. Scaling results were recorded here: A. Stooke & P. Abbeel, "Accelerated Methods for Deep Reinforcement Learning". For an insightful study of batch-size scaling across deep learning including RL, see S. McCandlish, et. al "An Empirical Model of Large-Batch Training".

Accel_rl was inspired by rllab (the logger here is nearly a direct copy). Rlpyt follows the rllab interfaces: agents output action, agent_info, environments output observation, reward, done, env_info. In general in rlpyt, agent inputs/outputs are torch tensors, and environment inputs/ouputs are numpy arrays, with conversions handled automatically.

  1. Regarding OpenAI Gym compatibility, rlpyt uses a namedtuple for env_info rather than a dict. This makes for easier data recording but does require the same fields to be output at every environment step. An environment wrapper is provided. Wrappers are also provided for Gym spaces to convert to rlpyt spaces (notably Dict to composite).

Acknowledgements

Thanks for support / mentoring from Pieter Abbeel, the Fannie & John Hertz Foundation, NVIDIA, Max Jaderberg, OpenAI, and the BAIR community. And thanks in advance to any contributors!

Happy reinforcement learning!

Nearby in the ranking
Similar items