Repository navigation
Fix crashes in tournament selection (n_round=1), XNES/SeparableNES default pop_size and Guided ES subspaces - #259
Merged
BillHuang2001 merged 3 commits intoOct 28, 2026
Conversation
squeeze() also dropped the round dimension, so n_round=1 returned a 0-d tensor. EvoMO's MOEADAWA hits this on 2-objective ZDT1 once a single candidate is selected and crashes. Squeeze only the gathered column.
The default pop_size read self.dim before it was assigned, so constructing either without pop_size raised AttributeError. Use the local dim.
grad_subspace stores the gradients as rows, but the QR factorized it as is, giving a subspace_dims x subspace_dims basis of its column space. With subspace_dims < dim the shapes do not match and step() raises; with the default subspace_dims = dim the basis spans the whole space, so the search was not guided. Factorize grad_subspace.T for a dim x subspace_dims basis.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Three small fixes, one commit each. All three fail on
mainwith a short script (outputs below are frommain).1.
tournament_selection/tournament_selection_multifitreturn a 0-d tensor forn_round=1. The trailing.squeeze()also drops the round dimension. EvoMO's MOEADAWA hits this on 2-objective ZDT1 (around generation 53, once a single candidate is selected) and crashes. Now.squeeze(1); forn_round > 1nothing changes.2.
XNESandSeparableNEScannot be built with the defaultpop_size=None. The default readsself.dim, which is only assigned later in__init__:Now it uses the local
dim.3. Guided ES factorizes the gradient subspace the wrong way round.
grad_subspacestores the lastsubspace_dimsgradients as rows ([subspace_dims, dim]), buttorch.linalg.qr(self.grad_subspace)gives asubspace_dims x subspace_dimsbasis of its column space. So:subspace_dims < dim,step()raises:The size of tensor a (10) must match the size of tensor b (2);subspace_dims = dim, the basis spans the whole space, so the guided term is just more isotropic noise.Now it factorizes
grad_subspace.T, adim x subspace_dimsbasisU, so the perturbation covariance isalpha/n I + (1 - alpha)/k U U^Tas in Maheswaranathan et al. (2019). Check: withalpha = 0,subspace_dims = 2,dim = 10, the part of the sampled perturbations outside the span of the stored gradients is 0.000 of their norm.Tests:
unit_test/operators/test_tournament_selection.py;test_nes_default_pop_size;test_guided_es_subspace(subspace_dims=2, throughrun_all).The first two fail on
mainand pass here. I am on Windows without MSVC, sotorch.compiledoes not work locally. I ran the eager and uncompiled vmap paths ofrun_allfor Guided ES (default,subspace_dims=2, Adam) and for XNES/SeparableNES with the defaultpop_size, and they pass. The compiled paths are left to CI.This was prepared with AI assistance (Claude); I reviewed and tested the change.