Skip to content

Add coarse observations map#482

Open
vcharraut wants to merge 5 commits into
emerge/temp_trainingfrom
vcha/obs-coarse
Open

Add coarse observations map#482
vcharraut wants to merge 5 commits into
emerge/temp_trainingfrom
vcha/obs-coarse

Conversation

@vcharraut

@vcharraut vcharraut commented Jun 11, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Add obs_lane_stride and obs_boundary_stride so lane and boundary road observations can be coarsened independently.
  • Apply stride filtering in the C grid map while keeping curved/intersection geometry when heading deviation crosses the threshold.
  • Thread the new knobs through config parsing, Python env args, C binding, map-cache keys, visualization metadata, notebooks, and architecture config handling.
  • Add coverage for env config propagation, invalid stride validation, map-cache separation by stride, eval args, and replay HTML metadata.

No stride

image

Stride=4 for lane

image

Copilot AI review requested due to automatic review settings June 11, 2026 14:40

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Adds configurable lane/boundary observation striding to the Drive environment, ensuring strided map geometry is cached correctly and surfaced through configs, tooling, and tests.

Changes:

  • Introduces obs_lane_stride / obs_boundary_stride through Python → binding → C env/config plumbing (incl. ini defaults).
  • Updates map caching and road-entity selection to respect stride (and avoid cache collisions across stride settings).
  • Extends visualization/replay metadata + notebooks + tests to validate the new behavior and config propagation.

Reviewed changes

Copilot reviewed 18 out of 18 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
tests/unit_tests/test_map_cache.py Adds a unit test asserting map-cache key includes road obs stride.
tests/unit_tests/test_eval_manager.py Ensures eval config/macro composition preserves or resets stride keys as intended.
tests/unit_tests/test_drive_config.py Adds CLI/config validation + checkpoint-arch merge coverage for stride keys.
tests/smoke_tests/test_validation_replay_html.py Includes stride params in smoke-test env config for HTML replay.
pufferlib/viz.py Displays stride in plots and embeds stride/dropout/slot metadata into interactive replay HTML.
pufferlib/pufferl.py Treats stride keys as observation-layout (arch) keys for training/eval compatibility.
pufferlib/ocean/env_config.h Parses stride keys from ini into C config struct.
pufferlib/ocean/drive/visualize.c Propagates stride into eval GIF env construction.
pufferlib/ocean/drive/drive.py Adds stride args, validates them, and passes them into C env init kwargs.
pufferlib/ocean/drive/drive.h Implements striding/curve densification via valid_for_obs, and keys map cache by stride.
pufferlib/ocean/drive/drive.c Propagates stride into demo/perf env construction.
pufferlib/ocean/drive/binding.c Unpacks stride kwargs from Python into the C env.
pufferlib/config/ocean/drive.ini Adds default stride settings + comment documentation.
notebooks/notebook_utils.py Records stride defaults in notebook config helper.
notebooks/05_inference.py Passes full road obs configuration (slots/dropout/stride) into obs unpacking.
notebooks/03_metrics.py Prints stride alongside road obs stats.
notebooks/02_rewards.py Prints stride alongside road obs stats.
notebooks/01_observations.py Prints stride + updates obs unpack calls to use slots/dropout/stride context.

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

Comment on lines 995 to 1000
for (int j = 0; j < count && entity_list_count < max_size; j++) {
entity_list[entity_list_count].entity_idx = env->grid_map->cells[neighbor_idx][j].entity_idx;
entity_list[entity_list_count].geometry_idx = env->grid_map->cells[neighbor_idx][j].geometry_idx;
entity_list[entity_list_count].valid_for_obs = env->grid_map->cells[neighbor_idx][j].valid_for_obs;
entity_list_count += 1;
}
Comment on lines +80 to +94
def test_map_cache_key_includes_road_obs_stride():
env_a = None
env_b = None
try:
env_a = _make_drive(use_map_cache=1, obs_lane_stride=1, obs_boundary_stride=1)
env_a.reset(seed=0)
live_after_a = drive_binding.map_cache_live_count()

env_b = _make_drive(use_map_cache=1, obs_lane_stride=2, obs_boundary_stride=3)
env_b.reset(seed=0)
live_after_b = drive_binding.map_cache_live_count()

assert live_after_b == live_after_a + 1, (
"Map cache reused a grid built with different obs_lane_stride/obs_boundary_stride."
)
Comment thread pufferlib/viz.py
Comment on lines +962 to +967
"obs_slots_lane_n": int(env_cfg["obs_slots_lane_n"]),
"obs_slots_boundary_n": int(env_cfg["obs_slots_boundary_n"]),
"obs_dropout_lane": float(env_cfg.get("obs_dropout_lane", 0.0)),
"obs_dropout_boundary": float(env_cfg.get("obs_dropout_boundary", 0.0)),
"obs_lane_stride": int(env_cfg.get("obs_lane_stride", 1)),
"obs_boundary_stride": int(env_cfg.get("obs_boundary_stride", 1)),
Comment on lines +200 to +203
} else if (MATCH("env", "obs_lane_stride")) {
env_config->obs_lane_stride = atoi(value);
} else if (MATCH("env", "obs_boundary_stride")) {
env_config->obs_boundary_stride = atoi(value);
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