-
Notifications
You must be signed in to change notification settings - Fork 21
Stagger map resampling across workers #373
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: 3.0
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -125,6 +125,7 @@ def __init__( | |
| self.episode_length = episode_length | ||
| self.termination_mode = termination_mode | ||
| self.resample_frequency = resample_frequency | ||
| self._rng = np.random.default_rng(seed) | ||
| self.dynamics_model = dynamics_model | ||
| # reward randomization bounds | ||
| self.reward_bound_goal_radius_min = reward_bound_goal_radius_min | ||
|
|
@@ -423,7 +424,13 @@ def __init__( | |
|
|
||
| def reset(self, seed=0): | ||
| binding.vec_reset(self.c_envs, seed) | ||
| self.tick = 0 | ||
| # Stagger initial tick so workers don't all resample maps at the same step. | ||
| # The first episode will be shorter than resample_frequency, but this | ||
| # desynchronizes resets across workers for the rest of training. | ||
| if self.resample_frequency > 0: | ||
| self.tick = int(self._rng.integers(self.resample_frequency)) | ||
|
Comment on lines
+427
to
+431
|
||
| else: | ||
| self.tick = 0 | ||
|
Comment on lines
+430
to
+433
|
||
| self.truncations[:] = 0 | ||
| return self.observations, [] | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
self._rngis seeded from the constructor argumentseed, butreset(seed=...)also accepts a seed and is used by PufferLib to control per-run determinism. Becauseself.tickstaggering draws fromself._rng, changing thereset()seed will not affect the stagger offset, which can be surprising for reproducibility. Consider deriving the stagger RNG from thereset()seed (or re-seeding_rngon reset) soreset(seed=...)fully controls stochastic reset behavior.