Repository navigation
fix(player): forward env_config seed to vecenv and regular envs - #426
Conversation
|
Thanks for the PR, and welcome. Two things. First, the use case: which setup are you evaluating where the player's seed not reaching the environment actually mattered for you (gymnasium vector env, custom env_creator, something else), and what did you observe? That tells me which part needs to land. Second, #408 just merged and already handles the GymnasiumVecEnv side (pending seed consumed on the next reset, per-env offsets on the manual path), so the constructor seeding in |
|
Thanks for the quick review @Denys88!
|
967b3ff to
b1ebe4a
Compare
Denys88
left a comment
There was a problem hiding this comment.
Thanks for the quick rebase and trim. The vecenv path now matches what training does (the full env_config including seed goes into create_vec_env), the regular-env path seeds once on the first reset with a plain try/except, and the player/seeding tests pass together on master (148 passed locally, CI green on 3.11-3.14).
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #426 +/- ##
=========================================
Coverage ? 63.94%
=========================================
Files ? 70
Lines ? 8923
Branches ? 0
=========================================
Hits ? 5706
Misses ? 3217
Partials ? 0 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
A clean merge: no file needed a change by hand. Master brings the FlashSAC options (#395), multi-GPU SAC with update_cuda_graph (#396) and the fix series of #391 to #426. PBT still supports the PPO agents only and refuses SAC. Both sides had changed README.md, central_value.py, a2c_common.py, torch_runner.py and tests/test_release_blockers.py, in separate places. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Summary
BasePlayer.__init__previously poppedseedfromenv_config(mutating the caller's dict in place) and never forwardedself.seedtovecenv.create_vec_env,create_env(), orenv_reset(). Complements #408 by ensuringBasePlayerforwardsenv_config['seed']during play/evaluation.Changes
env_configinBasePlayer.__init__(handlingNoneand falling back toconfig['env_config']['seed']whenplayer.env_configoverridesenv_configwithout aseedkey)._init_env()to keepBasePlayer.__init__cyclomatic complexity below the flake8 threshold and forwardseedtovecenv.create_vec_envwhenuse_vecenv=True(matchinga2c_common.py).use_vecenv=False), callself.env.seed(self.seed)if available and passseedon the firstenv_reset()viatry: obs = env.reset(seed=seed) except TypeError: obs = env.reset().CartPole-v1determinism tests intests/test_player_env_seed.py.Testing
pytest tests/test_player_env_seed.py tests/test_gymnasium_seeding.py tests/test_player_gymnasium_step.py -v(23 passed)flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics(0 errors)