Skip to main content

evosax: Evolution Strategies in JAX 🦎

Pyversions PyPI version Ruff codecov Paper

Tired of having to handle asynchronous processes for neuroevolution? Do you want to leverage massive vectorization and high-throughput accelerators for Evolution Strategies? evosax provides a comprehensive, high-performance library that implements Evolution Strategies (ES) in JAX. By leveraging XLA compilation and JAX's transformation primitives, evosax enables researchers and practitioners to efficiently scale evolutionary algorithms to modern hardware accelerators without the traditional overhead of distributed implementations.

The API follows the classical ask-eval-tell cycle of ES, with full support for JAX's transformations (jit, vmap, lax.scan). The library includes 30+ evolution strategies, from classics like CMA-ES and Differential Evolution to modern approaches like OpenAI-ES and Diffusion Evolution.

Get started here 👉 Colab

Basic evosax API Usage 🍲

import jax
from evosax.algorithms import CMA_ES


# Instantiate the search strategy
es = CMA_ES(population_size=32, solution=dummy_solution)
params = es.default_params

# Initialize state
key = jax.random.key(0)
state = es.init(key, dummy_solution, params)

# Ask-Eval-Tell loop
for i in range(num_generations):
    key, key_ask, key_eval = jax.random.split(key, 3)

    # Generate a set of candidate solutions to evaluate
    population, state = es.ask(key_ask, state, params)

    # Evaluate the fitness of the population
    fitness = ...

    # Update the evolution strategy
    state, metrics = es.tell(key, population, fitness, state, params)

# Get best solution
state.best_solution, state.best_fitness

Population-based algorithms such as SimpleGA use the same ask-tell loop, but their state is initialized from an explicit initial population and its fitness:

import jax
import jax.numpy as jnp
from evosax.algorithms import SimpleGA


key = jax.random.key(0)
solution = dummy_solution
ga = SimpleGA(population_size=32, solution=solution)
params = ga.default_params

# Replicate a template solution (or provide your own evaluated population).
population_init = jax.tree.map(
    lambda x: jnp.repeat(x[None, ...], ga.population_size, axis=0),
    solution,
)
fitness_init = ...

# Initialize state from the initial population and its fitness.
state = ga.init(key, population_init, fitness_init, params)

The fitness_init argument seeds the stored population ranking used by the first ask(...) call. After initialization, ga.ask(...) returns the next population to evaluate and ga.tell(...) updates the algorithm state with the evaluated population and fitness.

Implemented Evolution Strategies 🦎

Strategy Reference Import Example
Simple Evolution Strategy Rechenberg (1978) SimpleES Colab
OpenAI-ES Salimans et al. (2017) Open_ES Colab
CMA-ES Hansen & Ostermeier (2001) CMA_ES Colab
Sep-CMA-ES Ros & Hansen (2008) Sep_CMA_ES Colab
xNES Wierstra et al. (2014) xNES Colab
SNES Wierstra et al. (2014) SNES Colab
MA-ES Bayer & Sendhoff (2017) MA_ES Colab
LM-MA-ES Loshchilov et al. (2017) LM_MA_ES Colab
Rm_ES Li & Zhang (2017) Rm_ES Colab
PGPE Sehnke et al. (2010) PGPE Colab
ARS Mania et al. (2018) ARS Colab
ESMC Merchant et al. (2021) ESMC Colab
Persistent ES Vicol et al. (2021) PersistentES Colab
Noise-Reuse ES Li et al. (2023) NoiseReuseES Colab
CR-FM-NES Nomura & Ono (2022) CR_FM_NES Colab
Guided ES Maheswaranathan et al. (2018) GuidedES Colab
ASEBO Choromanski et al. (2019) ASEBO Colab
Discovered ES Lange et al. (2023a) DiscoveredES Colab
LES Lange et al. (2023a) LearnedES Colab
EvoTF Lange et al. (2024) EvoTF_ES Colab
iAMaLGaM-Full Bosman et al. (2013) iAMaLGaM_Full Colab
iAMaLGaM-Univariate Bosman et al. (2013) iAMaLGaM_Univariate Colab
Gradientless Descent Golovin et al. (2019) GradientlessDescent Colab
Simulated Annealing Rasdi Rere et al. (2015) SimAnneal Colab
Hill Climbing Rasdi Rere et al. (2015) HillClimbing Colab
Random Search Bergstra & Bengio (2012) RandomSearch Colab
SV-CMA-ES Braun et al. (2024) SV_CMA_ES Colab
SV-OpenAI-ES Liu et al. (2017) SV_OpenES Colab
Simple Genetic Algorithm Such et al. (2017) SimpleGA Colab
MR15-GA Rechenberg (1978) MR15_GA Colab
SAMR-GA Clune et al. (2008) SAMR_GA Colab
GESMR-GA Kumar et al. (2022) GESMR_GA Colab
LGA Lange et al. (2023b) LearnedGA Colab
Diffusion Evolution Zhang et al. (2024) DiffusionEvolution Colab
Differential Evolution Storn & Price (1997) DifferentialEvolution Colab
Particle Swarm Optimization Kennedy & Eberhart (1995) PSO Colab

Installation ⏳

You will need Python 3.10 or later, and a working JAX installation.

Then, install evosax from PyPi:

pip install evosax

To upgrade to the latest version of evosax, you can use:

pip install git+https://github.com/RobertTLange/evosax.git@main

Examples 📖

Key Features 💎

  • Comprehensive Algorithm Collection: 30+ classic and modern evolution strategies with a unified API
  • JAX Acceleration: Fully compatible with JAX transformations for speed and scalability
  • Vectorization & Parallelization: Fast execution on CPUs, GPUs, and TPUs
  • Production Ready: Well-tested, documented, and used in research environments
  • Batteries Included: Comes with optimizers like ClipUp, fitness shaping, and restart controllers

Related Resources 📚

Citing evosax ✏️

If you use evosax in your research, please cite the following paper:

@article{evosax2022github,
    author  = {Robert Tjarko Lange},
    title   = {evosax: JAX-based Evolution Strategies},
    journal = {arXiv preprint arXiv:2212.04180},
    year    = {2022},
}

Acknowledgements 🙏

We acknowledge financial support by the Google TRC and the Deutsche Forschungsgemeinschaft (DFG, German Research Foundation) under Germany's Excellence Strategy - EXC 2002/1 "Science of Intelligence" - project number 390523135.

Contributing 👷

Contributions are welcome! If you find a bug or are missing your favorite feature, please open an issue or submit a pull request following our contribution guidelines 🤗.

Disclaimer ⚠️

This repository contains independent reimplementations of LES and DES based and is unrelated to Google DeepMind. The implementation has been tested to reproduce the official results on a range of tasks.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

evosax-0.3.1.tar.gz (181.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

evosax-0.3.1-py3-none-any.whl (224.2 kB view details)

Uploaded Python 3

File details

Details for the file evosax-0.3.1.tar.gz.

File metadata

  • Download URL: evosax-0.3.1.tar.gz
  • Upload date:
  • Size: 181.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for evosax-0.3.1.tar.gz
Algorithm Hash digest
SHA256 38609f64704b48921b500b2d4729779beacd82eb39749978fe8e6db790a790dc
MD5 c931ae1b408a049cac518d88d9b61b20
BLAKE2b-256 652d3408839c2151b576ffa2fd53cb1e80ab335b6845f0bc9248884dfc79524c

See more details on using hashes here.

File details

Details for the file evosax-0.3.1-py3-none-any.whl.

File metadata

  • Download URL: evosax-0.3.1-py3-none-any.whl
  • Upload date:
  • Size: 224.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for evosax-0.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 9ffb75539daab3cab783b993b731088575170ed208bf0214310062f9d982d081
MD5 4bc1fcbefbd59c5a90e12279a8859b91
BLAKE2b-256 e6f74c4938c0da6a90b0b7df42968d55c72d74256d6ee0e82c64439bce93bba7

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.3.1 This release

2 files

0.3.0

2 files

0.2.0

2 files

0.1.6

2 files

0.1.5

2 files

0.1.4

2 files

0.1.3

2 files

0.1.2

2 files

0.1.1

2 files

0.1.0

2 files

0.0.9

2 files

0.0.8

2 files

0.0.7

2 files

0.0.6

2 files

0.0.5

2 files

0.0.4

2 files

0.0.3

2 files

0.0.2

2 files

0.0.1

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page