Evosax

Latest version: v0.2.0

Safety actively analyzes 722631 Python packages for vulnerabilities to keep your Python projects secure.

Scan your dependencies

Page 1 of 3

0.2.0

This major update includes significant architectural changes, dependency updates, bug fixes, and naming standardization across the library.

Breaking Changes

- Increased minimum Python requirement to >=3.10
- Updated to JAX >=0.5.0
- Switched from `setup.py` to `pyproject.toml` for package configuration
- Restructured algorithms into two main types: `PopulationBased` and `DistributionBased`
- Removed `ESLogger` in favor of user-provided `metrics_fn`
- Removed `ParameterReshape` class (now handled automatically by algorithm classes)
- Removed `n_devices` parameter and all `pmap` calls to align with JAX's new sharding mechanisms
- Renamed `Strategy.initialize` to `Strategy.init`
- Renamed `Fitness` to `Problem` with `.eval` method replacing `.rollout`

Optimization and Dependencies

- Replaced custom optimizer with `optax`
- Implemented ClipUp in Optax GradientTransformation
- Added ruff for code linting
- Removed chex dependency
- Added custom types.py file with Solution, Fitness, and Metrics types
- Removed RBF (now using JAX's `jax.scipy.stats.norm.pdf`)

Library Structure Improvements

- Made all MA-ES strategies inherit from CMA-ES
- Includes: cma_es, sep_cma_es, sv_cma_es, rm_es, ma_es, lm_ma_es
- For Stein Variational methods, implemented Strategies that inherit from CMA-ES/OpenES
- Refactored fitness shaping to use a direct function (`fitness_shaping_fn`) rather than an object
- Implemented SNES/xNES inheritance for weights
- Made all Genetic Algorithms return initial population for evaluation on first generation
- Moved Restart mechanism to core

Algorithm Fixes

- Fixed numerous bugs in evolution strategies:
- Fixed xNES implementation
- Fixed SimAnneal implementation
- Fixed PBT implementation
- Fixed GuidedES implementation
- Fixed MR15-GA implementation
- Fixed nan values in PGPE
- Fixed nan values in RM-ES
- Fixed incorrect z calculation in MA-ES
- Fixed sep_cma_es where D was never updated
- Fixed GESMR-GA algorithm

Naming Standardization

- Renamed `EvoState` to `State` and `EvoParams` to `Params`
- Renamed `es_params`/`es_state` to `params`/`state`
- Renamed `params`/`x` to `solution` or `solutions`
- Renamed `rng` to `key`
- Renamed `gen_counter` to `generation_counter` or `counter`
- Renamed `gen` to `generation`
- Renamed `popsize` to `population_size`
- Standardized naming between `mean`/`sigma` across algorithms
- Renamed `get_eval_params` to `get_eval_solution`
- Changed `lrate` to `lr`
- Renamed `persistent_es.py` to `pes.py`
- Renamed all `*_strategy` to `_*`
- Standardized all references to `total_params` and `num_dims`

Evolution Strategy Improvements

- Replaced `jnp.finfo(jnp.float32).max` with `jnp.inf` throughout codebase
- Avoided logic with `None` args in `Strategy.__init__` and `Strategy.ask`
- Refactored std decay to use optax schedules
- Removed mean decay from within strategies
- Added correct implementation of c_m in MA-ES algorithms
- Fixed incorrect p notation (now properly uses p_σ and p_c)
- Updated all static_argnums to static_argnames
- Fixed GuideES to pass gradient within EvoState rather than implementing tell

Problem Modules

- Renamed "classic" to "bbo"
- Renamed "control_gym" to "gymnax"
- Added Brax support
- Improved gymnax integration
- Created base class for problems
- All problems now provide a `sample_solution` method
- Added noise models for BBO problems
- Added `problem.eval`, `problem.sample_solution`, `dummy_solution` methods

Documentation

- Updated all notebooks
- Fixed license mismatch on PyPI
- Fixed all TODOs within codebase
- Updated examples and experimental code
- Added tests for experimental features

0.1.7

Added

- Adds an option for device-parallel evaluation of `BBOBFitness`.
- Implements fully `pmap`-compatible implementations of `OpenES`, `PGPE`, `Sep_CMA_ES` and `SNES`. Example: [`09_pmap_strategy.ipynb`](https://github.com/RobertTLange/evosax/blob/main/examples/09_pmap_strategy.ipynb):
python
set number of cpu devices for jax pmap
import os

num_devices = 4
os.environ["XLA_FLAGS"] = f"--xla_force_host_platform_device_count={num_devices}"

import jax
import jax.numpy as jnp
from flax import jax_utils

print(jax.devices())

from evosax.problems import BBOBFitness
from evosax.v2 import SNES

fn_name = "Sphere"
num_dims = 2
popsize = 64
rng = jax.random.PRNGKey(0)
problem = BBOBFitness(fn_name, num_dims=num_dims, n_devices=num_devices)

strategy = SNES(
popsize=popsize,
num_dims=num_dims,
sigma_init=0.1,
n_devices=num_devices,
maximize=False,
)

params = strategy.default_params.replace(init_min=-3.0, init_max=3.0)
params = jax_utils.replicate(params)

init_rng = jnp.tile(rng[None], (num_devices, 1))
state = jax.pmap(strategy.initialize)(init_rng, params)
print("Mean pre-update:", state.mean) (num_devices, num_dims)

rng, rng_a, rng_e = jax.random.split(rng, 3)
ask_rng = jax.random.split(rng_a, num_devices)
x, state = jax.pmap(strategy.ask, axis_name="device")(ask_rng, state, params)

print("Population shape:", x.shape) (num_devices, popsize/num_devices, num_dims)

fitness = problem.rollout(rng_e, x)
print("Fitness shape:", fitness.shape) (num_devices, popsize/num_devices)

state = jax.pmap(strategy.tell, axis_name="device")(x, fitness, state, params)
print("Mean post-update:", state.mean) (num_devices, num_dims)


- Added `DiffusionEvolution` based on [Zhang et al. (2024)](https://arxiv.org/pdf/2410.02543). Example: [`10_diffusion_evolution.ipynb`](https://github.com/RobertTLange/evosax/blob/main/examples/10_diffusion_evolution.ipynb)

- Added `SV_CMA_ES` ([Braun et al., 2024](https://arxiv.org/abs/2410.10390)) and `SV_OpenES` ([Liu et al., 2017](https://arxiv.org/abs/1704.02399)) as subpopulation ES with stein variational updates.

Big thanks to Cornelius Braun (cornelius-braun
) for adding the stein variational methods!

0.1.6

Added

- Implemented Hill Climbing strategy as a simple baseline.
- Adds `use_antithetic_sampling` option to OpenAI-ES.
- Added `EvoTransformer` and `EvoTF_ES` strategy with example trained checkpoint.

Fixed

- Gradientless Descent best member replacement.

Changed

- SNES import DES weights directly and reuses code
- Made `Sep_CMA_ES` and `OpenAI-ES` use vector sigmas for EvoTransformer data collection.

0.1.5

Added

- Adds string `fitness_trafo` option to `FitnessShaper` (e.g. `z_score`, etc.).
- Adds `sigma_meta` as kwarg to `SAMR_GA` and `GESMR_GA`.
- Adds `sigma_init` as kwarg to `LGA` and `LES`.
- Adds Noise-Reuse ES - `NoiseReuseES` - ([Li et al., 2023](https://arxiv.org/pdf/2304.12180.pdf)) as a generalization of PES.
- Fix LES evolution path calculation and re-ran meta-training for checkpoint.

Fixed

- Fixed error in LGA resulting from `elite_ratio=0.0` in sampling operator logit squeeze.
- Fixed range normalization in fitness transformation - `range_norm_trafo` - Thank you yudonglee

Changed

- Refactored core modules and utilities. Learned evolution utilities now in subdirectory.

0.1.4

Added

- Adds LGA checkpoint and optimizer class from [Lange et al. (2023b)](https://arxiv.org/abs/2304.03995).
- Adds optional `init_mean` to `strategy.initialize` to warm start strategy from e.g. pre-trained checkpoint.
- Adds `n_devices` option to every strategy to control reshaping for pmap in `ParameterReshaper` (if desired) explicitly.
- Adds `mean_decay` optional kwarg to LES for regularization.

Fixed

- Fix missing matplotlib requirement for BBOB Visualizer.
- Fix squeezing of sampled solutions in order to enable 1D optimization.
- Fix `ESLog` to work with `ParameterReshaper` reshaping of candidate solutions.
- Fix overflow errors in CMA-ES style ES when `num_dims ** 2` is too large.

Changed

- Changed default gradient descent optimizer of ARS to Adam.

0.1.3

- Finally solved checkpoint loading LES problem (needed `MANIFEST.in`)
- Fixed PGPE bug with regards to scaled noise.

Page 1 of 3

© 2025 Safety CLI Cybersecurity Inc. All Rights Reserved.