TorchRL ships built-in loaders for the most widely-used offline RL and robot-learning datasets. Every loader extendsDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/pytorch/rl/llms.txt
Use this file to discover all available pages before exploring further.
BaseDatasetExperienceReplay, which is itself a TensorDictReplayBuffer. This means offline data plugs directly into the same training loop as any online buffer: call dataset.sample(batch_size) to get a TensorDict, apply transforms via dataset.append_transform(t), and checkpoint with dataset.dumps(path). Data is stored in TorchRL’s TED (TensorDict Episode Data) format — a flat TensorDict with fields observation, action, reward, next.observation, next.done, next.terminated, and next.truncated.
Most dataset classes have optional external dependencies (e.g.,
d4rl, minari, lerobot). Import errors are caught at module load time and re-raised with a helpful message when the class is instantiated. See the individual class sections below for the required package.Base Class: BaseDatasetExperienceReplay
All dataset loaders inherit from this class, which extends TensorDictReplayBuffer with:
- Automatic download on first instantiation (controlled by
download). - A
TensorStoragebacked by memory-mapped tensors for zero-copy disk access. - An
ImmutableDatasetWriterto prevent accidental writes. - A class-level
available_datasetsproperty listing all downloadable dataset IDs.
torchrl.data.datasets.common.BaseDatasetExperienceReplay
D4RL Datasets
D4RLExperienceReplay
Wraps the D4RL offline RL benchmark (Offline datasets collected from MuJoCo locomotion tasks, AntMaze, Adroit hand manipulation, and Kitchen). Data can be loaded either via the d4rl package or via direct HTTP download without it.
Import path: torchrl.data.datasets.D4RLExperienceReplay
Requires: d4rl package (optional — pass direct_download=True to skip)
Dataset identifier, e.g.
"hopper-medium-v2", "maze2d-umaze-v1", "pen-expert-v1". See D4RLExperienceReplay.available_datasets for the full list.Batch size returned by
sample(). Can be overridden at call time: dataset.sample(64).Index sampler. Defaults to
RandomSampler.Transform applied after each sample.
Split transitions into individual trajectories (padded to equal length) using the
done signal (done = terminated | truncated).Collect the dataset from a live
d4rl environment rather than a pre-saved HDF5 file. Requires the d4rl package.Download raw HDF5 files without the
d4rl package. If None, falls back to direct_download=True when d4rl is not installed. Incompatible with from_env=True.Set
done = terminated | truncated. When False, only terminated is used.Root directory for cached datasets. Defaults to
~/.cache/torchrl/d4rl.Download if not cached. Pass
"force" to overwrite an existing cache.- Basic usage
- With transforms
- Without d4rl
Atari DQN Dataset
AtariDQNExperienceReplay
The DQN Replay Dataset — 5 training runs of DQN across all Atari 2600 games, totalling 200 million frames (50 million steps per game at frame-skip 4). The dataset is chunked into 50 shards of 1 million transitions each; data is formatted on-the-fly at sample time to avoid storing redundant (obs, next_obs) pairs.
Import path: torchrl.data.datasets.AtariDQNExperienceReplay
Requires: gsutil (for downloading from Google Cloud Storage)
"<game>/<run>", e.g. "Pong/1", "Breakout/5". See AtariDQNExperienceReplay.available_datasets.Batch size for
sample().Root directory for cached files. Defaults to
~/.cache/torchrl/atari.Download on first use. Pass
"force" to re-download.Index sampler. Supports
SliceSampler for sequence sampling.If provided, wraps the buffer in a
SliceSampler returning this many non-overlapping sub-sequences per batch.Fixed sub-sequence length. Mutually exclusive with
num_slices.Minari Datasets
MinariExperienceReplay
The Minari dataset library from the Farama Foundation. Covers robotics (Gymnasium-Robotics, D4RL-compatible MuJoCo), manipulation, and navigation tasks.
Import path: torchrl.data.datasets.MinariExperienceReplay
Requires: minari package (pip install minari)
Dataset ID from the Minari registry, e.g.
"door-human-v1", "pen-expert-v1". Use MinariExperienceReplay.available_datasets to list all registered IDs.Batch size for
sample().Root directory for cached datasets. Defaults to
~/.cache/torchrl/minari.Download on first use. Pass
"force" to overwrite an existing cache.Split into individual trajectory tensors using
done = truncated | terminated.Load directly from the local Minari cache (
~/.minari/datasets) without a network request. Useful for custom or private datasets.Post-processing transform applied to every sampled batch.
LeRobot Datasets
LeRobotExperienceReplay
LeRobot is Hugging Face’s dataset collection for robot manipulation. Datasets are hosted on the Hugging Face Hub and include video observations, proprioceptive state, language instructions, and actions from real and simulated robot arms.
Import path: torchrl.data.datasets.LeRobotExperienceReplay
Requires: huggingface_hub, datasets (pip install huggingface_hub datasets)
Hugging Face Hub repository ID, e.g.
"lerobot/pusht", "lerobot/aloha_sim_transfer_cube_human".Batch size for
sample().Local cache directory. Defaults to
~/.cache/torchrl/lerobot.Download from the Hub on first use.
Index sampler. Defaults to
SliceSampler for sequence-aware sampling.Post-processing transform. Use
torchrl.envs.transforms.DecodeVideoTransform to decode lazy VideoClipRef frames on-the-fly.Override the default column-to-TensorDict key mapping. The default maps
"action" → "action", "observation.state" → ("observation", "state"), "observation.images.<cam>" → ("observation", "image", "<cam>"), etc.Number of episode slices per batch. Passed to the default
SliceSampler.Length of each sampled slice. Mutually exclusive with
num_slices.- Basic usage
- With video decoding
lerobot_columns_to_tensordict
Utility function that converts a dictionary of LeRobot-style columnar data (e.g., from a datasets.Dataset row batch) into a canonical VLA-format TensorDict.
Open X-Embodiment
OpenXExperienceReplay
The Open X-Embodiment dataset collection — over 1 million real robot trajectories from 22 research groups across 527 tasks. Backed by TensorFlow Datasets (TFDS) and streamed lazily via torchrl’s RLDS adapter.
Import path: torchrl.data.datasets.OpenXExperienceReplay
Requires: tensorflow_datasets, tensorflow (pip install tensorflow_datasets)
TFDS dataset name, e.g.
"fractal20220817_data", "bridge", "kuka". Full list at OpenXExperienceReplay.available_datasets.Batch size for
sample().Local TFDS data directory.
Download and prepare data on first use.
Index sampler.
Dataset split. Most Open X datasets only have
"train".Roboset
RobosetExperienceReplay
Roboset — a large-scale multitask dataset for dexterous robot manipulation collected with the ROBEL D’Claw and D’Hand robotic hands.
Import path: torchrl.data.datasets.RobosetExperienceReplay
Requires: h5py (pip install h5py)
Dataset ID. See
RobosetExperienceReplay.available_datasets.Batch size for
sample().Cache directory. Defaults to
~/.cache/torchrl/roboset.Download on first use.
GenDGRL
GenDGRLExperienceReplay
The GenDGRL dataset — a synthetic, procedurally-generated dataset for goal-conditioned RL research.
Import path: torchrl.data.datasets.GenDGRLExperienceReplay
Dataset split identifier. See
GenDGRLExperienceReplay.available_datasets.Batch size for
sample().Cache directory. Defaults to
~/.cache/torchrl/gen_dgrl.Download on first use.
VD4RL
VD4RLExperienceReplay
VD4RL — pixel-based D4RL transitions collected from DMControl environments, matching the standard D4RL quality tiers (random, medium, medium-replay, expert).
Import path: torchrl.data.datasets.VD4RLExperienceReplay
Dataset ID, e.g.
"cheetah_run/medium/64px". See VD4RLExperienceReplay.available_datasets.Batch size for
sample().Cache directory. Defaults to
~/.cache/torchrl/vd4rl.Integration with TensorDictReplayBuffer
Dataset loaders return TensorDictReplayBuffer instances. You can mix offline and online data by combining two buffers with ReplayBufferEnsemble, or by using OfflineToOnlineReplayBuffer:
Optional Dependencies Summary
D4RL
Package:
d4rl (optional — direct_download=True works without it)Install: pip install d4rl or use direct_download=TrueDatasets: MuJoCo locomotion, AntMaze, Adroit, KitchenMinari
Package:
minariInstall: pip install minariDatasets: Robotics, manipulation, navigation (Farama Foundation)LeRobot
Package:
huggingface_hub, datasetsInstall: pip install huggingface_hub datasetsDatasets: Real and simulated robot manipulation (Hugging Face Hub)Open X-Embodiment
Package:
tensorflow_datasets, tensorflowInstall: pip install tensorflow_datasetsDatasets: 527 tasks across 22 robot platforms (RLDS format)