Reset opponent environments when swapping historical policies - #686
Open
bagel786 wants to merge 1 commit into
Open
Reset opponent environments when swapping historical policies#686bagel786 wants to merge 1 commit into
bagel786 wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
🔵 Needs a closer look
Environment matching must account for physical policy slots in multi-policy environments.
Pull request overview
Resets CPU environments and recurrent state when historical opponent policies are swapped.
Changes:
- Resets environment boundaries, rewards, terminals, and recurrent state.
- Uploads refreshed buffers before the next rollout.
- Applies resets after historical checkpoint swaps.
File summaries
| File | Summary |
|---|---|
src/pufferl.cu |
Implements policy-specific environment resets; matching can fail for multi-policy environments because env->tag reflects only the maximum policy ID. |
Review details
Suppressed comments (1)
src/pufferl.cu:1241
env->tagis assigned as the maximum effective policy ID for an environment inenv_setup, not as an identity for every policy used by its agents. Thus an environment containing policies[0, 1, 2]has tag2and is skipped when policy1is swapped, leaving that agent's recurrent state and environment trajectory on the old opponent. Determine whether any agent's physical slot maps topolicy_idxviapolicy_layout, and reset the whole environment when it does.
if (env->tag != policy_idx) {
continue;
- Files reviewed: 1/1 changed files
- Comments generated: 0
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
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.
Summary
When a historical opponent checkpoint is swapped in, reset every CPU environment assigned to that policy before the next rollout. Clear environment boundaries, recurrent state, reward state, and terminal state, then upload the refreshed buffers so episodes cannot span two different opponent policies.
Fixes #620.
Testing
git diff --checkpassed.