Repository navigation
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.
Resets every CPU environment containing a swapped opponent policy, locating that policy by physical agent slots and
policy_layout. Environment tags contain only the maximum policy ID and cannot identify all participating policies. Clears recurrent/reward/terminal state for all agents in each affected environment and uploads refreshed buffers.Fixes #620. Continues #672.
Validation: a host fixture compiles and executes the production reset function across three policies and two buffers; it fails on the original code and passes with this fix. Full Python suite attempted: 13 collection errors from unavailable torch/pufferlib/CUDA dependencies. CUDA compilation and GPU runtime validation remain outstanding; no claim of CUDA validation is made.