Skip to content

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
mini-router:mainfrom
shin-core:sn74-shin-core-cmaes-seed0
Open

fix(optim): sep-CMA-ES seed=0 is non-reproducible (pycma ignores seed 0) (#54)#96
shin-core wants to merge 2 commits into
mini-router:mainfrom
shin-core:sn74-shin-core-cmaes-seed0

Conversation

@shin-core

@shin-core shin-core commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

What changed

pycma ignores seed==0 and leaves numpy's global RNG unseeded, so SepCMAES(seed=0) — the documented reproducible default, also trinity.train's default — produced a different first population on every run. SepCMAES.__init__ now remaps seed==0 to a fixed nonzero value in pycma's valid range [1, 2**32-1] before building CMAEvolutionStrategy. Every other seed is unchanged; self.seed still reports the caller's original value.

Repro (from the issue)

first_pop(0) == first_pop(0)   # was False, now True
first_pop(7) == first_pop(7)   # still True

Tests

Added tests/test_sep_cmaes_seed.py, gated on cma via pytest.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.md per repository protocol (AGENTS.md §6).

@github-actions github-actions Bot added miner Miner contribution PR train Training or routing changes docs Documentation changes labels Jul 9, 2026
@shin-core shin-core force-pushed the sn74-shin-core-cmaes-seed0 branch from 97a3ed1 to ca7dafe Compare July 11, 2026 14:47
shin-core and others added 2 commits July 13, 2026 19:13
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>
@shin-core shin-core force-pushed the sn74-shin-core-cmaes-seed0 branch from ca7dafe to 12aac30 Compare July 13, 2026 09:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Documentation changes miner Miner contribution PR train Training or routing changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

optim: sep-CMA-ES training is non-reproducible at the default seed=0 (pycma ignores seed 0)

1 participant