RobertTLange/evosax

Evolution Strategies in JAX 🦎

evosax – Evolution Strategies in JAX

What it is

  • A pure‑Python library that implements more than 30 modern and classic Evolution Strategies (ES) and population‑based optimizers on top of JAX. By using JAX’s XLA compilation and transformation primitives (jit, vmap, lax.scan), the algorithms run efficiently on CPUs, GPUs, and TPUs without the need for custom distributed code.

Why it matters

  • ES are gradient‑free optimisation methods that are widely used for neuro‑evolution, reinforcement‑learning policy search, hyper‑parameter tuning, and black‑box optimisation. evosax makes these methods vectorised and hardware‑accelerated, letting researchers scale experiments that would otherwise be limited by Python‑level loops or manual parallelisation.

Key features

Feature Details
Broad algorithm catalogue 30+ strategies including CMA‑ES, Sep‑CMA‑ES, xNES, SNES, OpenAI‑ES, ARS, Guided‑ES, ASEBO, Persistent‑ES, Noise‑Reuse‑ES, SV‑CMA‑ES, SimpleGA, MR15‑GA, etc.
JAX‑native API Uses the classic ask → evaluate → tell loop; all components are JAX‑compatible and can be transformed with jit, vmap, scan for massive parallelism.
Stateless design Algorithm state is an explicit immutable object, making it easy to checkpoint, replay, or integrate with functional pipelines.
Ready‑to‑run notebooks Colab links for every algorithm (e.g., BBOB benchmark, RL‑policy search, persistent ES) let you try the library without any setup.
Tested & CI‑protected Badges show continuous‑integration coverage, linting with Ruff, and a published PyPI package.
Reference‑backed Each implementation links to the original paper, so users can trace the exact algorithmic details.

Typical use‑cases

  • Neuro‑evolution: evolve neural‑network weights or architectures for RL agents or supervised tasks.
  • Black‑box optimisation: optimise expensive functions (e.g., simulation parameters, hyper‑parameters) where gradients are unavailable.
  • Benchmarking: run standard BBOB or RL suites to compare ES variants.
  • Research: prototype new ES ideas by inheriting from the base Algorithm class and re‑using JAX utilities.

Installation

pip install evosax

The package requires Python 3.8+ and JAX (CPU, GPU, or TPU version as appropriate).

Quick start

import jax
from evosax.algorithms import CMA_ES

# Dummy objective – replace with your own function
def fitness_fn(params):
    return -jnp.sum(jnp.square(params))

# Create a CMA‑ES optimiser
es = CMA_ES(population_size=32, solution=jax.random.normal(jax.random.key(0), (10,)))
params = es.default_params
key = jax.random.key(0)
state = es.init(key, es.solution, params)

for gen in range(100):
    key, ask_key, eval_key = jax.random.split(key, 3)
    pop, state = es.ask(ask_key, state, params)          # propose candidates
    fitness = fitness_fn(pop)                           # evaluate them
    state, metrics = es.tell(eval_key, pop, fitness, state, params)

print('Best solution:', state.best_solution)
print('Best fitness :', state.best_fitness)

The loop mirrors the textbook ES workflow, but thanks to JAX the whole generation can be evaluated in a single vectorised call.

Documentation & examples

  • The repository ships a docs/ folder with a logo and badge badges, and every algorithm entry includes a direct link to a Colab notebook (examples/).
  • The accompanying arXiv paper (2212.04180) describes the design philosophy and performance benchmarks.

Who should try it

  • Researchers and engineers who already use JAX for deep‑learning or scientific computing and need a fast, scalable black‑box optimiser.
  • Anyone interested in comparing ES against gradient‑based methods on the same hardware stack.

All information above is taken directly from the project's README; no external claims have been added.

Related

  • Project
  • Project
  • Project
  • Project
  • Project