Skip to content

restore obs_slots_boundary_kept for obs dim#453

Open
Yvonne511 wants to merge 7 commits into
emerge/temp_trainingfrom
emerge/temp_training_oom
Open

restore obs_slots_boundary_kept for obs dim#453
Yvonne511 wants to merge 7 commits into
emerge/temp_trainingfrom
emerge/temp_training_oom

Conversation

@Yvonne511
Copy link
Copy Markdown
Collaborator

@Yvonne511 Yvonne511 commented May 29, 2026

Changes from 7eaee60 to a412614
Screenshot 2026-05-28 at 9 27 44 PM
Screenshot 2026-05-28 at 9 29 38 PM
Previously buffer always is sized by max_lane_segment_observations (the max, regardless of dropout), and unused slots were zero-padded. Later renamed max_lane_segment_observations → obs_slots_lane_n and obs_lane_segment_count → obs_slots_lane_kept. This introduce a bug when training with dropout and eval without it.
Close envs

Copilot AI review requested due to automatic review settings May 29, 2026 02:47
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR restores fixed-size road observation slots so model slicing and C observation packing stay aligned across dropout-enabled training and clean evaluation. It also adds render-client teardown during vector env close paths.

Changes:

  • Uses obs_slots_lane_n / obs_slots_boundary_n for observation sizing and Torch road slices.
  • Updates C road observation layout and padding to reserve max lane/boundary slots.
  • Adds client cleanup before vector env teardown and inside c_close.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
pufferlib/ocean/torch.py Aligns model road observation slicing with fixed max slot counts.
pufferlib/ocean/drive/drive.py Updates Python observation dimension calculation and adds explicit render-client close loops.
pufferlib/ocean/drive/drive.h Updates C observation size/layout/padding and closes render clients during env teardown.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread pufferlib/ocean/drive/drive.py Outdated
Comment on lines +489 to +490
for i in range(self.num_envs):
binding.vec_close_client(self.c_envs, i)
Comment thread pufferlib/ocean/drive/drive.py Outdated
Comment on lines +820 to +821
for i in range(self.num_envs):
binding.vec_close_client(self.c_envs, i)
Comment thread pufferlib/ocean/drive/drive.h Outdated
Comment on lines +3577 to +3580
if (env->client) {
close_client(env->client);
env->client = NULL;
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not relevant, strip from PR

Comment thread pufferlib/ocean/drive/drive.py Outdated
Comment on lines +494 to +495
for i in range(self.num_envs):
binding.vec_close_client(self.c_envs, i)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this might be the right thing to do, but include in separate PR

eugenevinitsky added a commit that referenced this pull request Jun 2, 2026
obs_dropout structurally shrinks the road-obs width via
compute_effective_road_obs_count (kept = n * (1 - dropout)), so a policy
trained with dropout (e.g. lane 40 / boundary 48) cannot slice the clean-eval
obs (dropout forced to 0 by CLEAN_EVAL_OVERRIDES -> lane 80 / boundary 80).
The misaligned slide_idx walk read garbage into traffic_control_type/state,
and F.one_hot's scatter asserted "index out of bounds" (device-side assert),
killing eval at epoch 250.

Branch the encoder slicing on self.training: use *_kept while training, full
*_n during eval (policy.eval() at benchmark base.py). The per-slot encoders +
max-pool are slot-count-agnostic, so the same weights consume both widths.

Net diff of PR #453 (restore obs_slots_boundary_kept for obs dim), torch.py
only; applied directly to skip the branch's unrelated merge/render commits.
Source commits: e7c5031, c613020, e4e8d02, a62f186.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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.

3 participants