RLgraph: Modular Computation Graphs for Deep Reinforcement Learning

Michael Schaarschmidt, Sven Mika, Kai Fricke, Eiko Yoneki · DOI

TL;DR

This paper introduces RLgraph, a novel framework that modularizes deep reinforcement learning (RL) by separating component composition, graph definition, and distributed execution. This separation leads to more robust, testable, and performant RL implementations, outperforming existing libraries in distributed execution benchmarks.

What Problem Does This Paper Address?

Developing and deploying deep reinforcement learning (RL) algorithms is notoriously complex. This complexity stems from several factors:

  • Algorithmic Instability and Hyper-parameter Sensitivity: RL algorithms often require extensive tuning and can be prone to unstable behavior.
  • Heterogeneous Distributed Communication: RL tasks frequently involve distributed systems for data collection and training, each with its own communication patterns and scheduling needs.
  • Lack of Standardization: Unlike supervised learning, RL lacks standardized approaches for designing, implementing, and executing models, leading to highly customized and often brittle code.
  • Tight Coupling: Existing RL libraries often tightly couple the logical components of an RL algorithm (e.g., neural network layers, replay buffers) with the specifics of deep learning frameworks (like TensorFlow or PyTorch) and distributed execution strategies. This makes code reuse, testing, and adaptation to different backends difficult.

The authors argue that this lack of separation of concerns is the root cause of these difficulties, hindering robustness, testability, and extensibility.

Methods

RLgraph tackles these challenges by introducing a modular computation graph architecture with a strong emphasis on separating concerns:

  • Modular Component Architecture: RLgraph defines components as first-class citizens with well-defined interfaces. These components encapsulate specific functionalities (e.g., replay buffers, neural networks, optimizers).
  • Backend-Independent Component Graph: The core of RLgraph is a component graph that is independent of specific deep learning framework implementations. This graph describes the dataflow and connections between components.
  • Separation of Concerns: RLgraph explicitly separates:
  • Logical Component Composition: Defining the building blocks of an RL algorithm.
  • Backend Graph Definition: Translating the component graph into a backend-specific computation graph (e.g., TensorFlow or PyTorch).
  • Distributed Execution: Handling the orchestration of training and data collection across multiple devices or machines.
  • Graph Builder and Executor: A graph builder translates the backend-independent component graph into a concrete computation graph for a chosen backend. A graph executor then handles the actual execution, managing devices, initialization, and monitoring.
  • Unified Interface: RLgraph provides a unified API for both static graph and define-by-run execution paradigms, supporting both TensorFlow and PyTorch.
  • Incremental Building and Testing: The modular design allows for individual components to be built and tested independently, significantly improving debugging and development cycles.

Datasets

Not discussed in the paper. The paper focuses on the framework's design and evaluation using standard RL environments like Atari Pong.

Key Insights and Ideas

  • Separation is Key: The most significant insight is that separating logical component composition from backend implementation and distributed execution is crucial for building robust and flexible RL systems. This modularity directly addresses the complexity and brittleness of existing approaches.
  • Component Graph as the Core Abstraction: RLgraph's component graph acts as a universal language for describing RL algorithms, abstracting away backend-specific details. This allows for greater reusability and easier adaptation.
  • Testability Through Modularity: By treating every component as a first-class citizen, RLgraph enables fine-grained, incremental testing. This is a major advantage over monolithic implementations where testing individual parts is difficult.
  • Unified Interface for Diverse Backends: Providing a single interface for both static graph and define-by-run execution, and supporting multiple deep learning frameworks (TF and PyTorch), significantly lowers the barrier to entry and experimentation.

Key Results

  • Performance Gains: RLgraph demonstrated significant performance improvements in distributed execution benchmarks.
  • On Ray, RLgraph outperformed Ray's native RLlib by up to 185% in sample throughput for distributed prioritized experience replay (Ape-X).
  • For IMPALA, RLgraph achieved 10-15% higher mean throughput with fewer workers compared to DeepMind's implementation.
  • Reduced Build Overhead: The build overhead for RLgraph's abstractions was found to be minimal, typically less than 100ms for single components and around 1 second for complex architectures. PyTorch backends showed even lower build times due to native Python list/NumPy array usage.
  • Improved Visualization: The modular structure of RLgraph leads to cleaner and more interpretable visualizations of computation graphs (e.g., in TensorBoard), making it easier to identify problems and understand dataflow.

Limitations and Future Work

  • AutoGraph Integration: While RLgraph's structure is amenable to automatic graph generation tools like TensorFlow's AutoGraph, direct integration is still a future direction. The authors plan to merge backend-dependent graph-function implementations into single-stream functions for better compatibility.
  • Graph Optimization: The paper mentions that emerging optimization techniques (e.g., automated device placement, backend-specific compilation) can be integrated at the graph build stage, suggesting this as a future area of exploration.
  • Mixed Backend Implementation Style: The authors acknowledge that the ad-hoc mixed-backend style of many RL libraries is a hurdle, but RLgraph's design provides a natural fit for future improvements in this area.
  • Further Backend Support: While TF and PyTorch are supported, expanding to other backends is a natural extension.

Summary updated

BibTeX
@inproceedings{schaarschmidt2018rlgraph,
  author = {Michael Schaarschmidt and Sven Mika and Kai Fricke and Eiko Yoneki},
  title = {{RLgraph: Modular Computation Graphs for Deep Reinforcement Learning}},
  booktitle = {Apollo},
  year = {2018},
  doi = {10.17863/cam.47584},
}
Figure