Merge LeRobot datasets with lerobot-edit-dataset --operation.type merge, passing --new_repo_id (required) and, for local work, --new_root and --operation.roots. The merge offsets episode and frame indices, relabels task_index by task string, re-slots files at the library defaults (1000 files per chunk, 100 MB data files, 200 MB video files), and aggregates statistics from the sources' existing meta/stats.json. That last step is the quiet one: in v0.7.0, released 2026-11-05, merged quantiles (q01 to q99) are a min/max envelope across the sources, which the code itself documents as bounds rather than whole-dataset quantiles. v0.6.1 used a frame-weighted mean instead, which issue #4156 measured at 38.74 to 42.12 percent of frames outside q01/q99 where about 2 percent is expected. Only policies that normalize with QUANTILES read those values: pi05, molmoact2, wall_oss_05 and dm05 for state and action, cosmos3 for action. Gate the merge on fps, robot_type and features, then count frames outside the saved bounds before training.
To merge LeRobot datasets, run lerobot-edit-dataset --operation.type merge with --new_repo_id for the output and the list of sources. The command is the easy part. What needs checking is what the merge writes: re-numbered indices, a re-built task table, re-slotted video files, and normalization statistics that in v0.7.0 are a min/max envelope across the sources rather than percentiles of the merged frames.
Every flag, function and default below was read from the v0.7.0 tag, released 2026-11-05, with the v0.6.1 behaviour noted where it differs. If you are merging weeks of operator sessions, or folding mixed teleoperation, simulation and human video into one corpus, this is the step where metadata can stop describing the data without any error.
The merge command that runs, entirely on local paths
lerobot-edit-dataset \
--new_repo_id your-org/cell_a_merged \
--new_root /data/lerobot/cell_a_merged \
--operation.type merge \
--operation.repo_ids "['your-org/cell_a_week01', 'your-org/cell_a_week02']" \
--operation.roots "['/data/lerobot/cell_a_week01', '/data/lerobot/cell_a_week02']"lerobot-edit-dataset registers nine operations. Merge is the one that derives a new dataset instead of editing one, so it takes its identity from --new_repo_id and --new_root. Omit --new_repo_id and the script raises before opening a file:
ValueError: --new_repo_id is required for merge operation (the merged dataset identifier)
Pass --repo_id or --root and handle_merge logs that merge uses --new_repo_id and --new_root and ignores the others. Copies of the documentation from before v0.7.0 showed a merge example with --repo_id; the v0.7.0 docs use --new_repo_id.
MergeConfig has four fields: repo_ids, roots, concatenate_videos and concatenate_data, the last two defaulting to True. There is no chunk size or file size override. Nothing in this path needs the Hub unless you add --push_to_hub true.
What a LeRobot merge rewrites
merge_datasets in src/lerobot/datasets/dataset_tools.py forwards to aggregate_datasets in src/lerobot/datasets/aggregate.py, which makes four rewrites.
episode_index gains the destination's running total_episodes and index gains its total_frames.task_index is remapped by task string against a union table of every source's tasks. Two sessions whose task strings differ by a trailing space or a capital letter become two tasks.merge_datasets forwards no sizing arguments, the output always takes the defaults from src/lerobot/datasets/utils.py: 1000 files per chunk, 100 MB data files and 200 MB video files, whatever the sources used. The reason files are shared at all is the v3 layout, covered in how LeRobotDataset v3 packs episodes into shared Parquet and MP4 files.finalize_aggregation writes info.json totals as sums over the sources, then sets the merged statistics with aggregate_stats([m.stats for m in all_metadata]). This is the step that changes meaning, and it has its own section below.What the merge validates, and what it does not
Before copying, validate_all_metadata compares each source with the first and raises on three mismatches. Two more checks happen later or not at all.
Encoder settings are forgiven, stream geometry is not, and the geometry check runs inside the copy loop. The source carries a TODO to move it before the loop. A camera swapped mid-quarter fails the merge halfway, and the retry then fails too: LeRobotDatasetMetadata.create calls mkdir(parents=True, exist_ok=False), so a second run against the same --new_root raises FileExistsError. Delete the partial output first.
Run a gate before the merge that mirrors the three checks and prints what the merge will write. The sources must already open as v3 datasets; an archived root that still declares v2.0 will not load, and reaching v3.0 from there runs through two releases.
from lerobot.datasets import LeRobotDatasetMetadata
from lerobot.datasets.feature_utils import features_equal_for_merge
ROOTS = {
"your-org/cell_a_week01": "/data/lerobot/cell_a_week01",
"your-org/cell_a_week02": "/data/lerobot/cell_a_week02",
}
metas = [LeRobotDatasetMetadata(rid, root=root) for rid, root in ROOTS.items()]
first = metas[0]
for meta in metas[1:]:
assert meta.fps == first.fps, f"fps {meta.fps} != {first.fps}"
assert meta.robot_type == first.robot_type, f"robot_type {meta.robot_type} != {first.robot_type}"
assert features_equal_for_merge(first.features, meta.features), "feature dicts differ"
tasks = [set(m.tasks.index) for m in metas]
print("union of task strings:", sorted(set().union(*tasks)))
print("expected merged episodes:", sum(m.total_episodes for m in metas))
print("expected merged frames:", sum(m.total_frames for m in metas))The printed union of task strings is your only warning before "pick up the red block" and "Pick up the red block " become two task indices. The gate does not cover stream geometry; compare camera resolution and codec across sessions from your recording log if a camera changed.
| Property | Checked where | Mismatch result |
|---|---|---|
| fps | validate_all_metadata | ValueError: Same fps is expected, ... |
| robot_type | validate_all_metadata | ValueError: Same robot_type is expected, ... |
| Feature keys, dtype, shape, names | features_equal_for_merge | ValueError: Same features is expected, ... |
| Encoder settings (video.g, crf, preset, fast_decode, extra_options, video_backend) | Ignored by features_equal_for_merge | Merge proceeds |
| Stream geometry (video.height, width, fps, codec, pix_fmt) | concatenate_video_files, during the copy | ValueError mid-merge, after files are written |
| Task strings | Not checked | Near-duplicates become separate task_index values |
Merged quantiles in v0.7.0: an envelope, not a percentile
A dataset's meta/stats.json is already an aggregation before any merge. Each episode's statistics come from RunningQuantileStats, a 5000-bin histogram estimate, and recording folds them in episode by episode with aggregate_stats. A merge aggregates those aggregations again. DEFAULT_QUANTILES is [0.01, 0.10, 0.50, 0.90, 0.99], and all five keys take the same path.
What that path computes depends on the version.
np.min for keys at or below q50 and np.max above it. The in-code comment states that exact global quantiles cannot be recovered from quantile summaries and that the values are bounds across the inputs, not global quantile estimates.Issue #4156 was closed on 2026-10-21 with the maintainers' position that #3804 removed the incorrect averaging, that main now uses documented conservative bounds, and that the augmentation script provides dataset-wide histogram estimates. PR #3801, which proposed a true histogram merge, was closed unmerged the same day, with a narrower follow-up planned. The envelope is the intended behaviour, not a bug awaiting a fix.
The repository's own test fixture shows what each version produces for two sources of 100 and 150 frames:
The two versions err in opposite directions. The weighted mean narrows the band to 8.6, inside both source spans, so real frames fall outside it. The envelope widens it to 10.0, wider than either source, so normalized values are compressed toward the centre. And the stored q50 on v0.7.0 is the smaller source median: a lower bound with a median's name.
Neither the recompute_stats operation nor recording fixes this, because both aggregate per-episode summaries through the same function. The pi05 documentation says so directly: recording, resuming and merging leave meta/stats.json holding a conservative envelope rather than whole-dataset quantiles.
| Stat | Source A | Source B | v0.6.1 merged (weighted mean) | v0.7.0 merged (envelope) |
|---|---|---|---|---|
| q01 | 1.5 | 2.5 | 2.1 | 1.5 |
| q10 | 2.0 | 3.0 | 2.6 | 2.0 |
| q50 | 5.0 | 6.0 | 5.6 | 5.0 |
| q90 | 9.0 | 11.0 | 10.2 | 11.0 |
| q99 | 9.5 | 11.5 | 10.7 | 11.5 |
| q99 minus q01 span | 8.0 | 9.0 | 8.6 | 10.0 |
The acceptance check: count frames outside the saved bounds
The check that works on every version asks one question: what fraction of frames sits outside the bounds the merged dataset saved for itself? For a true 1st and 99th percentile pair over the same frames, about 1 percent falls below q01 and 1 percent above q99, so roughly 2 percent per dimension. That follows from the definition of a percentile, not from a library constant.
import numpy as np
from lerobot.datasets import LeRobotDataset
from lerobot.utils.constants import ACTION, OBS_STATE
ds = LeRobotDataset("your-org/cell_a_merged", root="/data/lerobot/cell_a_merged")
BLOCK = 50_000
for key in (ACTION, OBS_STATE):
q01 = np.asarray(ds.meta.stats[key]["q01"], dtype=np.float64)
q99 = np.asarray(ds.meta.stats[key]["q99"], dtype=np.float64)
column = ds.select_columns([key])
outside = np.zeros_like(q01)
seen = 0
for start in range(0, ds.num_frames, BLOCK):
rows = np.asarray(column[start : start + BLOCK][key], dtype=np.float64)
outside += ((rows < q01) | (rows > q99)).sum(axis=0)
seen += len(rows)
pct = 100.0 * outside / seen
print(key, "outside saved q01/q99 per dim (%):", np.round(pct, 2))Read the output per dimension, not as an average. How to interpret it:
Also check the bookkeeping. episode_index max in stats.json should be total_episodes - 1 and task_index max should be total_tasks - 1. Open issue #3788 reports merged rows carrying task_index 0 and 1 while the stats report a max of 0, because statistics are aggregated before relabelling; its fix, PR #3791, is open.
Which policies read merged quantiles
A wrong band matters only if the policy's default normalization_mapping uses QUANTILES. From the v0.7.0 configuration files:
The QUANTILES branch in src/lerobot/processor/normalize_processor.py computes 2.0 * (tensor - q01) / denom - 1.0 with denom = q99 - q01, and has no clamp. Only a missing key raises. Present-but-misleading values raise nothing, so the observable is the input distribution and the loss scale, not a crash. Which VLA you are fine-tuning decides whether this section applies to you.
| Policy | STATE | ACTION | Exposed to merged q01/q99 |
|---|---|---|---|
| pi05 | QUANTILES | QUANTILES | Yes |
| molmoact2 | QUANTILES | QUANTILES | Yes |
| wall_oss_05 | QUANTILES | QUANTILES | Yes |
| dm05 | QUANTILES | QUANTILES | Yes |
| cosmos3 | IDENTITY | QUANTILES | Action only |
| pi0 | MEAN_STD | MEAN_STD | No |
| smolvla | MEAN_STD | MEAN_STD | No |
| act | MEAN_STD | MEAN_STD | No |
Repairing the statistics inside a private perimeter
Two repairs exist for an exposed policy. The first is the augmentation script, which accumulates one running histogram per feature across all episodes:
python src/lerobot/scripts/augment_dataset_quantile_stats.py \
--repo-id your-org/cell_a_merged \
--root /data/lerobot/cell_a_merged \
--overwrite \
--skip-imagesIt is not a console script, so it runs as a file path from a source checkout, and its flags are hyphenated (--repo-id), unlike the underscored --repo_id of lerobot-edit-dataset. --overwrite is mandatory on a merged dataset: without it the script sees existing quantile keys and returns. The pi05 docs note that the results are histogram estimates subject to binning error, so they change the normalized targets and the loss scale relative to the envelope; statistics already saved in a checkpoint are unaffected.
The part that matters on a segmented network: the script writes the stats locally, then calls push_to_hub() and recreates the Hub version tag, with no flag to skip it. On an isolated network the push fails after the write; on a network with egress, running it uploads the corpus. Run the acceptance check afterwards to confirm the local file changed, and see which LeRobot commands call Hugging Face when you run offline before running any of this near clinical, defence-supplier or plant-floor footage.
The second repair needs no script: override the policy's normalization_mapping to MEAN_STD for state and action, which the pi05 documentation offers as the alternative. Mean and standard deviation merge exactly.
Training on several datasets without merging is not an escape route either. make_dataset raises NotImplementedError on the multi-dataset branch in v0.7.0, and MultiLeRobotDataset uses the same aggregate_stats call.
Where the open issues stand on 2026-11-22
Issue #3883 reports a merge of 21 datasets with mixed 2-camera and 3-camera footage whose reads fail past frame 11,723 of a file holding 11,724 frames. The merge CLI has no file size override to work around it. Issue #2679 matters when you merge a merged dataset with an unmerged one: the bookkeeping features lose their fps, and the feature comparison can then reject the pair.
| Symptom | Tracker | Status | v0.7.0 |
|---|---|---|---|
| Merged q01/q99 a frame-weighted mean of source quantiles | issue #4156 | Closed 2026-10-21 | Replaced by min/max envelope (PR #3804) |
| Merged quantiles are not whole-dataset quantiles | PR #3801 | Closed unmerged 2026-10-21 | Envelope is documented behaviour |
| Per-episode episode_index and index stats not offset | issue #3508 | Closed 2026-08-03 by PR #4276 | Fixed |
| stats.json task_index left at pre-merge labels | issue #3788 | Open, fix in PR #3791 | Not fixed |
| Video chunk boundaries do not match file lengths | issue #3883 | Open | Not fixed |
| Merge strips fps from scalar features | issue #2679 | Open | Not fixed |
Keep the sessions immutable and gate the merge
aggregate_datasets never modifies its sources, writes a new root, and refuses to write into one that exists. Build on that. Mount operator session roots read-only, pass them with --operation.roots, and treat the merged tree as a rebuildable output with the merge command and the LeRobot version recorded beside it. The recovery for a mid-merge codec failure, a stale task index or a suspicious bounds report is then always the same: delete the output and re-derive. The rest of our physical AI and robot data guides follow the same rule.
If you are cutting bad sessions before the merge, the delete operation has the same statistics behaviour, covered in removing bad episodes from a LeRobot dataset.
This week, add three things to whatever script calls the merge: the pre-merge gate in front, the bounds check behind it with a threshold you set from your first clean run, and the LeRobot version written next to the output, because which aggregation ran is answerable only from the version, not from the files. If you need the collection and dataset pipeline built around this, see our robotics data collection service.
FAQ
Quick answers to the questions this post tends to raise.



