Skip to content

[Question] Parallel Sampling #136

Open
@daniellawson9999

Description

@daniellawson9999

Parallel episode sampling

I have a use case where we have a dataset consisting of image-based observations, and I notice that sampling speed seems to be slower than with 1D observations. I checked out how sampling is working internally, and noticed that Minari samples episodes serially, instead of sampling in parallel. I thought that parallelizing this call may have been thought about already, so I was curious for any recommendations on the best way to do this. I was also wondering if this was something that will be added in the future.

I have one more layer of complexity on top of this, where instead of 1 dataset, I have say 10 datasets from different envs, each have image-based observations. Think multi-task Atari. I have 10 minari datasets, and then say want 30 episodes from each for each gradient update. Also want to do this in parallel, and will experiment with different parallelization techniques but curious if others had intuition about this.

def get_episodes(self, episode_indices: Iterable[int]) -> List[dict]:
"""Get a list of episodes.
Args:
episode_indices (Iterable[int]): episodes id to return
Returns:
episodes (List[dict]): list of episodes data
"""
out = []
with h5py.File(self._data_path, "r") as file:
for ep_idx in episode_indices:
ep_group = file[f"episode_{ep_idx}"]
out.append(
{
"id": ep_group.attrs.get("id"),
"total_timesteps": ep_group.attrs.get("total_steps"),
"seed": ep_group.attrs.get("seed"),
"observations": self._decode_space(
ep_group["observations"], self.observation_space
),
"actions": self._decode_space(
ep_group["actions"], self.action_space
),
"rewards": ep_group["rewards"][()],
"terminations": ep_group["terminations"][()],
"truncations": ep_group["truncations"][()],
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions