Repository navigation
Fix CMA-ES crashing in torch.cond and re-enable its test - #255
Merged
BillHuang2001 merged 1 commit intoOct 28, 2026
Merged
Conversation
CMAES.step raised UncapturedHigherOrderOpError on its first call: torch.cond treats `C.T` of its operand as aliasing. Once that is avoided, the second call failed too, because B, D and C_invsqrt were views of the stacked cond output and torch.cond rejects captured buffers that alias each other. Transpose the operand explicitly and clone the unpacked outputs. test_cmaes was disabled with an early return; run it again.
2 of 5 tasks
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.
Description
CMAES.stepcurrently fails on its first call (torch 2.9.1 and 2.11 here, and on CI, which installs the latest CPU torch). This is presumably whytest_cmaeswas turned off with an earlyreturn.There are two separate causes, and the second appears once the first is fixed:
_decomposition,torch.condreportsC.T(andC.mT) of its operand as aliasing. BothC.t()andC.transpose(0, 1)trace fine, so the operand is now transposed explicitly.B, D, C_invsqrtare unpacked from the stackedtorch.condoutput, which makes them views of a single tensor. On the next step,_no_decompositioncaptures all three as buffers, andtorch.condrejects them as "input-to-input aliasing". The unpacked outputs are now cloned. Each is onlydim x dim.The numerics are unchanged.
test_cmaesis enabled again and runs CMA-ES throughrun_all, which covers the eager,torch.compileandvmappaths. Before this change, the eager step fails as shown above. With it, all 22 tests inunit_test/algorithms/test_es_variants.pypass. (I ran them locally withtorch.compile(backend="aot_eager"), since this Windows machine has no MSVC for inductor.)Checklist
ruff.