Dragonfly: a modular deep reinforcement learning library

Jonathan Viquerat, Paul Garnier, Amir-Hossein Bateni, Elie HachemarXiv 2025 · OpenReview

Abstract

Dragonfly is a deep reinforcement learning library focused on modularity, in order to ease experimentation and developments. It relies on a json serialization that allows to swap building blocks and perform parameter sweep, while minimizing code maintenance. Some of its features are specifically designed for CPU-intensive environments, such as numerical simulations. Its performance on standard agents using common benchmarks compares favorably with the literature.

Introduction

Deep Reinforcement Learning (DRL) has achieved remarkable success in domains like gaming and robotics. However, its application to complex engineering problems, such as fluid dynamics or structural mechanics, remains challenging due to the high computational cost of numerical simulations. Existing DRL libraries often lack the necessary modularity for research or the optimizations required for slow, CPU-intensive environments. Dragonfly addresses these gaps by providing a highly modular framework designed specifically for engineering simulations.

Architecture and Methods

Dragonfly is built on TensorFlow 2 and utilizes a modular architecture to facilitate rapid experimentation.

JSON-Based Factory Pattern

A core feature of Dragonfly is its JSON-driven factory pattern. The entire training pipeline—including agents, environments, and optimizers—is defined in a configuration file. This allows researchers to perform parameter sweeps and swap components without modifying the underlying Python code.

Dragonfly's modular architecture and training procedure.

Optimizations for Numerical Simulations

  • Parallel Bootstrapping: To handle slow environments, Dragonfly implements a bootstrapping termination technique. This allows for significantly higher parallelism (4 to 8 times more environments) while maintaining the "on-policy" requirements of algorithms like PPO.
  • State Representation Learning (SRL): Built-in modules for PCA and Auto-encoders allow for on-the-fly dimensionality reduction, compressing high-dimensional observations into manageable latent spaces.
  • Separable Environments: This feature treats environments with high-dimensional action spaces as multiple single-action environments, improving learning efficiency.

Experimental Evaluation

Dragonfly was benchmarked across several suites to prove its versatility:

  • Gymnasium: Standard tasks like Pendulum and LunarLander.
  • MuJoCo: Continuous control tasks like Ant and HalfCheetah.
  • BEACON: Specialized flow control problems representative of real-world simulations.

Key Results and Insights

Dragonfly's performance is competitive with established literature across standard benchmarks. A significant contribution is the parallel bootstrapping method, which dramatically improves training walltime for researchers limited by slow simulation solvers.

Impact of parallel bootstrapping on training efficiency.

As illustrated in Figure 3, bootstrapping enables faster convergence in terms of walltime by allowing for greater parallelization without sacrificing sample efficiency. Additionally, the library's SRL capabilities were shown to be highly effective; for instance, using a PCA-based latent space of 300 dimensions outperformed the full 1000-dimension observation vector by filtering out noise. The "Separable Environments" feature also proved vital for maintaining performance as action dimensionality increased from 5 to 20.

Conclusion and Future Work

Dragonfly provides a robust and modular platform for DRL research, particularly in engineering contexts. While currently limited to a TensorFlow 2 backend, its modular design simplifies the addition of new features. Future work may involve supporting additional backends like PyTorch or JAX and integrating more advanced representation learning techniques such as Variational Auto-encoders.

Summary updated

BibTeX
@misc{viquerat2025dragonfly,
  author = {Jonathan Viquerat and Paul Garnier and Amir-Hossein Bateni and Elie Hachem},
  title = {{Dragonfly: a modular deep reinforcement learning library}},
  year = {2025},
  eprint = {2505.03778},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2505.03778},
}
Figure