evosax: JAX-Based Evolution Strategies

Robert Tjarko Lange

TL;DR

evosax is a JAX-based library that implements over 30 evolution strategies (ES), 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.

What Problem Does This Paper Address?

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.

The author argues that ES can also benefit immensely from modern hardware accelerators. The challenge is that most existing ES libraries are written in standard Python/NumPy, which doesn't easily port to GPUs. evosax addresses this by providing a comprehensive, modular library built entirely on JAX, bridging the gap between evolutionary computation and modern high-performance computing.

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.

Datasets

To demonstrate the library's capabilities, the author evaluates several representative strategies on:

  • Brax: A JAX-native physics engine for continuous control tasks (Ant, Fetch, HalfCheetah, and Humanoid).
  • Standard Benchmarks: The library also supports BBOB (Black-Box Optimization Benchmarking) functions and Gymnax (classic RL control tasks).
  • Vision/Sequence Tasks: Utilities are provided for MNIST classification and sequential prediction.

Key Insights and Ideas

  • The Algorithm is the Bottleneck: While evaluating fitness (e.g., running a robot simulation) is often the slowest part, sampling high-dimensional Gaussian noise and updating large covariance matrices can also become a burden. Moving the entire algorithm to the GPU removes these bottlenecks.
  • Modularity is Key: evosax separates the strategy from "fitness shaping" (like rank-based normalization) and "parameter reshaping." This allows researchers to mix and match components—for example, using a CMA-ES update rule with a specific z-scoring transformation.
  • Neuroevolution at Scale: By combining evosax with other JAX-based libraries like EvoJAX or Brax, researchers can perform "neuroevolution"—evolving the weights of neural networks—at a scale previously reserved for gradient descent.

Key Results

The paper provides a benchmark comparison of four major strategies (OpenAI-ES, PGPE, SNES, and Sep-CMA-ES) across the Brax tasks.

  • Scalability: The results show how different strategies respond to increasing population sizes (from 64 to 512).
  • Performance: Strategies like SNES and PGPE showed strong performance across several continuous control tasks, with the library providing stable results across multiple independent runs.
  • Ease of Use: The author demonstrates that complex operations, like running a full ES loop across multiple seeds, can be reduced to a few lines of JAX code using vmap.

Limitations and Future Work

The primary limitation acknowledged is scaling to very high dimensions. Current ES methods struggle when the search space exceeds 100,000 parameters (the "curse of dimensionality"). 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 different devices. * Indirect Encodings: Implementing methods like HyperNEAT to represent large neural networks with fewer evolvable parameters, potentially bypassing the dimensionality limit. * Meta-Learning: Using evosax 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},
}

Loading related content...

Figure