BIue-Jay commited on
Commit
942788e
·
verified ·
1 Parent(s): aa7cdc3

Add files using upload-large-folder tool

Browse files
Files changed (31) hide show
  1. a18-pour-water/epoch-010/model-00001-of-00002.safetensors +3 -0
  2. a18-pour-water/epoch-010/model-00002-of-00002.safetensors +3 -0
  3. a18-pour-water/epoch-010/training_args.bin +3 -0
  4. a18-pour-water/epoch-020/model-00001-of-00002.safetensors +3 -0
  5. a18-pour-water/epoch-020/model-00002-of-00002.safetensors +3 -0
  6. a18-pour-water/epoch-020/training_args.bin +3 -0
  7. a3-fridge-open/epoch-010/model-00001-of-00002.safetensors +3 -0
  8. a3-fridge-open/epoch-010/model-00002-of-00002.safetensors +3 -0
  9. a3-fridge-open/epoch-010/training_args.bin +3 -0
  10. a3-fridge-open/epoch-020/model-00001-of-00002.safetensors +3 -0
  11. a3-fridge-open/epoch-020/model-00002-of-00002.safetensors +3 -0
  12. a3-fridge-open/epoch-020/training_args.bin +3 -0
  13. a7-cabinet-close/epoch-010/model-00001-of-00002.safetensors +3 -0
  14. a7-cabinet-close/epoch-010/model-00002-of-00002.safetensors +3 -0
  15. a7-cabinet-close/epoch-010/training_args.bin +3 -0
  16. a7-cabinet-close/epoch-020/model-00001-of-00002.safetensors +3 -0
  17. a7-cabinet-close/epoch-020/model-00002-of-00002.safetensors +3 -0
  18. a7-cabinet-close/epoch-020/training_args.bin +3 -0
  19. b6-pedal-bin/epoch-010/model-00001-of-00002.safetensors +3 -0
  20. b6-pedal-bin/epoch-010/model-00002-of-00002.safetensors +3 -0
  21. b6-pedal-bin/epoch-010/training_args.bin +3 -0
  22. b6-pedal-bin/epoch-020/model-00001-of-00002.safetensors +3 -0
  23. b6-pedal-bin/epoch-020/model-00002-of-00002.safetensors +3 -0
  24. b6-pedal-bin/epoch-020/training_args.bin +3 -0
  25. code/hb_groot/groot_chain.py +139 -0
  26. code/hb_groot/h2_body31_hand44_h16.py +24 -0
  27. code/hb_groot/hb_aug_v2.py +163 -0
  28. code/hb_groot/hb_launch.py +92 -0
  29. code/hb_groot/hb_offline_fix.py +24 -0
  30. code/hb_groot/prepare_groot_data.py +155 -0
  31. code/hb_groot/verify_groot_cpu.py +51 -0
a18-pour-water/epoch-010/model-00001-of-00002.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:5bb76c14e761b1b85e615420e95da1a9ec10b8f2fc62aee88fb2726fc2426c6e
3
+ size 4990519232
a18-pour-water/epoch-010/model-00002-of-00002.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:247e797baaed90bde696a996625df671f22e5063b963cce535890654e8ebe02c
3
+ size 1919980184
a18-pour-water/epoch-010/training_args.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:c9b98d3a11150bb3ed45311648a244e62fbbfe4ae80fc128c7cd92c31705ea97
3
+ size 8017
a18-pour-water/epoch-020/model-00001-of-00002.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:9f8e8861053cde17c010b018f3549f9d73e8573fd8c0f777c8fcb8113606ec66
3
+ size 4990519232
a18-pour-water/epoch-020/model-00002-of-00002.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:2f2adb3e7dd8d64e3565155a48b02bae2c9871c9c682e14767a92a270a40f833
3
+ size 1919980184
a18-pour-water/epoch-020/training_args.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:c9b98d3a11150bb3ed45311648a244e62fbbfe4ae80fc128c7cd92c31705ea97
3
+ size 8017
a3-fridge-open/epoch-010/model-00001-of-00002.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:85b6aae972d3398c90b695ca5a14c6260778bc05c62932c23cd9a11f25ae0696
3
+ size 4990519232
a3-fridge-open/epoch-010/model-00002-of-00002.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:182b6e251169b37f049c0e0b3ef5238d936bf9a881011cc019c7a2e2323cc23d
3
+ size 1919980184
a3-fridge-open/epoch-010/training_args.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:70a6b1a0e4d95256ab19401789ec0781600e6949da7facc2610a837b70b9ddb3
3
+ size 8017
a3-fridge-open/epoch-020/model-00001-of-00002.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:27a7733988811c5657fe4fb45145d0f940b32fd5cdb5d20256cbab440737bd91
3
+ size 4990519232
a3-fridge-open/epoch-020/model-00002-of-00002.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b467790f8fbcba723d687a5b44a21870c8c143658f38686d9d4692738d93207e
3
+ size 1919980184
a3-fridge-open/epoch-020/training_args.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:70a6b1a0e4d95256ab19401789ec0781600e6949da7facc2610a837b70b9ddb3
3
+ size 8017
a7-cabinet-close/epoch-010/model-00001-of-00002.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:06a0b1736fb418e7bbe4862c9a8e65926ea91370bfff3171dcd1ad4f65591542
3
+ size 4990519232
a7-cabinet-close/epoch-010/model-00002-of-00002.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:722afc64c4146621652eb4610f951bbaab70e9084188ea0412ebf5ca37a79efc
3
+ size 1919980184
a7-cabinet-close/epoch-010/training_args.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:56e1a5bbd8c71cf280208385c4a1c24d8a9f74fb48e9dd88d1476d05572781e3
3
+ size 8017
a7-cabinet-close/epoch-020/model-00001-of-00002.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:1515cb7089041dd28e5073dd2915ed815f8782dce25cf127dc47a1fe716dd571
3
+ size 4990519232
a7-cabinet-close/epoch-020/model-00002-of-00002.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:53c3c033adfb0ada62cf9391131b8a48587812af9b37721ead7eaed1de64de57
3
+ size 1919980184
a7-cabinet-close/epoch-020/training_args.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:56e1a5bbd8c71cf280208385c4a1c24d8a9f74fb48e9dd88d1476d05572781e3
3
+ size 8017
b6-pedal-bin/epoch-010/model-00001-of-00002.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a7ad2f4eb78456e60565595b42ade7c8157bf37514e77872acb6b3a5623788bd
3
+ size 4990519232
b6-pedal-bin/epoch-010/model-00002-of-00002.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:5e187525428610eb84e28a53e4a4e405da59d609ae979d84afe955bd0e7949ce
3
+ size 1919980184
b6-pedal-bin/epoch-010/training_args.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:c8417ba3e031b007cb6ec6f405128686cc6a52eb749b37aa02bed5795f98ca08
3
+ size 8017
b6-pedal-bin/epoch-020/model-00001-of-00002.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:3addec651b884df3dd13f1a7ddcc3531b0f1b1642c40604a37505ad6a24dcf54
3
+ size 4990519232
b6-pedal-bin/epoch-020/model-00002-of-00002.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:24d707ff55613bdb9febebbe7b1f20369664261943bcdf09bbf46c1ed0638e4f
3
+ size 1919980184
b6-pedal-bin/epoch-020/training_args.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:c8417ba3e031b007cb6ec6f405128686cc6a52eb749b37aa02bed5795f98ca08
3
+ size 8017
code/hb_groot/groot_chain.py ADDED
@@ -0,0 +1,139 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Per-node GR00T relay: per-layout batch-size probe (largest that fits), then 20-epoch production per task.
2
+
3
+ Run on every node (nohup), node rank from the DLC env RANK: python groot_chain.py [task ...]
4
+ Default tasks: b6 a3 a7 a18 (basket postponed). A phase succeeds only if all 4 node launchers exit 0.
5
+
6
+ Batch (user rule: as large as memory allows, 2026-11-10): descending CANDIDATES, 4 steps each on all 32 GPUs; a
7
+ candidate fits when all launchers exit 0 AND the peak reserved memory of every rank (written by hb_launch.py to
8
+ logs/peak-<phase>-rank<r>.json) is <= MAX_FRAC of the GPU. Node 0 alone judges each probe and writes a verdict file
9
+ the other nodes wait for, so all nodes take the same decision. One decision per robot layout (g1 / h2).
10
+ Outputs: $G/groot-runs-bmax/ (the earlier per-GPU-64 runs stay in $G/groot-runs/).
11
+ """
12
+ import fcntl
13
+ import json
14
+ import math
15
+ import os
16
+ import shutil
17
+ import subprocess
18
+ import sys
19
+ import time
20
+ from pathlib import Path
21
+
22
+ H = Path(__file__).resolve().parent
23
+ G = H.parent
24
+ RUNS = G / os.environ.get("HB_GROOT_RUNS_NAME", "groot-runs-bmax")
25
+ NODE = int(os.environ["RANK"])
26
+ TASKS = sys.argv[1:] or ["b6", "a3", "a7", "a18"] # basket postponed (user plan 2026-11-10)
27
+ CANDIDATES = [320, 288, 256, 224, 192, 160, 128, 96, 64, 48, 32]
28
+ MAX_FRAC = 0.92
29
+ EPOCHS = 20
30
+ PORT_BASE = int(os.environ.get("HB_GROOT_PORT_BASE", "32500")) # probe PORT_BASE+i, production PORT_BASE+50+k
31
+ RUNS.mkdir(parents=True, exist_ok=True)
32
+ os.environ["HB_GROOT_RUNS"] = str(RUNS) # read by groot_node.sh
33
+ lock = (RUNS / f"chain-node-{NODE}.lock").open("a")
34
+ fcntl.flock(lock, fcntl.LOCK_EX | fcntl.LOCK_NB)
35
+
36
+
37
+ def log(msg):
38
+ line = f"{time.strftime('%Y-%m-%d %H:%M:%S')} node{NODE} {msg}"
39
+ print(line, flush=True)
40
+ with (RUNS / f"chain-node-{NODE}.log").open("a") as f:
41
+ f.write(line + "\n")
42
+
43
+
44
+ def run_phase(task, phase, bs, steps, save, port):
45
+ logs = RUNS / task / "logs"
46
+ exits = [logs / f"{phase}-node-{r}.exit" for r in range(4)]
47
+ if all(p.is_file() for p in exits):
48
+ return all(p.read_text().strip() == "0" for p in exits)
49
+ subprocess.run(["bash", str(H / "groot_node.sh"), task, phase, str(bs), str(steps), str(save), str(port)])
50
+ deadline = time.monotonic() + 600
51
+ while not all(p.is_file() for p in exits):
52
+ if time.monotonic() > deadline:
53
+ log(f"{task}/{phase}: timed out waiting for peer exit files")
54
+ return False
55
+ time.sleep(5)
56
+ ok = all(p.read_text().strip() == "0" for p in exits)
57
+ log(f"{task}/{phase}: bs={bs} steps={steps} -> {'OK' if ok else 'FAIL'}")
58
+ return ok
59
+
60
+
61
+ def peak_frac(task, phase):
62
+ """Max over ranks of peak reserved / total; None when no rank reported."""
63
+ fracs = []
64
+ for f in (RUNS / task / "logs").glob(f"peak-{phase}-rank*.json"):
65
+ try:
66
+ d = json.loads(f.read_text())
67
+ fracs.append(d["peak_reserved_gb"] / d["total_gb"])
68
+ except (ValueError, KeyError, OSError):
69
+ continue
70
+ return (max(fracs), len(fracs)) if fracs else (None, 0)
71
+
72
+
73
+ def probe_verdict(task, cand, port):
74
+ phase = f"probe-bs{cand}"
75
+ verdict = RUNS / task / "logs" / f"{phase}.verdict.json"
76
+ ok = run_phase(task, phase, cand, 4, 1000000, port)
77
+ if NODE == 0 and not verdict.is_file():
78
+ time.sleep(10) # let peak files from the other nodes become visible on NAS
79
+ frac, n = peak_frac(task, phase) if ok else (None, 0)
80
+ fits = bool(ok and frac is not None and frac <= MAX_FRAC)
81
+ verdict.write_text(json.dumps({"per_gpu_batch": cand, "ran_ok": ok, "peak_frac": frac, "ranks_reported": n,
82
+ "max_frac": MAX_FRAC, "fits": fits}) + "\n")
83
+ deadline = time.monotonic() + 600
84
+ while not verdict.is_file():
85
+ if time.monotonic() > deadline:
86
+ log(f"{task}/{phase}: no verdict from node 0")
87
+ return False
88
+ time.sleep(5)
89
+ v = json.loads(verdict.read_text())
90
+ log(f"{task}/{phase}: verdict {v}")
91
+ return v["fits"]
92
+
93
+
94
+ def prune_resume_state(out):
95
+ """Keep weights of every checkpoint but resume state (DeepSpeed optimizer shards, scheduler, RNG) only in the latest."""
96
+ ckpts = sorted((p for p in out.glob("checkpoint-*") if p.name.split("-")[-1].isdigit()),
97
+ key=lambda p: int(p.name.split("-")[-1]))
98
+ for c in ckpts[:-1]:
99
+ for p in list(c.glob("global_step*")) + list(c.glob("optimizer*.pt")) + list(c.glob("scheduler.pt")) \
100
+ + list(c.glob("rng_state*.pth")) + list(c.glob("latest")) + list(c.glob("zero_to_fp32.py")):
101
+ if p.is_dir():
102
+ shutil.rmtree(p, ignore_errors=True)
103
+ else:
104
+ p.unlink(missing_ok=True)
105
+ log(f"{c.name}: resume state dropped (weights kept)")
106
+
107
+
108
+ def batch_for(task):
109
+ layout = "h2" if task == "a18" else "g1"
110
+ decision = RUNS / f"batch-decision-{layout}.json"
111
+ if decision.is_file():
112
+ return json.loads(decision.read_text())["per_gpu_batch"]
113
+ for i, cand in enumerate(CANDIDATES):
114
+ if probe_verdict(task, cand, PORT_BASE + i + (20 if layout == "h2" else 0)):
115
+ if NODE == 0:
116
+ decision.write_text(json.dumps({"per_gpu_batch": cand, "global_batch": cand * 32, "probe_task": task,
117
+ "layout": layout, "candidates": CANDIDATES,
118
+ "max_frac": MAX_FRAC}) + "\n")
119
+ return cand
120
+ time.sleep(20)
121
+ log(f"{layout}: no batch size fit; stopping")
122
+ sys.exit(1)
123
+
124
+
125
+ for k, task in enumerate(TASKS):
126
+ bs = batch_for(task)
127
+ log(f"{task}: per-GPU batch {bs} (global {bs * 32})")
128
+ receipt = json.loads((G / "groot-data" / task / "hb-dataset-receipt.json").read_text())
129
+ steps = math.ceil(EPOCHS * receipt["frames"] / (bs * 32))
130
+ save = math.ceil(steps / 2)
131
+ if not run_phase(task, "production", bs, steps, save, PORT_BASE + 50 + k):
132
+ log(f"{task}: production failed; stopping chain")
133
+ sys.exit(1)
134
+ if NODE == 0:
135
+ prune_resume_state(RUNS / task / "production")
136
+ (RUNS / task / "production-complete.json").write_text(json.dumps(
137
+ {"task": task, "frames": receipt["frames"], "epochs": EPOCHS, "per_gpu_batch": bs,
138
+ "global_batch": bs * 32, "max_steps": steps, "save_steps": save}) + "\n")
139
+ log("all tasks done")
code/hb_groot/h2_body31_hand44_h16.py ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """A18 H2 (Sharpa hands) GR00T modality config, same protocol as the A18 Delta-flow run
2
+ (schema a18-h2-sharpa-body31-hand44-state78-chunk16-v1): cameras head+chest, state = 75 joints + projected
3
+ gravity, action = action.body_target (31) + action.hands (44), horizon 16, absolute targets."""
4
+ from gr00t.configs.data.embodiment_configs import register_modality_config
5
+ from gr00t.data.embodiment_tags import EmbodimentTag
6
+ from gr00t.data.types import ActionConfig, ActionFormat, ActionRepresentation, ActionType, ModalityConfig
7
+
8
+ h2_body31_hand44_h16 = {
9
+ "video": ModalityConfig(delta_indices=[0], modality_keys=["head", "chest"]),
10
+ "state": ModalityConfig(
11
+ delta_indices=[0],
12
+ modality_keys=["left_leg", "right_leg", "waist", "left_arm", "right_arm", "head", "left_hand", "right_hand",
13
+ "projected_gravity"],
14
+ ),
15
+ "action": ModalityConfig(
16
+ delta_indices=list(range(16)),
17
+ modality_keys=["body_target", "left_hand_target", "right_hand_target"],
18
+ action_configs=[ActionConfig(rep=ActionRepresentation.ABSOLUTE, type=ActionType.NON_EEF,
19
+ format=ActionFormat.DEFAULT) for _ in range(3)],
20
+ ),
21
+ "language": ModalityConfig(delta_indices=[0], modality_keys=["annotation.human.task_description"]),
22
+ }
23
+
24
+ register_modality_config(h2_body31_hand44_h16, embodiment_tag=EmbodimentTag.NEW_EMBODIMENT)
code/hb_groot/hb_aug_v2.py ADDED
@@ -0,0 +1,163 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Humanoid Benchmark data augmentation v2 (project CLAUDE.md), model-agnostic torch implementation.
2
+
3
+ augment(x, rng, obs_mask=None) takes x: float [T, V, 3, H, W] in [0, 1] (T frames, V cameras) and returns the
4
+ augmented tensor. Each call is one training sample: one of the 15 effects is chosen uniformly and its magnitude
5
+ is scaled by 1.5 around identity; the rest stay at x1. Colour is shared across cameras and time; geometry, light
6
+ patches and white balance are drawn per camera and fixed over time; sensor/optics effects (noise, gaussian blur,
7
+ JPEG, motion blur, sharpen, defocus) apply only to observation frames (obs_mask True).
8
+ Pixel-size parameters are defined at 224 px and scaled by H / 224.
9
+ perturb_joints(q, rng) applies the proprio spec: per-joint bias +-2 deg plus N(0, 0.25 deg) clipped at 3 sigma.
10
+ """
11
+ import io
12
+ import math
13
+
14
+ import numpy as np
15
+ import torch
16
+ import torch.nn.functional as F
17
+ from PIL import Image
18
+ from torchvision.transforms import InterpolationMode
19
+ from torchvision.transforms import functional as TF
20
+
21
+ EFFECTS = ("exposure", "contrast", "saturation", "hue", "gamma", "temperature", "rotation_crop", "noise",
22
+ "gaussian_blur", "jpeg", "motion_blur", "sharpen", "defocus", "light_shadow", "wb_channel")
23
+ CENTER = {"exposure": 0.0, "contrast": 1.0, "saturation": 1.0, "hue": 0.0, "gamma": 1.0, "temperature": 0.0}
24
+ RANGE = {"exposure": (-0.22, 0.22), "contrast": (0.88, 1.12), "saturation": (0.76, 1.24), "hue": (-0.015, 0.015),
25
+ "gamma": (0.89, 1.11), "temperature": (-0.066, 0.066)}
26
+ VERSION = "hb-aug-v2-20261109"
27
+
28
+
29
+ def sample(rng, views, height):
30
+ boost = EFFECTS[int(rng.integers(len(EFFECTS)))]
31
+
32
+ def k(name):
33
+ return 1.5 if boost == name else 1.0
34
+
35
+ px = height / 224.0
36
+ p = {"boost": boost}
37
+ for name, (a, b) in RANGE.items():
38
+ c = CENTER[name]
39
+ p[name] = float(rng.uniform(c + k(name) * (a - c), c + k(name) * (b - c)))
40
+ p["geometry"] = []
41
+ for _ in range(views):
42
+ angle = float(rng.uniform(-1.5 * k("rotation_crop"), 1.5 * k("rotation_crop")))
43
+ p["geometry"].append((angle, 1.0 + abs(angle) * 0.015 + float(rng.uniform(0, 0.02 * k("rotation_crop")))))
44
+ p["noise"] = 4.0 / 255.0 * k("noise") if rng.random() < 0.5 else 0.0
45
+ p["gaussian_blur"] = float(rng.uniform(0.25, 0.65)) * k("gaussian_blur") if rng.random() < 0.15 else 0.0
46
+ if rng.random() < 0.35:
47
+ lo = int(round(100 - k("jpeg") * 30))
48
+ hi = int(round(100 - k("jpeg") * 5))
49
+ p["jpeg"] = int(rng.integers(lo, hi + 1))
50
+ else:
51
+ p["jpeg"] = None
52
+ p["motion_blur"] = ((float(rng.uniform(3, 7)) * k("motion_blur") * px, float(rng.uniform(0, 180)))
53
+ if rng.random() < 0.15 else None)
54
+ p["sharpen"] = float(rng.uniform(0.2, 0.6)) * k("sharpen") if rng.random() < 0.15 else 0.0
55
+ p["defocus"] = float(rng.uniform(1, 2)) * k("defocus") * px if rng.random() < 0.10 else 0.0
56
+ if rng.random() < 0.30:
57
+ g = 0.30 * k("light_shadow")
58
+ p["light_shadow"] = [[(float(rng.uniform(0.1, 0.9)), float(rng.uniform(0.1, 0.9)),
59
+ float(rng.uniform(0.15, 0.35)), float(rng.uniform(1 - g, 1 + g)))
60
+ for _ in range(int(rng.integers(1, 3)))] for _ in range(views)]
61
+ else:
62
+ p["light_shadow"] = None
63
+ if rng.random() < 0.30:
64
+ g = 0.10 * k("wb_channel")
65
+ gains = []
66
+ for _ in range(views):
67
+ row = [1.0, 1.0, 1.0]
68
+ row[int(rng.integers(0, 3))] = float(rng.uniform(1 - g, 1 + g))
69
+ gains.append(row)
70
+ p["wb_channel"] = gains
71
+ else:
72
+ p["wb_channel"] = None
73
+ return p
74
+
75
+
76
+ def _conv(x, kernel):
77
+ n, c, h, w = x.shape
78
+ k = kernel.to(x)[None, None].repeat(c, 1, 1, 1)
79
+ pad = kernel.shape[-1] // 2
80
+ return F.conv2d(F.pad(x, (pad, pad, pad, pad), mode="reflect"), k, groups=c)
81
+
82
+
83
+ def motion_kernel(length, angle_deg):
84
+ size = max(3, int(round(length)) | 1)
85
+ k = torch.zeros(size, size)
86
+ c = size // 2
87
+ th = math.radians(angle_deg)
88
+ for s in np.linspace(-(length - 1) / 2, (length - 1) / 2, 8 * size):
89
+ k[int(round(c - s * math.sin(th))), int(round(c + s * math.cos(th)))] = 1.0
90
+ return k / k.sum()
91
+
92
+
93
+ def disk_kernel(r):
94
+ size = 2 * int(math.ceil(r)) + 1
95
+ c = size // 2
96
+ yy, xx = torch.meshgrid(torch.arange(size), torch.arange(size), indexing="ij")
97
+ k = (((yy - c) ** 2 + (xx - c) ** 2) <= (r + 0.5) ** 2).float()
98
+ return k / k.sum()
99
+
100
+
101
+ def apply(x, p, obs_mask=None, noise_seed=0):
102
+ t, v, c, h, w = x.shape
103
+ x = x.clone().clamp(0, 1)
104
+ for vi, (angle, scale) in enumerate(p["geometry"]):
105
+ x[:, vi] = TF.affine(x[:, vi], angle=angle, translate=[0, 0], scale=scale, shear=[0, 0],
106
+ interpolation=InterpolationMode.BILINEAR)
107
+ if p["light_shadow"] is not None:
108
+ yy, xx = torch.meshgrid(torch.linspace(0, 1, h), torch.linspace(0, 1, w), indexing="ij")
109
+ for vi, blobs in enumerate(p["light_shadow"]):
110
+ m = torch.ones(h, w)
111
+ for cx, cy, s, g in blobs:
112
+ m = m + (g - 1.0) * torch.exp(-((xx - cx) ** 2 + (yy - cy) ** 2) / (2 * s * s))
113
+ x[:, vi] = (x[:, vi] * m.clamp(min=0).to(x)).clamp(0, 1)
114
+ if p["wb_channel"] is not None:
115
+ for vi, g in enumerate(p["wb_channel"]):
116
+ x[:, vi] = (x[:, vi] * torch.tensor(g, dtype=x.dtype).view(1, 3, 1, 1)).clamp(0, 1)
117
+ y = x.reshape(t * v, c, h, w)
118
+ y = (y * float(2.0 ** p["exposure"])).clamp(0, 1)
119
+ d = p["temperature"]
120
+ y = (y * y.new_tensor([1.0 + d, 1.0, 1.0 - d]).view(1, 3, 1, 1)).clamp(0, 1)
121
+ y = ((y - 0.5) * p["contrast"] + 0.5).clamp(0, 1)
122
+ y = TF.adjust_saturation(y, p["saturation"])
123
+ y = TF.adjust_hue(y, p["hue"])
124
+ y = y.clamp(0, 1).pow(p["gamma"])
125
+ x = y.reshape(t, v, c, h, w)
126
+ mask = torch.ones(t, dtype=torch.bool) if obs_mask is None else torch.as_tensor(obs_mask, dtype=torch.bool)
127
+ if bool(mask.any()):
128
+ o = x[mask].reshape(-1, c, h, w)
129
+ if p["gaussian_blur"] > 0:
130
+ o = TF.gaussian_blur(o, [3, 3], [p["gaussian_blur"]] * 2)
131
+ if p["motion_blur"] is not None:
132
+ o = _conv(o, motion_kernel(*p["motion_blur"]))
133
+ if p["defocus"] > 0:
134
+ o = _conv(o, disk_kernel(p["defocus"]))
135
+ if p["sharpen"] > 0:
136
+ o = o + p["sharpen"] * (o - TF.gaussian_blur(o, [5, 5], [1.0, 1.0]))
137
+ o = o.clamp(0, 1)
138
+ if p["noise"] > 0:
139
+ gen = torch.Generator().manual_seed(int(noise_seed))
140
+ o = (o + torch.randn(o.shape, generator=gen, dtype=o.dtype) * p["noise"]).clamp(0, 1)
141
+ if p["jpeg"] is not None:
142
+ for i in range(o.shape[0]):
143
+ buf = io.BytesIO()
144
+ TF.to_pil_image(o[i]).save(buf, format="JPEG", quality=int(p["jpeg"]))
145
+ buf.seek(0)
146
+ with Image.open(buf) as im:
147
+ o[i] = TF.pil_to_tensor(im.convert("RGB")).to(o.dtype).div(255.0)
148
+ x[mask] = o.reshape(-1, v, c, h, w)
149
+ return x.clamp(0, 1)
150
+
151
+
152
+ def augment(x, rng, obs_mask=None):
153
+ p = sample(rng, x.shape[1], x.shape[-2])
154
+ return apply(x, p, obs_mask, noise_seed=int(rng.integers(0, 2 ** 62))), p
155
+
156
+
157
+ def perturb_joints(q, rng):
158
+ q = np.asarray(q, dtype=np.float64)
159
+ d = q.shape[-1]
160
+ bias = rng.uniform(-math.radians(2.0), math.radians(2.0), size=d)
161
+ sigma = math.radians(0.25)
162
+ noise = np.clip(rng.normal(0.0, sigma, size=q.shape), -3 * sigma, 3 * sigma)
163
+ return (q + bias + noise).astype(np.float32)
code/hb_groot/hb_launch.py ADDED
@@ -0,0 +1,92 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """GR00T N1.7 fine-tuning entry with Humanoid Benchmark augmentation v2.
2
+
3
+ Patches Gr00tN1d7Processor in training mode only:
4
+ - images: native random crop / colour jitter / rotation are bypassed (the deterministic eval resize+center-crop is
5
+ used), then hb_aug_v2 is applied jointly to all cameras of the sample;
6
+ - proprio: the body-joint state groups (HB_BODY_STATE_KEYS) get the v2 bias + noise before normalization.
7
+ Then runs the pinned upstream gr00t/experiment/launch_finetune.py unchanged.
8
+ """
9
+ import json
10
+ import os
11
+ import runpy
12
+ import sys
13
+ from pathlib import Path
14
+
15
+ import numpy as np
16
+ import torch
17
+
18
+ HERE = Path(__file__).resolve().parent
19
+ sys.path.insert(0, str(HERE))
20
+ import hb_offline_fix # noqa: E402,F401 (tokenizer load under HF_HUB_OFFLINE=1, see module docstring)
21
+ import hb_aug_v2 as A # noqa: E402
22
+ from gr00t.model.gr00t_n1d7 import processing_gr00t_n1d7 as P # noqa: E402
23
+
24
+ Proc = P.Gr00tN1d7Processor
25
+ BODY_KEYS = [k for k in os.environ.get("HB_BODY_STATE_KEYS", "left_leg,right_leg,waist,left_arm,right_arm").split(",") if k]
26
+ LOG = os.environ.get("HB_AUG_LOG")
27
+ _state = {"rng": None, "count": 0}
28
+
29
+
30
+ def _rng():
31
+ if _state["rng"] is None:
32
+ _state["rng"] = np.random.default_rng([os.getpid(), int.from_bytes(os.urandom(8), "little")])
33
+ return _state["rng"]
34
+
35
+
36
+ _orig_get, _orig_apply, _orig_call = Proc._get_vlm_inputs, Proc._apply_vlm_processing, Proc.__call__
37
+
38
+
39
+ def _get_vlm_inputs(self, image_keys, images, masks, image_transform, language):
40
+ if getattr(self, "training", False):
41
+ self._hb_views = len(image_keys)
42
+ try:
43
+ return _orig_get(self, image_keys, images, masks, self.eval_image_transform, language)
44
+ finally:
45
+ self._hb_views = None
46
+ return _orig_get(self, image_keys, images, masks, image_transform, language)
47
+
48
+
49
+ def _apply_vlm_processing(self, images, language):
50
+ views = getattr(self, "_hb_views", None)
51
+ if views and isinstance(images, torch.Tensor):
52
+ shape = images.shape
53
+ x = images.reshape(-1, views, *shape[1:]).float().div(255.0)
54
+ x, p = A.augment(x, _rng())
55
+ images = (x * 255.0 + 0.5).clamp(0, 255).to(torch.uint8).reshape(shape)
56
+ _state["count"] += 1
57
+ if LOG and _state["count"] in (1, 50):
58
+ with open(f"{LOG}.{os.getpid()}", "a") as f:
59
+ f.write(json.dumps({"count": _state["count"], "views": views, "hw": list(shape[-2:]),
60
+ "boost": p["boost"], "version": A.VERSION}) + "\n")
61
+ return _orig_apply(self, images, language)
62
+
63
+
64
+ def _call(self, messages):
65
+ if getattr(self, "training", False) and BODY_KEYS:
66
+ states = messages[0]["content"].states
67
+ for key in BODY_KEYS:
68
+ if key in states:
69
+ states[key] = A.perturb_joints(states[key], _rng())
70
+ return _orig_call(self, messages)
71
+
72
+
73
+ Proc._get_vlm_inputs = _get_vlm_inputs
74
+ Proc._apply_vlm_processing = _apply_vlm_processing
75
+ Proc.__call__ = _call
76
+
77
+ if os.environ.get("HB_PATCH_ONLY") != "1":
78
+ entry = Path(os.environ["GROOT_SRC"]) / "gr00t/experiment/launch_finetune.py"
79
+ sys.argv = [str(entry)] + sys.argv[1:]
80
+ try:
81
+ runpy.run_path(str(entry), run_name="__main__")
82
+ finally: # batch probe: report this rank's peak reserved memory (groot_chain.py compares it with MAX_FRAC)
83
+ _peak = os.environ.get("HB_PEAK_FILE")
84
+ if _peak and torch.cuda.is_available():
85
+ try:
86
+ _dev = torch.cuda.current_device()
87
+ with open(f"{_peak}-rank{os.environ.get('RANK', '0')}.json", "w") as _f:
88
+ json.dump({"rank": int(os.environ.get("RANK", "0")),
89
+ "peak_reserved_gb": torch.cuda.max_memory_reserved(_dev) / 1e9,
90
+ "total_gb": torch.cuda.get_device_properties(_dev).total_memory / 1e9}, _f)
91
+ except Exception: # noqa: BLE001 - never mask the training result
92
+ pass
code/hb_groot/hb_offline_fix.py ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Make tokenizer loading work with HF_HUB_OFFLINE=1 on transformers 4.57.x.
2
+
3
+ PreTrainedTokenizerBase._patch_mistral_regex calls huggingface_hub.model_info() for every hub-named tokenizer with a
4
+ vocab > 100k (to detect Mistral base models). With HF_HUB_OFFLINE=1 that raises OfflineModeIsEnabled even though all
5
+ files are in the cache. GR00T's Cosmos-Reason2-2B / Qwen3-VL tokenizer is not a Mistral tokenizer, so when offline the
6
+ check is skipped and the tokenizer is returned unchanged. Online behaviour is untouched.
7
+ """
8
+ import os
9
+
10
+ from transformers.tokenization_utils_base import PreTrainedTokenizerBase as _PTB
11
+
12
+ if not getattr(_PTB, "_hb_offline_fix", False):
13
+ _orig = _PTB._patch_mistral_regex.__func__
14
+
15
+ def _patch_mistral_regex(cls, tokenizer, *args, **kwargs):
16
+ try:
17
+ return _orig(cls, tokenizer, *args, **kwargs)
18
+ except Exception as error:
19
+ if os.environ.get("HF_HUB_OFFLINE") == "1" or type(error).__name__ == "OfflineModeIsEnabled":
20
+ return tokenizer
21
+ raise
22
+
23
+ _PTB._patch_mistral_regex = classmethod(_patch_mistral_regex)
24
+ _PTB._hb_offline_fix = True
code/hb_groot/prepare_groot_data.py ADDED
@@ -0,0 +1,155 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Build GR00T dataset views (symlinked episodes + rewritten meta + stats) for the G1 tasks.
2
+
3
+ Usage: <groot python> prepare_groot_data.py <task> [<task> ...] (tasks: b6 basket a3 a7)
4
+ B6 always uses the fixed first 100 episodes (0-99) of b6-v5t7-ready-start-20261109.
5
+ """
6
+ import hashlib
7
+ import json
8
+ import os
9
+ import subprocess
10
+ import sys
11
+ from pathlib import Path
12
+
13
+ H = Path(__file__).resolve().parent
14
+ G = H.parent
15
+ P = G.parent
16
+ OUT = G / "groot-data"
17
+ TASKS = {
18
+ "b6": (P / "b6-v5t7-ready-start-60ep-20261109/data/deliveries/g1/b6-v5t7-ready-start-20261109", 100),
19
+ "basket": (P / "g1-basket-transfer-ed77719-40epochs/dataset", None),
20
+ "trolley": (P / "trolley-push-expert-v1-20261110/data/trolley_push", 100), # HF trolley-push-expert-v1 @ef9024a: fixed first 100 of 103
21
+ "a3": (P / "a3-a7-20261109/a3-fridge-open-expert-v1/780fcf1e4bd7db947a8c2d8f7b92e61f24f71b45", None),
22
+ "a7": (P / "a3-a7-20261109/a7-cabinet-close-expert-v1/1935a98e8f55d4d1d2d1615ddb97c2679713595c", None),
23
+ "a18": (P / "a18-h2-dataset-audit-8e956a10/dataset", None),
24
+ }
25
+ CONFIG = {"a18": "h2_body31_hand44_h16.py"}
26
+ H2_GROUPS = {"left_leg": (0, 6), "right_leg": (6, 12), "waist": (12, 15), "left_arm": (15, 22), "right_arm": (22, 29),
27
+ "head": (29, 31), "left_hand": (31, 53), "right_hand": (53, 75)}
28
+
29
+
30
+ def h2_modality(info):
31
+ f = info["features"]
32
+ names = f["observation.state"]["names"]
33
+ assert len(names) == 75 and names[:31] == f["action.body_target"]["names"] and names[31:] == f["action.hands"]["names"]
34
+ assert f["observation.projected_gravity"]["shape"] == [3]
35
+ state = {g: {"original_key": "observation.state", "start": a, "end": b} for g, (a, b) in H2_GROUPS.items()}
36
+ state["projected_gravity"] = {"original_key": "observation.projected_gravity", "start": 0, "end": 3}
37
+ return {"state": state,
38
+ "action": {"body_target": {"original_key": "action.body_target", "start": 0, "end": 31},
39
+ "left_hand_target": {"original_key": "action.hands", "start": 0, "end": 22},
40
+ "right_hand_target": {"original_key": "action.hands", "start": 22, "end": 44}},
41
+ "video": {"head": {"original_key": "observation.images.head"},
42
+ "chest": {"original_key": "observation.images.chest"}},
43
+ "annotation": {"human.task_description": {"original_key": "task_index"}}}
44
+ BODY = ["left_hip_pitch_joint", "left_hip_roll_joint", "left_hip_yaw_joint", "left_knee_joint", "left_ankle_pitch_joint",
45
+ "left_ankle_roll_joint", "right_hip_pitch_joint", "right_hip_roll_joint", "right_hip_yaw_joint",
46
+ "right_knee_joint", "right_ankle_pitch_joint", "right_ankle_roll_joint", "waist_yaw_joint", "waist_roll_joint",
47
+ "waist_pitch_joint", "left_shoulder_pitch_joint", "left_shoulder_roll_joint", "left_shoulder_yaw_joint",
48
+ "left_elbow_joint", "left_wrist_roll_joint", "left_wrist_pitch_joint", "left_wrist_yaw_joint",
49
+ "right_shoulder_pitch_joint", "right_shoulder_roll_joint", "right_shoulder_yaw_joint", "right_elbow_joint",
50
+ "right_wrist_roll_joint", "right_wrist_pitch_joint", "right_wrist_yaw_joint"]
51
+ GROUPS = {"left_leg": (0, 6), "right_leg": (6, 12), "waist": (12, 15), "left_arm": (15, 22), "right_arm": (22, 29)}
52
+
53
+
54
+ def jl(path):
55
+ return [json.loads(x) for x in Path(path).read_text().splitlines() if x.strip()]
56
+
57
+
58
+ def wl(path, rows):
59
+ Path(path).write_text("".join(json.dumps(r) + "\n" for r in rows))
60
+
61
+
62
+ def build(task):
63
+ src, limit = TASKS[task]
64
+ info = json.loads((src / "meta/info.json").read_text())
65
+ names = info["features"]["observation.state"]["names"]
66
+ if task in CONFIG:
67
+ idx = list(range(31))
68
+ else:
69
+ idx = [names.index(n) for n in BODY]
70
+ for g, (a, b) in GROUPS.items():
71
+ assert idx[a:b] == list(range(idx[a], idx[a] + (b - a))), (task, g, idx[a:b])
72
+ for key, dim in (("action.motion_token", 64), ("observation.inspire_left_hand_state", 6),
73
+ ("observation.inspire_right_hand_state", 6), ("observation.projected_gravity", 3),
74
+ ("observation.images.ego_view", None), ("observation.images.chest", None)):
75
+ assert key in info["features"], (task, key)
76
+ if dim:
77
+ assert info["features"][key]["shape"] == [dim], (task, key)
78
+ episodes = jl(src / "meta/episodes.jsonl")
79
+ stats = jl(src / "meta/episodes_stats.jsonl")
80
+ n = len(episodes) if limit is None else limit
81
+ episodes, stats = episodes[:n], stats[:n]
82
+ assert [e["episode_index"] for e in episodes] == list(range(n)) == [s["episode_index"] for s in stats]
83
+ frames = sum(int(e["length"]) for e in episodes)
84
+ dst = OUT / task
85
+ if dst.exists():
86
+ raise SystemExit(f"{dst} exists")
87
+ (dst / "meta").mkdir(parents=True)
88
+ vkeys = [k for k, f in info["features"].items() if f.get("dtype") == "video"]
89
+ for e in episodes:
90
+ i = e["episode_index"]
91
+ chunk = i // int(info["chunks_size"])
92
+ rel = info["data_path"].format(episode_chunk=chunk, episode_index=i)
93
+ (dst / rel).parent.mkdir(parents=True, exist_ok=True)
94
+ os.symlink(src / rel, dst / rel)
95
+ for k in vkeys:
96
+ relv = info["video_path"].format(episode_chunk=chunk, video_key=k, episode_index=i)
97
+ (dst / relv).parent.mkdir(parents=True, exist_ok=True)
98
+ os.symlink(src / relv, dst / relv)
99
+ if task in CONFIG:
100
+ # stats.py computes stats for every low-dim feature in info.json and cannot handle e.g. observation.tactile
101
+ # [10,24,24]; keep only what the H2 modality uses (parquet columns stay untouched behind the symlinks).
102
+ keep = {"observation.state", "observation.projected_gravity", "action.body_target", "action.hands",
103
+ "observation.images.head", "observation.images.chest", "timestamp", "frame_index", "episode_index",
104
+ "index", "task_index"}
105
+ info["features"] = {k: v for k, v in info["features"].items() if k in keep}
106
+ vkeys = [k for k in vkeys if k in keep]
107
+ stats = [{**s, "stats": {k: v for k, v in s["stats"].items() if k in keep}} if "stats" in s else s
108
+ for s in stats]
109
+ info.update(total_episodes=n, total_frames=frames, total_videos=n * len(vkeys),
110
+ total_chunks=(n - 1) // int(info["chunks_size"]) + 1, splits={"train": f"0:{n}"})
111
+ (dst / "meta/info.json").write_text(json.dumps(info, indent=2))
112
+ wl(dst / "meta/episodes.jsonl", episodes)
113
+ wl(dst / "meta/episodes_stats.jsonl", stats)
114
+ (dst / "meta/tasks.jsonl").write_text((src / "meta/tasks.jsonl").read_text())
115
+ if task in CONFIG:
116
+ modality = h2_modality(info)
117
+ else:
118
+ state = {g: {"original_key": "observation.state", "start": idx[a], "end": idx[a] + (b - a)}
119
+ for g, (a, b) in GROUPS.items()}
120
+ state.update(left_hand={"original_key": "observation.inspire_left_hand_state", "start": 0, "end": 6},
121
+ right_hand={"original_key": "observation.inspire_right_hand_state", "start": 0, "end": 6},
122
+ projected_gravity={"original_key": "observation.projected_gravity", "start": 0, "end": 3})
123
+ modality = {"state": state,
124
+ "action": {"motion_token": {"original_key": "action.motion_token", "start": 0, "end": 64},
125
+ "left_hand_joints": {"original_key": "observation.inspire_left_hand_state", "start": 0, "end": 6},
126
+ "right_hand_joints": {"original_key": "observation.inspire_right_hand_state", "start": 0, "end": 6}},
127
+ "video": {"ego_view": {"original_key": "observation.images.ego_view"},
128
+ "chest": {"original_key": "observation.images.chest"}},
129
+ "annotation": {"human.task_description": {"original_key": "task_index"}}}
130
+ (dst / "meta/modality.json").write_text(json.dumps(modality, indent=2))
131
+ py = sys.executable
132
+ src_g = G / "HumanWAM/third_party/Isaac-GR00T"
133
+ env = dict(os.environ, PYTHONPATH=f"{src_g}:{H}")
134
+ done = None
135
+ for tag in ("NEW_EMBODIMENT", "new_embodiment"):
136
+ r = subprocess.run([py, str(src_g / "gr00t/data/stats.py"), "--dataset-path", str(dst), "--embodiment-tag", tag,
137
+ "--modality-config-path", str(H / CONFIG.get(task, "g1_feedback76_h16.py"))], env=env, cwd=src_g,
138
+ capture_output=True, text=True)
139
+ if r.returncode == 0:
140
+ done = tag
141
+ break
142
+ last = r.stdout[-1500:] + r.stderr[-1500:]
143
+ if done is None:
144
+ raise SystemExit(f"stats failed for {task}:\n{last}")
145
+ assert (dst / "meta/stats.json").is_file()
146
+ receipt = dict(task=task, source=str(src), episodes=n, frames=frames, video_keys=vkeys,
147
+ state_dim_raw=len(names), body_index=idx, stats_tag=done,
148
+ modality_sha256=hashlib.sha256((dst / "meta/modality.json").read_bytes()).hexdigest(),
149
+ stats_sha256=hashlib.sha256((dst / "meta/stats.json").read_bytes()).hexdigest())
150
+ (dst / "hb-dataset-receipt.json").write_text(json.dumps(receipt, indent=2) + "\n")
151
+ print("DATASET_OK", json.dumps(receipt)[:400], flush=True)
152
+
153
+
154
+ for t in sys.argv[1:]:
155
+ build(t)
code/hb_groot/verify_groot_cpu.py ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """CPU check of the GR00T data path for one task view: loader shapes, v2 augmentation, processor patch import."""
2
+ import json
3
+ import os
4
+ import sys
5
+ from pathlib import Path
6
+
7
+ import numpy as np
8
+ import torch
9
+
10
+ H = Path(__file__).resolve().parent
11
+ sys.path.insert(0, str(H))
12
+ os.environ["HB_PATCH_ONLY"] = "1"
13
+ import hb_launch # noqa: E402,F401 (applies the processor patch)
14
+ import hb_aug_v2 as A # noqa: E402
15
+ from gr00t.data.dataset.lerobot_episode_loader import LeRobotEpisodeLoader # noqa: E402
16
+ from gr00t.model.gr00t_n1d7.processing_gr00t_n1d7 import Gr00tN1d7Processor # noqa: E402
17
+
18
+ view = Path(sys.argv[1])
19
+ if view.name == "a18":
20
+ import h2_body31_hand44_h16 as C # noqa: E402
21
+ cfg = C.h2_body31_hand44_h16
22
+ else:
23
+ import g1_feedback76_h16 as C # noqa: E402
24
+ cfg = C.feedback76_h16
25
+ loader = LeRobotEpisodeLoader(view, cfg)
26
+ df = loader[0]
27
+ cols = list(df.columns)
28
+ row = df.iloc[20]
29
+ out = {"episodes": len(loader), "columns": cols[:40], "rows_ep0": len(df)}
30
+ state_dims = {c: int(np.asarray(row[c]).size) for c in cols if c.startswith("state.")}
31
+ action_dims = {c: int(np.asarray(row[c]).size) for c in cols if c.startswith("action.")}
32
+ out.update(state_dims=state_dims, action_dims=action_dims, state_total=sum(state_dims.values()),
33
+ action_total=sum(action_dims.values()))
34
+ vids = [c for c in cols if c.startswith("video.")]
35
+ imgs = [np.asarray(row[c]) for c in vids]
36
+ out["video"] = {c: list(i.shape) for c, i in zip(vids, imgs)}
37
+ x = torch.stack([torch.from_numpy(i).permute(2, 0, 1).float().div(255) for i in imgs])[None]
38
+ rng = np.random.default_rng(0)
39
+ boosts = {}
40
+ for _ in range(60):
41
+ y, p = A.augment(x, rng)
42
+ boosts[p["boost"]] = boosts.get(p["boost"], 0) + 1
43
+ assert y.shape == x.shape and torch.isfinite(y).all() and float(y.min()) >= 0 and float(y.max()) <= 1
44
+ out["aug_boost_counts_60"] = boosts
45
+ out["mean_abs_change_last"] = round(float((y - x).abs().mean()), 4)
46
+ q = np.zeros((1, 29))
47
+ dq = A.perturb_joints(q, rng)
48
+ out["proprio_max_abs_deg"] = round(float(np.degrees(np.abs(dq).max())), 3)
49
+ out["patched"] = Gr00tN1d7Processor._get_vlm_inputs.__name__ == "_get_vlm_inputs" and \
50
+ Gr00tN1d7Processor.__call__.__module__ == "hb_launch"
51
+ print("CPU_VERIFY", json.dumps(out), flush=True)