Skip to content

[Fix] road_traffic map_type="2" crashes on GPU reset#175

Open
vtalpaert wants to merge 2 commits intoproroklab:mainfrom
vtalpaert:fix/road-traffic-map-type-2-device-bugs
Open

[Fix] road_traffic map_type="2" crashes on GPU reset#175
vtalpaert wants to merge 2 commits intoproroklab:mainfrom
vtalpaert:fix/road-traffic-map-type-2-device-bugs

Conversation

@vtalpaert
Copy link
Copy Markdown

Fixes three bugs in vmas/scenarios/road_traffic.py that caused crashes when using map_type="2" on a GPU device, once the initial state buffer has accumulated at least one entry.

Missing return in reset_init_state
When is_use_state_buffer=True, the function set agent position/rotation/velocity from the buffer but is missing a return statement (TypeError: cannot unpack non-iterable NoneType object)
Fixed by adding return ref_path, path_id in the is_use_state_buffer branch.

Device mismatch in reset/record conditions
torch.rand(1) created a CPU tensor while probability_use_recording and probability_record lived on the env device (possibly GPU), raising: RuntimeError: Expected all tensors to be on the same device
Fixed by passing device=self.world.device to both torch.rand(1) in two calls.

Tests added in tests/test_scenarios/test_road_traffic.py:

  • test_map_type_runs — sanity check for both map types on CPU
  • test_map_type_2_reset_uses_buffer — CPU, reproduces first bug
  • test_gpu_map_type_2_rand_device — GPU-only, reproduces device bug

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.

1 participant