-
Notifications
You must be signed in to change notification settings - Fork 0
local_ego_id changes for bsz > 1 #18
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: main
Are you sure you want to change the base?
Conversation
Greptile OverviewGreptile SummaryThis PR fixes a bug in ego agent indexing when using batch_size > 1 in population play mode. The old code incorrectly used global Key Changes:
Critical Assumption: The Confidence Score: 3/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant VecEnv as Vector Environment
participant PuffeRL as PuffeRL.evaluate()
participant Drive as Drive Environment
Drive->>Drive: Initialize ego_ids (global, flattened)
Drive->>VecEnv: Return observations with info[-1] = ego_ids
VecEnv->>PuffeRL: recv() returns (o, r, d, t, info, env_id, mask)
alt batch_size > 1
PuffeRL->>PuffeRL: Get ego_ids from info[-1]
PuffeRL->>PuffeRL: Calculate num_agents_per_env = total_agents // batch_size
PuffeRL->>PuffeRL: Count num_ego_per_env (ego IDs in first environment)
PuffeRL->>PuffeRL: Convert to local_ego_ids using modulo
PuffeRL->>PuffeRL: Reshape to (batch_size, num_agents_per_env, ...)
PuffeRL->>PuffeRL: Index with local_ego_ids across all batches
PuffeRL->>PuffeRL: Reshape back to (batch_size * num_ego_per_env, ...)
else batch_size == 1
PuffeRL->>PuffeRL: Use ego_ids directly to filter observations
end
PuffeRL->>PuffeRL: Continue with ego-only 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.
2 files reviewed, 1 comment
| num_ego_per_env = sum(1 for eid in ego_ids if eid < num_agents_per_env) | ||
| local_ego_ids = [eid % num_agents_per_env for eid in ego_ids[:num_ego_per_env]] |
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.
assumes all environments have the same number of ego agents at identical local indices. If env 0 has ego at local index [0, 1] and env 1 has ego at local index [2, 3], this will fail and only select indices [0, 1] from both environments. verify this assumption holds in your use case, or consider using the pre-computed local_ego_ids from drive.py instead
Prompt To Fix With AI
This is a comment left during a code review.
Path: pufferlib/pufferl.py
Line: 308:309
Comment:
assumes all environments have the same number of ego agents at identical local indices. If env 0 has ego at local index [0, 1] and env 1 has ego at local index [2, 3], this will fail and only select indices [0, 1] from both environments. verify this assumption holds in your use case, or consider using the pre-computed `local_ego_ids` from `drive.py` instead
How can I resolve this? If you propose a fix, please make it concise.
No description provided.