evox.algorithms.so.es_variants.virtual_lora_es#

Module Contents#

Classes#

VirtualLoRAES

Virtual LoRA-based Evolution Strategy for neuroevolution.

API#

class evox.algorithms.so.es_variants.virtual_lora_es.VirtualLoRAES(param_shapes: list[tuple], lora_rank: int, pop_size: int, center_init: torch.Tensor, learning_rate: float, noise_stdev: float, optimizer: Literal[adam] | None = None, device: torch.device | None = None)[source]#

Bases: evox.core.Algorithm

Virtual LoRA-based Evolution Strategy for neuroevolution.

Instead of materializing a full (pop_size, dim) population, this algorithm stores a center vector (dim,) and per-individual seeds (pop_size,). Using the Philox counter-based PRNG and LoRA low-rank noise, per-individual weight perturbations are generated on-demand, achieving O(dim) memory instead of O(pop_size * dim).

For a 2D weight (d, k), rather than generating a full (d, k) noise matrix per individual, two low-rank factors A (rank, k) and B (d, rank) are sampled and combined as delta_W = B @ A, reducing the search-space dimensionality from d * k to rank * (d + k).

The algorithm passes a (center_flat, seeds, sigma) tuple to self.evaluate(), which the workflow routes to a VirtualLoRAProblem for on-demand evaluation.

Initialization

Initialize the VirtualLoRAES algorithm with the given parameters.

Parameters:
  • param_shapes – List of parameter shapes, e.g. [(256, 784), (256,), (10, 256), (10,)].

  • lora_rank – LoRA rank for 2D weights (e.g. 4, 8, 16).

  • pop_size – The size of the population.

  • center_init – The initial center of the population. Must be a 1D tensor of length equal to the total number of parameters (sum of element counts over param_shapes).

  • learning_rate – The learning rate for the optimizer.

  • noise_stdev – The standard deviation of the noise (sigma).

  • optimizer – The optimizer to use. Defaults to None. Currently, only “adam” or None is supported.

  • device – The device to use for the tensors. Defaults to None.

step()[source]#

Step the VirtualLoRAES algorithm by regenerating seeds, generating LoRA factors, evaluating fitness through the virtual-population tuple, and updating the center.

record_step()[source]#