fix(optim): ship the CMA-ES distribution mean, not the noisy xbest (#69)#112
Open
minion1227 wants to merge 1 commit into
Open
fix(optim): ship the CMA-ES distribution mean, not the noisy xbest (#69)#112minion1227 wants to merge 1 commit into
minion1227 wants to merge 1 commit into
Conversation
…ini-router#69) SepCMAES.best() returned pycma's xbest — the single best-*evaluated* candidate. TRINITY's fitness J(theta)=E[R(tau)] is a stochastic minibatch reward with a sampled policy, so xbest is selection-on-noise: the luckiest evaluation of the run, not the policy with the best expected reward. train.py saves best()[0] as best_theta.npy, so the shipped router was chosen by minibatch luck and overfits sampling noise. Return the distribution mean (result.xfavorite) instead — pycma's recommended optimum estimate for noisy objectives and the maximum-likelihood point of the search distribution. The reported fitness stays the best *observed* training fitness (self._best_f), so run()'s history and the S7 smoke contract remain monotone; only the shipped vector changes. The no-eval-before-tell RuntimeError contract is preserved. Adds tests/test_sep_cmaes.py: best() returns xfavorite (not xbest), raises before the first tell, reports the running-max fitness, and run()'s logged best_fitness stays non-decreasing. Fixes mini-router#69
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.
Fixes #69
Re-submitted from my personal
sn74-minion1227-69branch per CONTRIBUTOIN.md (previous PR #85 used a non-conforming branch name).Problem
SepCMAES.best()returned pycma’sresult.xbest— the single candidate with the best evaluated fitness across the run. TRINITY’s training fitnessJ(θ) = E[R(τ)]is a stochastic signal: each candidate is scored on a freshly sampled minibatch with a sampled policy (sample=True). Under a noisy objective,xbestis selection-on-noise — the luckiest evaluation, not the policy with the best expected reward. Sincetrain.pysavesbest()[0]asbest_theta.npy, the shipped router was chosen by minibatch luck and overfits sampling noise (the same noise the README notes swung random routing 0.792 → 0.733 between runs).Fix
Return the distribution mean (
result.xfavorite) as the solution vector. pycma documentsxfavoriteas the recommended estimate of the optimum for noisy problems, and it is the maximum-likelihood point of the search distribution. This is the issue author’s first proposed option ("ship the mean"), kept minimal and self-contained.Because
train.pyalready saves whateverbest()returns, no change totrain.pyis needed —best_theta.npynow holds the mean automatically.Kept stable on purpose
self._best_f), sorun()’shistory["best_fitness"]and the S7 smoke contract remain monotone; only the shipped vector changes.RuntimeErrorbefore the firsttell()is preserved.xfavorite.Tests
Adds
tests/test_sep_cmaes.py(CPU-only, torch-free,importorskip("cma")):best()returnsxfavorite, notxbestbest()raises before the firsttell()run()’s loggedbest_fitnessstays non-decreasing (S7 regression guard)Full root suite: 165 passed.
ruff checkclean on the changed files.