Fix 7 bugs found in deep code review: models, env wrappers, train loop - #9
Draft
MatPoliquin with Copilot wants to merge 2 commits into
Draft
Fix 7 bugs found in deep code review: models, env wrappers, train loop#9MatPoliquin with Copilot wants to merge 2 commits into
MatPoliquin with Copilot wants to merge 2 commits into
Conversation
…wrappers, and train loop Agent-Logs-Url: https://github.com/MatPoliquin/stable-retro-scripts/sessions/7bd4f31d-eafc-474c-91ac-15831ed29952 Co-authored-by: MatPoliquin <7024551+MatPoliquin@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Conduct full code review and suggest improvements
Fix 7 bugs found in deep code review: models, env wrappers, train loop
Mar 31, 2026
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.
Deep review of the RL pipeline and model architectures surfaced several correctness bugs and a few code quality issues.
Critical bugs
DartPolicy.value_netfinalnn.ReLU()— clamped all critic outputs to ≥ 0, preventing the value function from representing negative returns. Removed.AttentionMLPattention was a no-op —bmm(q[B,1,d], k[B,d,1])produces a(B,1,1)scalar;softmaxof a single value is always1.0, so every attention weight was constant andattended_x == x. The Q/K layers had zero effect. Replaced with element-wise per-feature attention:CustomMLPExtractor.forward()ranshared_nettwice — delegated toforward_actorthenforward_critic, each independently runningshared_net. Fixed by computingsharedonce inforward()and passing it directly to both heads.WarpFrameDictnon-grayscale path returned HWC — thenp.transpose((2,0,1))converting back to CHW after resize was commented out, whileobservation_spacedeclared CHW. Uncommented.Minor bugs
HybridMambaMLPExtractordeadgru_layersparam — copied fromGRUMlpExtractor, never used inside the Mamba_build_temporal_model. Removed.Code quality
isMLP()— replaced longor-chain with afrozensetfor O(1) lookup and easier maintenance.train.py— removed deprecatedmode='human'kwarg fromenv.render()(dropped in Gymnasium ≥ 0.26).