Add coarse observations map#482
Open
vcharraut wants to merge 5 commits into
Open
Conversation
There was a problem hiding this comment.
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_stridethrough 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 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); |
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.
Summary
obs_lane_strideandobs_boundary_strideso lane and boundary road observations can be coarsened independently.No stride
Stride=4 for lane