evosax: JAX-based Evolution Strategies

Robert Tjarko Lange

Abstract

The deep learning revolution has greatly been accelerated by the 'hardware lottery': Recent advances in modern hardware accelerators and compilers paved the way for large-scale batch gradient optimization. Evolutionary optimization, on the other hand, has mainly relied on CPU-parallelism, e.g. using Dask scheduling and distributed multi-host infrastructure. Here we argue that also modern evolutionary computation can significantly benefit from the massive computational throughput provided by GPUs and TPUs. In order to better harness these resources and to enable the next generation of black-box optimization algorithms, we release evosax: A JAX-based library of evolution strategies which allows researchers to leverage powerful function transformations such as just-in-time compilation, automatic vectorization and hardware parallelization. evosax implements 30 evolutionary optimization algorithms including finite-difference-based, estimation-of-distribution evolution strategies and various genetic algorithms. Every single algorithm can directly be executed on hardware accelerators and automatically vectorized or parallelized across devices using a single line of code. It is designed in a modular fashion and allows for flexible usage via a simple ask-evaluate-tell API. We thereby hope to facilitate a new wave of scalable evolutionary optimization algorithms.

Introduction

The "deep learning revolution" was largely fueled by the "hardware lottery" — the fact that gradient-based optimization is exceptionally well-suited for the parallel architecture of GPUs. In contrast, Evolutionary Strategies (ES) — which perform black-box optimization without needing gradients — have traditionally relied on CPU-based parallelism. This has made ES feel "slow" or "unscalable" compared to backpropagation.

evosax addresses this by providing a comprehensive, modular library built entirely on JAX, bridging the gap between evolutionary computation and modern high-performance computing. It implements over 30 evolution strategies, allowing researchers to run black-box optimization directly on GPUs and TPUs. By leveraging JIT compilation and automatic vectorization, it enables massive speedups and the parallel execution of multiple evolutionary runs with just a single line of code.

Methods

The core of evosax is its implementation of evolutionary operators using JAX’s functional transformations:

  • Just-In-Time (JIT) Compilation: The entire "ask-evaluate-tell" loop can be compiled into optimized machine code, minimizing Python overhead.
  • Vectorization (vmap): This allows users to run multiple independent ES runs (e.g., for different random seeds or hyperparameters) in parallel on a single device.
  • Parallelization (pmap): This enables scaling across multiple GPUs or TPU cores.

The library follows a standardized ask-evaluate-tell API:

  1. Ask: The strategy suggests a batch of candidate solutions (a population).
  2. Evaluate: The user evaluates these candidates on a task (e.g., a neural network's loss or a robot's fitness).
  3. Tell: The strategy updates its internal state (mean, covariance, etc.) based on the results.

evosax categorizes its 30+ algorithms into groups like Finite-Difference Gradient (FDG), Natural Evolution Strategies (PFD), and Estimation of Distribution (EOD) methods like CMA-ES.

Experiments and Results

To demonstrate the library's capabilities, several representative strategies were evaluated on JAX-native physics engine tasks (Brax) including Ant, Fetch, HalfCheetah, and Humanoid.

Performance of various ES algorithms on Brax tasks over 2000 generations.

The benchmark comparison of four major strategies (OpenAI-ES, PGPE, SNES, and Sep-CMA-ES) shows that moving the entire algorithm to the GPU removes bottlenecks associated with sampling high-dimensional noise and updating large covariance matrices.

Scalability of ES algorithms with increasing population sizes (64 to 512) on Brax tasks.

Key findings include:

  • Scalability: Different strategies respond uniquely to increasing population sizes. For instance, SNES and PGPE showed strong performance across several continuous control tasks.
  • Ease of Use: Complex operations, like running a full ES loop across multiple seeds, are reduced to a few lines of JAX code using vmap.

Discussion and Future Work

The primary limitation is scaling to very high dimensions, as current ES methods struggle when the search space exceeds 100,000 parameters. Additionally, large populations can hit the memory limits of modern accelerators.

Future directions include sub-population management using jax.lax.pmean to aggregate evolutionary gradients across devices, implementing indirect encodings like HyperNEAT to represent large neural networks with fewer parameters, and exploring meta-learning to discover new neural-network-parametrized evolution strategies.

Summary updated

BibTeX
@inproceedings{lange2023evosax,
  author = {Robert Tjarko Lange},
  title = {{evosax: JAX-based Evolution Strategies}},
  booktitle = {GECCO Companion},
  year = {2023},
  doi = {10.1145/3583133.3590733},
}
Figure