fix(optim): sep-CMA-ES seed=0 is non-reproducible (pycma ignores seed 0) (#54)#96
Open
shin-core wants to merge 2 commits into
Open
fix(optim): sep-CMA-ES seed=0 is non-reproducible (pycma ignores seed 0) (#54)#96shin-core wants to merge 2 commits into
shin-core wants to merge 2 commits into
Conversation
97a3ed1 to
ca7dafe
Compare
pycma ignores seed==0 ('cma ignores if seed==0') and leaves numpy's global
RNG unseeded, so SepCMAES(seed=0) -- the documented reproducible default and
trinity.train's default -- produced a different first population on every
run. Remap seed==0 to a fixed nonzero value in pycma's valid range before
handing it to CMAEvolutionStrategy; every other seed is unchanged and
self.seed still reports the caller's original value.
Add cma-gated offline tests (skipped when pycma is absent).
Fixes mini-router#54
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
ca7dafe to
12aac30
Compare
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.
What changed
pycma ignores
seed==0and leaves numpy's global RNG unseeded, soSepCMAES(seed=0)— the documented reproducible default, alsotrinity.train's default — produced a different first population on every run.SepCMAES.__init__now remapsseed==0to a fixed nonzero value in pycma's valid range[1, 2**32-1]before buildingCMAEvolutionStrategy. Every other seed is unchanged;self.seedstill reports the caller's original value.Repro (from the issue)
Tests
Added
tests/test_sep_cmaes_seed.py, gated oncmaviapytest.importorskip(skipped when pycma is absent): seed-0 reproducibility, nonzero-seed reproducibility, distinct seeds differ, and caller-seed preservation. The seed-0 test fails on old source, passes with the fix.Fixes #54
🤖 Generated with Claude Code
Notes
A corresponding lab-notebook entry was added to
docs/JOURNAL.mdper repository protocol (AGENTS.md §6).