Skip to content

Fix split-local LeRobot frame offsets - #19

Merged
KunYing-Lee merged 1 commit into
mainfrom
agent/fix-split-episode-offset
Aug 11, 2026
Merged

Fix split-local LeRobot frame offsets#19
KunYing-Lee merged 1 commit into
mainfrom
agent/fix-split-episode-offset

Conversation

@KunYing-Lee

Copy link
Copy Markdown
Contributor

Summary

  • translate global LeRobot episode row intervals into the split-local frame dataset coordinate system before batched reads
  • share the same bounds-checked conversion across single-episode reads, grouped materialization, and batched statistics
  • add regressions for nonzero split offsets in validation-cache materialization and exhaustive training statistics

Root cause

The release loader selects only parquet shards intersecting the requested split. Their Hugging Face dataset therefore uses local row coordinates and records the selected files' global starting row in frame_dataset_offset.

The ordinary __getitem__ path subtracted this offset, but iter_episode_kinematics_groups and iter_stats_batches sliced the local dataset with global episode rows. This was invisible for the train split, which starts at row zero, and produced an empty qpos_36 tensor immediately for validation/test splits.

Validation

  • focused LeRobot dataset tests: 7 passed
  • data + generation suites: 124 passed
  • full-suite collection was additionally attempted; unrelated headless MuJoCo EGL/OSMesa initialization is unavailable on the validation host
  • git diff --check passed

@KunYing-Lee
KunYing-Lee marked this pull request as ready for review August 11, 2026 04:31
Copilot AI lite review requested due to automatic review settings August 11, 2026 04:31
@KunYing-Lee
KunYing-Lee merged commit 4b21193 into main Aug 11, 2026
@KunYing-Lee
KunYing-Lee deleted the agent/fix-split-episode-offset branch August 11, 2026 04:31

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Fixes incorrect frame slicing for non-train LeRobot splits by consistently translating global episode frame row intervals into the split-local Hugging Face dataset coordinate system (using frame_dataset_offset) before performing grouped/batched reads.

Changes:

  • Introduce a shared _local_frame_interval(...) helper to convert and bounds-check global frame intervals into split-local dataset indices.
  • Apply the shared conversion to single-episode reads, grouped kinematics materialization, and exhaustive-window statistics batching.
  • Add regression tests covering nonzero split offsets for validation materialization and exhaustive training stats.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
src/omg/data/lerobot_dataset.py Adds shared global→local frame interval conversion and applies it to grouped/batched readers to prevent empty reads on val/test splits.
tests/data/test_lerobot_dataset.py Adds fixtures + regressions to ensure nonzero split offsets are handled correctly in grouped reads and stats batching.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines 367 to +371
def _read_episode(self, sample: dict[str, Any]) -> dict[str, np.ndarray]:
episode_index = int(sample["episode_index"])
if self._cached_episode_index == episode_index and self._cached_episode_data is not None:
return self._cached_episode_data
start = int(sample["data_start_row"]) - self.frame_dataset_offset
end = int(sample["data_end_row"]) - self.frame_dataset_offset
if start < 0 or end > len(self.frame_dataset) or end <= start:
raise IndexError(
"Episode frame interval is outside the loaded LeRobot split shards: "
f"episode={episode_index} local={start}:{end} loaded=0:{len(self.frame_dataset)}"
)
start, end = self._local_frame_interval(sample["data_start_row"], sample["data_end_row"])
Comment on lines +266 to +267
assert summary["episodes"] == 1
assert summary["frames"] == 5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants