Skip to content

Preserve agent boundaries when flattening frame history - #434

Open
Afloat16 wants to merge 1 commit into
Denys88:masterfrom
Afloat16:fix/batched-frame-history-layout-20261127
Open

Afloat16 wants to merge 1 commit into
Denys88:masterfrom
Afloat16:fix/batched-frame-history-layout-20261127

Conversation

@Afloat16

Copy link
Copy Markdown
Contributor

Problem

The flattened paths in BatchedFrameStack and BatchedFrameStackWithStates transpose the frame buffer from (time, agent, feature) to (agent, time, feature), but then reshape the original, untransposed data. With multiple agents, each policy input consequently contains other agents' observations instead of that agent's history. This already happens on reset.

create_smac and create_smac_v2 select these wrappers when frame stacking is enabled and default to flatten=True.

Change

Reshape the transposed array in both wrappers. This keeps each agent's temporal sequence contiguous. The change is two production lines.

Validation

  • Added 12 cases exercising the complete production wrappers through reset and six steps, including history rollover.
  • Covered one/three agents, two/four frames, observation-only and state-carrying wrappers, and stacked/transposed controls. References are assembled independently per agent.
  • Pristine base: 4 failed, 8 passed. Patched source: 12 passed.
  • Python 3.12, real NumPy 2.3.5 and Gymnasium 1.4.0. A deterministic Gymnasium environment supplies observations at the environment boundary; no wrapper or numerical implementation is substituted. StarCraft, PPO training and GPU execution were not run.
  • Python compilation and git diff --check passed.

This concerns numerical layout independently of #379's Gymnasium return-contract migration; that patch leaves these two reshape expressions unchanged. Checked all 34 author PRs, all-state related PR/issue and commit searches, and every one of the 39 existing fork branches. None contains this wrapper layout correction.

@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     #434   +/-   ##
=========================================
  Coverage          ?   68.45%           
=========================================
  Files             ?       72           
  Lines             ?    10182           
  Branches          ?        0           
=========================================
  Hits              ?     6970           
  Misses            ?     3212           
  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