Download scripts/check_dataloader.py from simpk/single_pickplace: direct link, hf CLI and curl.
- Browser
- Download file 3.76 kB
-
https://huggingface.co/datasets/simpk/single_pickplace/resolve/main/scripts/check_dataloader.py
- Command line
-
hf download hf://datasets/simpk/single_pickplace/scripts/check_dataloader.py
-
curl -L -o check_dataloader.py https://huggingface.co/datasets/simpk/single_pickplace/resolve/main/scripts/check_dataloader.py
3.76 kB
| """Pull one fully-transformed sample through the real openpi data pipeline. Fails in seconds. | |
| uv run python scripts/check_dataloader.py pi05_g1_pickplace | |
| Run this BEFORE compute_norm_stats.py. It exercises exactly the path that norm-stat computation | |
| and training use -- LeRobotDataset construction, delta_timestamps, repack, the policy transforms, | |
| the delta-action transform and the model transforms -- but on a single sample with no workers, so | |
| a wiring error surfaces immediately instead of inside a DataLoader worker after a minute of setup. | |
| The class of bug this catches: `action_sequence_keys` defaults to ("actions",) while a LeRobot | |
| dataset's column may be "action". That name is fed raw into delta_timestamps, so it is resolved | |
| against the hf_dataset BEFORE any repack renames it, and the failure looks like | |
| KeyError: Column actions not in the dataset. Current columns: [... 'action' ...] | |
| buried in a torch worker traceback. | |
| """ | |
| import sys | |
| import numpy as np | |
| def main() -> int: | |
| if len(sys.argv) < 2: | |
| print(__doc__) | |
| return 2 | |
| name = sys.argv[1] | |
| from openpi.training import config as _config | |
| from openpi.training import data_loader as _data_loader | |
| cfg = _config.get_config(name) | |
| data_config = cfg.data.create(cfg.assets_dirs, cfg.model) | |
| print(f"config {cfg.name}") | |
| print(f"repo_id {data_config.repo_id}") | |
| print(f"action_sequence_keys{'':<0} {tuple(data_config.action_sequence_keys)}") | |
| print(f"action_horizon {cfg.model.action_horizon}") | |
| print(f"use_quantile_norm {data_config.use_quantile_norm}") | |
| print(f"prompt_from_task {data_config.prompt_from_task}") | |
| # Raw dataset first: this is where an action_sequence_keys mismatch blows up. | |
| ds = _data_loader.create_torch_dataset(data_config, cfg.model.action_horizon, cfg.model) | |
| print(f"\nraw dataset {len(ds)} samples") | |
| raw = ds[0] | |
| for k, v in sorted(raw.items()): | |
| if hasattr(v, "shape"): | |
| print(f" {k:<44} {tuple(v.shape)}") | |
| if isinstance(raw.get("prompt"), str) or isinstance(raw.get("task"), str): | |
| print(f" prompt/task{'':<33} {raw.get('prompt') or raw.get('task')!r}") | |
| # Then the full transform stack. skip_norm_stats=True so this works before Step 8. | |
| tds = _data_loader.transform_dataset(ds, data_config, skip_norm_stats=True) | |
| item = tds[0] | |
| print("\ntransformed sample (what the model actually receives):") | |
| for k, v in sorted(item.items()): | |
| if isinstance(v, dict): | |
| for kk, vv in sorted(v.items()): | |
| print(f" {k}/{kk:<38} {getattr(vv, 'shape', vv)}") | |
| elif hasattr(v, "shape"): | |
| print(f" {k:<44} {tuple(np.asarray(v).shape)} {np.asarray(v).dtype}") | |
| else: | |
| print(f" {k:<44} {v!r}") | |
| problems = [] | |
| st, ac = np.asarray(item["state"]), np.asarray(item["actions"]) | |
| if st.shape != (cfg.model.action_dim,): | |
| problems.append(f"state is {st.shape}, expected ({cfg.model.action_dim},)") | |
| if ac.shape != (cfg.model.action_horizon, cfg.model.action_dim): | |
| problems.append(f"actions is {ac.shape}, expected " | |
| f"({cfg.model.action_horizon}, {cfg.model.action_dim})") | |
| if not np.all(np.isfinite(st)) or not np.all(np.isfinite(ac)): | |
| problems.append("non-finite values in state/actions") | |
| if np.all(ac == 0): | |
| problems.append("every action is exactly 0 -- the action column is probably not wired") | |
| print() | |
| if problems: | |
| for p in problems: | |
| print("FAIL", p) | |
| return 1 | |
| print("PASS -- the pipeline produces well-formed model inputs. Safe to run compute_norm_stats.py.") | |
| return 0 | |
| if __name__ == "__main__": | |
| sys.exit(main()) | |