Skip to content

Use the environment RNG for seeded no-op resets - #436

Open
Afloat16 wants to merge 1 commit into
Denys88:masterfrom
Afloat16:fix/noop-reset-environment-rng-20261127
Open

Afloat16 wants to merge 1 commit into
Denys88:masterfrom
Afloat16:fix/noop-reset-environment-rng-20261127

Conversation

@Afloat16

Copy link
Copy Markdown
Contributor

Problem

NoopResetEnv.reset(seed=...) seeds the underlying Gymnasium environment but selects its no-op count from NumPy's process-global random generator. Consequently, identical environment seeds can produce different starting observations when unrelated code consumes global randomness. The wrapper also advances a random stream that does not belong to the environment.

Change

Draw the count from self.unwrapped.np_random, using the same inclusive range of one through noop_max. Explicit override_num_noops values continue to bypass random sampling.

Validation

  • Added 12 cases using the complete production wrapper, real NumPy 2.3.5 and Gymnasium 1.4.0.
  • Covered three environment seeds under two different global seeds, consecutive unseeded resets, preservation of the global NumPy stream, explicit overrides, and the single-no-op case.
  • Pristine base: 9 failed, 3 passed. Patched source: 12 passed.
  • A small Gymnasium counter environment supplies observations and actions at the environment boundary. No RNG or wrapper implementation is replaced. Atari, full training and GPU execution were not run.
  • Python compilation and git diff --check passed.

Checked the earlier author PR history, related all-state PR/issue/commit searches, and all 41 fork branches present before creating this branch. The seed propagation changes in #138, #332, #408 and #426 do not change this sampling site; #379's Gymnasium migration also leaves the global RNG draw unchanged.

@codecov-commenter

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

✅ All modified and coverable lines are covered by tests.
⚠️ Please upload report for BASE (master@bd6b04b). Learn more about missing BASE report.
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff            @@
##             master     #436   +/-   ##
=========================================
  Coverage          ?   67.88%           
=========================================
  Files             ?       72           
  Lines             ?    10181           
  Branches          ?        0           
=========================================
  Hits              ?     6911           
  Misses            ?     3270           
  Partials          ?        0           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants