Skip to main content
The dataset module provides classes for loading, sharding, and mixing multi-modal robotics datasets.

ShardedDataset

Abstract base class for sharded datasets.

Constructor

str
required
Path to the dataset directory.

Methods

__len__

Return the number of shards in the dataset.

get_shard_length

Get the number of samples in a specific shard.
int
required
Shard index.

get_shard

Load and return all samples from a specific shard.
int
required
Shard index to load.

set_processor

Set the data processor for this dataset.
BaseProcessor
required
Processor instance to use for data processing.

get_dataset_statistics

Get dataset statistics for normalization.
dict[str, Any]
Dictionary containing statistics for each modality and joint group.

ShardedSingleStepDataset

Single-step dataset that creates shards from individual timesteps across episodes. This dataset provides step-level data access for VLA training by:
  1. Loading episodes using LeRobotEpisodeLoader
  2. Splitting episodes into individual timesteps
  3. Organizing timesteps into balanced shards for efficient loading
  4. Supporting episode subsampling for data efficiency
The sharding strategy ensures balanced shard sizes while maintaining randomization across episodes and timesteps within episodes.

Constructor

str | Path
required
Path to LeRobot format dataset directory.
EmbodimentTag
required
Embodiment identifier for cross-embodiment training.
dict[str, ModalityConfig]
required
Configuration for each modality (sampling, keys). Should include “video”, “state”, “action”, and optionally “language”.
str
default:"torchcodec"
Video decoding backend (‘torchcodec’, ‘decord’, etc.).
dict[str, Any] | None
default:"None"
Additional arguments for video backend.
int
default:"1024"
Target number of timesteps per shard.
float
default:"0.1"
Fraction of episode timesteps to use (for efficiency). Value of 0.1 means 10% of timesteps are sampled.
int
default:"42"
Random seed for reproducible sharding and sampling.
bool
default:"False"
Whether to allow padding of indices to valid range [0, max_length - 1].

Usage example

ShardedMixtureDataset

Iterable dataset that combines multiple sharded datasets with configurable mixing ratios. This dataset provides the core functionality for multi-dataset training:
  1. Combines multiple ShardedDataset instances with specified mixing weights
  2. Implements intelligent shard sampling that accounts for dataset sizes
  3. Provides efficient background shard caching for continuous data loading
  4. Handles distributed training across multiple workers and processes
  5. Merges dataset statistics for consistent normalization
The sampling strategy ensures that datasets are sampled proportionally to their weights while accounting for differences in shard sizes.

Constructor

list[ShardedDataset]
required
List of ShardedDataset instances to combine.
list[float]
required
Mixing weights for each dataset (will be normalized to sum to 1.0).
BaseProcessor
required
Data processor to apply to all datasets.
int
default:"42"
Random seed for reproducible sampling.
bool
default:"True"
Whether in training mode (affects sampling strategy). In training mode, samples shards randomly. In eval mode, samples every shard once.
int
default:"100000"
Number of shards to sample per epoch during training.
bool
default:"False"
Whether to override pretraining statistics with merged statistics.

Methods

merge_statistics

Merge dataset statistics across all datasets, grouped by embodiment. Combines statistics from datasets with the same embodiment tag using weighted averaging, then configures the processor with merged statistics.

get_dataset_statistics

Get the merged dataset statistics.
dict[str, dict[str, dict[str, list[float]]]]
Nested dictionary: {embodiment_tag: {modality: {joint_group: {stat_type: values}}}}

reset_seed

Reset the random seed and regenerate sampling schedules.
int
required
New random seed to use.
Print formatted dataset statistics for debugging and monitoring.

get_initial_actions

Collect initial actions from all datasets.
list
Combined list of initial actions from all constituent datasets.

Usage example

LeRobotEpisodeLoader

Episode-level data loader for LeRobot format datasets. This class handles the loading and preprocessing of individual episodes from LeRobot datasets. It manages metadata parsing, video decoding, and data extraction across multiple modalities (video, state, action, language).

Constructor

str | Path
required
Path to dataset root directory containing meta/ and data files.
dict[str, ModalityConfig]
required
Dictionary mapping modality names to ModalityConfig objects that specify temporal sampling and data keys to load.
str
default:"torchcodec"
Video decoding backend (‘torchcodec’, ‘decord’, etc.).
dict[str, Any] | None
default:"None"
Additional arguments for the video backend.

Methods

__getitem__

Load complete episode data as a processed DataFrame.
int
required
Episode index to load.
pd.DataFrame
DataFrame with columns for all modalities and timestamps, with video frames as PIL Images.

get_dataset_statistics

Extract dataset statistics for normalization from loaded metadata.
dict[str, Any]
Nested dictionary: {modality: {joint_group: {stat_type: values}}}

get_initial_actions

Load initial actions for policy initialization if available.
list
List containing initial action dictionaries, or empty list if not available.

Usage example