Skip to content

Commit

Permalink
[Feature] Dict specs in vmas (#2415)
Browse files Browse the repository at this point in the history
Co-authored-by: Vincent Moens <vmoens@meta.com>
  • Loading branch information
matteobettini and vmoens authored Sep 4, 2024
1 parent 49d7f74 commit df4fa78
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions torchrl/envs/libs/vmas.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,16 @@ def _vmas_to_torchrl_spec_transform(
device=device,
)
)
elif isinstance(spec, gym_spaces.Dict):
spec_out = {}
for key in spec.keys():
spec_out[key] = _vmas_to_torchrl_spec_transform(
spec[key],
device=device,
categorical_action_encoding=categorical_action_encoding,
)
# the batch-size must be set later
return Composite(spec_out, device=device)
else:
raise NotImplementedError(
f"spec of type {type(spec).__name__} is currently unaccounted for vmas"
Expand Down

1 comment on commit df4fa78

@github-actions
Copy link

Choose a reason for hiding this comment

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

⚠️ Performance Alert ⚠️

Possible performance regression was detected for benchmark 'GPU Benchmark Results'.
Benchmark result of this commit is worse than the previous benchmark result exceeding threshold 2.

Benchmark suite Current: df4fa78 Previous: 49d7f74 Ratio
benchmarks/test_replaybuffer_benchmark.py::test_rb_populate[TensorDictReplayBuffer-LazyTensorStorage-RandomSampler-400] 278.91422463312745 iter/sec (stddev: 0.018805195968952637) 986.7247434360693 iter/sec (stddev: 0.0003073996760283604) 3.54

This comment was automatically generated by workflow using github-action-benchmark.

CC: @vmoens

Please sign in to comment.