pyribs: A Bare-Bones Python Library for Quality Diversity Optimization

Bryon Tjanaka, Matthew C. Fontaine, David H. Lee, Yulun Zhang, Nivedit Reddy Balam, Nathaniel Dennler, Sujay S. Garlanka, Nikitas Dimitri Klapsis, Stefanos Nikolaidis · DOI

Abstract

Quality Diversity (QD) optimization is a class of evolutionary algorithms that seeks to find a collection of high-performing and functionally diverse solutions. While the field has seen rapid growth, the lack of a modular, accessible, and high-performance software framework has hindered broader adoption. This paper introduces pyribs, a "bare-bones" Python library designed to democratize QD optimization. By decomposing algorithms into three core components—Archives, Emitters, and Schedulers—and utilizing a flexible "ask-tell" interface, pyribs provides a modular foundation for both research and application in complex optimization domains.

Introduction

In traditional optimization, the objective is typically to find a single global optimum. However, in fields such as robotics, procedural content generation, and design, a single solution is often insufficient. Quality Diversity (QD) optimization addresses this by searching for an "archive" of solutions that are both high-performing and behaviorally diverse. For instance, in robotics, a QD algorithm might find multiple distinct ways for a robot to walk, providing a repertoire of behaviors that allows the system to adapt if a specific limb fails.

Despite the potential of QD, the software landscape has historically been fragmented. Existing libraries were often implemented in complex C++, lacked modularity, or were tied to specific hardware. pyribs was developed to fill this gap, offering a "PyTorch-like" experience for the QD community: a library that is simple to use, easy to extend, and deeply integrated with the Python scientific ecosystem.

The RIBS Framework

The core of pyribs is the RIBS framework, which conceptualizes any QD algorithm as the interaction between three modular components:

  1. Archive: A data structure that organizes solutions based on their "measures" (behavioral characteristics). It maintains the diversity of the population by only keeping the best solutions for specific regions of the behavior space.
  2. Emitters: These components are responsible for generating new candidate solutions. They can implement various strategies, such as Gaussian noise or more sophisticated Evolution Strategies like CMA-ES.
  3. Scheduler: The scheduler acts as the manager, coordinating which emitters are active and handling the flow of data between the archive and the user.

The Ask-Tell Interface

A defining feature of pyribs is its ask-tell interface. Unlike frameworks that require users to pass their objective functions into a library-controlled loop, pyribs allows the user to maintain control. The user "asks" the scheduler for a batch of solutions, evaluates them using their own code—which may involve complex simulations or parallel processing—and then "tells" the results back to the library. This design ensures that pyribs remains agnostic to the user's evaluation environment.

Design Philosophy and Implementation

The authors adhered to a "bare-bones" philosophy to ensure the library remains a useful tool for researchers rather than a "black box." Key design choices include:

  • Vectorized Performance: While early versions utilized JIT compilation (Numba), the authors transitioned to vectorized NumPy batch operations in version 0.5.0. This change simplified the codebase and improved debuggability while providing a significant performance boost—reducing runtimes by more than 2x on standard benchmarks.
  • Shallow Hierarchy: To make the library a learning tool, the authors utilized a one-layer class hierarchy. This allows users to understand the implementation of specific archives or emitters by looking at a single base class rather than navigating deep inheritance trees.
  • Continuous Optimization Focus: The library is primarily optimized for continuous search spaces (arrays of floats), which covers the majority of modern QD research applications.

Benchmarks and Applications

pyribs has been validated across a diverse set of benchmark problems, demonstrating its versatility:

  • CMA-ME Efficiency: Tested using the Sphere Linear Projection benchmark to evaluate the efficiency of the Covariance Matrix Adaptation Map-Elites algorithm.
  • Reinforcement Learning: Finding diverse landing strategies in the Lunar Lander environment.
  • Generative Modeling: Using QD to "illuminate" the latent space of MNIST GANs to find diverse handwritten digit styles.
  • Robotics: Generating repertoires of joint configurations for robotic arms to reach various points in 3D space.

Results and Community Impact

Since its release in 2021, pyribs has achieved its goal of democratizing QD optimization. The library's modularity allows researchers to create hybrid algorithms—such as combining specific archive types with novel emitters—without writing extensive boilerplate code. It has been adopted by over a dozen research groups globally for applications ranging from internet congestion control to architectural design. The transition to vectorized operations has ensured that the library remains competitive in terms of speed, even as it maintains its pure-Python accessibility.

Limitations and Future Work

Currently, the internal logic of pyribs is single-threaded, though users can easily parallelize their own evaluation steps. While the library handles discrete problems, its primary design is centered on continuous search spaces. Future development aims to include more diverse archive types, such as those used in Novelty Search, and exploring ways to integrate GPU support without compromising the library's signature simplicity and ease of installation.

Summary updated

BibTeX
@inproceedings{tjanaka2023pyribs,
  author = {Bryon Tjanaka and Matthew C. Fontaine and David H. Lee and Yulun Zhang and Nivedit Reddy Balam and Nathaniel Dennler and Sujay S. Garlanka and Nikitas Dimitri Klapsis and Stefanos Nikolaidis},
  title = {{pyribs: A Bare-Bones Python Library for Quality Diversity Optimization}},
  booktitle = {GECCO},
  year = {2023},
  url = {https://openreview.net/forum?id=c31bcQWl1N},
}
Figure