pytorch/rl
A modular, primitive-first, python-first PyTorch library for Reinforcement Learning.
What it solves
TorchRL addresses the fragmentation in reinforcement learning (RL) research by providing a unified, PyTorch-native toolkit. It eliminates the need for "glue code" that typically arises when combining different environments, algorithms, and data structures, allowing researchers to build complex systems without hidden assumptions about data format or batch layouts.
How it works
The library is built around a common data model called TensorDict, which acts as a dictionary-like container for tensors. By using TensorDict, components like environments, policies, replay buffers, and loss modules can communicate seamlessly. Because every module uses explicit input and output keys, you can swap out parts of your pipeline—such as changing an environment or a loss function—without rewriting the rest of your code.
Who it’s for
TorchRL is designed for researchers and developers working in reinforcement learning, robotics, simulation, and LLM post-training. It is suitable for those who want to scale from local prototypes to distributed, multi-agent, or recurrent workflows while staying within the familiar PyTorch programming model.
Highlights
- Composable Architecture: Environments, replay buffers, and policies are independent, swappable modules.
- TensorDict-First: A unified data structure that handles complex data (like multi-agent observations or recurrent states) consistently across the entire training loop.
- High-Performance Backends: Includes optimized paths for recurrent RL (Triton/scan backends) and CUDA-accelerated prioritized replay buffers.
- Broad Compatibility: Supports a wide range of environments including MuJoCo, Gymnasium, and PettingZoo, as well as advanced techniques like MAPPO, DreamerV3, and GRPO for LLM post-training.
Related
- Project
- Project
- Project
- Project
- Project