BIue-Jay commited on
Commit
25e5f1e
·
verified ·
1 Parent(s): d7f1dc6

fm_dit b8-table-wipe/b512-cont-20261117-stop50k: steps [46000, 50000] (MLP flash30k, mlp1)

Browse files
Files changed (34) hide show
  1. b8-table-wipe/b512-cont-20261117-stop50k/step-046000/SHA256SUMS +3 -0
  2. b8-table-wipe/b512-cont-20261117-stop50k/step-046000/config.json +1002 -0
  3. b8-table-wipe/b512-cont-20261117-stop50k/step-046000/model.pt +3 -0
  4. b8-table-wipe/b512-cont-20261117-stop50k/step-046000/protocol.json +331 -0
  5. b8-table-wipe/b512-cont-20261117-stop50k/step-050000/SHA256SUMS +29 -0
  6. b8-table-wipe/b512-cont-20261117-stop50k/step-050000/config.json +1002 -0
  7. b8-table-wipe/b512-cont-20261117-stop50k/step-050000/model.pt +3 -0
  8. b8-table-wipe/b512-cont-20261117-stop50k/step-050000/protocol.json +435 -0
  9. b8-table-wipe/b512-cont-20261117-stop50k/step-050000/training_records/code_hb_bai_433ba198_stopat39f9b83a/HB_CODE_COMMIT +2 -0
  10. b8-table-wipe/b512-cont-20261117-stop50k/step-050000/training_records/code_hb_bai_433ba198_stopat39f9b83a/evaluation/augmentation/hb_aug_v2.py +163 -0
  11. b8-table-wipe/b512-cont-20261117-stop50k/step-050000/training_records/code_hb_bai_433ba198_stopat39f9b83a/evaluation/baselines/__init__.py +13 -0
  12. b8-table-wipe/b512-cont-20261117-stop50k/step-050000/training_records/code_hb_bai_433ba198_stopat39f9b83a/evaluation/baselines/act_nets.py +615 -0
  13. b8-table-wipe/b512-cont-20261117-stop50k/step-050000/training_records/code_hb_bai_433ba198_stopat39f9b83a/evaluation/baselines/adapters.py +58 -0
  14. b8-table-wipe/b512-cont-20261117-stop50k/step-050000/training_records/code_hb_bai_433ba198_stopat39f9b83a/evaluation/baselines/check_flash_adapter.py +114 -0
  15. b8-table-wipe/b512-cont-20261117-stop50k/step-050000/training_records/code_hb_bai_433ba198_stopat39f9b83a/evaluation/baselines/check_flash_parity.py +141 -0
  16. b8-table-wipe/b512-cont-20261117-stop50k/step-050000/training_records/code_hb_bai_433ba198_stopat39f9b83a/evaluation/baselines/data.py +446 -0
  17. b8-table-wipe/b512-cont-20261117-stop50k/step-050000/training_records/code_hb_bai_433ba198_stopat39f9b83a/evaluation/baselines/flash.py +412 -0
  18. b8-table-wipe/b512-cont-20261117-stop50k/step-050000/training_records/code_hb_bai_433ba198_stopat39f9b83a/evaluation/baselines/fm_dit_v2.py +99 -0
  19. b8-table-wipe/b512-cont-20261117-stop50k/step-050000/training_records/code_hb_bai_433ba198_stopat39f9b83a/evaluation/baselines/inloop.py +117 -0
  20. b8-table-wipe/b512-cont-20261117-stop50k/step-050000/training_records/code_hb_bai_433ba198_stopat39f9b83a/evaluation/baselines/nets.py +212 -0
  21. b8-table-wipe/b512-cont-20261117-stop50k/step-050000/training_records/code_hb_bai_433ba198_stopat39f9b83a/evaluation/baselines/ode_nets.py +181 -0
  22. b8-table-wipe/b512-cont-20261117-stop50k/step-050000/training_records/code_hb_bai_433ba198_stopat39f9b83a/evaluation/baselines/policies.py +459 -0
  23. b8-table-wipe/b512-cont-20261117-stop50k/step-050000/training_records/code_hb_bai_433ba198_stopat39f9b83a/evaluation/baselines/requirements.lock.txt +61 -0
  24. b8-table-wipe/b512-cont-20261117-stop50k/step-050000/training_records/code_hb_bai_433ba198_stopat39f9b83a/evaluation/baselines/requirements.txt +15 -0
  25. b8-table-wipe/b512-cont-20261117-stop50k/step-050000/training_records/code_hb_bai_433ba198_stopat39f9b83a/evaluation/baselines/runtime.py +179 -0
  26. b8-table-wipe/b512-cont-20261117-stop50k/step-050000/training_records/code_hb_bai_433ba198_stopat39f9b83a/evaluation/baselines/train.py +974 -0
  27. b8-table-wipe/b512-cont-20261117-stop50k/step-050000/training_records/launch.sh +21 -0
  28. b8-table-wipe/b512-cont-20261117-stop50k/step-050000/training_records/logs/inloop-mse.jsonl +0 -0
  29. b8-table-wipe/b512-cont-20261117-stop50k/step-050000/training_records/pip_freeze_hb-baselines.txt +0 -0
  30. b8-table-wipe/b512-cont-20261117-stop50k/step-050000/training_records/run.json +1036 -0
  31. b8-table-wipe/b512-cont-20261117-stop50k/step-050000/training_records/stopat_39f9b83a_train.diff +84 -0
  32. b8-table-wipe/b512-cont-20261117-stop50k/step-050000/training_records/stopped.json +13 -0
  33. b8-table-wipe/b512-cont-20261117-stop50k/step-050000/training_records/train.log +0 -0
  34. b8-table-wipe/b512-cont-20261117-stop50k/step-050000/training_records/train_log.jsonl +0 -0
b8-table-wipe/b512-cont-20261117-stop50k/step-046000/SHA256SUMS ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ e80e17d1297cad0eb805adb6c8b79f9f469e55723bebc5a4763754d02285a073 config.json
2
+ 615a1ffb029281707c318e423eab4b1340d132ee9e2bb5ed7215e34e7de0d268 model.pt
3
+ e65406b30388bbd58e83f618408243eaaa5caa4842c1f6fd8d62727f8c06d7f0 protocol.json
b8-table-wipe/b512-cont-20261117-stop50k/step-046000/config.json ADDED
@@ -0,0 +1,1002 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "policy": {
3
+ "policy": "fm_dit",
4
+ "n_cameras": 2,
5
+ "state_dim": 44,
6
+ "action_dim": 76,
7
+ "horizon": 16,
8
+ "backbone": "resnet18",
9
+ "backbone_weights": "IMAGENET1K_V1",
10
+ "backbone_norm": "frozen_bn",
11
+ "hidden_dim": 384,
12
+ "num_layers": 4,
13
+ "num_heads": 8,
14
+ "mlp_ratio": 4.0,
15
+ "dropout": 0.1,
16
+ "time_embed_dim": 128,
17
+ "num_inference_steps": null,
18
+ "num_train_timesteps": 100,
19
+ "beta_schedule": "squaredcos_cap_v2",
20
+ "prediction_type": "epsilon",
21
+ "clip_sample": true,
22
+ "act_hidden_dim": 512,
23
+ "dim_feedforward": 3200,
24
+ "enc_layers": 4,
25
+ "dec_layers": 7,
26
+ "nheads": 8,
27
+ "latent_dim": 32,
28
+ "kl_weight": 10.0,
29
+ "ode_body_dim": null,
30
+ "ode_width": 512,
31
+ "ode_layers": 4,
32
+ "ode_cond_dim": 512,
33
+ "ode_field_scale": 1.0,
34
+ "ode_dit_hidden": 512,
35
+ "ode_dit_layers": 4,
36
+ "ode_dit_heads": 8,
37
+ "ode_dit_tokens": 4,
38
+ "extra": {}
39
+ },
40
+ "contract": {
41
+ "name": "g1_sonic_cmd",
42
+ "robot": "g1",
43
+ "cameras": [
44
+ "ego_view",
45
+ "chest"
46
+ ],
47
+ "state": [
48
+ [
49
+ "observation.state",
50
+ 0,
51
+ 29
52
+ ],
53
+ [
54
+ "observation.inspire_left_hand_state",
55
+ 0,
56
+ 6
57
+ ],
58
+ [
59
+ "observation.inspire_right_hand_state",
60
+ 0,
61
+ 6
62
+ ],
63
+ [
64
+ "observation.projected_gravity",
65
+ 0,
66
+ 3
67
+ ]
68
+ ],
69
+ "action": [
70
+ [
71
+ "action.motion_token",
72
+ 0,
73
+ 64
74
+ ],
75
+ [
76
+ "teleop.inspire_left_hand_cmd",
77
+ 0,
78
+ 6
79
+ ],
80
+ [
81
+ "teleop.inspire_right_hand_cmd",
82
+ 0,
83
+ 6
84
+ ]
85
+ ],
86
+ "state_dim": 44,
87
+ "action_dim": 76,
88
+ "action_space": "sonic_dfx6",
89
+ "body_dims": 29,
90
+ "history": [
91
+ [
92
+ "action.motion_token",
93
+ 0,
94
+ 64
95
+ ],
96
+ [
97
+ "observation.inspire_left_hand_state",
98
+ 0,
99
+ 6
100
+ ],
101
+ [
102
+ "observation.inspire_right_hand_state",
103
+ 0,
104
+ 6
105
+ ]
106
+ ]
107
+ },
108
+ "image_hw": [
109
+ 168,
110
+ 224
111
+ ],
112
+ "task_text": "Approach the flat block with a naturally aligned wrist, stop before closing the hand, wipe sideways at a top-view 45-degree heading, then set the block on the tabletop and release it.",
113
+ "dataset": {
114
+ "name": "b8-table-wipe-expert-v1-3b2e6180",
115
+ "root": "/root/hb_data/b8-table-wipe-expert-v1-3b2e6180",
116
+ "robot_type": null,
117
+ "fps": 30.0,
118
+ "episodes": [
119
+ 0,
120
+ 1,
121
+ 2,
122
+ 3,
123
+ 4,
124
+ 5,
125
+ 6,
126
+ 7,
127
+ 8,
128
+ 9,
129
+ 10,
130
+ 11,
131
+ 12,
132
+ 13,
133
+ 14,
134
+ 15,
135
+ 16,
136
+ 17,
137
+ 18,
138
+ 19,
139
+ 20,
140
+ 21,
141
+ 22,
142
+ 23,
143
+ 24,
144
+ 25,
145
+ 26,
146
+ 27,
147
+ 28,
148
+ 29,
149
+ 30,
150
+ 31,
151
+ 32,
152
+ 33,
153
+ 34,
154
+ 35,
155
+ 36,
156
+ 37,
157
+ 38,
158
+ 39,
159
+ 40,
160
+ 41,
161
+ 42,
162
+ 43,
163
+ 44,
164
+ 45,
165
+ 46,
166
+ 47,
167
+ 48,
168
+ 49,
169
+ 50,
170
+ 51,
171
+ 52,
172
+ 53,
173
+ 54,
174
+ 55,
175
+ 56,
176
+ 57,
177
+ 58,
178
+ 59,
179
+ 60,
180
+ 61,
181
+ 62,
182
+ 63,
183
+ 64,
184
+ 65,
185
+ 66,
186
+ 67,
187
+ 68,
188
+ 69,
189
+ 70,
190
+ 71,
191
+ 72,
192
+ 73,
193
+ 74,
194
+ 75,
195
+ 76,
196
+ 77,
197
+ 78,
198
+ 79,
199
+ 80,
200
+ 81,
201
+ 82,
202
+ 83,
203
+ 84,
204
+ 85,
205
+ 86,
206
+ 87,
207
+ 88,
208
+ 89,
209
+ 90,
210
+ 91,
211
+ 92,
212
+ 93,
213
+ 94,
214
+ 95,
215
+ 96,
216
+ 97,
217
+ 98,
218
+ 99
219
+ ],
220
+ "train_episodes": [
221
+ 0,
222
+ 1,
223
+ 2,
224
+ 3,
225
+ 4,
226
+ 5,
227
+ 6,
228
+ 7,
229
+ 8,
230
+ 9,
231
+ 10,
232
+ 11,
233
+ 12,
234
+ 13,
235
+ 14,
236
+ 15,
237
+ 16,
238
+ 17,
239
+ 18,
240
+ 19,
241
+ 20,
242
+ 21,
243
+ 22,
244
+ 23,
245
+ 24,
246
+ 25,
247
+ 26,
248
+ 27,
249
+ 28,
250
+ 29,
251
+ 30,
252
+ 31,
253
+ 32,
254
+ 33,
255
+ 34,
256
+ 35,
257
+ 36,
258
+ 37,
259
+ 38,
260
+ 39,
261
+ 40,
262
+ 41,
263
+ 42,
264
+ 43,
265
+ 44,
266
+ 45,
267
+ 46,
268
+ 47,
269
+ 48,
270
+ 49,
271
+ 50,
272
+ 51,
273
+ 52,
274
+ 53,
275
+ 54,
276
+ 55,
277
+ 56,
278
+ 57,
279
+ 58,
280
+ 59,
281
+ 60,
282
+ 61,
283
+ 62,
284
+ 63,
285
+ 64,
286
+ 65,
287
+ 66,
288
+ 67,
289
+ 68,
290
+ 69,
291
+ 70,
292
+ 71,
293
+ 72,
294
+ 73,
295
+ 74,
296
+ 75,
297
+ 76,
298
+ 77,
299
+ 78,
300
+ 79,
301
+ 80,
302
+ 81,
303
+ 82,
304
+ 83,
305
+ 84,
306
+ 85,
307
+ 86,
308
+ 87,
309
+ 88,
310
+ 89,
311
+ 90,
312
+ 91,
313
+ 92,
314
+ 93,
315
+ 94,
316
+ 95,
317
+ 96,
318
+ 97,
319
+ 98,
320
+ 99
321
+ ],
322
+ "val_episodes": [],
323
+ "train_frames": 61498,
324
+ "git_commit": null
325
+ },
326
+ "training": {
327
+ "steps": 60000,
328
+ "batch_size": 512,
329
+ "lr": 0.0001,
330
+ "betas": [
331
+ 0.95,
332
+ 0.999
333
+ ],
334
+ "weight_decay": 1e-06,
335
+ "warmup": 500,
336
+ "schedule": "linear warm-up + cosine",
337
+ "backbone_lr_scale": 0.1,
338
+ "ema": 0.9999,
339
+ "shift_px": 0,
340
+ "amp": true,
341
+ "seed": 42,
342
+ "augmentation": {
343
+ "spec": "docs/augmentation_v2.md",
344
+ "version": "hb-aug-v2-20261109",
345
+ "implementation": "evaluation/augmentation/hb_aug_v2.py",
346
+ "visual": {
347
+ "effects": [
348
+ "exposure",
349
+ "contrast",
350
+ "saturation",
351
+ "hue",
352
+ "gamma",
353
+ "temperature",
354
+ "rotation_crop",
355
+ "noise",
356
+ "gaussian_blur",
357
+ "jpeg",
358
+ "motion_blur",
359
+ "sharpen",
360
+ "defocus",
361
+ "light_shadow",
362
+ "wb_channel"
363
+ ],
364
+ "boosted_per_sample": 1,
365
+ "boost": 1.5,
366
+ "pixel_scale": "H / 224",
367
+ "future_targets": "none (one observation frame)"
368
+ },
369
+ "proprio": {
370
+ "robot": "g1",
371
+ "body_dims": 29,
372
+ "bias_deg": 2.0,
373
+ "bias_scope": "per_sample",
374
+ "noise_deg": 0.25,
375
+ "noise_clip_sigma": 3,
376
+ "delay_probability": 0.0,
377
+ "history_drop_probability": 0.0,
378
+ "velocity": false
379
+ },
380
+ "native_image_augmentation": "off",
381
+ "evaluation": "off"
382
+ },
383
+ "preflight": {
384
+ "samples": 64,
385
+ "state_dim": 44,
386
+ "body_dims": 29,
387
+ "images_changed": 64,
388
+ "body_values_moved": 1.0,
389
+ "max_body_offset_deg": 2.5908,
390
+ "actions_bit_identical": true,
391
+ "non_body_state_bit_identical": true,
392
+ "eval_items_deterministic": 8
393
+ },
394
+ "aug_seed": 42,
395
+ "layout": {
396
+ "nodes": 1,
397
+ "gpus": 1,
398
+ "per_gpu_batch": 512,
399
+ "global_batch": 512,
400
+ "gradient_accumulation": 1,
401
+ "num_workers": 32,
402
+ "prefetch": 2
403
+ },
404
+ "continuation": {
405
+ "init_from": "/root/hb_runs/flash30k/staging/fm_b8_init_source/checkpoints/step-006000",
406
+ "init_step": 6000,
407
+ "init_weights": "raw policy and EMA from /root/hb_runs/flash30k/staging/fm_b8_init_source/train_state.pt (written at step 6000)",
408
+ "init_model_sha256": "49f877e3a020061ca3fd91b94f178596a9348d02548e116ea261eeecb5675ed8",
409
+ "init_code_commit": "028df1bb7024fb1e3d176de7e60c84d3333cd97f",
410
+ "original_peak_lr": 0.0001,
411
+ "peak_lr": 0.0001,
412
+ "peak_lr_factor": 1.0,
413
+ "warmup_steps": 500,
414
+ "warmup_ratio": 0.008333,
415
+ "more_steps": 60000,
416
+ "total_steps": 66000,
417
+ "optimizer": "fresh AdamW (same groups, betas, weight decay)",
418
+ "schedule": "fresh: warm-up then the policy's cosine over the continuation steps",
419
+ "ema_decay_steps": "total steps (the EMA keeps averaging as in the original run)",
420
+ "init_contract": "g1_sonic_dfx6",
421
+ "hands_switch": "measured -> commanded hands (owner 2026-11-28); state and action normalizers re-fit on the data of this run",
422
+ "protocol": {
423
+ "peak_lr_factor": 0.3,
424
+ "warmup_ratio": 0.05,
425
+ "steps": [
426
+ 2000,
427
+ 4000
428
+ ],
429
+ "deviations": [
430
+ "lr 0.0001",
431
+ "warmup 500",
432
+ "steps 60000"
433
+ ],
434
+ "exception": "owner 2026-11-28: \u7eed\u8bad\u7684\u6b65\u6570\u6bd4\u8f83\u591a\u7684\u5c31\u4e0d\u9700\u8981\u53bb\u964d\u4f4e\u5b66\u4e60\u7387\u7684\u5cf0\u503c\u3002\u6211\u89c9\u5f97\u5b66\u4e60\u7387\u5cf0\u503c\u53ef\u4ee5\u8ddf\u4ece\u5934\u8bad\u4e00\u6837\u53bb\u5b89\u6392; FM-DiT v1 base 58000 (collaborator's A17 80000 steps on 751.84 frames/episode); measured -> commanded hands (owner: \u7eed\u8bad\u65f6\u6539\u6210\u5b66\u6307\u4ee4\u624b\uff0c\u80af\u5b9a\u8981\u8fd9\u4e48\u505a)"
435
+ }
436
+ },
437
+ "total_steps": 66000,
438
+ "save_steps": [
439
+ 16000,
440
+ 26000,
441
+ 36000,
442
+ 46000,
443
+ 50000,
444
+ 56000,
445
+ 66000
446
+ ],
447
+ "save_rule": "6 checkpoints spread evenly over the steps on the 250-step grid (owner 2026-11-27)",
448
+ "protocol_exceptions": [
449
+ "owner 2026-11-28: FM-DiT v1 base steps 58000 (HumanWAM bai a7c875b); steps = ceil1000(58000 x 614.98 frames per episode / 544.33) = 66000; continued from step 6000 to 66000; commanded hands (owner 2026-11-27)",
450
+ "owner 2026-11-30: FM-DiT \u7167\u539f\u5b66\u4e60\u7387\u66f2\u7ebf\u8bad\u5230\u7d2f\u8ba1 50000 \u6b65\u622a\u505c\uff08\u300c\u884c\uff0c\u622a\u505c\u300d\uff09: --stop-at 50000, the learning-rate curve that of --steps; code = Humanoid_benchmark bai 433ba198 + stop-at patch (the evaluation/baselines/train.py part of bai 39f9b83a, git diff 39f9b83a^ 39f9b83a -- evaluation/baselines/train.py, sha256 db0911a84ba7a847befd22955ac99a9c04c2307a97f696be4e73da510fc19977); trained on the MLP 4090D (24 GB, one card, batch 512, same recipe as the A800)"
451
+ ],
452
+ "stop_at": 50000,
453
+ "ema_schedule": "hb",
454
+ "inloop": {
455
+ "task": "b8c",
456
+ "code": "/root/hb_runs/flash30k/policies/eval-action-mse",
457
+ "every": 250,
458
+ "exception": null,
459
+ "code_sha256": {
460
+ "hb_inloop_core.py": "154fa6d905e32d61c0def546caf6979c3a148b7bef0c1284e773b9051dddce97",
461
+ "hb_eval_common.py": "d89b1bfc1ac03d489b6ba2ac7c61eab3f318023ec37677dd5ee02b93d851d6ac"
462
+ }
463
+ },
464
+ "protocol_recipe": {
465
+ "batch_size": 512,
466
+ "long_task_factor": 1
467
+ },
468
+ "protocol_deviations": [],
469
+ "environment": {
470
+ "python": "3.12.1",
471
+ "torch": "2.9.0+cu128",
472
+ "numpy": "2.2.6",
473
+ "cuda": "12.8",
474
+ "cudnn": 91002,
475
+ "torchvision": "0.24.0+cu128",
476
+ "pillow": "13.0.0",
477
+ "gpu": "NVIDIA GeForce RTX 4090 D",
478
+ "driver": "595.58.03"
479
+ },
480
+ "code_dirty": null,
481
+ "allow_dirty_tree": false,
482
+ "augmentation_sha256": "9f7713cea4f846efcfc924234267ced48210357f419d67915c10b504316bedde",
483
+ "order": "EpochSampler: default_rng([seed, 1, epoch]) permutation; augmentation default_rng([aug_seed, draw])"
484
+ },
485
+ "stats": {
486
+ "state": {
487
+ "min": [
488
+ -0.2515260875225067,
489
+ -0.03310006856918335,
490
+ -0.08915279805660248,
491
+ 0.14301416277885437,
492
+ -0.18305416405200958,
493
+ -0.10634835064411163,
494
+ -0.2634684145450592,
495
+ -0.05348178371787071,
496
+ -0.21431514620780945,
497
+ 0.13807232677936554,
498
+ -0.2242385447025299,
499
+ -0.09678935259580612,
500
+ -0.18892650306224823,
501
+ -0.10323800146579742,
502
+ -0.09472811967134476,
503
+ -0.2798849642276764,
504
+ 0.1722967028617859,
505
+ -1.1891459226608276,
506
+ 0.3821650445461273,
507
+ -0.5277573466300964,
508
+ -0.1239900067448616,
509
+ -0.025756916031241417,
510
+ -1.5671592950820923,
511
+ -1.708814024925232,
512
+ -0.94542396068573,
513
+ -0.8548623323440552,
514
+ -0.9579849243164062,
515
+ -0.9779664278030396,
516
+ -0.5873764157295227,
517
+ 0.9998621344566345,
518
+ 0.9998221397399902,
519
+ 0.9998023509979248,
520
+ 0.9998185634613037,
521
+ 0.9975361227989197,
522
+ 0.9988760948181152,
523
+ 0.360027939081192,
524
+ 0.4790782630443573,
525
+ 0.5461887717247009,
526
+ 0.48382189869880676,
527
+ 0.6635858416557312,
528
+ 0.0,
529
+ -0.10022255033254623,
530
+ -0.03946204483509064,
531
+ -1.0
532
+ ],
533
+ "max": [
534
+ 0.00482684513553977,
535
+ 0.13756881654262543,
536
+ 0.2979176640510559,
537
+ 0.3711587190628052,
538
+ 0.031152762472629547,
539
+ 0.010087746195495129,
540
+ 0.019378269091248512,
541
+ 0.1355365365743637,
542
+ 0.182325080037117,
543
+ 0.4443013668060303,
544
+ -0.05482839047908783,
545
+ 0.011374615132808685,
546
+ 0.165291890501976,
547
+ 0.05307222157716751,
548
+ 0.177412211894989,
549
+ 0.22115345299243927,
550
+ 0.6989883780479431,
551
+ -0.3335850238800049,
552
+ 1.1546826362609863,
553
+ 0.28441083431243896,
554
+ 0.08963758498430252,
555
+ 0.3550512492656708,
556
+ 1.1140739917755127,
557
+ -0.22596199810504913,
558
+ 1.7804871797561646,
559
+ 1.2184052467346191,
560
+ 1.2347023487091064,
561
+ 1.5067987442016602,
562
+ 1.0105962753295898,
563
+ 1.0,
564
+ 1.0,
565
+ 1.0,
566
+ 1.0,
567
+ 0.9982408285140991,
568
+ 0.9999225735664368,
569
+ 1.0,
570
+ 1.0,
571
+ 1.0,
572
+ 0.9999973177909851,
573
+ 1.0,
574
+ 1.0,
575
+ 0.038201265037059784,
576
+ 0.023285934701561928,
577
+ -0.9949650168418884
578
+ ],
579
+ "mean": [
580
+ -0.07244415528619287,
581
+ 0.016438895257606716,
582
+ -0.03188766069938736,
583
+ 0.19652274108921836,
584
+ -0.09995080381043964,
585
+ -0.0335864852112993,
586
+ -0.06201331924385435,
587
+ 0.0041316509641342114,
588
+ -0.07562538691067132,
589
+ 0.22342829523439264,
590
+ -0.13939505500881355,
591
+ -0.02568257955335654,
592
+ 0.020507808718722174,
593
+ 0.0030919114143910654,
594
+ 0.11976549024164236,
595
+ -0.04130542899628228,
596
+ 0.27413152575942573,
597
+ -0.667075950232086,
598
+ 0.9776525052369189,
599
+ -0.15594609082852004,
600
+ -0.04114803172895316,
601
+ 0.07066678088305102,
602
+ -0.44530701068620304,
603
+ -0.7956643808095055,
604
+ 0.6432070891275159,
605
+ 0.07140851169135853,
606
+ -0.22403887370387132,
607
+ 0.19658286211869352,
608
+ 0.3118955244879216,
609
+ 0.9999827171293537,
610
+ 0.999982850921418,
611
+ 0.9999830789480982,
612
+ 0.9999811406495951,
613
+ 0.9977658298817017,
614
+ 0.9997360855995177,
615
+ 0.7778945983312991,
616
+ 0.8171959691692932,
617
+ 0.8399288212288848,
618
+ 0.8394280370284749,
619
+ 0.8745686375938581,
620
+ 0.12291562838728093,
621
+ -0.023435156143715264,
622
+ -0.004820223051842413,
623
+ -0.999617456030026
624
+ ],
625
+ "std": [
626
+ 0.045712745420827386,
627
+ 0.013154301249487431,
628
+ 0.02405439153160751,
629
+ 0.0422870935042734,
630
+ 0.01604373013239405,
631
+ 0.010666838959405088,
632
+ 0.0447255039612766,
633
+ 0.014369854397034587,
634
+ 0.025451572022126993,
635
+ 0.05279699313574748,
636
+ 0.02213303083995789,
637
+ 0.011183898115253933,
638
+ 0.07041149453770397,
639
+ 0.015833724218855847,
640
+ 0.039560888033149964,
641
+ 0.08342761969885264,
642
+ 0.0587237913039723,
643
+ 0.22301655606787774,
644
+ 0.08125572382728762,
645
+ 0.1281115145665045,
646
+ 0.03600107397023974,
647
+ 0.04123008646611267,
648
+ 0.5831912382159029,
649
+ 0.23706341250281637,
650
+ 0.5432748450536339,
651
+ 0.504036388323598,
652
+ 0.31188020039153314,
653
+ 0.3436391052756804,
654
+ 0.26504982482523237,
655
+ 1.8214790335763182e-05,
656
+ 2.3385127857745866e-05,
657
+ 2.5684815254370892e-05,
658
+ 2.368414515012511e-05,
659
+ 7.802892144541008e-05,
660
+ 6.03931448414821e-05,
661
+ 0.2307055833669559,
662
+ 0.1900819078013402,
663
+ 0.16354430170740317,
664
+ 0.16593648793853702,
665
+ 0.1286487353890603,
666
+ 0.3083183803524622,
667
+ 0.013093107258771247,
668
+ 0.004580775936054731,
669
+ 0.0002959946385408924
670
+ ]
671
+ },
672
+ "action": {
673
+ "min": [
674
+ 0.0,
675
+ -0.375,
676
+ -0.4375,
677
+ -0.125,
678
+ -0.375,
679
+ -0.3125,
680
+ -0.375,
681
+ -0.3125,
682
+ -0.25,
683
+ -0.25,
684
+ -0.5625,
685
+ -0.1875,
686
+ -0.125,
687
+ -0.3125,
688
+ -0.125,
689
+ -0.25,
690
+ -0.125,
691
+ -0.1875,
692
+ -0.5,
693
+ -0.25,
694
+ -0.1875,
695
+ -0.5625,
696
+ -0.25,
697
+ -0.375,
698
+ -0.4375,
699
+ -0.0625,
700
+ -0.375,
701
+ -0.375,
702
+ -0.3125,
703
+ -0.3125,
704
+ 0.0,
705
+ 0.125,
706
+ -0.3125,
707
+ 0.0,
708
+ 0.125,
709
+ -0.4375,
710
+ -0.1875,
711
+ -0.4375,
712
+ -0.25,
713
+ -0.1875,
714
+ -0.4375,
715
+ -0.375,
716
+ -0.1875,
717
+ -0.0625,
718
+ -0.3125,
719
+ -0.25,
720
+ -0.1875,
721
+ -0.3125,
722
+ -0.3125,
723
+ -0.5625,
724
+ -0.125,
725
+ -0.125,
726
+ -0.4375,
727
+ -0.5,
728
+ -0.1875,
729
+ -0.25,
730
+ -0.375,
731
+ -0.0625,
732
+ -0.4375,
733
+ -0.25,
734
+ -0.4375,
735
+ 0.0625,
736
+ -0.25,
737
+ 0.0,
738
+ 1.0,
739
+ 1.0,
740
+ 1.0,
741
+ 1.0,
742
+ 1.0,
743
+ 1.0,
744
+ 0.36000001430511475,
745
+ 0.36000001430511475,
746
+ 0.36000001430511475,
747
+ 0.36000001430511475,
748
+ 0.36000001430511475,
749
+ 0.0
750
+ ],
751
+ "max": [
752
+ 0.375,
753
+ 0.25,
754
+ 0.25,
755
+ 0.1875,
756
+ 0.1875,
757
+ 0.1875,
758
+ 0.25,
759
+ 0.25,
760
+ 0.1875,
761
+ 0.125,
762
+ 0.0625,
763
+ 0.1875,
764
+ 0.5,
765
+ 0.1875,
766
+ 0.25,
767
+ 0.0625,
768
+ 0.3125,
769
+ 0.5,
770
+ 0.1875,
771
+ 0.25,
772
+ 0.25,
773
+ 0.0625,
774
+ 0.4375,
775
+ 0.25,
776
+ 0.0,
777
+ 0.4375,
778
+ 0.0,
779
+ 0.1875,
780
+ 0.1875,
781
+ 0.1875,
782
+ 0.4375,
783
+ 0.5,
784
+ 0.3125,
785
+ 0.3125,
786
+ 0.3125,
787
+ 0.0625,
788
+ 0.1875,
789
+ 0.3125,
790
+ 0.1875,
791
+ 0.25,
792
+ 0.0,
793
+ 0.25,
794
+ 0.125,
795
+ 0.5,
796
+ 0.125,
797
+ 0.5,
798
+ 0.4375,
799
+ 0.4375,
800
+ 0.4375,
801
+ 0.0,
802
+ 0.125,
803
+ 0.25,
804
+ 0.5,
805
+ -0.0625,
806
+ 0.125,
807
+ 0.4375,
808
+ 0.5,
809
+ 0.3125,
810
+ 0.125,
811
+ 0.125,
812
+ 0.125,
813
+ 0.5,
814
+ 0.125,
815
+ 0.6875,
816
+ 1.0,
817
+ 1.0,
818
+ 1.0,
819
+ 1.0,
820
+ 1.0,
821
+ 1.0,
822
+ 1.0,
823
+ 1.0,
824
+ 1.0,
825
+ 1.0,
826
+ 1.0,
827
+ 1.0
828
+ ],
829
+ "mean": [
830
+ 0.2026803717194055,
831
+ -0.07236617450974016,
832
+ -0.02242552603336694,
833
+ 0.02358918176200852,
834
+ -0.12101816319229894,
835
+ -0.10377979771699893,
836
+ -0.04818144492503821,
837
+ -0.09367987576831767,
838
+ -0.015672257634394615,
839
+ -0.07295460827994406,
840
+ -0.28937628052944814,
841
+ 0.023045464893167257,
842
+ 0.12778362710982472,
843
+ -0.014680355458714104,
844
+ 0.047179379817229826,
845
+ -0.12413716706234348,
846
+ 0.0648974356889655,
847
+ 0.1738440680997756,
848
+ -0.1366050521968194,
849
+ 0.05253626134183226,
850
+ 0.005097726755341637,
851
+ -0.21554664379329408,
852
+ 0.09576226056131906,
853
+ -0.11485841002959446,
854
+ -0.21714120784415752,
855
+ 0.25317489999674786,
856
+ -0.23478507431135973,
857
+ -0.10450746365735471,
858
+ -0.049666249308920614,
859
+ -0.03343909558034407,
860
+ 0.2612117467234707,
861
+ 0.28021846238902076,
862
+ 0.013058351491105402,
863
+ 0.14741942827409021,
864
+ 0.23094043708738496,
865
+ -0.2599698364174445,
866
+ 0.054112532114865525,
867
+ -0.18685465380988,
868
+ -0.021627735861328823,
869
+ -0.045454730235129595,
870
+ -0.261119264041107,
871
+ -0.09780399362580897,
872
+ -0.03171647858466942,
873
+ 0.30728844840482616,
874
+ -0.13527167550164232,
875
+ 0.061584319815278545,
876
+ 0.07089966340368792,
877
+ 0.06740158216527367,
878
+ 0.18057091287521546,
879
+ -0.27359832840092363,
880
+ -0.01098104816416794,
881
+ 0.03545237243487593,
882
+ 0.1730208705974178,
883
+ -0.26741316790789943,
884
+ -0.03493507918956714,
885
+ 0.1694120133988097,
886
+ 0.01502691144427461,
887
+ 0.05571421021821848,
888
+ -0.22518415233015707,
889
+ -0.05392248528407428,
890
+ -0.1961598344661615,
891
+ 0.3429247699112166,
892
+ -0.04006126215486683,
893
+ 0.40486580864418353,
894
+ 1.0,
895
+ 1.0,
896
+ 1.0,
897
+ 1.0,
898
+ 1.0,
899
+ 1.0,
900
+ 0.7644257025600019,
901
+ 0.7644257025600019,
902
+ 0.7644257025600019,
903
+ 0.7644257025600019,
904
+ 0.7659686295247596,
905
+ 0.13423402414162272
906
+ ],
907
+ "std": [
908
+ 0.07423638798986239,
909
+ 0.10276070894626457,
910
+ 0.11812702387971753,
911
+ 0.05957396656117891,
912
+ 0.1218417031488596,
913
+ 0.08063836551976374,
914
+ 0.1020635000819969,
915
+ 0.10540346375069484,
916
+ 0.08296831170197061,
917
+ 0.05989282207073844,
918
+ 0.131405419274155,
919
+ 0.07688508477180626,
920
+ 0.15530657456533145,
921
+ 0.09090021877289593,
922
+ 0.07144535330531092,
923
+ 0.07721423672952077,
924
+ 0.061937753226413185,
925
+ 0.12535445915332458,
926
+ 0.1406645362754369,
927
+ 0.09610483490082063,
928
+ 0.0892112540257282,
929
+ 0.10101183108941218,
930
+ 0.14459992137856284,
931
+ 0.09259695505428482,
932
+ 0.07250089525780803,
933
+ 0.07751064616894329,
934
+ 0.09003536032570492,
935
+ 0.08768655804866919,
936
+ 0.0793513264967945,
937
+ 0.0799717022695259,
938
+ 0.08767655242632699,
939
+ 0.06686962750120226,
940
+ 0.11139553980852172,
941
+ 0.05962527954838032,
942
+ 0.03113638664810605,
943
+ 0.1104336480130166,
944
+ 0.0900293543854962,
945
+ 0.17353368370821917,
946
+ 0.06621053001132303,
947
+ 0.07044267349366652,
948
+ 0.07468062148900616,
949
+ 0.13559357690832427,
950
+ 0.051673248141484364,
951
+ 0.11970962808802042,
952
+ 0.09873016730126778,
953
+ 0.1482997857923691,
954
+ 0.14644960009292055,
955
+ 0.12362418143308783,
956
+ 0.14892813932159055,
957
+ 0.1264928491368565,
958
+ 0.04485723360367807,
959
+ 0.06556638017875786,
960
+ 0.23014907315132233,
961
+ 0.07366488770406758,
962
+ 0.05520901424631441,
963
+ 0.1518289001396863,
964
+ 0.1840720418570084,
965
+ 0.05832378814080937,
966
+ 0.11903714776197126,
967
+ 0.05677283141546173,
968
+ 0.09207849117719222,
969
+ 0.09729334507011746,
970
+ 0.0780996197326025,
971
+ 0.16351388381996734,
972
+ 0.0,
973
+ 0.0,
974
+ 0.0,
975
+ 0.0,
976
+ 0.0,
977
+ 0.0,
978
+ 0.24588449589222341,
979
+ 0.24588449589222341,
980
+ 0.24588449589222341,
981
+ 0.24588449589222341,
982
+ 0.24578410015930552,
983
+ 0.3348986548442017
984
+ ]
985
+ }
986
+ },
987
+ "code_commit": "433ba198964eb54173f2beb5085ba96f7fab0f9e",
988
+ "task": "b8c",
989
+ "dataset_id": "humanoid-benchmark/b8-table-wipe-expert-v1@3b2e6180508f84f70fda8b33cd3e41c14225f0b5",
990
+ "step": 46000,
991
+ "weights": "ema",
992
+ "offline_eval": {
993
+ "mse": 0.005906721111387014,
994
+ "mse_row0": 0.006677551660686731,
995
+ "mse_motion_token": 0.00651158019900322,
996
+ "mse_inspire_left_hand_cmd": 2.276322447869461e-05,
997
+ "mse_inspire_right_hand_cmd": 0.005338840186595917,
998
+ "samples": 256,
999
+ "frames": "train"
1000
+ },
1001
+ "format": "hb_baselines/1"
1002
+ }
b8-table-wipe/b512-cont-20261117-stop50k/step-046000/model.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:615a1ffb029281707c318e423eab4b1340d132ee9e2bb5ed7215e34e7de0d268
3
+ size 90315733
b8-table-wipe/b512-cont-20261117-stop50k/step-046000/protocol.json ADDED
@@ -0,0 +1,331 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "format": "hb_baselines/1",
3
+ "step": 46000,
4
+ "policy": "fm_dit",
5
+ "task": "b8c",
6
+ "dataset_id": "humanoid-benchmark/b8-table-wipe-expert-v1@3b2e6180508f84f70fda8b33cd3e41c14225f0b5",
7
+ "episodes": 100,
8
+ "frames": 61498,
9
+ "fps": 30.0,
10
+ "steps": 60000,
11
+ "total_steps": 66000,
12
+ "save_steps": [
13
+ 16000,
14
+ 26000,
15
+ 36000,
16
+ 46000,
17
+ 50000,
18
+ 56000,
19
+ 66000
20
+ ],
21
+ "global_batch": 512,
22
+ "per_gpu_batch": 512,
23
+ "num_gpus": 1,
24
+ "gradient_accumulation_steps": 1,
25
+ "lr": 0.0001,
26
+ "warmup": 500,
27
+ "schedule": "linear warm-up + cosine",
28
+ "seed": 42,
29
+ "aug_seed": 42,
30
+ "code_commit": "433ba198964eb54173f2beb5085ba96f7fab0f9e",
31
+ "code_dirty": null,
32
+ "environment": {
33
+ "python": "3.12.1",
34
+ "torch": "2.9.0+cu128",
35
+ "numpy": "2.2.6",
36
+ "cuda": "12.8",
37
+ "cudnn": 91002,
38
+ "torchvision": "0.24.0+cu128",
39
+ "pillow": "13.0.0",
40
+ "gpu": "NVIDIA GeForce RTX 4090 D",
41
+ "driver": "595.58.03"
42
+ },
43
+ "continuation": {
44
+ "init_from": "/root/hb_runs/flash30k/staging/fm_b8_init_source/checkpoints/step-006000",
45
+ "init_step": 6000,
46
+ "init_weights": "raw policy and EMA from /root/hb_runs/flash30k/staging/fm_b8_init_source/train_state.pt (written at step 6000)",
47
+ "init_model_sha256": "49f877e3a020061ca3fd91b94f178596a9348d02548e116ea261eeecb5675ed8",
48
+ "init_code_commit": "028df1bb7024fb1e3d176de7e60c84d3333cd97f",
49
+ "original_peak_lr": 0.0001,
50
+ "peak_lr": 0.0001,
51
+ "peak_lr_factor": 1.0,
52
+ "warmup_steps": 500,
53
+ "warmup_ratio": 0.008333,
54
+ "more_steps": 60000,
55
+ "total_steps": 66000,
56
+ "optimizer": "fresh AdamW (same groups, betas, weight decay)",
57
+ "schedule": "fresh: warm-up then the policy's cosine over the continuation steps",
58
+ "ema_decay_steps": "total steps (the EMA keeps averaging as in the original run)",
59
+ "init_contract": "g1_sonic_dfx6",
60
+ "hands_switch": "measured -> commanded hands (owner 2026-11-28); state and action normalizers re-fit on the data of this run",
61
+ "protocol": {
62
+ "peak_lr_factor": 0.3,
63
+ "warmup_ratio": 0.05,
64
+ "steps": [
65
+ 2000,
66
+ 4000
67
+ ],
68
+ "deviations": [
69
+ "lr 0.0001",
70
+ "warmup 500",
71
+ "steps 60000"
72
+ ],
73
+ "exception": "owner 2026-11-28: 续训的步数比较多的就不需要去降低学习率的峰值。我觉得学习率峰值可以跟从头训一样去安排; FM-DiT v1 base 58000 (collaborator's A17 80000 steps on 751.84 frames/episode); measured -> commanded hands (owner: 续训时改成学指令手,肯定要这么做)"
74
+ }
75
+ },
76
+ "protocol_deviations": [],
77
+ "protocol_exceptions": [
78
+ "owner 2026-11-28: FM-DiT v1 base steps 58000 (HumanWAM bai a7c875b); steps = ceil1000(58000 x 614.98 frames per episode / 544.33) = 66000; continued from step 6000 to 66000; commanded hands (owner 2026-11-27)",
79
+ "owner 2026-11-30: FM-DiT 照原学习率曲线训到累计 50000 步截停(「行,截停」): --stop-at 50000, the learning-rate curve that of --steps; code = Humanoid_benchmark bai 433ba198 + stop-at patch (the evaluation/baselines/train.py part of bai 39f9b83a, git diff 39f9b83a^ 39f9b83a -- evaluation/baselines/train.py, sha256 db0911a84ba7a847befd22955ac99a9c04c2307a97f696be4e73da510fc19977); trained on the MLP 4090D (24 GB, one card, batch 512, same recipe as the A800)"
80
+ ],
81
+ "files": {
82
+ "config.json": {
83
+ "bytes": 19330,
84
+ "sha256": "e80e17d1297cad0eb805adb6c8b79f9f469e55723bebc5a4763754d02285a073"
85
+ },
86
+ "model.pt": {
87
+ "bytes": 90315733,
88
+ "sha256": "615a1ffb029281707c318e423eab4b1340d132ee9e2bb5ed7215e34e7de0d268"
89
+ }
90
+ },
91
+ "global_step": 46000,
92
+ "run_step": 40000,
93
+ "stop_at": 50000,
94
+ "planned_total_steps": 66000,
95
+ "task_dir": "b8-table-wipe",
96
+ "training_data": "humanoid-benchmark/b8-table-wipe-expert-v1 @3b2e6180 (100 episodes, commanded hands)",
97
+ "published_steps": [
98
+ 46000,
99
+ 50000
100
+ ],
101
+ "lr_schedule": "linear warm-up + cosine after a 500-step linear warm-up",
102
+ "ema": 0.9999,
103
+ "augmentation": "Humanoid Benchmark online augmentation spec v2 (hb-aug-v2-20261109): 15 visual effects, one per sample at 1.5x; proprio per-joint bias U(+-2 deg) + N(0, 0.25 deg); no delay, no history drop; model-native image augmentation off",
104
+ "state_dim": 44,
105
+ "action_dim": 76,
106
+ "cameras": [
107
+ "ego_view",
108
+ "chest"
109
+ ],
110
+ "contract": "g1_sonic_cmd",
111
+ "image_hw": [
112
+ 168,
113
+ 224
114
+ ],
115
+ "task_text": "Approach the flat block with a naturally aligned wrist, stop before closing the hand, wipe sideways at a top-view 45-degree heading, then set the block on the tabletop and release it.",
116
+ "inloop_mse": {
117
+ "task": "b8c",
118
+ "split": "train10",
119
+ "every": 250,
120
+ "seed": 1234,
121
+ "weights": "ema",
122
+ "nmse_at_this_step": 0.0436,
123
+ "lowest_published": 50000,
124
+ "curve": {
125
+ "6250": 0.1535,
126
+ "6500": 0.15,
127
+ "6750": 0.1467,
128
+ "7000": 0.1433,
129
+ "7250": 0.1401,
130
+ "7500": 0.1372,
131
+ "7750": 0.1344,
132
+ "8000": 0.1318,
133
+ "8250": 0.1294,
134
+ "8500": 0.127,
135
+ "8750": 0.1249,
136
+ "9000": 0.1228,
137
+ "9250": 0.1207,
138
+ "9500": 0.1187,
139
+ "9750": 0.1168,
140
+ "10000": 0.1149,
141
+ "10250": 0.1131,
142
+ "10500": 0.1112,
143
+ "10750": 0.1095,
144
+ "11000": 0.1078,
145
+ "11250": 0.1062,
146
+ "11500": 0.1044,
147
+ "11750": 0.1028,
148
+ "12000": 0.1012,
149
+ "12250": 0.0996,
150
+ "12500": 0.0981,
151
+ "12750": 0.0967,
152
+ "13000": 0.0953,
153
+ "13250": 0.0939,
154
+ "13500": 0.0927,
155
+ "13750": 0.0915,
156
+ "14000": 0.0904,
157
+ "14250": 0.0892,
158
+ "14500": 0.0882,
159
+ "14750": 0.0871,
160
+ "15000": 0.0861,
161
+ "15250": 0.0851,
162
+ "15500": 0.0842,
163
+ "15750": 0.0832,
164
+ "16000": 0.0823,
165
+ "16250": 0.0814,
166
+ "16500": 0.0805,
167
+ "16750": 0.0797,
168
+ "17000": 0.0789,
169
+ "17250": 0.0782,
170
+ "17500": 0.0774,
171
+ "17750": 0.0767,
172
+ "18000": 0.076,
173
+ "18250": 0.0752,
174
+ "18500": 0.0746,
175
+ "18750": 0.0739,
176
+ "19000": 0.0732,
177
+ "19250": 0.0726,
178
+ "19500": 0.072,
179
+ "19750": 0.0713,
180
+ "20000": 0.0706,
181
+ "20250": 0.07,
182
+ "20500": 0.0693,
183
+ "20750": 0.0688,
184
+ "21000": 0.0682,
185
+ "21250": 0.0676,
186
+ "21500": 0.0671,
187
+ "21750": 0.0666,
188
+ "22000": 0.0661,
189
+ "22250": 0.0656,
190
+ "22500": 0.0651,
191
+ "22750": 0.0646,
192
+ "23000": 0.0642,
193
+ "23250": 0.0638,
194
+ "23500": 0.0633,
195
+ "23750": 0.0629,
196
+ "24000": 0.0625,
197
+ "24250": 0.0621,
198
+ "24500": 0.0617,
199
+ "24750": 0.0613,
200
+ "25000": 0.0609,
201
+ "25250": 0.0606,
202
+ "25500": 0.0602,
203
+ "25750": 0.0598,
204
+ "26000": 0.0594,
205
+ "26250": 0.0591,
206
+ "26500": 0.0587,
207
+ "26750": 0.0584,
208
+ "27000": 0.0581,
209
+ "27250": 0.0577,
210
+ "27500": 0.0575,
211
+ "27750": 0.0572,
212
+ "28000": 0.0569,
213
+ "28250": 0.0566,
214
+ "28500": 0.0562,
215
+ "28750": 0.0559,
216
+ "29000": 0.0556,
217
+ "29250": 0.0553,
218
+ "29500": 0.055,
219
+ "29750": 0.0547,
220
+ "30000": 0.0544,
221
+ "30250": 0.0541,
222
+ "30500": 0.0539,
223
+ "30750": 0.0536,
224
+ "31000": 0.0534,
225
+ "31250": 0.0531,
226
+ "31500": 0.0529,
227
+ "31750": 0.0527,
228
+ "32000": 0.0524,
229
+ "32250": 0.0522,
230
+ "32500": 0.0519,
231
+ "32750": 0.0517,
232
+ "33000": 0.0515,
233
+ "33250": 0.0512,
234
+ "33500": 0.051,
235
+ "33750": 0.0508,
236
+ "34000": 0.0506,
237
+ "34250": 0.0504,
238
+ "34500": 0.0502,
239
+ "34750": 0.05,
240
+ "35000": 0.0498,
241
+ "35250": 0.0496,
242
+ "35500": 0.0494,
243
+ "35750": 0.0492,
244
+ "36000": 0.0491,
245
+ "36250": 0.0489,
246
+ "36500": 0.0487,
247
+ "36750": 0.0485,
248
+ "37000": 0.0483,
249
+ "37250": 0.0482,
250
+ "37500": 0.048,
251
+ "37750": 0.0478,
252
+ "38000": 0.0476,
253
+ "38250": 0.0475,
254
+ "38500": 0.0473,
255
+ "38750": 0.0472,
256
+ "39000": 0.047,
257
+ "39250": 0.0469,
258
+ "39500": 0.0467,
259
+ "39750": 0.0465,
260
+ "40000": 0.0464,
261
+ "40250": 0.0463,
262
+ "40500": 0.0462,
263
+ "40750": 0.046,
264
+ "41000": 0.0459,
265
+ "41250": 0.0457,
266
+ "41500": 0.0456,
267
+ "41750": 0.0455,
268
+ "42000": 0.0453,
269
+ "42250": 0.0452,
270
+ "42500": 0.0451,
271
+ "42750": 0.045,
272
+ "43000": 0.0448,
273
+ "43250": 0.0447,
274
+ "43500": 0.0446,
275
+ "43750": 0.0445,
276
+ "44000": 0.0444,
277
+ "44250": 0.0443,
278
+ "44500": 0.0442,
279
+ "44750": 0.0441,
280
+ "45000": 0.044,
281
+ "45250": 0.0439,
282
+ "45500": 0.0438,
283
+ "45750": 0.0437,
284
+ "46000": 0.0436,
285
+ "46250": 0.0435,
286
+ "46500": 0.0435,
287
+ "46750": 0.0434,
288
+ "47000": 0.0433,
289
+ "47250": 0.0432,
290
+ "47500": 0.0431,
291
+ "47750": 0.043,
292
+ "48000": 0.0429,
293
+ "48250": 0.0428,
294
+ "48500": 0.0428,
295
+ "48750": 0.0427,
296
+ "49000": 0.0426,
297
+ "49250": 0.0426,
298
+ "49500": 0.0425,
299
+ "49750": 0.0424,
300
+ "50000": 0.0423
301
+ }
302
+ },
303
+ "reproducibility": {
304
+ "protocol": "https://github.com/zuo-kuangji/HumanWAM/blob/main/hb_training/REPRODUCIBILITY.md",
305
+ "protocol_commit": "dbd9bfe529e2a3229d01ad9e27b102cf9d821eec",
306
+ "training_seed": 42,
307
+ "inloop_mse_seed": 1234,
308
+ "aug_seed": 42,
309
+ "layout": {
310
+ "nodes": 1,
311
+ "gpus": 1,
312
+ "per_gpu_batch": 512,
313
+ "global_batch": 512,
314
+ "gradient_accumulation": 1,
315
+ "num_workers": 32,
316
+ "prefetch": 2
317
+ },
318
+ "environment": "hb-baselines (Python 3.12.1, torch 2.9.0+cu128, torchvision 0.24.0); training_records/pip_freeze_hb-baselines.txt",
319
+ "hardware": "NVIDIA GeForce RTX 4090 D (this checkpoint); continuation from step 6000; trained on the MLP RTX 4090D 24 GB from that start; stopped at the total step 50000 with the learning-rate curve of the planned schedule",
320
+ "code": "github.com/zuo-kuangji/Humanoid_benchmark bai @ 433ba198964eb54173f2beb5085ba96f7fab0f9e + the evaluation/baselines/train.py part of bai 39f9b83a (--stop-at; training_records/stopat_39f9b83a_train.diff)",
321
+ "determinism": "statistical reproducibility: same data commit, config, seed and layout give the same curves within run-to-run noise; GPU kernels are not bitwise deterministic",
322
+ "exceptions": [
323
+ "owner 2026-11-28: FM-DiT v1 base steps 58000 (HumanWAM bai a7c875b); steps = ceil1000(58000 x 614.98 frames per episode / 544.33) = 66000; continued from step 6000 to 66000; commanded hands (owner 2026-11-27)",
324
+ "owner 2026-11-30: FM-DiT 照原学习率曲线训到累计 50000 步截停(「行,截停」): --stop-at 50000, the learning-rate curve that of --steps; code = Humanoid_benchmark bai 433ba198 + stop-at patch (the evaluation/baselines/train.py part of bai 39f9b83a, git diff 39f9b83a^ 39f9b83a -- evaluation/baselines/train.py, sha256 db0911a84ba7a847befd22955ac99a9c04c2307a97f696be4e73da510fc19977); trained on the MLP 4090D (24 GB, one card, batch 512, same recipe as the A800)",
325
+ "continuation: owner 2026-11-28: 续训的步数比较多的就不需要去降低学习率的峰值。我觉得学习率峰值可以跟从头训一样去安排; FM-DiT v1 base 58000 (collaborator's A17 80000 steps on 751.84 frames/episode); measured -> commanded hands (owner: 续训时改成学指令手,肯定要这么做)",
326
+ "owner 2026-11-30: FM-DiT 照原学习率曲线训到累计 50000 步截停(「行,截停」); recorded in HumanWAM main 39a6b24 / dbd9bfe (hb_training/REPRODUCIBILITY.md section 7, protocol.yaml exceptions); train.py --stop-at 50000 = Humanoid_benchmark bai 433ba198 + the evaluation/baselines/train.py part of bai 39f9b83a (sha256 of the diff db0911a84ba7a847befd22955ac99a9c04c2307a97f696be4e73da510fc19977)"
327
+ ]
328
+ },
329
+ "inference": "Humanoid_benchmark evaluation/policy/FM_DIT (evaluation/baselines/adapters.py, runtime.BaselinePolicy) loads this folder (config.json + model.pt); training_records/ in the last step has the exact code",
330
+ "resume_state_included": false
331
+ }
b8-table-wipe/b512-cont-20261117-stop50k/step-050000/SHA256SUMS ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ d6d6cd3b1e8dc93116e8d3fa8a1b1ccbc1130a2cc92a53ab12246838713a5404 config.json
2
+ 20b971e928337046c8e6a7163d43a2b6e3590a1881db50f254b5f0678bbc70dc model.pt
3
+ 99d92cb1b0c06f46b67327bef0361e792c5c2a0ef4f4e434464bf513b597190a protocol.json
4
+ d1292971838d7eb488e7ebb102f9da1a41449aa46f0729703be1d1c51257498c training_records/code_hb_bai_433ba198_stopat39f9b83a/HB_CODE_COMMIT
5
+ 9f7713cea4f846efcfc924234267ced48210357f419d67915c10b504316bedde training_records/code_hb_bai_433ba198_stopat39f9b83a/evaluation/augmentation/hb_aug_v2.py
6
+ bfbb52f85ac5d91e37f3cfc24bb8671de447b5b566760bfe091204ae69e1f7f6 training_records/code_hb_bai_433ba198_stopat39f9b83a/evaluation/baselines/__init__.py
7
+ 3db95cd8e4e436875e11f1054a99d250ca7d94e0127909090b58730402340f19 training_records/code_hb_bai_433ba198_stopat39f9b83a/evaluation/baselines/act_nets.py
8
+ 87e47332381fcb34e75d08cb258475c200519cb5cf17fd0e218bf2a1b21fa890 training_records/code_hb_bai_433ba198_stopat39f9b83a/evaluation/baselines/adapters.py
9
+ e25699516ea9f4a9276fb1c57848055142799bf2535a30c4a6f4ca84f41bf4e3 training_records/code_hb_bai_433ba198_stopat39f9b83a/evaluation/baselines/check_flash_adapter.py
10
+ 91f714aa3b7ec6b5c28764496163671cadabe4a833c0b06b6bc4c155cec7f66f training_records/code_hb_bai_433ba198_stopat39f9b83a/evaluation/baselines/check_flash_parity.py
11
+ f4266f0896ef55f11915bc0a282c3c654660207b59ab89e6a14d6c685cfda44e training_records/code_hb_bai_433ba198_stopat39f9b83a/evaluation/baselines/data.py
12
+ 35c01a4e2edd80f85878b37928069c09ed3238127bbb51a5443e7f1c92703e53 training_records/code_hb_bai_433ba198_stopat39f9b83a/evaluation/baselines/flash.py
13
+ c987d9e641f5e5266703a8154b708d9ccab203b06d5ab82774d39a1cba602d62 training_records/code_hb_bai_433ba198_stopat39f9b83a/evaluation/baselines/fm_dit_v2.py
14
+ 0e6343d7d28893c4107864b943193eb4a402cf97b1625e94eb2acb1d163ca85c training_records/code_hb_bai_433ba198_stopat39f9b83a/evaluation/baselines/inloop.py
15
+ 2d72e3c455d5e376a6f5954886fd4c7a6478eb516380c6a05515fa043c62fbce training_records/code_hb_bai_433ba198_stopat39f9b83a/evaluation/baselines/nets.py
16
+ 38f2ea6050fa45e6c0d5e3f19caf21f1a72a50f80e356044dddcf76da22b144a training_records/code_hb_bai_433ba198_stopat39f9b83a/evaluation/baselines/ode_nets.py
17
+ 74ca169fe453f64bf6ffc3f3a85a4208aed2961d0abd9eb3e92b96457f86daf1 training_records/code_hb_bai_433ba198_stopat39f9b83a/evaluation/baselines/policies.py
18
+ 4b79b9dcc98f05bfe7bc9e64e3492f4565728f6d1f75cbdecc1c817d03ff32a5 training_records/code_hb_bai_433ba198_stopat39f9b83a/evaluation/baselines/requirements.lock.txt
19
+ 56a8db94a98c5256028b475d9a0293cdee4cf475e415df763b3a0232433663ba training_records/code_hb_bai_433ba198_stopat39f9b83a/evaluation/baselines/requirements.txt
20
+ 8cd8963bb87cdc453293a369658c97a97aadbef77281538d8a4c484925af00c5 training_records/code_hb_bai_433ba198_stopat39f9b83a/evaluation/baselines/runtime.py
21
+ a2868aee419c17676d586228e12d38029f323dd35e3ad4f34de1b0a8a079d7a0 training_records/code_hb_bai_433ba198_stopat39f9b83a/evaluation/baselines/train.py
22
+ b60c833306979ec73dd53108c522c7c84524a554374d41413b35fcb0c0e4a415 training_records/launch.sh
23
+ 1a52b1ba1848c0d1ec2919f884e647bcea4a095cb6c5056023262b2a2a122b82 training_records/logs/inloop-mse.jsonl
24
+ e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 training_records/pip_freeze_hb-baselines.txt
25
+ 162bde13a2620ee4f90c8b763f190fe10d27d23392c011138ca07811a7b7b898 training_records/run.json
26
+ db0911a84ba7a847befd22955ac99a9c04c2307a97f696be4e73da510fc19977 training_records/stopat_39f9b83a_train.diff
27
+ 2712bb699cd78d5b2c84049319b0244bd8667be050a878e8f3ff4c9d62e2f71e training_records/stopped.json
28
+ f7d3930b2b445172746d64bb7d0cd64d5bf9c34951fdffdb73cdf62b1a1af602 training_records/train.log
29
+ c94fa5fcfd5bda291de409bc4fb532f51dcfe38a856c6fbefadec9861ddc446e training_records/train_log.jsonl
b8-table-wipe/b512-cont-20261117-stop50k/step-050000/config.json ADDED
@@ -0,0 +1,1002 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "policy": {
3
+ "policy": "fm_dit",
4
+ "n_cameras": 2,
5
+ "state_dim": 44,
6
+ "action_dim": 76,
7
+ "horizon": 16,
8
+ "backbone": "resnet18",
9
+ "backbone_weights": "IMAGENET1K_V1",
10
+ "backbone_norm": "frozen_bn",
11
+ "hidden_dim": 384,
12
+ "num_layers": 4,
13
+ "num_heads": 8,
14
+ "mlp_ratio": 4.0,
15
+ "dropout": 0.1,
16
+ "time_embed_dim": 128,
17
+ "num_inference_steps": null,
18
+ "num_train_timesteps": 100,
19
+ "beta_schedule": "squaredcos_cap_v2",
20
+ "prediction_type": "epsilon",
21
+ "clip_sample": true,
22
+ "act_hidden_dim": 512,
23
+ "dim_feedforward": 3200,
24
+ "enc_layers": 4,
25
+ "dec_layers": 7,
26
+ "nheads": 8,
27
+ "latent_dim": 32,
28
+ "kl_weight": 10.0,
29
+ "ode_body_dim": null,
30
+ "ode_width": 512,
31
+ "ode_layers": 4,
32
+ "ode_cond_dim": 512,
33
+ "ode_field_scale": 1.0,
34
+ "ode_dit_hidden": 512,
35
+ "ode_dit_layers": 4,
36
+ "ode_dit_heads": 8,
37
+ "ode_dit_tokens": 4,
38
+ "extra": {}
39
+ },
40
+ "contract": {
41
+ "name": "g1_sonic_cmd",
42
+ "robot": "g1",
43
+ "cameras": [
44
+ "ego_view",
45
+ "chest"
46
+ ],
47
+ "state": [
48
+ [
49
+ "observation.state",
50
+ 0,
51
+ 29
52
+ ],
53
+ [
54
+ "observation.inspire_left_hand_state",
55
+ 0,
56
+ 6
57
+ ],
58
+ [
59
+ "observation.inspire_right_hand_state",
60
+ 0,
61
+ 6
62
+ ],
63
+ [
64
+ "observation.projected_gravity",
65
+ 0,
66
+ 3
67
+ ]
68
+ ],
69
+ "action": [
70
+ [
71
+ "action.motion_token",
72
+ 0,
73
+ 64
74
+ ],
75
+ [
76
+ "teleop.inspire_left_hand_cmd",
77
+ 0,
78
+ 6
79
+ ],
80
+ [
81
+ "teleop.inspire_right_hand_cmd",
82
+ 0,
83
+ 6
84
+ ]
85
+ ],
86
+ "state_dim": 44,
87
+ "action_dim": 76,
88
+ "action_space": "sonic_dfx6",
89
+ "body_dims": 29,
90
+ "history": [
91
+ [
92
+ "action.motion_token",
93
+ 0,
94
+ 64
95
+ ],
96
+ [
97
+ "observation.inspire_left_hand_state",
98
+ 0,
99
+ 6
100
+ ],
101
+ [
102
+ "observation.inspire_right_hand_state",
103
+ 0,
104
+ 6
105
+ ]
106
+ ]
107
+ },
108
+ "image_hw": [
109
+ 168,
110
+ 224
111
+ ],
112
+ "task_text": "Approach the flat block with a naturally aligned wrist, stop before closing the hand, wipe sideways at a top-view 45-degree heading, then set the block on the tabletop and release it.",
113
+ "dataset": {
114
+ "name": "b8-table-wipe-expert-v1-3b2e6180",
115
+ "root": "/root/hb_data/b8-table-wipe-expert-v1-3b2e6180",
116
+ "robot_type": null,
117
+ "fps": 30.0,
118
+ "episodes": [
119
+ 0,
120
+ 1,
121
+ 2,
122
+ 3,
123
+ 4,
124
+ 5,
125
+ 6,
126
+ 7,
127
+ 8,
128
+ 9,
129
+ 10,
130
+ 11,
131
+ 12,
132
+ 13,
133
+ 14,
134
+ 15,
135
+ 16,
136
+ 17,
137
+ 18,
138
+ 19,
139
+ 20,
140
+ 21,
141
+ 22,
142
+ 23,
143
+ 24,
144
+ 25,
145
+ 26,
146
+ 27,
147
+ 28,
148
+ 29,
149
+ 30,
150
+ 31,
151
+ 32,
152
+ 33,
153
+ 34,
154
+ 35,
155
+ 36,
156
+ 37,
157
+ 38,
158
+ 39,
159
+ 40,
160
+ 41,
161
+ 42,
162
+ 43,
163
+ 44,
164
+ 45,
165
+ 46,
166
+ 47,
167
+ 48,
168
+ 49,
169
+ 50,
170
+ 51,
171
+ 52,
172
+ 53,
173
+ 54,
174
+ 55,
175
+ 56,
176
+ 57,
177
+ 58,
178
+ 59,
179
+ 60,
180
+ 61,
181
+ 62,
182
+ 63,
183
+ 64,
184
+ 65,
185
+ 66,
186
+ 67,
187
+ 68,
188
+ 69,
189
+ 70,
190
+ 71,
191
+ 72,
192
+ 73,
193
+ 74,
194
+ 75,
195
+ 76,
196
+ 77,
197
+ 78,
198
+ 79,
199
+ 80,
200
+ 81,
201
+ 82,
202
+ 83,
203
+ 84,
204
+ 85,
205
+ 86,
206
+ 87,
207
+ 88,
208
+ 89,
209
+ 90,
210
+ 91,
211
+ 92,
212
+ 93,
213
+ 94,
214
+ 95,
215
+ 96,
216
+ 97,
217
+ 98,
218
+ 99
219
+ ],
220
+ "train_episodes": [
221
+ 0,
222
+ 1,
223
+ 2,
224
+ 3,
225
+ 4,
226
+ 5,
227
+ 6,
228
+ 7,
229
+ 8,
230
+ 9,
231
+ 10,
232
+ 11,
233
+ 12,
234
+ 13,
235
+ 14,
236
+ 15,
237
+ 16,
238
+ 17,
239
+ 18,
240
+ 19,
241
+ 20,
242
+ 21,
243
+ 22,
244
+ 23,
245
+ 24,
246
+ 25,
247
+ 26,
248
+ 27,
249
+ 28,
250
+ 29,
251
+ 30,
252
+ 31,
253
+ 32,
254
+ 33,
255
+ 34,
256
+ 35,
257
+ 36,
258
+ 37,
259
+ 38,
260
+ 39,
261
+ 40,
262
+ 41,
263
+ 42,
264
+ 43,
265
+ 44,
266
+ 45,
267
+ 46,
268
+ 47,
269
+ 48,
270
+ 49,
271
+ 50,
272
+ 51,
273
+ 52,
274
+ 53,
275
+ 54,
276
+ 55,
277
+ 56,
278
+ 57,
279
+ 58,
280
+ 59,
281
+ 60,
282
+ 61,
283
+ 62,
284
+ 63,
285
+ 64,
286
+ 65,
287
+ 66,
288
+ 67,
289
+ 68,
290
+ 69,
291
+ 70,
292
+ 71,
293
+ 72,
294
+ 73,
295
+ 74,
296
+ 75,
297
+ 76,
298
+ 77,
299
+ 78,
300
+ 79,
301
+ 80,
302
+ 81,
303
+ 82,
304
+ 83,
305
+ 84,
306
+ 85,
307
+ 86,
308
+ 87,
309
+ 88,
310
+ 89,
311
+ 90,
312
+ 91,
313
+ 92,
314
+ 93,
315
+ 94,
316
+ 95,
317
+ 96,
318
+ 97,
319
+ 98,
320
+ 99
321
+ ],
322
+ "val_episodes": [],
323
+ "train_frames": 61498,
324
+ "git_commit": null
325
+ },
326
+ "training": {
327
+ "steps": 60000,
328
+ "batch_size": 512,
329
+ "lr": 0.0001,
330
+ "betas": [
331
+ 0.95,
332
+ 0.999
333
+ ],
334
+ "weight_decay": 1e-06,
335
+ "warmup": 500,
336
+ "schedule": "linear warm-up + cosine",
337
+ "backbone_lr_scale": 0.1,
338
+ "ema": 0.9999,
339
+ "shift_px": 0,
340
+ "amp": true,
341
+ "seed": 42,
342
+ "augmentation": {
343
+ "spec": "docs/augmentation_v2.md",
344
+ "version": "hb-aug-v2-20261109",
345
+ "implementation": "evaluation/augmentation/hb_aug_v2.py",
346
+ "visual": {
347
+ "effects": [
348
+ "exposure",
349
+ "contrast",
350
+ "saturation",
351
+ "hue",
352
+ "gamma",
353
+ "temperature",
354
+ "rotation_crop",
355
+ "noise",
356
+ "gaussian_blur",
357
+ "jpeg",
358
+ "motion_blur",
359
+ "sharpen",
360
+ "defocus",
361
+ "light_shadow",
362
+ "wb_channel"
363
+ ],
364
+ "boosted_per_sample": 1,
365
+ "boost": 1.5,
366
+ "pixel_scale": "H / 224",
367
+ "future_targets": "none (one observation frame)"
368
+ },
369
+ "proprio": {
370
+ "robot": "g1",
371
+ "body_dims": 29,
372
+ "bias_deg": 2.0,
373
+ "bias_scope": "per_sample",
374
+ "noise_deg": 0.25,
375
+ "noise_clip_sigma": 3,
376
+ "delay_probability": 0.0,
377
+ "history_drop_probability": 0.0,
378
+ "velocity": false
379
+ },
380
+ "native_image_augmentation": "off",
381
+ "evaluation": "off"
382
+ },
383
+ "preflight": {
384
+ "samples": 64,
385
+ "state_dim": 44,
386
+ "body_dims": 29,
387
+ "images_changed": 64,
388
+ "body_values_moved": 1.0,
389
+ "max_body_offset_deg": 2.5908,
390
+ "actions_bit_identical": true,
391
+ "non_body_state_bit_identical": true,
392
+ "eval_items_deterministic": 8
393
+ },
394
+ "aug_seed": 42,
395
+ "layout": {
396
+ "nodes": 1,
397
+ "gpus": 1,
398
+ "per_gpu_batch": 512,
399
+ "global_batch": 512,
400
+ "gradient_accumulation": 1,
401
+ "num_workers": 32,
402
+ "prefetch": 2
403
+ },
404
+ "continuation": {
405
+ "init_from": "/root/hb_runs/flash30k/staging/fm_b8_init_source/checkpoints/step-006000",
406
+ "init_step": 6000,
407
+ "init_weights": "raw policy and EMA from /root/hb_runs/flash30k/staging/fm_b8_init_source/train_state.pt (written at step 6000)",
408
+ "init_model_sha256": "49f877e3a020061ca3fd91b94f178596a9348d02548e116ea261eeecb5675ed8",
409
+ "init_code_commit": "028df1bb7024fb1e3d176de7e60c84d3333cd97f",
410
+ "original_peak_lr": 0.0001,
411
+ "peak_lr": 0.0001,
412
+ "peak_lr_factor": 1.0,
413
+ "warmup_steps": 500,
414
+ "warmup_ratio": 0.008333,
415
+ "more_steps": 60000,
416
+ "total_steps": 66000,
417
+ "optimizer": "fresh AdamW (same groups, betas, weight decay)",
418
+ "schedule": "fresh: warm-up then the policy's cosine over the continuation steps",
419
+ "ema_decay_steps": "total steps (the EMA keeps averaging as in the original run)",
420
+ "init_contract": "g1_sonic_dfx6",
421
+ "hands_switch": "measured -> commanded hands (owner 2026-11-28); state and action normalizers re-fit on the data of this run",
422
+ "protocol": {
423
+ "peak_lr_factor": 0.3,
424
+ "warmup_ratio": 0.05,
425
+ "steps": [
426
+ 2000,
427
+ 4000
428
+ ],
429
+ "deviations": [
430
+ "lr 0.0001",
431
+ "warmup 500",
432
+ "steps 60000"
433
+ ],
434
+ "exception": "owner 2026-11-28: \u7eed\u8bad\u7684\u6b65\u6570\u6bd4\u8f83\u591a\u7684\u5c31\u4e0d\u9700\u8981\u53bb\u964d\u4f4e\u5b66\u4e60\u7387\u7684\u5cf0\u503c\u3002\u6211\u89c9\u5f97\u5b66\u4e60\u7387\u5cf0\u503c\u53ef\u4ee5\u8ddf\u4ece\u5934\u8bad\u4e00\u6837\u53bb\u5b89\u6392; FM-DiT v1 base 58000 (collaborator's A17 80000 steps on 751.84 frames/episode); measured -> commanded hands (owner: \u7eed\u8bad\u65f6\u6539\u6210\u5b66\u6307\u4ee4\u624b\uff0c\u80af\u5b9a\u8981\u8fd9\u4e48\u505a)"
435
+ }
436
+ },
437
+ "total_steps": 66000,
438
+ "save_steps": [
439
+ 16000,
440
+ 26000,
441
+ 36000,
442
+ 46000,
443
+ 50000,
444
+ 56000,
445
+ 66000
446
+ ],
447
+ "save_rule": "6 checkpoints spread evenly over the steps on the 250-step grid (owner 2026-11-27)",
448
+ "protocol_exceptions": [
449
+ "owner 2026-11-28: FM-DiT v1 base steps 58000 (HumanWAM bai a7c875b); steps = ceil1000(58000 x 614.98 frames per episode / 544.33) = 66000; continued from step 6000 to 66000; commanded hands (owner 2026-11-27)",
450
+ "owner 2026-11-30: FM-DiT \u7167\u539f\u5b66\u4e60\u7387\u66f2\u7ebf\u8bad\u5230\u7d2f\u8ba1 50000 \u6b65\u622a\u505c\uff08\u300c\u884c\uff0c\u622a\u505c\u300d\uff09: --stop-at 50000, the learning-rate curve that of --steps; code = Humanoid_benchmark bai 433ba198 + stop-at patch (the evaluation/baselines/train.py part of bai 39f9b83a, git diff 39f9b83a^ 39f9b83a -- evaluation/baselines/train.py, sha256 db0911a84ba7a847befd22955ac99a9c04c2307a97f696be4e73da510fc19977); trained on the MLP 4090D (24 GB, one card, batch 512, same recipe as the A800)"
451
+ ],
452
+ "stop_at": 50000,
453
+ "ema_schedule": "hb",
454
+ "inloop": {
455
+ "task": "b8c",
456
+ "code": "/root/hb_runs/flash30k/policies/eval-action-mse",
457
+ "every": 250,
458
+ "exception": null,
459
+ "code_sha256": {
460
+ "hb_inloop_core.py": "154fa6d905e32d61c0def546caf6979c3a148b7bef0c1284e773b9051dddce97",
461
+ "hb_eval_common.py": "d89b1bfc1ac03d489b6ba2ac7c61eab3f318023ec37677dd5ee02b93d851d6ac"
462
+ }
463
+ },
464
+ "protocol_recipe": {
465
+ "batch_size": 512,
466
+ "long_task_factor": 1
467
+ },
468
+ "protocol_deviations": [],
469
+ "environment": {
470
+ "python": "3.12.1",
471
+ "torch": "2.9.0+cu128",
472
+ "numpy": "2.2.6",
473
+ "cuda": "12.8",
474
+ "cudnn": 91002,
475
+ "torchvision": "0.24.0+cu128",
476
+ "pillow": "13.0.0",
477
+ "gpu": "NVIDIA GeForce RTX 4090 D",
478
+ "driver": "595.58.03"
479
+ },
480
+ "code_dirty": null,
481
+ "allow_dirty_tree": false,
482
+ "augmentation_sha256": "9f7713cea4f846efcfc924234267ced48210357f419d67915c10b504316bedde",
483
+ "order": "EpochSampler: default_rng([seed, 1, epoch]) permutation; augmentation default_rng([aug_seed, draw])"
484
+ },
485
+ "stats": {
486
+ "state": {
487
+ "min": [
488
+ -0.2515260875225067,
489
+ -0.03310006856918335,
490
+ -0.08915279805660248,
491
+ 0.14301416277885437,
492
+ -0.18305416405200958,
493
+ -0.10634835064411163,
494
+ -0.2634684145450592,
495
+ -0.05348178371787071,
496
+ -0.21431514620780945,
497
+ 0.13807232677936554,
498
+ -0.2242385447025299,
499
+ -0.09678935259580612,
500
+ -0.18892650306224823,
501
+ -0.10323800146579742,
502
+ -0.09472811967134476,
503
+ -0.2798849642276764,
504
+ 0.1722967028617859,
505
+ -1.1891459226608276,
506
+ 0.3821650445461273,
507
+ -0.5277573466300964,
508
+ -0.1239900067448616,
509
+ -0.025756916031241417,
510
+ -1.5671592950820923,
511
+ -1.708814024925232,
512
+ -0.94542396068573,
513
+ -0.8548623323440552,
514
+ -0.9579849243164062,
515
+ -0.9779664278030396,
516
+ -0.5873764157295227,
517
+ 0.9998621344566345,
518
+ 0.9998221397399902,
519
+ 0.9998023509979248,
520
+ 0.9998185634613037,
521
+ 0.9975361227989197,
522
+ 0.9988760948181152,
523
+ 0.360027939081192,
524
+ 0.4790782630443573,
525
+ 0.5461887717247009,
526
+ 0.48382189869880676,
527
+ 0.6635858416557312,
528
+ 0.0,
529
+ -0.10022255033254623,
530
+ -0.03946204483509064,
531
+ -1.0
532
+ ],
533
+ "max": [
534
+ 0.00482684513553977,
535
+ 0.13756881654262543,
536
+ 0.2979176640510559,
537
+ 0.3711587190628052,
538
+ 0.031152762472629547,
539
+ 0.010087746195495129,
540
+ 0.019378269091248512,
541
+ 0.1355365365743637,
542
+ 0.182325080037117,
543
+ 0.4443013668060303,
544
+ -0.05482839047908783,
545
+ 0.011374615132808685,
546
+ 0.165291890501976,
547
+ 0.05307222157716751,
548
+ 0.177412211894989,
549
+ 0.22115345299243927,
550
+ 0.6989883780479431,
551
+ -0.3335850238800049,
552
+ 1.1546826362609863,
553
+ 0.28441083431243896,
554
+ 0.08963758498430252,
555
+ 0.3550512492656708,
556
+ 1.1140739917755127,
557
+ -0.22596199810504913,
558
+ 1.7804871797561646,
559
+ 1.2184052467346191,
560
+ 1.2347023487091064,
561
+ 1.5067987442016602,
562
+ 1.0105962753295898,
563
+ 1.0,
564
+ 1.0,
565
+ 1.0,
566
+ 1.0,
567
+ 0.9982408285140991,
568
+ 0.9999225735664368,
569
+ 1.0,
570
+ 1.0,
571
+ 1.0,
572
+ 0.9999973177909851,
573
+ 1.0,
574
+ 1.0,
575
+ 0.038201265037059784,
576
+ 0.023285934701561928,
577
+ -0.9949650168418884
578
+ ],
579
+ "mean": [
580
+ -0.07244415528619287,
581
+ 0.016438895257606716,
582
+ -0.03188766069938736,
583
+ 0.19652274108921836,
584
+ -0.09995080381043964,
585
+ -0.0335864852112993,
586
+ -0.06201331924385435,
587
+ 0.0041316509641342114,
588
+ -0.07562538691067132,
589
+ 0.22342829523439264,
590
+ -0.13939505500881355,
591
+ -0.02568257955335654,
592
+ 0.020507808718722174,
593
+ 0.0030919114143910654,
594
+ 0.11976549024164236,
595
+ -0.04130542899628228,
596
+ 0.27413152575942573,
597
+ -0.667075950232086,
598
+ 0.9776525052369189,
599
+ -0.15594609082852004,
600
+ -0.04114803172895316,
601
+ 0.07066678088305102,
602
+ -0.44530701068620304,
603
+ -0.7956643808095055,
604
+ 0.6432070891275159,
605
+ 0.07140851169135853,
606
+ -0.22403887370387132,
607
+ 0.19658286211869352,
608
+ 0.3118955244879216,
609
+ 0.9999827171293537,
610
+ 0.999982850921418,
611
+ 0.9999830789480982,
612
+ 0.9999811406495951,
613
+ 0.9977658298817017,
614
+ 0.9997360855995177,
615
+ 0.7778945983312991,
616
+ 0.8171959691692932,
617
+ 0.8399288212288848,
618
+ 0.8394280370284749,
619
+ 0.8745686375938581,
620
+ 0.12291562838728093,
621
+ -0.023435156143715264,
622
+ -0.004820223051842413,
623
+ -0.999617456030026
624
+ ],
625
+ "std": [
626
+ 0.045712745420827386,
627
+ 0.013154301249487431,
628
+ 0.02405439153160751,
629
+ 0.0422870935042734,
630
+ 0.01604373013239405,
631
+ 0.010666838959405088,
632
+ 0.0447255039612766,
633
+ 0.014369854397034587,
634
+ 0.025451572022126993,
635
+ 0.05279699313574748,
636
+ 0.02213303083995789,
637
+ 0.011183898115253933,
638
+ 0.07041149453770397,
639
+ 0.015833724218855847,
640
+ 0.039560888033149964,
641
+ 0.08342761969885264,
642
+ 0.0587237913039723,
643
+ 0.22301655606787774,
644
+ 0.08125572382728762,
645
+ 0.1281115145665045,
646
+ 0.03600107397023974,
647
+ 0.04123008646611267,
648
+ 0.5831912382159029,
649
+ 0.23706341250281637,
650
+ 0.5432748450536339,
651
+ 0.504036388323598,
652
+ 0.31188020039153314,
653
+ 0.3436391052756804,
654
+ 0.26504982482523237,
655
+ 1.8214790335763182e-05,
656
+ 2.3385127857745866e-05,
657
+ 2.5684815254370892e-05,
658
+ 2.368414515012511e-05,
659
+ 7.802892144541008e-05,
660
+ 6.03931448414821e-05,
661
+ 0.2307055833669559,
662
+ 0.1900819078013402,
663
+ 0.16354430170740317,
664
+ 0.16593648793853702,
665
+ 0.1286487353890603,
666
+ 0.3083183803524622,
667
+ 0.013093107258771247,
668
+ 0.004580775936054731,
669
+ 0.0002959946385408924
670
+ ]
671
+ },
672
+ "action": {
673
+ "min": [
674
+ 0.0,
675
+ -0.375,
676
+ -0.4375,
677
+ -0.125,
678
+ -0.375,
679
+ -0.3125,
680
+ -0.375,
681
+ -0.3125,
682
+ -0.25,
683
+ -0.25,
684
+ -0.5625,
685
+ -0.1875,
686
+ -0.125,
687
+ -0.3125,
688
+ -0.125,
689
+ -0.25,
690
+ -0.125,
691
+ -0.1875,
692
+ -0.5,
693
+ -0.25,
694
+ -0.1875,
695
+ -0.5625,
696
+ -0.25,
697
+ -0.375,
698
+ -0.4375,
699
+ -0.0625,
700
+ -0.375,
701
+ -0.375,
702
+ -0.3125,
703
+ -0.3125,
704
+ 0.0,
705
+ 0.125,
706
+ -0.3125,
707
+ 0.0,
708
+ 0.125,
709
+ -0.4375,
710
+ -0.1875,
711
+ -0.4375,
712
+ -0.25,
713
+ -0.1875,
714
+ -0.4375,
715
+ -0.375,
716
+ -0.1875,
717
+ -0.0625,
718
+ -0.3125,
719
+ -0.25,
720
+ -0.1875,
721
+ -0.3125,
722
+ -0.3125,
723
+ -0.5625,
724
+ -0.125,
725
+ -0.125,
726
+ -0.4375,
727
+ -0.5,
728
+ -0.1875,
729
+ -0.25,
730
+ -0.375,
731
+ -0.0625,
732
+ -0.4375,
733
+ -0.25,
734
+ -0.4375,
735
+ 0.0625,
736
+ -0.25,
737
+ 0.0,
738
+ 1.0,
739
+ 1.0,
740
+ 1.0,
741
+ 1.0,
742
+ 1.0,
743
+ 1.0,
744
+ 0.36000001430511475,
745
+ 0.36000001430511475,
746
+ 0.36000001430511475,
747
+ 0.36000001430511475,
748
+ 0.36000001430511475,
749
+ 0.0
750
+ ],
751
+ "max": [
752
+ 0.375,
753
+ 0.25,
754
+ 0.25,
755
+ 0.1875,
756
+ 0.1875,
757
+ 0.1875,
758
+ 0.25,
759
+ 0.25,
760
+ 0.1875,
761
+ 0.125,
762
+ 0.0625,
763
+ 0.1875,
764
+ 0.5,
765
+ 0.1875,
766
+ 0.25,
767
+ 0.0625,
768
+ 0.3125,
769
+ 0.5,
770
+ 0.1875,
771
+ 0.25,
772
+ 0.25,
773
+ 0.0625,
774
+ 0.4375,
775
+ 0.25,
776
+ 0.0,
777
+ 0.4375,
778
+ 0.0,
779
+ 0.1875,
780
+ 0.1875,
781
+ 0.1875,
782
+ 0.4375,
783
+ 0.5,
784
+ 0.3125,
785
+ 0.3125,
786
+ 0.3125,
787
+ 0.0625,
788
+ 0.1875,
789
+ 0.3125,
790
+ 0.1875,
791
+ 0.25,
792
+ 0.0,
793
+ 0.25,
794
+ 0.125,
795
+ 0.5,
796
+ 0.125,
797
+ 0.5,
798
+ 0.4375,
799
+ 0.4375,
800
+ 0.4375,
801
+ 0.0,
802
+ 0.125,
803
+ 0.25,
804
+ 0.5,
805
+ -0.0625,
806
+ 0.125,
807
+ 0.4375,
808
+ 0.5,
809
+ 0.3125,
810
+ 0.125,
811
+ 0.125,
812
+ 0.125,
813
+ 0.5,
814
+ 0.125,
815
+ 0.6875,
816
+ 1.0,
817
+ 1.0,
818
+ 1.0,
819
+ 1.0,
820
+ 1.0,
821
+ 1.0,
822
+ 1.0,
823
+ 1.0,
824
+ 1.0,
825
+ 1.0,
826
+ 1.0,
827
+ 1.0
828
+ ],
829
+ "mean": [
830
+ 0.2026803717194055,
831
+ -0.07236617450974016,
832
+ -0.02242552603336694,
833
+ 0.02358918176200852,
834
+ -0.12101816319229894,
835
+ -0.10377979771699893,
836
+ -0.04818144492503821,
837
+ -0.09367987576831767,
838
+ -0.015672257634394615,
839
+ -0.07295460827994406,
840
+ -0.28937628052944814,
841
+ 0.023045464893167257,
842
+ 0.12778362710982472,
843
+ -0.014680355458714104,
844
+ 0.047179379817229826,
845
+ -0.12413716706234348,
846
+ 0.0648974356889655,
847
+ 0.1738440680997756,
848
+ -0.1366050521968194,
849
+ 0.05253626134183226,
850
+ 0.005097726755341637,
851
+ -0.21554664379329408,
852
+ 0.09576226056131906,
853
+ -0.11485841002959446,
854
+ -0.21714120784415752,
855
+ 0.25317489999674786,
856
+ -0.23478507431135973,
857
+ -0.10450746365735471,
858
+ -0.049666249308920614,
859
+ -0.03343909558034407,
860
+ 0.2612117467234707,
861
+ 0.28021846238902076,
862
+ 0.013058351491105402,
863
+ 0.14741942827409021,
864
+ 0.23094043708738496,
865
+ -0.2599698364174445,
866
+ 0.054112532114865525,
867
+ -0.18685465380988,
868
+ -0.021627735861328823,
869
+ -0.045454730235129595,
870
+ -0.261119264041107,
871
+ -0.09780399362580897,
872
+ -0.03171647858466942,
873
+ 0.30728844840482616,
874
+ -0.13527167550164232,
875
+ 0.061584319815278545,
876
+ 0.07089966340368792,
877
+ 0.06740158216527367,
878
+ 0.18057091287521546,
879
+ -0.27359832840092363,
880
+ -0.01098104816416794,
881
+ 0.03545237243487593,
882
+ 0.1730208705974178,
883
+ -0.26741316790789943,
884
+ -0.03493507918956714,
885
+ 0.1694120133988097,
886
+ 0.01502691144427461,
887
+ 0.05571421021821848,
888
+ -0.22518415233015707,
889
+ -0.05392248528407428,
890
+ -0.1961598344661615,
891
+ 0.3429247699112166,
892
+ -0.04006126215486683,
893
+ 0.40486580864418353,
894
+ 1.0,
895
+ 1.0,
896
+ 1.0,
897
+ 1.0,
898
+ 1.0,
899
+ 1.0,
900
+ 0.7644257025600019,
901
+ 0.7644257025600019,
902
+ 0.7644257025600019,
903
+ 0.7644257025600019,
904
+ 0.7659686295247596,
905
+ 0.13423402414162272
906
+ ],
907
+ "std": [
908
+ 0.07423638798986239,
909
+ 0.10276070894626457,
910
+ 0.11812702387971753,
911
+ 0.05957396656117891,
912
+ 0.1218417031488596,
913
+ 0.08063836551976374,
914
+ 0.1020635000819969,
915
+ 0.10540346375069484,
916
+ 0.08296831170197061,
917
+ 0.05989282207073844,
918
+ 0.131405419274155,
919
+ 0.07688508477180626,
920
+ 0.15530657456533145,
921
+ 0.09090021877289593,
922
+ 0.07144535330531092,
923
+ 0.07721423672952077,
924
+ 0.061937753226413185,
925
+ 0.12535445915332458,
926
+ 0.1406645362754369,
927
+ 0.09610483490082063,
928
+ 0.0892112540257282,
929
+ 0.10101183108941218,
930
+ 0.14459992137856284,
931
+ 0.09259695505428482,
932
+ 0.07250089525780803,
933
+ 0.07751064616894329,
934
+ 0.09003536032570492,
935
+ 0.08768655804866919,
936
+ 0.0793513264967945,
937
+ 0.0799717022695259,
938
+ 0.08767655242632699,
939
+ 0.06686962750120226,
940
+ 0.11139553980852172,
941
+ 0.05962527954838032,
942
+ 0.03113638664810605,
943
+ 0.1104336480130166,
944
+ 0.0900293543854962,
945
+ 0.17353368370821917,
946
+ 0.06621053001132303,
947
+ 0.07044267349366652,
948
+ 0.07468062148900616,
949
+ 0.13559357690832427,
950
+ 0.051673248141484364,
951
+ 0.11970962808802042,
952
+ 0.09873016730126778,
953
+ 0.1482997857923691,
954
+ 0.14644960009292055,
955
+ 0.12362418143308783,
956
+ 0.14892813932159055,
957
+ 0.1264928491368565,
958
+ 0.04485723360367807,
959
+ 0.06556638017875786,
960
+ 0.23014907315132233,
961
+ 0.07366488770406758,
962
+ 0.05520901424631441,
963
+ 0.1518289001396863,
964
+ 0.1840720418570084,
965
+ 0.05832378814080937,
966
+ 0.11903714776197126,
967
+ 0.05677283141546173,
968
+ 0.09207849117719222,
969
+ 0.09729334507011746,
970
+ 0.0780996197326025,
971
+ 0.16351388381996734,
972
+ 0.0,
973
+ 0.0,
974
+ 0.0,
975
+ 0.0,
976
+ 0.0,
977
+ 0.0,
978
+ 0.24588449589222341,
979
+ 0.24588449589222341,
980
+ 0.24588449589222341,
981
+ 0.24588449589222341,
982
+ 0.24578410015930552,
983
+ 0.3348986548442017
984
+ ]
985
+ }
986
+ },
987
+ "code_commit": "433ba198964eb54173f2beb5085ba96f7fab0f9e",
988
+ "task": "b8c",
989
+ "dataset_id": "humanoid-benchmark/b8-table-wipe-expert-v1@3b2e6180508f84f70fda8b33cd3e41c14225f0b5",
990
+ "step": 50000,
991
+ "weights": "ema",
992
+ "offline_eval": {
993
+ "mse": 0.005728583782911301,
994
+ "mse_row0": 0.006520981900393963,
995
+ "mse_motion_token": 0.006324972957372665,
996
+ "mse_inspire_left_hand_cmd": 2.261386725876946e-05,
997
+ "mse_inspire_right_hand_cmd": 0.005073076114058495,
998
+ "samples": 256,
999
+ "frames": "train"
1000
+ },
1001
+ "format": "hb_baselines/1"
1002
+ }
b8-table-wipe/b512-cont-20261117-stop50k/step-050000/model.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:20b971e928337046c8e6a7163d43a2b6e3590a1881db50f254b5f0678bbc70dc
3
+ size 90315733
b8-table-wipe/b512-cont-20261117-stop50k/step-050000/protocol.json ADDED
@@ -0,0 +1,435 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "format": "hb_baselines/1",
3
+ "step": 50000,
4
+ "policy": "fm_dit",
5
+ "task": "b8c",
6
+ "dataset_id": "humanoid-benchmark/b8-table-wipe-expert-v1@3b2e6180508f84f70fda8b33cd3e41c14225f0b5",
7
+ "episodes": 100,
8
+ "frames": 61498,
9
+ "fps": 30.0,
10
+ "steps": 60000,
11
+ "total_steps": 66000,
12
+ "save_steps": [
13
+ 16000,
14
+ 26000,
15
+ 36000,
16
+ 46000,
17
+ 50000,
18
+ 56000,
19
+ 66000
20
+ ],
21
+ "global_batch": 512,
22
+ "per_gpu_batch": 512,
23
+ "num_gpus": 1,
24
+ "gradient_accumulation_steps": 1,
25
+ "lr": 0.0001,
26
+ "warmup": 500,
27
+ "schedule": "linear warm-up + cosine",
28
+ "seed": 42,
29
+ "aug_seed": 42,
30
+ "code_commit": "433ba198964eb54173f2beb5085ba96f7fab0f9e",
31
+ "code_dirty": null,
32
+ "environment": {
33
+ "python": "3.12.1",
34
+ "torch": "2.9.0+cu128",
35
+ "numpy": "2.2.6",
36
+ "cuda": "12.8",
37
+ "cudnn": 91002,
38
+ "torchvision": "0.24.0+cu128",
39
+ "pillow": "13.0.0",
40
+ "gpu": "NVIDIA GeForce RTX 4090 D",
41
+ "driver": "595.58.03"
42
+ },
43
+ "continuation": {
44
+ "init_from": "/root/hb_runs/flash30k/staging/fm_b8_init_source/checkpoints/step-006000",
45
+ "init_step": 6000,
46
+ "init_weights": "raw policy and EMA from /root/hb_runs/flash30k/staging/fm_b8_init_source/train_state.pt (written at step 6000)",
47
+ "init_model_sha256": "49f877e3a020061ca3fd91b94f178596a9348d02548e116ea261eeecb5675ed8",
48
+ "init_code_commit": "028df1bb7024fb1e3d176de7e60c84d3333cd97f",
49
+ "original_peak_lr": 0.0001,
50
+ "peak_lr": 0.0001,
51
+ "peak_lr_factor": 1.0,
52
+ "warmup_steps": 500,
53
+ "warmup_ratio": 0.008333,
54
+ "more_steps": 60000,
55
+ "total_steps": 66000,
56
+ "optimizer": "fresh AdamW (same groups, betas, weight decay)",
57
+ "schedule": "fresh: warm-up then the policy's cosine over the continuation steps",
58
+ "ema_decay_steps": "total steps (the EMA keeps averaging as in the original run)",
59
+ "init_contract": "g1_sonic_dfx6",
60
+ "hands_switch": "measured -> commanded hands (owner 2026-11-28); state and action normalizers re-fit on the data of this run",
61
+ "protocol": {
62
+ "peak_lr_factor": 0.3,
63
+ "warmup_ratio": 0.05,
64
+ "steps": [
65
+ 2000,
66
+ 4000
67
+ ],
68
+ "deviations": [
69
+ "lr 0.0001",
70
+ "warmup 500",
71
+ "steps 60000"
72
+ ],
73
+ "exception": "owner 2026-11-28: 续训的步数比较多的就不需要去降低学习率的峰值。我觉得学习率峰值可以跟从头训一样去安排; FM-DiT v1 base 58000 (collaborator's A17 80000 steps on 751.84 frames/episode); measured -> commanded hands (owner: 续训时改成学指令手,肯定要这么做)"
74
+ }
75
+ },
76
+ "protocol_deviations": [],
77
+ "protocol_exceptions": [
78
+ "owner 2026-11-28: FM-DiT v1 base steps 58000 (HumanWAM bai a7c875b); steps = ceil1000(58000 x 614.98 frames per episode / 544.33) = 66000; continued from step 6000 to 66000; commanded hands (owner 2026-11-27)",
79
+ "owner 2026-11-30: FM-DiT 照原学习率曲线训到累计 50000 步截停(「行,截停」): --stop-at 50000, the learning-rate curve that of --steps; code = Humanoid_benchmark bai 433ba198 + stop-at patch (the evaluation/baselines/train.py part of bai 39f9b83a, git diff 39f9b83a^ 39f9b83a -- evaluation/baselines/train.py, sha256 db0911a84ba7a847befd22955ac99a9c04c2307a97f696be4e73da510fc19977); trained on the MLP 4090D (24 GB, one card, batch 512, same recipe as the A800)"
80
+ ],
81
+ "files": {
82
+ "config.json": {
83
+ "bytes": 19331,
84
+ "sha256": "d6d6cd3b1e8dc93116e8d3fa8a1b1ccbc1130a2cc92a53ab12246838713a5404"
85
+ },
86
+ "model.pt": {
87
+ "bytes": 90315733,
88
+ "sha256": "20b971e928337046c8e6a7163d43a2b6e3590a1881db50f254b5f0678bbc70dc"
89
+ },
90
+ "training_records/code_hb_bai_433ba198_stopat39f9b83a/HB_CODE_COMMIT": {
91
+ "bytes": 332,
92
+ "sha256": "d1292971838d7eb488e7ebb102f9da1a41449aa46f0729703be1d1c51257498c"
93
+ },
94
+ "training_records/code_hb_bai_433ba198_stopat39f9b83a/evaluation/augmentation/hb_aug_v2.py": {
95
+ "bytes": 7475,
96
+ "sha256": "9f7713cea4f846efcfc924234267ced48210357f419d67915c10b504316bedde"
97
+ },
98
+ "training_records/code_hb_bai_433ba198_stopat39f9b83a/evaluation/baselines/__init__.py": {
99
+ "bytes": 1060,
100
+ "sha256": "bfbb52f85ac5d91e37f3cfc24bb8671de447b5b566760bfe091204ae69e1f7f6"
101
+ },
102
+ "training_records/code_hb_bai_433ba198_stopat39f9b83a/evaluation/baselines/act_nets.py": {
103
+ "bytes": 22435,
104
+ "sha256": "3db95cd8e4e436875e11f1054a99d250ca7d94e0127909090b58730402340f19"
105
+ },
106
+ "training_records/code_hb_bai_433ba198_stopat39f9b83a/evaluation/baselines/adapters.py": {
107
+ "bytes": 3479,
108
+ "sha256": "87e47332381fcb34e75d08cb258475c200519cb5cf17fd0e218bf2a1b21fa890"
109
+ },
110
+ "training_records/code_hb_bai_433ba198_stopat39f9b83a/evaluation/baselines/check_flash_adapter.py": {
111
+ "bytes": 6004,
112
+ "sha256": "e25699516ea9f4a9276fb1c57848055142799bf2535a30c4a6f4ca84f41bf4e3"
113
+ },
114
+ "training_records/code_hb_bai_433ba198_stopat39f9b83a/evaluation/baselines/check_flash_parity.py": {
115
+ "bytes": 7900,
116
+ "sha256": "91f714aa3b7ec6b5c28764496163671cadabe4a833c0b06b6bc4c155cec7f66f"
117
+ },
118
+ "training_records/code_hb_bai_433ba198_stopat39f9b83a/evaluation/baselines/data.py": {
119
+ "bytes": 23892,
120
+ "sha256": "f4266f0896ef55f11915bc0a282c3c654660207b59ab89e6a14d6c685cfda44e"
121
+ },
122
+ "training_records/code_hb_bai_433ba198_stopat39f9b83a/evaluation/baselines/flash.py": {
123
+ "bytes": 24032,
124
+ "sha256": "35c01a4e2edd80f85878b37928069c09ed3238127bbb51a5443e7f1c92703e53"
125
+ },
126
+ "training_records/code_hb_bai_433ba198_stopat39f9b83a/evaluation/baselines/fm_dit_v2.py": {
127
+ "bytes": 6013,
128
+ "sha256": "c987d9e641f5e5266703a8154b708d9ccab203b06d5ab82774d39a1cba602d62"
129
+ },
130
+ "training_records/code_hb_bai_433ba198_stopat39f9b83a/evaluation/baselines/inloop.py": {
131
+ "bytes": 6993,
132
+ "sha256": "0e6343d7d28893c4107864b943193eb4a402cf97b1625e94eb2acb1d163ca85c"
133
+ },
134
+ "training_records/code_hb_bai_433ba198_stopat39f9b83a/evaluation/baselines/nets.py": {
135
+ "bytes": 10478,
136
+ "sha256": "2d72e3c455d5e376a6f5954886fd4c7a6478eb516380c6a05515fa043c62fbce"
137
+ },
138
+ "training_records/code_hb_bai_433ba198_stopat39f9b83a/evaluation/baselines/ode_nets.py": {
139
+ "bytes": 9148,
140
+ "sha256": "38f2ea6050fa45e6c0d5e3f19caf21f1a72a50f80e356044dddcf76da22b144a"
141
+ },
142
+ "training_records/code_hb_bai_433ba198_stopat39f9b83a/evaluation/baselines/policies.py": {
143
+ "bytes": 25760,
144
+ "sha256": "74ca169fe453f64bf6ffc3f3a85a4208aed2961d0abd9eb3e92b96457f86daf1"
145
+ },
146
+ "training_records/code_hb_bai_433ba198_stopat39f9b83a/evaluation/baselines/requirements.lock.txt": {
147
+ "bytes": 1481,
148
+ "sha256": "4b79b9dcc98f05bfe7bc9e64e3492f4565728f6d1f75cbdecc1c817d03ff32a5"
149
+ },
150
+ "training_records/code_hb_bai_433ba198_stopat39f9b83a/evaluation/baselines/requirements.txt": {
151
+ "bytes": 850,
152
+ "sha256": "56a8db94a98c5256028b475d9a0293cdee4cf475e415df763b3a0232433663ba"
153
+ },
154
+ "training_records/code_hb_bai_433ba198_stopat39f9b83a/evaluation/baselines/runtime.py": {
155
+ "bytes": 11034,
156
+ "sha256": "8cd8963bb87cdc453293a369658c97a97aadbef77281538d8a4c484925af00c5"
157
+ },
158
+ "training_records/code_hb_bai_433ba198_stopat39f9b83a/evaluation/baselines/train.py": {
159
+ "bytes": 64805,
160
+ "sha256": "a2868aee419c17676d586228e12d38029f323dd35e3ad4f34de1b0a8a079d7a0"
161
+ },
162
+ "training_records/launch.sh": {
163
+ "bytes": 2982,
164
+ "sha256": "b60c833306979ec73dd53108c522c7c84524a554374d41413b35fcb0c0e4a415"
165
+ },
166
+ "training_records/logs/inloop-mse.jsonl": {
167
+ "bytes": 288307,
168
+ "sha256": "1a52b1ba1848c0d1ec2919f884e647bcea4a095cb6c5056023262b2a2a122b82"
169
+ },
170
+ "training_records/pip_freeze_hb-baselines.txt": {
171
+ "bytes": 0,
172
+ "sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"
173
+ },
174
+ "training_records/run.json": {
175
+ "bytes": 21239,
176
+ "sha256": "162bde13a2620ee4f90c8b763f190fe10d27d23392c011138ca07811a7b7b898"
177
+ },
178
+ "training_records/stopat_39f9b83a_train.diff": {
179
+ "bytes": 5691,
180
+ "sha256": "db0911a84ba7a847befd22955ac99a9c04c2307a97f696be4e73da510fc19977"
181
+ },
182
+ "training_records/stopped.json": {
183
+ "bytes": 548,
184
+ "sha256": "2712bb699cd78d5b2c84049319b0244bd8667be050a878e8f3ff4c9d62e2f71e"
185
+ },
186
+ "training_records/train.log": {
187
+ "bytes": 211608,
188
+ "sha256": "f7d3930b2b445172746d64bb7d0cd64d5bf9c34951fdffdb73cdf62b1a1af602"
189
+ },
190
+ "training_records/train_log.jsonl": {
191
+ "bytes": 189761,
192
+ "sha256": "c94fa5fcfd5bda291de409bc4fb532f51dcfe38a856c6fbefadec9861ddc446e"
193
+ }
194
+ },
195
+ "global_step": 50000,
196
+ "run_step": 44000,
197
+ "stop_at": 50000,
198
+ "planned_total_steps": 66000,
199
+ "task_dir": "b8-table-wipe",
200
+ "training_data": "humanoid-benchmark/b8-table-wipe-expert-v1 @3b2e6180 (100 episodes, commanded hands)",
201
+ "published_steps": [
202
+ 46000,
203
+ 50000
204
+ ],
205
+ "lr_schedule": "linear warm-up + cosine after a 500-step linear warm-up",
206
+ "ema": 0.9999,
207
+ "augmentation": "Humanoid Benchmark online augmentation spec v2 (hb-aug-v2-20261109): 15 visual effects, one per sample at 1.5x; proprio per-joint bias U(+-2 deg) + N(0, 0.25 deg); no delay, no history drop; model-native image augmentation off",
208
+ "state_dim": 44,
209
+ "action_dim": 76,
210
+ "cameras": [
211
+ "ego_view",
212
+ "chest"
213
+ ],
214
+ "contract": "g1_sonic_cmd",
215
+ "image_hw": [
216
+ 168,
217
+ 224
218
+ ],
219
+ "task_text": "Approach the flat block with a naturally aligned wrist, stop before closing the hand, wipe sideways at a top-view 45-degree heading, then set the block on the tabletop and release it.",
220
+ "inloop_mse": {
221
+ "task": "b8c",
222
+ "split": "train10",
223
+ "every": 250,
224
+ "seed": 1234,
225
+ "weights": "ema",
226
+ "nmse_at_this_step": 0.0423,
227
+ "lowest_published": 50000,
228
+ "curve": {
229
+ "6250": 0.1535,
230
+ "6500": 0.15,
231
+ "6750": 0.1467,
232
+ "7000": 0.1433,
233
+ "7250": 0.1401,
234
+ "7500": 0.1372,
235
+ "7750": 0.1344,
236
+ "8000": 0.1318,
237
+ "8250": 0.1294,
238
+ "8500": 0.127,
239
+ "8750": 0.1249,
240
+ "9000": 0.1228,
241
+ "9250": 0.1207,
242
+ "9500": 0.1187,
243
+ "9750": 0.1168,
244
+ "10000": 0.1149,
245
+ "10250": 0.1131,
246
+ "10500": 0.1112,
247
+ "10750": 0.1095,
248
+ "11000": 0.1078,
249
+ "11250": 0.1062,
250
+ "11500": 0.1044,
251
+ "11750": 0.1028,
252
+ "12000": 0.1012,
253
+ "12250": 0.0996,
254
+ "12500": 0.0981,
255
+ "12750": 0.0967,
256
+ "13000": 0.0953,
257
+ "13250": 0.0939,
258
+ "13500": 0.0927,
259
+ "13750": 0.0915,
260
+ "14000": 0.0904,
261
+ "14250": 0.0892,
262
+ "14500": 0.0882,
263
+ "14750": 0.0871,
264
+ "15000": 0.0861,
265
+ "15250": 0.0851,
266
+ "15500": 0.0842,
267
+ "15750": 0.0832,
268
+ "16000": 0.0823,
269
+ "16250": 0.0814,
270
+ "16500": 0.0805,
271
+ "16750": 0.0797,
272
+ "17000": 0.0789,
273
+ "17250": 0.0782,
274
+ "17500": 0.0774,
275
+ "17750": 0.0767,
276
+ "18000": 0.076,
277
+ "18250": 0.0752,
278
+ "18500": 0.0746,
279
+ "18750": 0.0739,
280
+ "19000": 0.0732,
281
+ "19250": 0.0726,
282
+ "19500": 0.072,
283
+ "19750": 0.0713,
284
+ "20000": 0.0706,
285
+ "20250": 0.07,
286
+ "20500": 0.0693,
287
+ "20750": 0.0688,
288
+ "21000": 0.0682,
289
+ "21250": 0.0676,
290
+ "21500": 0.0671,
291
+ "21750": 0.0666,
292
+ "22000": 0.0661,
293
+ "22250": 0.0656,
294
+ "22500": 0.0651,
295
+ "22750": 0.0646,
296
+ "23000": 0.0642,
297
+ "23250": 0.0638,
298
+ "23500": 0.0633,
299
+ "23750": 0.0629,
300
+ "24000": 0.0625,
301
+ "24250": 0.0621,
302
+ "24500": 0.0617,
303
+ "24750": 0.0613,
304
+ "25000": 0.0609,
305
+ "25250": 0.0606,
306
+ "25500": 0.0602,
307
+ "25750": 0.0598,
308
+ "26000": 0.0594,
309
+ "26250": 0.0591,
310
+ "26500": 0.0587,
311
+ "26750": 0.0584,
312
+ "27000": 0.0581,
313
+ "27250": 0.0577,
314
+ "27500": 0.0575,
315
+ "27750": 0.0572,
316
+ "28000": 0.0569,
317
+ "28250": 0.0566,
318
+ "28500": 0.0562,
319
+ "28750": 0.0559,
320
+ "29000": 0.0556,
321
+ "29250": 0.0553,
322
+ "29500": 0.055,
323
+ "29750": 0.0547,
324
+ "30000": 0.0544,
325
+ "30250": 0.0541,
326
+ "30500": 0.0539,
327
+ "30750": 0.0536,
328
+ "31000": 0.0534,
329
+ "31250": 0.0531,
330
+ "31500": 0.0529,
331
+ "31750": 0.0527,
332
+ "32000": 0.0524,
333
+ "32250": 0.0522,
334
+ "32500": 0.0519,
335
+ "32750": 0.0517,
336
+ "33000": 0.0515,
337
+ "33250": 0.0512,
338
+ "33500": 0.051,
339
+ "33750": 0.0508,
340
+ "34000": 0.0506,
341
+ "34250": 0.0504,
342
+ "34500": 0.0502,
343
+ "34750": 0.05,
344
+ "35000": 0.0498,
345
+ "35250": 0.0496,
346
+ "35500": 0.0494,
347
+ "35750": 0.0492,
348
+ "36000": 0.0491,
349
+ "36250": 0.0489,
350
+ "36500": 0.0487,
351
+ "36750": 0.0485,
352
+ "37000": 0.0483,
353
+ "37250": 0.0482,
354
+ "37500": 0.048,
355
+ "37750": 0.0478,
356
+ "38000": 0.0476,
357
+ "38250": 0.0475,
358
+ "38500": 0.0473,
359
+ "38750": 0.0472,
360
+ "39000": 0.047,
361
+ "39250": 0.0469,
362
+ "39500": 0.0467,
363
+ "39750": 0.0465,
364
+ "40000": 0.0464,
365
+ "40250": 0.0463,
366
+ "40500": 0.0462,
367
+ "40750": 0.046,
368
+ "41000": 0.0459,
369
+ "41250": 0.0457,
370
+ "41500": 0.0456,
371
+ "41750": 0.0455,
372
+ "42000": 0.0453,
373
+ "42250": 0.0452,
374
+ "42500": 0.0451,
375
+ "42750": 0.045,
376
+ "43000": 0.0448,
377
+ "43250": 0.0447,
378
+ "43500": 0.0446,
379
+ "43750": 0.0445,
380
+ "44000": 0.0444,
381
+ "44250": 0.0443,
382
+ "44500": 0.0442,
383
+ "44750": 0.0441,
384
+ "45000": 0.044,
385
+ "45250": 0.0439,
386
+ "45500": 0.0438,
387
+ "45750": 0.0437,
388
+ "46000": 0.0436,
389
+ "46250": 0.0435,
390
+ "46500": 0.0435,
391
+ "46750": 0.0434,
392
+ "47000": 0.0433,
393
+ "47250": 0.0432,
394
+ "47500": 0.0431,
395
+ "47750": 0.043,
396
+ "48000": 0.0429,
397
+ "48250": 0.0428,
398
+ "48500": 0.0428,
399
+ "48750": 0.0427,
400
+ "49000": 0.0426,
401
+ "49250": 0.0426,
402
+ "49500": 0.0425,
403
+ "49750": 0.0424,
404
+ "50000": 0.0423
405
+ }
406
+ },
407
+ "reproducibility": {
408
+ "protocol": "https://github.com/zuo-kuangji/HumanWAM/blob/main/hb_training/REPRODUCIBILITY.md",
409
+ "protocol_commit": "dbd9bfe529e2a3229d01ad9e27b102cf9d821eec",
410
+ "training_seed": 42,
411
+ "inloop_mse_seed": 1234,
412
+ "aug_seed": 42,
413
+ "layout": {
414
+ "nodes": 1,
415
+ "gpus": 1,
416
+ "per_gpu_batch": 512,
417
+ "global_batch": 512,
418
+ "gradient_accumulation": 1,
419
+ "num_workers": 32,
420
+ "prefetch": 2
421
+ },
422
+ "environment": "hb-baselines (Python 3.12.1, torch 2.9.0+cu128, torchvision 0.24.0); training_records/pip_freeze_hb-baselines.txt",
423
+ "hardware": "NVIDIA GeForce RTX 4090 D (this checkpoint); continuation from step 6000; trained on the MLP RTX 4090D 24 GB from that start; stopped at the total step 50000 with the learning-rate curve of the planned schedule",
424
+ "code": "github.com/zuo-kuangji/Humanoid_benchmark bai @ 433ba198964eb54173f2beb5085ba96f7fab0f9e + the evaluation/baselines/train.py part of bai 39f9b83a (--stop-at; training_records/stopat_39f9b83a_train.diff)",
425
+ "determinism": "statistical reproducibility: same data commit, config, seed and layout give the same curves within run-to-run noise; GPU kernels are not bitwise deterministic",
426
+ "exceptions": [
427
+ "owner 2026-11-28: FM-DiT v1 base steps 58000 (HumanWAM bai a7c875b); steps = ceil1000(58000 x 614.98 frames per episode / 544.33) = 66000; continued from step 6000 to 66000; commanded hands (owner 2026-11-27)",
428
+ "owner 2026-11-30: FM-DiT 照原学习率曲线训到累计 50000 步截停(「行,截停」): --stop-at 50000, the learning-rate curve that of --steps; code = Humanoid_benchmark bai 433ba198 + stop-at patch (the evaluation/baselines/train.py part of bai 39f9b83a, git diff 39f9b83a^ 39f9b83a -- evaluation/baselines/train.py, sha256 db0911a84ba7a847befd22955ac99a9c04c2307a97f696be4e73da510fc19977); trained on the MLP 4090D (24 GB, one card, batch 512, same recipe as the A800)",
429
+ "continuation: owner 2026-11-28: 续训的步数比较多的就不需要去降低学习率的峰值。我觉得学习率峰值可以跟从头训一样去安排; FM-DiT v1 base 58000 (collaborator's A17 80000 steps on 751.84 frames/episode); measured -> commanded hands (owner: 续训时改成学指令手,肯定要这么做)",
430
+ "owner 2026-11-30: FM-DiT 照原学习率曲线训到累计 50000 步截停(「行,截停」); recorded in HumanWAM main 39a6b24 / dbd9bfe (hb_training/REPRODUCIBILITY.md section 7, protocol.yaml exceptions); train.py --stop-at 50000 = Humanoid_benchmark bai 433ba198 + the evaluation/baselines/train.py part of bai 39f9b83a (sha256 of the diff db0911a84ba7a847befd22955ac99a9c04c2307a97f696be4e73da510fc19977)"
431
+ ]
432
+ },
433
+ "inference": "Humanoid_benchmark evaluation/policy/FM_DIT (evaluation/baselines/adapters.py, runtime.BaselinePolicy) loads this folder (config.json + model.pt); training_records/ in the last step has the exact code",
434
+ "resume_state_included": false
435
+ }
b8-table-wipe/b512-cont-20261117-stop50k/step-050000/training_records/code_hb_bai_433ba198_stopat39f9b83a/HB_CODE_COMMIT ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ 433ba198964eb54173f2beb5085ba96f7fab0f9e
2
+ + stop-at patch: the evaluation/baselines/train.py part of Humanoid_benchmark bai 39f9b83abe55263bcb1be7d7190bbcfebd5660cf (git diff 39f9b83a^ 39f9b83a -- evaluation/baselines/train.py, sha256 db0911a84ba7a847befd22955ac99a9c04c2307a97f696be4e73da510fc19977), applied 2026-11-30 on MLP mlp1
b8-table-wipe/b512-cont-20261117-stop50k/step-050000/training_records/code_hb_bai_433ba198_stopat39f9b83a/evaluation/augmentation/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)
b8-table-wipe/b512-cont-20261117-stop50k/step-050000/training_records/code_hb_bai_433ba198_stopat39f9b83a/evaluation/baselines/__init__.py ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """FM-DiT, DP (Diffusion Policy, DDPM-DiT), ACT, FLASH, ODE-MLP and ODE-DiT visuomotor baselines of the Humanoid
2
+ Benchmark.
3
+
4
+ FM-DiT, DP and ACT are ported from DextraVerse's imitation-learning core (`dextraverse/algorithms/il/models/
5
+ {fm_dit,ddpm_dit,act}.py` and their networks), FLASH and FM-DiT v2 (FLASH-Policy's own FM-DiT; `fm_dit_v2.py`, a separate entry from the
6
+ DextraVerse FM-DiT) from NTUMARS/FLASH-Policy @ f47e490 (`flash.py`), ODE-MLP and
7
+ ODE-DiT after ODE Policy's G1 port (github.com/NTUMARS/ODE-POLICY real-g1; networks in ode_nets.py), each in its
8
+ authors' own configuration; torch only. `train.py` trains one on a task's LeRobot v2.1 expert dataset through a robot
9
+ contract (`data.CONTRACTS`: G1 state44/action76 or H2 state78/action75); `runtime.BaselinePolicy` serves a checkpoint
10
+ to the G1 evaluation adapters (`evaluation/policy/{FMDiT,FMDiT_v2,DP,ACT,FLASH,ODEMLP,ODEDiT}/model.py`, via `adapters.py`) and
11
+ to the H2 adapter
12
+ (`debug/newton/h2_policy_adapters/baseline.py`). Usage and the environment: evaluation/README.md#baselines.
13
+ """
b8-table-wipe/b512-cont-20261117-stop50k/step-050000/training_records/code_hb_bai_433ba198_stopat39f9b83a/evaluation/baselines/act_nets.py ADDED
@@ -0,0 +1,615 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """ACT (Zhao et al. 2023, "Learning Fine-Grained Bimanual Manipulation with Low-Cost Hardware") network core: the
2
+ ResNet backbone with frozen BatchNorm and sine position embedding, the DETR encoder-decoder transformer and the CVAE
3
+ action-chunk decoder.
4
+
5
+ Ported unchanged from DextraVerse (`dextraverse/algorithms/il/models/nets/act/`), which vendors the ACT repository's
6
+ `detr/models/{backbone,position_encoding,transformer,detr_vae}.py` (Apache-2.0, (c) Facebook, Inc. and its
7
+ affiliates; see THIRD_PARTY_NOTICES.md) with the NestedTensor/argparse plumbing removed, explicit `qpos_dim` /
8
+ `action_dim` instead of the ALOHA 14-DoF constants, and one backbone shared by every camera (upstream behaviour).
9
+ The policy uses `return_intermediate_dec=False`: `Transformer.forward(...)[0]` is the final decoder layer.
10
+ """
11
+ from __future__ import annotations
12
+
13
+ import copy
14
+ import math
15
+ from typing import Optional
16
+
17
+ import numpy as np
18
+ import torch
19
+ import torch.nn.functional as F
20
+ import torchvision
21
+ from torch import Tensor, nn
22
+ from torchvision.models._utils import IntermediateLayerGetter
23
+
24
+
25
+ class PositionEmbeddingSine(nn.Module):
26
+ """Standard DETR sine embedding over a ``(B, C, H, W)`` feature map."""
27
+
28
+ def __init__(
29
+ self, num_pos_feats: int = 64, temperature: int = 10000, normalize: bool = False
30
+ ) -> None:
31
+ super().__init__()
32
+ self.num_pos_feats = num_pos_feats
33
+ self.temperature = temperature
34
+ self.normalize = normalize
35
+ self.scale = 2 * math.pi
36
+
37
+ def forward(self, x: torch.Tensor) -> torch.Tensor:
38
+ not_mask = torch.ones((1, x.shape[-2], x.shape[-1]), device=x.device)
39
+ y_embed = not_mask.cumsum(1, dtype=torch.float32)
40
+ x_embed = not_mask.cumsum(2, dtype=torch.float32)
41
+ if self.normalize:
42
+ eps = 1e-6
43
+ y_embed = y_embed / (y_embed[:, -1:, :] + eps) * self.scale
44
+ x_embed = x_embed / (x_embed[:, :, -1:] + eps) * self.scale
45
+
46
+ dim_t = torch.arange(self.num_pos_feats, dtype=torch.float32, device=x.device)
47
+ dim_t = self.temperature ** (2 * (dim_t // 2) / self.num_pos_feats)
48
+
49
+ pos_x = x_embed[:, :, :, None] / dim_t
50
+ pos_y = y_embed[:, :, :, None] / dim_t
51
+ pos_x = torch.stack(
52
+ (pos_x[:, :, :, 0::2].sin(), pos_x[:, :, :, 1::2].cos()), dim=4
53
+ ).flatten(3)
54
+ pos_y = torch.stack(
55
+ (pos_y[:, :, :, 0::2].sin(), pos_y[:, :, :, 1::2].cos()), dim=4
56
+ ).flatten(3)
57
+ return torch.cat((pos_y, pos_x), dim=3).permute(0, 3, 1, 2)
58
+
59
+
60
+ class FrozenBatchNorm2d(nn.Module):
61
+ """BatchNorm2d with fixed statistics and affine parameters (the DETR/ACT backbone norm)."""
62
+
63
+ def __init__(self, n: int) -> None:
64
+ super().__init__()
65
+ self.register_buffer("weight", torch.ones(n))
66
+ self.register_buffer("bias", torch.zeros(n))
67
+ self.register_buffer("running_mean", torch.zeros(n))
68
+ self.register_buffer("running_var", torch.ones(n))
69
+
70
+ def _load_from_state_dict(self, state_dict, prefix, local_metadata, strict, *args):
71
+ state_dict.pop(prefix + "num_batches_tracked", None)
72
+ super()._load_from_state_dict(state_dict, prefix, local_metadata, strict, *args)
73
+
74
+ def forward(self, x: torch.Tensor) -> torch.Tensor:
75
+ w = self.weight.reshape(1, -1, 1, 1)
76
+ b = self.bias.reshape(1, -1, 1, 1)
77
+ rv = self.running_var.reshape(1, -1, 1, 1)
78
+ rm = self.running_mean.reshape(1, -1, 1, 1)
79
+ scale = w * (rv + 1e-5).rsqrt()
80
+ return x * scale + (b - rm * scale)
81
+
82
+
83
+ class Backbone(nn.Module):
84
+ """ResNet trunk returning the layer4 feature map."""
85
+
86
+ def __init__(self, name: str = "resnet18", weights: str | None = None) -> None:
87
+ super().__init__()
88
+ trunk = getattr(torchvision.models, name)(
89
+ replace_stride_with_dilation=[False, False, False],
90
+ weights=weights,
91
+ norm_layer=FrozenBatchNorm2d,
92
+ )
93
+ self.body = IntermediateLayerGetter(trunk, return_layers={"layer4": "0"})
94
+ self.num_channels = 512 if name in ("resnet18", "resnet34") else 2048
95
+
96
+ def forward(self, x: torch.Tensor) -> dict[str, torch.Tensor]:
97
+ return self.body(x)
98
+
99
+
100
+ class Joiner(nn.Sequential):
101
+ """Backbone + position embedding, returning matched feature/position lists."""
102
+
103
+ def __init__(self, backbone: Backbone, position_embedding: PositionEmbeddingSine) -> None:
104
+ super().__init__(backbone, position_embedding)
105
+ self.num_channels = backbone.num_channels
106
+
107
+ def forward(self, x: torch.Tensor) -> tuple[list[torch.Tensor], list[torch.Tensor]]:
108
+ features = list(self[0](x).values())
109
+ pos = [self[1](f).to(f.dtype) for f in features]
110
+ return features, pos
111
+
112
+
113
+ def build_backbone(
114
+ name: str = "resnet18", hidden_dim: int = 512, weights: str | None = None
115
+ ) -> Joiner:
116
+ """The ACT camera backbone: ResNet + sine embedding sized to the transformer width."""
117
+ return Joiner(Backbone(name, weights=weights), PositionEmbeddingSine(hidden_dim // 2))
118
+
119
+
120
+ class Transformer(nn.Module):
121
+ def __init__(
122
+ self,
123
+ d_model=512,
124
+ nhead=8,
125
+ num_encoder_layers=6,
126
+ num_decoder_layers=6,
127
+ dim_feedforward=2048,
128
+ dropout=0.1,
129
+ activation="relu",
130
+ normalize_before=False,
131
+ return_intermediate_dec=False,
132
+ ):
133
+ super().__init__()
134
+
135
+ encoder_layer = TransformerEncoderLayer(
136
+ d_model, nhead, dim_feedforward, dropout, activation, normalize_before
137
+ )
138
+ encoder_norm = nn.LayerNorm(d_model) if normalize_before else None
139
+ self.encoder = TransformerEncoder(encoder_layer, num_encoder_layers, encoder_norm)
140
+
141
+ decoder_layer = TransformerDecoderLayer(
142
+ d_model, nhead, dim_feedforward, dropout, activation, normalize_before
143
+ )
144
+ decoder_norm = nn.LayerNorm(d_model)
145
+ self.decoder = TransformerDecoder(
146
+ decoder_layer,
147
+ num_decoder_layers,
148
+ decoder_norm,
149
+ return_intermediate=return_intermediate_dec,
150
+ )
151
+
152
+ self._reset_parameters()
153
+
154
+ self.d_model = d_model
155
+ self.nhead = nhead
156
+
157
+ def _reset_parameters(self):
158
+ for p in self.parameters():
159
+ if p.dim() > 1:
160
+ nn.init.xavier_uniform_(p)
161
+
162
+ def forward(
163
+ self,
164
+ src,
165
+ mask,
166
+ query_embed,
167
+ pos_embed,
168
+ latent_input=None,
169
+ proprio_input=None,
170
+ additional_pos_embed=None,
171
+ ):
172
+ # TODO flatten only when input has H and W
173
+ if len(src.shape) == 4: # has H and W
174
+ # flatten NxCxHxW to HWxNxC
175
+ bs, c, h, w = src.shape
176
+ src = src.flatten(2).permute(2, 0, 1)
177
+ pos_embed = pos_embed.flatten(2).permute(2, 0, 1).repeat(1, bs, 1)
178
+ query_embed = query_embed.unsqueeze(1).repeat(1, bs, 1)
179
+ # mask = mask.flatten(1)
180
+
181
+ additional_pos_embed = additional_pos_embed.unsqueeze(1).repeat(
182
+ 1, bs, 1
183
+ ) # seq, bs, dim
184
+ pos_embed = torch.cat([additional_pos_embed, pos_embed], axis=0)
185
+
186
+ addition_input = torch.stack([latent_input, proprio_input], axis=0)
187
+ src = torch.cat([addition_input, src], axis=0)
188
+ else:
189
+ assert len(src.shape) == 3
190
+ # flatten NxHWxC to HWxNxC
191
+ bs, hw, c = src.shape
192
+ src = src.permute(1, 0, 2)
193
+ pos_embed = pos_embed.unsqueeze(1).repeat(1, bs, 1)
194
+ query_embed = query_embed.unsqueeze(1).repeat(1, bs, 1)
195
+
196
+ tgt = torch.zeros_like(query_embed)
197
+ memory = self.encoder(src, src_key_padding_mask=mask, pos=pos_embed)
198
+ hs = self.decoder(
199
+ tgt, memory, memory_key_padding_mask=mask, pos=pos_embed, query_pos=query_embed
200
+ )
201
+ hs = hs.transpose(1, 2)
202
+ return hs
203
+
204
+
205
+ class TransformerEncoder(nn.Module):
206
+ def __init__(self, encoder_layer, num_layers, norm=None):
207
+ super().__init__()
208
+ self.layers = _get_clones(encoder_layer, num_layers)
209
+ self.num_layers = num_layers
210
+ self.norm = norm
211
+
212
+ def forward(
213
+ self,
214
+ src,
215
+ mask: Optional[Tensor] = None,
216
+ src_key_padding_mask: Optional[Tensor] = None,
217
+ pos: Optional[Tensor] = None,
218
+ ):
219
+ output = src
220
+
221
+ for layer in self.layers:
222
+ output = layer(
223
+ output, src_mask=mask, src_key_padding_mask=src_key_padding_mask, pos=pos
224
+ )
225
+
226
+ if self.norm is not None:
227
+ output = self.norm(output)
228
+
229
+ return output
230
+
231
+
232
+ class TransformerDecoder(nn.Module):
233
+ def __init__(self, decoder_layer, num_layers, norm=None, return_intermediate=False):
234
+ super().__init__()
235
+ self.layers = _get_clones(decoder_layer, num_layers)
236
+ self.num_layers = num_layers
237
+ self.norm = norm
238
+ self.return_intermediate = return_intermediate
239
+
240
+ def forward(
241
+ self,
242
+ tgt,
243
+ memory,
244
+ tgt_mask: Optional[Tensor] = None,
245
+ memory_mask: Optional[Tensor] = None,
246
+ tgt_key_padding_mask: Optional[Tensor] = None,
247
+ memory_key_padding_mask: Optional[Tensor] = None,
248
+ pos: Optional[Tensor] = None,
249
+ query_pos: Optional[Tensor] = None,
250
+ ):
251
+ output = tgt
252
+
253
+ intermediate = []
254
+
255
+ for layer in self.layers:
256
+ output = layer(
257
+ output,
258
+ memory,
259
+ tgt_mask=tgt_mask,
260
+ memory_mask=memory_mask,
261
+ tgt_key_padding_mask=tgt_key_padding_mask,
262
+ memory_key_padding_mask=memory_key_padding_mask,
263
+ pos=pos,
264
+ query_pos=query_pos,
265
+ )
266
+ if self.return_intermediate:
267
+ intermediate.append(self.norm(output))
268
+
269
+ if self.norm is not None:
270
+ output = self.norm(output)
271
+ if self.return_intermediate:
272
+ intermediate.pop()
273
+ intermediate.append(output)
274
+
275
+ if self.return_intermediate:
276
+ return torch.stack(intermediate)
277
+
278
+ return output.unsqueeze(0)
279
+
280
+
281
+ class TransformerEncoderLayer(nn.Module):
282
+ def __init__(
283
+ self,
284
+ d_model,
285
+ nhead,
286
+ dim_feedforward=2048,
287
+ dropout=0.1,
288
+ activation="relu",
289
+ normalize_before=False,
290
+ ):
291
+ super().__init__()
292
+ self.self_attn = nn.MultiheadAttention(d_model, nhead, dropout=dropout)
293
+ # Implementation of Feedforward model
294
+ self.linear1 = nn.Linear(d_model, dim_feedforward)
295
+ self.dropout = nn.Dropout(dropout)
296
+ self.linear2 = nn.Linear(dim_feedforward, d_model)
297
+
298
+ self.norm1 = nn.LayerNorm(d_model)
299
+ self.norm2 = nn.LayerNorm(d_model)
300
+ self.dropout1 = nn.Dropout(dropout)
301
+ self.dropout2 = nn.Dropout(dropout)
302
+
303
+ self.activation = _get_activation_fn(activation)
304
+ self.normalize_before = normalize_before
305
+
306
+ def with_pos_embed(self, tensor, pos: Optional[Tensor]):
307
+ return tensor if pos is None else tensor + pos
308
+
309
+ def forward_post(
310
+ self,
311
+ src,
312
+ src_mask: Optional[Tensor] = None,
313
+ src_key_padding_mask: Optional[Tensor] = None,
314
+ pos: Optional[Tensor] = None,
315
+ ):
316
+ q = k = self.with_pos_embed(src, pos)
317
+ src2 = self.self_attn(
318
+ q, k, value=src, attn_mask=src_mask, key_padding_mask=src_key_padding_mask
319
+ )[0]
320
+ src = src + self.dropout1(src2)
321
+ src = self.norm1(src)
322
+ src2 = self.linear2(self.dropout(self.activation(self.linear1(src))))
323
+ src = src + self.dropout2(src2)
324
+ src = self.norm2(src)
325
+ return src
326
+
327
+ def forward_pre(
328
+ self,
329
+ src,
330
+ src_mask: Optional[Tensor] = None,
331
+ src_key_padding_mask: Optional[Tensor] = None,
332
+ pos: Optional[Tensor] = None,
333
+ ):
334
+ src2 = self.norm1(src)
335
+ q = k = self.with_pos_embed(src2, pos)
336
+ src2 = self.self_attn(
337
+ q, k, value=src2, attn_mask=src_mask, key_padding_mask=src_key_padding_mask
338
+ )[0]
339
+ src = src + self.dropout1(src2)
340
+ src2 = self.norm2(src)
341
+ src2 = self.linear2(self.dropout(self.activation(self.linear1(src2))))
342
+ src = src + self.dropout2(src2)
343
+ return src
344
+
345
+ def forward(
346
+ self,
347
+ src,
348
+ src_mask: Optional[Tensor] = None,
349
+ src_key_padding_mask: Optional[Tensor] = None,
350
+ pos: Optional[Tensor] = None,
351
+ ):
352
+ if self.normalize_before:
353
+ return self.forward_pre(src, src_mask, src_key_padding_mask, pos)
354
+ return self.forward_post(src, src_mask, src_key_padding_mask, pos)
355
+
356
+
357
+ class TransformerDecoderLayer(nn.Module):
358
+ def __init__(
359
+ self,
360
+ d_model,
361
+ nhead,
362
+ dim_feedforward=2048,
363
+ dropout=0.1,
364
+ activation="relu",
365
+ normalize_before=False,
366
+ ):
367
+ super().__init__()
368
+ self.self_attn = nn.MultiheadAttention(d_model, nhead, dropout=dropout)
369
+ self.multihead_attn = nn.MultiheadAttention(d_model, nhead, dropout=dropout)
370
+ # Implementation of Feedforward model
371
+ self.linear1 = nn.Linear(d_model, dim_feedforward)
372
+ self.dropout = nn.Dropout(dropout)
373
+ self.linear2 = nn.Linear(dim_feedforward, d_model)
374
+
375
+ self.norm1 = nn.LayerNorm(d_model)
376
+ self.norm2 = nn.LayerNorm(d_model)
377
+ self.norm3 = nn.LayerNorm(d_model)
378
+ self.dropout1 = nn.Dropout(dropout)
379
+ self.dropout2 = nn.Dropout(dropout)
380
+ self.dropout3 = nn.Dropout(dropout)
381
+
382
+ self.activation = _get_activation_fn(activation)
383
+ self.normalize_before = normalize_before
384
+
385
+ def with_pos_embed(self, tensor, pos: Optional[Tensor]):
386
+ return tensor if pos is None else tensor + pos
387
+
388
+ def forward_post(
389
+ self,
390
+ tgt,
391
+ memory,
392
+ tgt_mask: Optional[Tensor] = None,
393
+ memory_mask: Optional[Tensor] = None,
394
+ tgt_key_padding_mask: Optional[Tensor] = None,
395
+ memory_key_padding_mask: Optional[Tensor] = None,
396
+ pos: Optional[Tensor] = None,
397
+ query_pos: Optional[Tensor] = None,
398
+ ):
399
+ q = k = self.with_pos_embed(tgt, query_pos)
400
+ tgt2 = self.self_attn(
401
+ q, k, value=tgt, attn_mask=tgt_mask, key_padding_mask=tgt_key_padding_mask
402
+ )[0]
403
+ tgt = tgt + self.dropout1(tgt2)
404
+ tgt = self.norm1(tgt)
405
+ tgt2 = self.multihead_attn(
406
+ query=self.with_pos_embed(tgt, query_pos),
407
+ key=self.with_pos_embed(memory, pos),
408
+ value=memory,
409
+ attn_mask=memory_mask,
410
+ key_padding_mask=memory_key_padding_mask,
411
+ )[0]
412
+ tgt = tgt + self.dropout2(tgt2)
413
+ tgt = self.norm2(tgt)
414
+ tgt2 = self.linear2(self.dropout(self.activation(self.linear1(tgt))))
415
+ tgt = tgt + self.dropout3(tgt2)
416
+ tgt = self.norm3(tgt)
417
+ return tgt
418
+
419
+ def forward_pre(
420
+ self,
421
+ tgt,
422
+ memory,
423
+ tgt_mask: Optional[Tensor] = None,
424
+ memory_mask: Optional[Tensor] = None,
425
+ tgt_key_padding_mask: Optional[Tensor] = None,
426
+ memory_key_padding_mask: Optional[Tensor] = None,
427
+ pos: Optional[Tensor] = None,
428
+ query_pos: Optional[Tensor] = None,
429
+ ):
430
+ tgt2 = self.norm1(tgt)
431
+ q = k = self.with_pos_embed(tgt2, query_pos)
432
+ tgt2 = self.self_attn(
433
+ q, k, value=tgt2, attn_mask=tgt_mask, key_padding_mask=tgt_key_padding_mask
434
+ )[0]
435
+ tgt = tgt + self.dropout1(tgt2)
436
+ tgt2 = self.norm2(tgt)
437
+ tgt2 = self.multihead_attn(
438
+ query=self.with_pos_embed(tgt2, query_pos),
439
+ key=self.with_pos_embed(memory, pos),
440
+ value=memory,
441
+ attn_mask=memory_mask,
442
+ key_padding_mask=memory_key_padding_mask,
443
+ )[0]
444
+ tgt = tgt + self.dropout2(tgt2)
445
+ tgt2 = self.norm3(tgt)
446
+ tgt2 = self.linear2(self.dropout(self.activation(self.linear1(tgt2))))
447
+ tgt = tgt + self.dropout3(tgt2)
448
+ return tgt
449
+
450
+ def forward(
451
+ self,
452
+ tgt,
453
+ memory,
454
+ tgt_mask: Optional[Tensor] = None,
455
+ memory_mask: Optional[Tensor] = None,
456
+ tgt_key_padding_mask: Optional[Tensor] = None,
457
+ memory_key_padding_mask: Optional[Tensor] = None,
458
+ pos: Optional[Tensor] = None,
459
+ query_pos: Optional[Tensor] = None,
460
+ ):
461
+ if self.normalize_before:
462
+ return self.forward_pre(
463
+ tgt,
464
+ memory,
465
+ tgt_mask,
466
+ memory_mask,
467
+ tgt_key_padding_mask,
468
+ memory_key_padding_mask,
469
+ pos,
470
+ query_pos,
471
+ )
472
+ return self.forward_post(
473
+ tgt,
474
+ memory,
475
+ tgt_mask,
476
+ memory_mask,
477
+ tgt_key_padding_mask,
478
+ memory_key_padding_mask,
479
+ pos,
480
+ query_pos,
481
+ )
482
+
483
+
484
+ def _get_clones(module, N):
485
+ return nn.ModuleList([copy.deepcopy(module) for i in range(N)])
486
+
487
+
488
+ def _get_activation_fn(activation):
489
+ """Return an activation function given a string."""
490
+ if activation == "relu":
491
+ return F.relu
492
+ if activation == "gelu":
493
+ return F.gelu
494
+ raise RuntimeError(f"activation should be relu/gelu, not {activation}.")
495
+
496
+
497
+
498
+ def reparametrize(mu: torch.Tensor, logvar: torch.Tensor) -> torch.Tensor:
499
+ std = logvar.div(2).exp()
500
+ return mu + std * torch.randn_like(std)
501
+
502
+
503
+ def get_sinusoid_encoding_table(n_position: int, d_hid: int) -> torch.Tensor:
504
+ def angle_vec(position: int) -> list[float]:
505
+ return [position / np.power(10000, 2 * (j // 2) / d_hid) for j in range(d_hid)]
506
+
507
+ table = np.array([angle_vec(i) for i in range(n_position)])
508
+ table[:, 0::2] = np.sin(table[:, 0::2])
509
+ table[:, 1::2] = np.cos(table[:, 1::2])
510
+ return torch.FloatTensor(table).unsqueeze(0)
511
+
512
+
513
+ def build_style_encoder(
514
+ hidden_dim: int, nheads: int, dim_feedforward: int, enc_layers: int, dropout: float
515
+ ) -> TransformerEncoder:
516
+ """The CVAE style encoder (a plain transformer encoder over [CLS, qpos, action seq])."""
517
+ layer = TransformerEncoderLayer(hidden_dim, nheads, dim_feedforward, dropout, "relu", False)
518
+ return TransformerEncoder(layer, enc_layers, norm=None)
519
+
520
+
521
+ class DETRVAE(nn.Module):
522
+ """CVAE decoder: (qpos, images[, action seq]) → ``num_queries`` future actions."""
523
+
524
+ def __init__(
525
+ self,
526
+ backbone: Joiner,
527
+ transformer: Transformer,
528
+ encoder: TransformerEncoder,
529
+ *,
530
+ qpos_dim: int,
531
+ action_dim: int,
532
+ num_queries: int,
533
+ latent_dim: int = 32,
534
+ ) -> None:
535
+ super().__init__()
536
+ self.num_queries = num_queries
537
+ self.transformer = transformer
538
+ self.encoder = encoder
539
+ hidden_dim = transformer.d_model
540
+ self.action_head = nn.Linear(hidden_dim, action_dim)
541
+ self.query_embed = nn.Embedding(num_queries, hidden_dim)
542
+ self.backbone = backbone # ONE backbone shared by every camera (upstream behavior)
543
+ self.input_proj = nn.Conv2d(backbone.num_channels, hidden_dim, kernel_size=1)
544
+ self.input_proj_robot_state = nn.Linear(qpos_dim, hidden_dim)
545
+
546
+ # CVAE style encoder inputs
547
+ self.latent_dim = latent_dim
548
+ self.cls_embed = nn.Embedding(1, hidden_dim)
549
+ self.encoder_action_proj = nn.Linear(action_dim, hidden_dim)
550
+ self.encoder_joint_proj = nn.Linear(qpos_dim, hidden_dim)
551
+ self.latent_proj = nn.Linear(hidden_dim, latent_dim * 2)
552
+ self.register_buffer(
553
+ "pos_table", get_sinusoid_encoding_table(1 + 1 + num_queries, hidden_dim)
554
+ )
555
+ # decoder side
556
+ self.latent_out_proj = nn.Linear(latent_dim, hidden_dim)
557
+ self.additional_pos_embed = nn.Embedding(2, hidden_dim) # latent + proprio slots
558
+
559
+ def forward(
560
+ self,
561
+ qpos: torch.Tensor,
562
+ images: torch.Tensor,
563
+ actions: torch.Tensor | None = None,
564
+ is_pad: torch.Tensor | None = None,
565
+ ) -> tuple[torch.Tensor, tuple[torch.Tensor | None, torch.Tensor | None]]:
566
+ """``qpos (B, Dq)``, ``images (B, ncam, C, H, W)``; train passes ``actions (B, T, Da)``."""
567
+ is_training = actions is not None
568
+ bs = qpos.shape[0]
569
+ if is_training:
570
+ action_embed = self.encoder_action_proj(actions)
571
+ qpos_embed = self.encoder_joint_proj(qpos).unsqueeze(1)
572
+ cls_embed = self.cls_embed.weight.unsqueeze(0).repeat(bs, 1, 1)
573
+ encoder_input = torch.cat([cls_embed, qpos_embed, action_embed], dim=1)
574
+ encoder_input = encoder_input.permute(1, 0, 2)
575
+ if is_pad is None:
576
+ is_pad = torch.zeros(bs, actions.shape[1], dtype=torch.bool, device=qpos.device)
577
+ cls_joint_is_pad = torch.full((bs, 2), False, device=qpos.device)
578
+ key_pad = torch.cat([cls_joint_is_pad, is_pad], dim=1)
579
+ pos_embed = self.pos_table.clone().detach().permute(1, 0, 2)
580
+ encoder_output = self.encoder(
581
+ encoder_input, pos=pos_embed, src_key_padding_mask=key_pad
582
+ )[0]
583
+ latent_info = self.latent_proj(encoder_output)
584
+ mu = latent_info[:, : self.latent_dim]
585
+ logvar = latent_info[:, self.latent_dim :]
586
+ latent_input = self.latent_out_proj(reparametrize(mu, logvar))
587
+ else:
588
+ mu = logvar = None
589
+ latent_sample = torch.zeros(bs, self.latent_dim, device=qpos.device)
590
+ latent_input = self.latent_out_proj(latent_sample)
591
+
592
+ all_cam_features, all_cam_pos = [], []
593
+ for cam_id in range(images.shape[1]):
594
+ features, pos = self.backbone(images[:, cam_id])
595
+ all_cam_features.append(self.input_proj(features[0]))
596
+ all_cam_pos.append(pos[0])
597
+ proprio_input = self.input_proj_robot_state(qpos)
598
+ src = torch.cat(all_cam_features, dim=3) # cameras fold into the width axis
599
+ pos = torch.cat(all_cam_pos, dim=3)
600
+ hs = self.transformer(
601
+ src,
602
+ None,
603
+ self.query_embed.weight,
604
+ pos,
605
+ latent_input,
606
+ proprio_input,
607
+ self.additional_pos_embed.weight,
608
+ )[0]
609
+ return self.action_head(hs), (mu, logvar)
610
+
611
+
612
+ def kl_divergence(mu: torch.Tensor, logvar: torch.Tensor) -> torch.Tensor:
613
+ """Total KL(q(z|x) || N(0, I)), summed over latent dims, meaned over the batch."""
614
+ klds = -0.5 * (1 + logvar - mu.pow(2) - logvar.exp())
615
+ return klds.sum(1).mean()
b8-table-wipe/b512-cont-20261117-stop50k/step-050000/training_records/code_hb_bai_433ba198_stopat39f9b83a/evaluation/baselines/adapters.py ADDED
@@ -0,0 +1,58 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """The G1 evaluation adapters of the baselines (evaluation/README.md#the-model-interface): `make_model('fm_dit')`
2
+ returns the `Model` class that `evaluation/policy/FMDiT/model.py` exports (likewise DP, ACT, FLASH, ODEMLP, ODEDiT).
3
+
4
+ Observation: the current ego_view and chest frames (480x640 RGB, resized as the training cache) and state44; FM-DiT,
5
+ DP and ACT read no past actions or earlier frames (one frame); FLASH and the ODE policies also read the interface's
6
+ executed rows before the query (`past_actions`, `history_valid`: the token sent and the INSPIRE opening measured at
7
+ each earlier frame): FLASH for its polynomial history, the ODE policies the last one (frame t-1) as their start.
8
+ Output: the checkpoint's whole chunk (16 rows of action76, row 0 executed at the request's frame), `execution_steps`
9
+ rows of it executed before the next query (deploy.yml `config: execution_steps`, default the whole chunk; the runners
10
+ re-query after at most 12 rows), the request's seed for the sampling noise (FM-DiT, DP).
11
+ """
12
+ from __future__ import annotations
13
+
14
+ from .runtime import BaselinePolicy
15
+
16
+ WIDTH = {'sonic_dfx6': 76}
17
+
18
+
19
+ def require(condition, message):
20
+ if not condition:
21
+ raise RuntimeError(message)
22
+
23
+
24
+ def make_model(policy_name: str):
25
+ class Model:
26
+ history_length = 1 # the current head and chest frames only
27
+ video_frames = 0
28
+
29
+ def __init__(self, cfg):
30
+ self.policy = BaselinePolicy(cfg['checkpoint_path'], device=cfg.get('device', 'cuda:0'),
31
+ policy=policy_name, robot='g1')
32
+ contract = self.policy.contract
33
+ require(cfg['action_space'] in WIDTH and contract['action_space'] == cfg['action_space']
34
+ and self.policy.action_dim == WIDTH[cfg['action_space']] and self.policy.state_dim == 44
35
+ and list(self.policy.cameras) == ['ego_view', 'chest'],
36
+ f"checkpoint contract {contract['name']} does not serve {cfg['action_space']}")
37
+ extra = cfg.get('config') or {}
38
+ if extra.get('check_task', True):
39
+ require(cfg['task'].strip() == (self.policy.task_text or '').strip(),
40
+ f'task text {cfg["task"]!r} is not the training task {self.policy.task_text!r}')
41
+ self.execution_steps = int(extra.get('execution_steps') or self.policy.horizon)
42
+ require(1 <= self.execution_steps <= self.policy.horizon, f'execution_steps {self.execution_steps}')
43
+ self.uses_history = self.policy.name == 'flash' or self.policy.uses_previous
44
+ self.info = dict(self.policy.info(), execution_steps=self.execution_steps,
45
+ inputs='current frames + state44' + (' + executed-action history' if self.uses_history
46
+ else ''))
47
+
48
+ def get_action(self, obs):
49
+ if self.uses_history:
50
+ action, _ = self.policy.predict(obs['images'], obs['state'], seed=obs['seed'],
51
+ past_actions=obs['past_actions'], history_valid=obs['history_valid'])
52
+ else:
53
+ action, _ = self.policy.predict(obs['images'], obs['state'], seed=obs['seed'])
54
+ return dict(action=action, execution_steps=self.execution_steps,
55
+ sampling_steps=self.policy.sampling_steps)
56
+
57
+ Model.__name__ = Model.__qualname__ = f'Model_{policy_name}'
58
+ return Model
b8-table-wipe/b512-cont-20261117-stop50k/step-050000/training_records/code_hb_bai_433ba198_stopat39f9b83a/evaluation/baselines/check_flash_adapter.py ADDED
@@ -0,0 +1,114 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Offline check of the FLASH adapter against the training path on recorded frames (before any closed-loop run):
2
+
3
+ <baselines env>/bin/python -I evaluation/baselines/check_flash_adapter.py --checkpoint <checkpoints/step-NNNNNN> \\
4
+ --dataset <LeRobot v2.1 root> --episodes 0,60 --queries 8 [--device cuda:0]
5
+
6
+ For query frames t of each episode (0, then evenly spaced) it builds
7
+ (a) the interface observation a runner sends: the 480x640 ego_view / chest frames (decoded from the dataset videos),
8
+ state44 and past_actions = the 40 recorded action rows before t (history_valid 0 before the episode start), and
9
+ calls evaluation/policy/FLASH/model.py Model.get_action, the deployed adapter;
10
+ (b) the training path: FlashChunkDataset's item for the same anchor (frames resized as the frame cache, the dataset's
11
+ history rule) through FlashPolicy.predict.
12
+ Both chunks must be equal bit for bit (same weights, same device); it also prints the normalized MSE of the chunk
13
+ against the recorded rows from t (rows past the episode's end excluded). Exits 1 on a mismatch.
14
+ """
15
+ from __future__ import annotations
16
+
17
+ import argparse
18
+ import json
19
+ from pathlib import Path
20
+ import sys
21
+
22
+ import numpy as np
23
+
24
+ HERE = Path(__file__).resolve().parent
25
+ EVALUATION = HERE.parent
26
+ if str(EVALUATION) not in sys.path:
27
+ sys.path.insert(0, str(EVALUATION))
28
+
29
+ HISTORY_ROWS = 40 # the interface's past_actions rows (debug/newton/b6_policy_eval.py HISTORY_ROWS)
30
+
31
+
32
+ def decode(path, indices):
33
+ import av
34
+ want, out = set(int(i) for i in indices), {}
35
+ with av.open(str(path)) as container:
36
+ for k, frame in enumerate(container.decode(video=0)):
37
+ if k in want:
38
+ out[k] = frame.to_ndarray(format='rgb24')
39
+ if len(out) == len(want):
40
+ break
41
+ return out
42
+
43
+
44
+ def main():
45
+ p = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter)
46
+ p.add_argument('--checkpoint', type=Path, required=True)
47
+ p.add_argument('--dataset', type=Path, required=True)
48
+ p.add_argument('--episodes', default='0')
49
+ p.add_argument('--queries', type=int, default=8)
50
+ p.add_argument('--device', default='cuda:0')
51
+ a = p.parse_args()
52
+
53
+ import torch
54
+ from baselines.data import CONTRACTS, FlashChunkDataset, LeRobotDataset, load_lowdim, resize_frame
55
+ from baselines.runtime import BaselinePolicy
56
+ sys.path.insert(0, str(EVALUATION / 'policy' / 'FLASH'))
57
+ import model as flash_model
58
+
59
+ base = BaselinePolicy(a.checkpoint, device=a.device, policy='flash', robot='g1')
60
+ contract = CONTRACTS[base.contract['name']]
61
+ adapter = flash_model.Model(dict(checkpoint_path=str(a.checkpoint), device=a.device, action_space='sonic_dfx6',
62
+ task=base.task_text or '', config={}))
63
+ policy = adapter.policy.model # the adapter's own loaded weights
64
+ dataset = LeRobotDataset(a.dataset)
65
+ episodes = [int(e) for e in a.episodes.split(',')]
66
+ lowdim = load_lowdim(dataset, contract, episodes)
67
+ report, worst = [], 0.0
68
+ for pos, ep in enumerate(episodes):
69
+ s, n = int(lowdim['starts'][pos]), int(lowdim['lengths'][pos])
70
+ ts = sorted({0, *np.linspace(0, n - 1, a.queries).astype(int).tolist()})[:a.queries]
71
+ frames = {c: decode(dataset.video(ep, c), ts) for c in base.cameras}
72
+ hw = base.image_hw
73
+ maps = {c: np.zeros((lowdim['lengths'].sum(), *hw, 3), np.uint8) for c in base.cameras}
74
+ for t in ts:
75
+ for c in base.cameras:
76
+ maps[c][s + t] = resize_frame(frames[c][t], hw) # the frame cache's resize of the same frame
77
+ f = policy.flash
78
+ H_ext = f['poly_prefix'] + f['n_action'] + f['poly_suffix'] + 2 * f['fit_pad']
79
+ offsets = (np.arange(H_ext) - (f['fit_pad'] + f['poly_prefix'])) * f['stride']
80
+ ds = FlashChunkDataset(lowdim, {}, base.cameras, hw, [pos], offsets=offsets, stride=f['stride'],
81
+ n_history=f['n_history'], rows=f['rows'], with_dense=True)
82
+ ds._maps, ds._pid = maps, __import__('os').getpid()
83
+ for t in ts:
84
+ k = int(np.nonzero(ds.index == s + t)[0][0])
85
+ images, state, _, hist, has, dense, dense_valid = ds[k]
86
+ idx = np.arange(t - HISTORY_ROWS, t)
87
+ past = lowdim['history'][s + np.clip(idx, 0, n - 1)].astype(np.float32)
88
+ valid = (idx >= 0).astype(np.float32)
89
+ past[idx < 0] = 0.0
90
+ obs = dict(images={c: frames[c][t] for c in base.cameras}, state=lowdim['state'][s + t],
91
+ past_actions=past, history_valid=valid, seed=0, frame=t, history_frame=t)
92
+ a_chunk = adapter.get_action(obs)['action']
93
+ with torch.inference_mode():
94
+ img = images[None].to(a.device).permute(0, 1, 4, 2, 3).float().div_(255.)
95
+ b_chunk, _ = policy.predict(img, state[None].to(a.device), hist[None].to(a.device),
96
+ has[None].to(a.device))
97
+ b_chunk = b_chunk[0].float().cpu().numpy()
98
+ diff = float(np.abs(a_chunk - b_chunk).max())
99
+ worst = max(worst, diff)
100
+ nrm = policy.action_norm
101
+ err = (nrm.normalize(torch.from_numpy(a_chunk).to(a.device)) -
102
+ nrm.normalize(dense.to(a.device))).pow(2).cpu().numpy()[dense_valid.numpy()]
103
+ report.append(dict(episode=ep, t=t, has_history=bool(has), max_abs_diff=diff,
104
+ nmse_vs_recorded=float(err.mean()),
105
+ token_cos_row0=float(np.dot(a_chunk[0, :64], dense[0, :64].numpy()) /
106
+ (np.linalg.norm(a_chunk[0, :64]) *
107
+ np.linalg.norm(dense[0, :64].numpy()) + 1e-12))))
108
+ ok = worst == 0.0
109
+ print(json.dumps(dict(ok=ok, max_abs_diff=worst, checkpoint=str(a.checkpoint), queries=report), indent=1))
110
+ sys.exit(0 if ok else 1)
111
+
112
+
113
+ if __name__ == '__main__':
114
+ main()
b8-table-wipe/b512-cont-20261117-stop50k/step-050000/training_records/code_hb_bai_433ba198_stopat39f9b83a/evaluation/baselines/check_flash_parity.py ADDED
@@ -0,0 +1,141 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Check the FLASH port (evaluation/baselines/flash.py) against the upstream policy, on the CPU:
2
+
3
+ <baselines env>/bin/python -I evaluation/baselines/check_flash_parity.py --upstream <FLASH-Policy checkout>
4
+
5
+ Upstream is NTUMARS/FLASH-Policy @ f47e490 (roboverse_learn/il/...); its `zarr` and `einops` imports are shimmed
6
+ when the environment lacks them (only the parts used here run). Compared, for flash.yaml's settings with n_obs_steps =
7
+ n_history (8), n_action_steps 8, horizon 16:
8
+
9
+ - the polynomial buffers: least-squares matrix, coefficient scales, Tikhonov history fit, KKT boundary-constraint
10
+ matrices and pinned indices;
11
+ - target coefficients (least squares + boundary constraint) and history coefficients on random normalized
12
+ trajectories (identity normalizers on both sides);
13
+ - the DiT: upstream FlowTransformer's weights loaded strictly into FlashFlowTransformer, same outputs;
14
+ - the image encoder: upstream MultiImageObsEncoder (two rgb keys, agent_pos) with this port's weights, same features
15
+ (upstream concatenates its rgb keys in sorted order);
16
+ - the 30 Hz output rows: at multiples of the stride they equal upstream's trajectory points from the anchor.
17
+ Prints one JSON line with the largest differences; exits 1 when one exceeds its tolerance.
18
+ """
19
+ from __future__ import annotations
20
+
21
+ import argparse
22
+ import json
23
+ from pathlib import Path
24
+ import sys
25
+ import types
26
+
27
+ import torch
28
+
29
+ HERE = Path(__file__).resolve().parent
30
+ if str(HERE.parent) not in sys.path:
31
+ sys.path.insert(0, str(HERE.parent))
32
+
33
+
34
+ def shim_upstream_imports():
35
+ try:
36
+ import zarr # noqa: F401
37
+ except ImportError:
38
+ zarr = types.ModuleType('zarr')
39
+ zarr.Array = type('Array', (), {})
40
+ sys.modules['zarr'] = zarr
41
+ try:
42
+ import einops # noqa: F401
43
+ except ImportError:
44
+ einops = types.ModuleType('einops')
45
+ einops.reduce = lambda x, pattern, op: x.reshape(x.shape[0], -1) # "b ... -> b (...)" (no reduced axis)
46
+ sys.modules['einops'] = einops
47
+
48
+
49
+ def main():
50
+ p = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter)
51
+ p.add_argument('--upstream', type=Path, required=True, help='FLASH-Policy checkout (commit f47e490)')
52
+ p.add_argument('--stride', type=int, default=2)
53
+ a = p.parse_args()
54
+ shim_upstream_imports()
55
+ sys.path.insert(0, str(a.upstream.resolve()))
56
+ from roboverse_learn.il.policies.flash.flash_policy import FlashDiTImagePolicy
57
+ from roboverse_learn.il.utils.models.flow_net import FlowTransformer
58
+ from roboverse_learn.il.utils.vision.model_getter import get_resnet
59
+ from roboverse_learn.il.utils.vision.multi_image_obs_encoder import MultiImageObsEncoder
60
+ from baselines.flash import FLASH_DEFAULTS, FLASH_POLICY_FIELDS, FlashFlowTransformer
61
+ from baselines.policies import PolicyConfig, build_policy
62
+
63
+ torch.manual_seed(0)
64
+ Da, Ds, H, W = 76, 44, 48, 64
65
+ f = dict(FLASH_DEFAULTS, stride=a.stride)
66
+ cfg = PolicyConfig.from_dict(dict(policy='flash', n_cameras=2, state_dim=Ds, action_dim=Da, horizon=f['rows'],
67
+ **FLASH_POLICY_FIELDS, extra=dict(flash=f)))
68
+ ours = build_policy(cfg, pretrained=False).eval()
69
+ shape_meta = dict(obs=dict(ego_view=dict(shape=[3, H, W], type='rgb'), chest=dict(shape=[3, H, W], type='rgb'),
70
+ agent_pos=dict(shape=[Ds], type='low_dim')), action=dict(shape=[Da]))
71
+ enc = MultiImageObsEncoder(shape_meta=shape_meta, rgb_model=get_resnet('resnet18', weights=None),
72
+ resize_shape=None, crop_shape=None, random_crop=True, use_group_norm=True,
73
+ share_rgb_model=False, imagenet_norm=True)
74
+ up = FlashDiTImagePolicy(shape_meta=shape_meta, obs_encoder=enc, horizon=f['n_history'] + f['n_action'],
75
+ n_action_steps=f['n_action'], n_obs_steps=f['n_history'], num_inference_steps=1,
76
+ obs_as_global_cond=True, diffusion_step_embed_dim=256, hidden_dim=512, num_layers=4,
77
+ num_heads=8, mlp_ratio=4, dropout=0.0, poly_order=f['poly_order'], basis_type='legendre',
78
+ fit_pad=f['fit_pad'], boundary_constraint=f['boundary_constraint'],
79
+ history_noise_std=f['history_noise_std'], history_reg_lambda=f['history_reg_lambda'],
80
+ consistency_weight=f['consistency_weight'], flash_solver='euler',
81
+ poly_prefix=f['poly_prefix'], poly_suffix=f['poly_suffix']).eval()
82
+ res, tol = {}, {}
83
+
84
+ def diff(name, x, y, t):
85
+ res[name] = float((x.double() - y.double()).abs().max())
86
+ tol[name] = t
87
+
88
+ for b in ('_lstsq_matrix', '_coeff_scale', '_history_lstsq_matrix', '_bc_eval_pos', '_bc_eval_vel',
89
+ '_bc_correction'):
90
+ diff(b, getattr(ours, b), getattr(up, b), 1e-6)
91
+ res['_bc_pos_indices_equal'] = bool(torch.equal(ours._bc_pos_indices, up._bc_pos_indices))
92
+
93
+ # identity normalizers on both sides: compare the polynomial algebra itself
94
+ B = 6
95
+ traj = torch.randn(B, ours.H_ext, Da)
96
+ hist = torch.randn(B, f['n_history'], Da)
97
+ with torch.no_grad():
98
+ t_up = up._apply_boundary_constraint(up._trajectory_to_coefficients(traj), traj)
99
+ t_ours = ours._apply_boundary_constraint(ours._to_coeff(traj), traj)
100
+ diff('target_coeff', t_ours, t_up, 1e-4)
101
+ h_up = up._history_to_coefficients(hist)
102
+ h_ours = torch.einsum('ch,bhd->bcd', ours._history_lstsq_matrix, hist) / ours._coeff_scale
103
+ diff('history_coeff', h_ours, h_up, 1e-5)
104
+
105
+ # DiT: upstream weights into the port
106
+ dit_up = FlowTransformer(input_dim=Da, condition_dim=300, hidden_dim=512, output_dim=Da, num_layers=4,
107
+ num_heads=8, mlp_ratio=4, dropout=0.0, time_embed_dim=256).eval()
108
+ dit_ours = FlashFlowTransformer(input_dim=Da, condition_dim=300, hidden_dim=512, output_dim=Da, num_layers=4,
109
+ num_heads=8, mlp_ratio=4, dropout=0.0, time_embed_dim=256).eval()
110
+ dit_ours.load_state_dict(dit_up.state_dict(), strict=True)
111
+ x, t, c = torch.randn(B, ours.num_coeff, Da), torch.rand(B), torch.randn(B, 300)
112
+ diff('dit', dit_ours(x, t, c), dit_up(x, t, c), 1e-5)
113
+
114
+ # encoder: the port's ResNets into upstream's per-key models (sorted keys: chest, ego_view)
115
+ for i, cam in enumerate(('ego_view', 'chest')):
116
+ enc.key_model_map[cam].load_state_dict(ours.obs_encoder.rgb[i].state_dict(), strict=True)
117
+ imgs, state_n = torch.rand(B, 2, 3, H, W), torch.rand(B, Ds) * 2 - 1
118
+ f_ours = ours.obs_encoder(imgs, state_n)
119
+ f_up = enc({'ego_view': imgs[:, 0] * 2 - 1, 'chest': imgs[:, 1] * 2 - 1, 'agent_pos': state_n})
120
+ n = 512
121
+ f_up_reordered = torch.cat([f_up[:, n:2 * n], f_up[:, :n], f_up[:, 2 * n:]], dim=-1) # chest|ego -> ego|chest
122
+ diff('encoder', f_ours, f_up_reordered, 1e-4)
123
+
124
+ # 30 Hz rows from the anchor vs upstream's points: identity normalizer on ours
125
+ ours.action_norm.scale.fill_(1.0)
126
+ ours.action_norm.offset.zero_()
127
+ coeff = torch.randn(B, ours.num_coeff, Da)
128
+ dense = ours.dense_from_coeff(coeff)
129
+ sparse = up._coefficients_to_trajectory(coeff) # (B, H_poly, Da), anchor at up._anchor_idx
130
+ k = torch.arange(0, ours.rows, a.stride)
131
+ j = up._anchor_idx + k // a.stride
132
+ diff('dense_vs_upstream_points', dense[:, k], sparse[:, j], 1e-4)
133
+ bad = {k: v for k, v in res.items() if k in tol and v > tol[k]}
134
+ ok = not bad and res['_bc_pos_indices_equal']
135
+ print(json.dumps(dict(ok=ok, max_abs_diff=res, tolerance=tol, stride=a.stride,
136
+ upstream_anchor_idx=int(up._anchor_idx), port_anchor=int(ours.anchor))), flush=True)
137
+ sys.exit(0 if ok else 1)
138
+
139
+
140
+ if __name__ == '__main__':
141
+ main()
b8-table-wipe/b512-cont-20261117-stop50k/step-050000/training_records/code_hb_bai_433ba198_stopat39f9b83a/evaluation/baselines/data.py ADDED
@@ -0,0 +1,446 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Training data of the baselines: a task's LeRobot v2.1 expert dataset read through a robot contract.
2
+
3
+ A contract names the cameras and which dataset columns form the policy state and the action rows, the same layouts
4
+ the registered GR00T / Psi0 checkpoints were trained on:
5
+
6
+ - `g1_sonic_dfx6` (G1 + INSPIRE, the evaluation/README.md interface; ego_view, chest): state44 =
7
+ `observation.state[0:29]` body, measured `observation.inspire_{left,right}_hand_state`,
8
+ `observation.projected_gravity`; action76 (`sonic_dfx6`) = `action.motion_token` 64 and the measured DFX6 of the
9
+ same row (row 0 = the current opening);
10
+ - `h2_sharpa` (H2 + Sharpa, debug/newton/h2_sharpa_policy_eval.py; head, chest): state78 = `observation.state` 75,
11
+ `observation.projected_gravity` 3; action75 = `action.body_target` 31, `action.hands` 44 (absolute targets);
12
+ - `h2_sharpa_planner` (H2 + Sharpa a14 v2, h2_policy_planner_eval.py; head, chest): state78; action82 = action75 +
13
+ `action.planner` 7.
14
+
15
+ Frames: every camera's video is decoded once (PyAV), each frame resized with `resize_frame` (OpenCV INTER_AREA, the
16
+ same function the policy runtime applies to live frames) and stored as a uint8 memory map in a cache directory keyed by
17
+ the dataset, episodes, camera and size. A training sample is the frame t of an episode: the cameras and the state at t,
18
+ and the action rows t..t+horizon-1 (rows past the episode's end repeat its last row, as DextraVerse's windows).
19
+ """
20
+ from __future__ import annotations
21
+
22
+ from dataclasses import dataclass
23
+ import hashlib
24
+ import json
25
+ import os
26
+ from pathlib import Path
27
+ import sys
28
+
29
+ import numpy as np
30
+
31
+ CACHE_VERSION = 1
32
+
33
+
34
+ @dataclass(frozen=True)
35
+ class Contract:
36
+ name: str
37
+ robot: str
38
+ cameras: tuple
39
+ state: tuple # ((column, start, end), ...) concatenated in order
40
+ action: tuple
41
+ action_space: str | None = None # the G1 evaluation interface's action space, if any
42
+ body_dims: int = 0 # leading raw-radian body joint angles of the state (augmentation spec v2 perturbs these)
43
+ # the executed rows a policy conditions on (FLASH's history, the ODE policies' row before t), when they are not the
44
+ # action rows: g1_sonic_cmd trains on the commanded hands but conditions on the measured ones, as at deployment
45
+ # (the interface's past_actions = the token sent + the measured DFX6)
46
+ history: tuple | None = None
47
+
48
+ @property
49
+ def history_columns(self) -> tuple:
50
+ return self.history if self.history is not None else self.action
51
+
52
+ @property
53
+ def state_dim(self) -> int:
54
+ return sum(end - start for _, start, end in self.state)
55
+
56
+ @property
57
+ def action_dim(self) -> int:
58
+ return sum(end - start for _, start, end in self.action)
59
+
60
+ def to_dict(self, cameras=None) -> dict:
61
+ out = dict(name=self.name, robot=self.robot, cameras=list(cameras or self.cameras),
62
+ state=[list(s) for s in self.state], action=[list(a) for a in self.action],
63
+ state_dim=self.state_dim, action_dim=self.action_dim, action_space=self.action_space,
64
+ body_dims=self.body_dims)
65
+ if self.history is not None:
66
+ out['history'] = [list(h) for h in self.history]
67
+ return out
68
+
69
+
70
+ _G1_HANDS = (('observation.inspire_left_hand_state', 0, 6), ('observation.inspire_right_hand_state', 0, 6))
71
+ # the INSPIRE commands the expert sent (same [0, 1] DFX6 openings, same finger order; thumb pitch / yaw = the measured
72
+ # thumb bend / rotation). Owner 2026-11-27: every policy learns the commanded actions, hands included, never measured
73
+ # states (a closing hand stops on the object while its command keeps closing: b6 holds 0.13-0.34 tighter).
74
+ _G1_HAND_CMDS = (('teleop.inspire_left_hand_cmd', 0, 6), ('teleop.inspire_right_hand_cmd', 0, 6))
75
+ _G1_STATE = (('observation.state', 0, 29), *_G1_HANDS, ('observation.projected_gravity', 0, 3))
76
+ _H2_STATE = (('observation.state', 0, 75), ('observation.projected_gravity', 0, 3))
77
+ _H2_ACTION = (('action.body_target', 0, 31), ('action.hands', 0, 44))
78
+ # body_dims: G1 observation.state[0:29] are the 29 body joints; H2 observation.state[0:31] are legs 6+6, waist 3,
79
+ # head 2, arms 7+7 (docs/unitree_h2_sharpa.md), then the Sharpa hands.
80
+ CONTRACTS = {c.name: c for c in (
81
+ Contract('g1_sonic_dfx6', 'g1', ('ego_view', 'chest'), _G1_STATE,
82
+ (('action.motion_token', 0, 64), *_G1_HANDS), action_space='sonic_dfx6', body_dims=29),
83
+ # owner 2026-11-27: the default G1 contract of every new training (the same sonic_dfx6 interface and 76 values)
84
+ Contract('g1_sonic_cmd', 'g1', ('ego_view', 'chest'), _G1_STATE,
85
+ (('action.motion_token', 0, 64), *_G1_HAND_CMDS), action_space='sonic_dfx6', body_dims=29,
86
+ history=(('action.motion_token', 0, 64), *_G1_HANDS)),
87
+ Contract('h2_sharpa', 'h2_sharpa', ('head', 'chest'), _H2_STATE, _H2_ACTION, body_dims=31),
88
+ Contract('h2_sharpa_planner', 'h2_sharpa', ('head', 'chest'), _H2_STATE,
89
+ (*_H2_ACTION, ('action.planner', 0, 7)), body_dims=31),
90
+ )}
91
+
92
+
93
+ def augmentation_module():
94
+ """evaluation/augmentation: the augmentation spec v2 shared by every model's training (imported on demand)."""
95
+ evaluation = str(Path(__file__).resolve().parents[1])
96
+ if evaluation not in sys.path:
97
+ sys.path.insert(0, evaluation)
98
+ import augmentation
99
+ return augmentation
100
+
101
+
102
+ def resize_frame(frame: np.ndarray, hw) -> np.ndarray:
103
+ """(H, W, 3) uint8 RGB -> (h, w, 3) uint8, OpenCV INTER_AREA (training cache and live frames alike)."""
104
+ import cv2
105
+ frame = np.ascontiguousarray(frame, dtype=np.uint8)
106
+ if frame.ndim != 3 or frame.shape[2] != 3:
107
+ raise ValueError(f'expected an (H, W, 3) RGB frame, got {frame.shape}')
108
+ h, w = int(hw[0]), int(hw[1])
109
+ if frame.shape[:2] == (h, w):
110
+ return frame
111
+ return cv2.resize(frame, (w, h), interpolation=cv2.INTER_AREA)
112
+
113
+
114
+ class LeRobotDataset:
115
+ """A LeRobot v2.1 dataset directory (meta/info.json, meta/episodes.jsonl, data/, videos/)."""
116
+
117
+ def __init__(self, root):
118
+ self.root = Path(root).expanduser().resolve()
119
+ self.info = json.loads((self.root / 'meta/info.json').read_text())
120
+ if self.info.get('codebase_version') != 'v2.1':
121
+ raise ValueError(f"{self.root}: LeRobot {self.info.get('codebase_version')}, expected v2.1")
122
+ rows = [json.loads(line) for line in (self.root / 'meta/episodes.jsonl').read_text().splitlines() if line]
123
+ self.lengths = {int(r['episode_index']): int(r['length']) for r in rows}
124
+ tasks = [json.loads(line) for line in (self.root / 'meta/tasks.jsonl').read_text().splitlines() if line]
125
+ self.tasks = {int(t['task_index']): t['task'] for t in tasks}
126
+ self.fps = float(self.info['fps'])
127
+
128
+ @property
129
+ def name(self) -> str:
130
+ """The dataset's folder name (its parent's for an export folder named `lerobot`)."""
131
+ return self.root.parent.name if self.root.name == 'lerobot' else self.root.name
132
+
133
+ def chunk(self, episode: int) -> int:
134
+ return episode // int(self.info['chunks_size'])
135
+
136
+ def parquet(self, episode: int) -> Path:
137
+ return self.root / self.info['data_path'].format(episode_chunk=self.chunk(episode), episode_index=episode)
138
+
139
+ def video(self, episode: int, camera: str) -> Path:
140
+ return self.root / self.info['video_path'].format(episode_chunk=self.chunk(episode), episode_index=episode,
141
+ video_key=f'observation.images.{camera}')
142
+
143
+ def check_contract(self, contract: Contract, cameras):
144
+ features = self.info['features']
145
+ for column, start, end in (*contract.state, *contract.action, *contract.history_columns):
146
+ if column not in features:
147
+ raise KeyError(f'{self.root.name}: no column {column!r} (contract {contract.name})')
148
+ width = int(np.prod(features[column]['shape']))
149
+ if end > width:
150
+ raise ValueError(f'{column} has {width} values; the contract reads {start}:{end}')
151
+ for camera in cameras:
152
+ key = f'observation.images.{camera}'
153
+ if features.get(key, {}).get('dtype') != 'video':
154
+ raise KeyError(f'{self.root.name}: no video {key!r}')
155
+
156
+
157
+ def parse_episodes(spec: str | None, available) -> list:
158
+ """'0:100', '0,3,7' or None (all), restricted to the dataset's episodes, sorted."""
159
+ available = sorted(available)
160
+ if not spec:
161
+ return available
162
+ chosen = set()
163
+ for part in spec.split(','):
164
+ if ':' in part:
165
+ lo, hi = part.split(':')
166
+ chosen.update(range(int(lo or 0), int(hi) if hi else available[-1] + 1))
167
+ else:
168
+ chosen.add(int(part))
169
+ missing = sorted(chosen - set(available))
170
+ if missing:
171
+ raise ValueError(f'episodes not in the dataset: {missing[:10]}')
172
+ return sorted(chosen)
173
+
174
+
175
+ def load_lowdim(dataset: LeRobotDataset, contract: Contract, episodes) -> dict:
176
+ """State (N, state_dim) and action (N, action_dim) float32 of the episodes in order, plus each episode's start
177
+ row, length and task text; `history` (N, action_dim) is the executed rows a policy conditions on (the action rows
178
+ themselves unless the contract names other columns)."""
179
+ import pyarrow.parquet as pq
180
+ columns = sorted({c for c, _, _ in (*contract.state, *contract.action, *contract.history_columns)}
181
+ | {'frame_index', 'task_index'})
182
+ states, actions, histories, starts, lengths, tasks, offset = [], [], [], [], [], set(), 0
183
+ for episode in episodes:
184
+ table = pq.read_table(dataset.parquet(episode), columns=columns)
185
+ data = {c: np.asarray(table.column(c).to_pylist(), dtype=np.float64) for c in columns}
186
+ n = len(data['frame_index'])
187
+ if n != dataset.lengths[episode] or not np.array_equal(data['frame_index'], np.arange(n)):
188
+ raise ValueError(f'episode {episode}: {n} rows / frame_index differ from episodes.jsonl')
189
+
190
+ def pick(spec):
191
+ return np.concatenate([data[c].reshape(n, -1)[:, s:e] for c, s, e in spec], axis=1).astype(np.float32)
192
+
193
+ states.append(pick(contract.state))
194
+ actions.append(pick(contract.action))
195
+ if contract.history is not None:
196
+ histories.append(pick(contract.history))
197
+ tasks.update(dataset.tasks[int(i)] for i in np.unique(data['task_index']))
198
+ starts.append(offset)
199
+ lengths.append(n)
200
+ offset += n
201
+ state, action = np.concatenate(states), np.concatenate(actions)
202
+ history = np.concatenate(histories) if contract.history is not None else action
203
+ if not (np.isfinite(state).all() and np.isfinite(action).all() and np.isfinite(history).all()):
204
+ raise ValueError('non-finite state or action values')
205
+ return dict(state=state, action=action, history=history, starts=np.asarray(starts), lengths=np.asarray(lengths),
206
+ episodes=list(episodes), tasks=sorted(tasks))
207
+
208
+
209
+ def statistics(lowdim: dict, rows: np.ndarray, quantiles: bool = False) -> dict:
210
+ """min / max / mean / std of state and action over `rows`; with `quantiles` also their q01 / q99 (the ODE
211
+ policies' normalization bounds, as ODE Policy's G1 port fits them)."""
212
+ out = {}
213
+ for key in ('state', 'action'):
214
+ x = lowdim[key][rows].astype(np.float64)
215
+ out[key] = dict(min=x.min(0).tolist(), max=x.max(0).tolist(), mean=x.mean(0).tolist(), std=x.std(0).tolist())
216
+ if quantiles:
217
+ q01, q99 = np.quantile(x, [0.01, 0.99], axis=0)
218
+ out[key].update(q01=q01.tolist(), q99=q99.tolist())
219
+ return out
220
+
221
+
222
+ # Columns recorded in physical [0, 1] (the INSPIRE DFX6 openings): the ODE policies normalize them with these fixed
223
+ # bounds instead of the data's, as ODE Policy's G1 port does.
224
+ UNIT_RANGE_COLUMNS = ('observation.inspire_left_hand_state', 'observation.inspire_right_hand_state',
225
+ 'teleop.inspire_left_hand_cmd', 'teleop.inspire_right_hand_cmd')
226
+
227
+
228
+ def unit_range_dims(contract: Contract) -> dict:
229
+ """{'state': [...], 'action': [...]}: the positions of the UNIT_RANGE_COLUMNS values in the contract's layouts."""
230
+ out = {}
231
+ for key, spec in (('state', contract.state), ('action', contract.action)):
232
+ dims, offset = [], 0
233
+ for column, start, end in spec:
234
+ if column in UNIT_RANGE_COLUMNS:
235
+ dims.extend(range(offset, offset + end - start))
236
+ offset += end - start
237
+ out[key] = dims
238
+ return out
239
+
240
+
241
+ # -- frame cache --------------------------------------------------------------------------------------------------
242
+ def _decode_into(job):
243
+ path, out_path, total, start, length, hw = job
244
+ import av
245
+ frames = np.memmap(out_path, dtype=np.uint8, mode='r+', shape=(total, hw[0], hw[1], 3))
246
+ count = 0
247
+ with av.open(str(path)) as container:
248
+ stream = container.streams.video[0]
249
+ stream.thread_type = 'AUTO'
250
+ for frame in container.decode(stream):
251
+ if count < length:
252
+ frames[start + count] = resize_frame(frame.to_ndarray(format='rgb24'), hw)
253
+ count += 1
254
+ frames.flush()
255
+ del frames
256
+ if count != length:
257
+ raise ValueError(f'{path}: {count} video frames, {length} data rows')
258
+ return length
259
+
260
+
261
+ def frame_cache(dataset: LeRobotDataset, lowdim: dict, cameras, hw, cache_root, workers=8) -> dict:
262
+ """{camera: path of the (N, h, w, 3) uint8 memory map} for the episodes of `lowdim`, decoded once and reused."""
263
+ from multiprocessing import get_context
264
+ total = int(lowdim['lengths'].sum())
265
+ paths = {}
266
+ for camera in cameras:
267
+ key = json.dumps(dict(version=CACHE_VERSION, root=str(dataset.root), episodes=lowdim['episodes'],
268
+ lengths=lowdim['lengths'].tolist(), camera=camera, hw=list(hw)), sort_keys=True)
269
+ digest = hashlib.sha256(key.encode()).hexdigest()[:16]
270
+ folder = Path(cache_root).expanduser() / f'{dataset.name}_{camera}_{hw[0]}x{hw[1]}_{digest}'
271
+ folder.mkdir(parents=True, exist_ok=True)
272
+ out, meta = folder / 'frames.u8', folder / 'meta.json'
273
+ if meta.exists() and json.loads(meta.read_text()).get('complete'):
274
+ paths[camera] = out
275
+ continue
276
+ np.memmap(out, dtype=np.uint8, mode='w+', shape=(total, hw[0], hw[1], 3)).flush()
277
+ jobs = [(dataset.video(e, camera), out, total, int(s), int(n), tuple(hw))
278
+ for e, s, n in zip(lowdim['episodes'], lowdim['starts'], lowdim['lengths'])]
279
+ with get_context('spawn').Pool(max(1, int(workers))) as pool: # the caller may hold torch threads
280
+ for done, _ in enumerate(pool.imap_unordered(_decode_into, jobs), 1):
281
+ if done % 20 == 0 or done == len(jobs):
282
+ print(json.dumps(dict(event='frame_cache', camera=camera, episodes=done, of=len(jobs))),
283
+ flush=True)
284
+ meta.write_text(json.dumps(dict(json.loads(key), frames=total, complete=True), indent=1))
285
+ paths[camera] = out
286
+ return paths
287
+
288
+
289
+ class ChunkDataset:
290
+ """torch-style dataset of (images (n_cameras, h, w, 3) uint8, state (state_dim,), action (horizon, action_dim))
291
+ over the frames of the selected episodes (positions into lowdim['episodes']). Memory maps open lazily per
292
+ process (DataLoader workers).
293
+
294
+ `body_dims` > 0 turns on the training augmentation (docs/augmentation_v2.md, evaluation/augmentation): per item,
295
+ the cached frames of all cameras get one hb_aug_v2.augment call (one time step, no future targets) and the first
296
+ `body_dims` state values the per-sample joint bias + noise; the action rows are never touched. 0 (evaluation,
297
+ offline checks) returns the cached frames and the recorded state unchanged, deterministically.
298
+
299
+ `lead` > 0 prepends that many rows before t to the action rows (lead + horizon rows, t-lead..t+horizon-1) and
300
+ adds a fourth item, the rows' validity (lead + horizon,) float: 0 for a row before the episode's first or past its
301
+ last (whose values repeat the nearest row); the ODE policies start from the row before t, or from their BOS where
302
+ it is invalid, and leave invalid future rows out of the loss (policies.ODEPolicy).
303
+
304
+ aug_seed (HumanWAM hb_training/REPRODUCIBILITY.md section 3; the training seed, `HB_AUG_SEED`): an item asked for
305
+ as (k, draw) (train.EpochSampler, 2026-11-27) is augmented with numpy default_rng([aug_seed, draw]), draw being its
306
+ position in the run's sample stream: the same seed and step give the same augmentations whatever the worker count
307
+ and across an interrupted run's --resume. A plain index k (the preflight) uses the per-worker stream
308
+ default_rng([aug_seed, torch.initial_seed(), worker id]) of the runs trained before; None the shared worker_rng
309
+ (pid + urandom: not reproducible)."""
310
+
311
+ def __init__(self, lowdim: dict, frames: dict, cameras, hw, horizon: int, positions, body_dims: int = 0,
312
+ lead: int = 0, aug_seed=None):
313
+ self.lowdim, self.paths, self.cameras, self.hw, self.horizon = lowdim, frames, list(cameras), tuple(hw), horizon
314
+ self.positions, self.body_dims, self.lead = list(positions), int(body_dims), int(lead)
315
+ self.aug_seed = aug_seed
316
+ self._rng_key, self._rng_obj = None, None
317
+ if self.body_dims:
318
+ augmentation_module() # asserts the spec version before any worker starts
319
+ self.total = int(lowdim['lengths'].sum())
320
+ index, begin, end = [], np.zeros(self.total, np.int64), np.zeros(self.total, np.int64)
321
+ for p in positions:
322
+ s, n = int(lowdim['starts'][p]), int(lowdim['lengths'][p])
323
+ index.append(np.arange(s, s + n))
324
+ begin[s:s + n] = s
325
+ end[s:s + n] = s + n
326
+ self.index, self.begin, self.end = np.concatenate(index), begin, end
327
+ self._maps, self._pid = None, None
328
+
329
+ def __len__(self):
330
+ return len(self.index)
331
+
332
+ def _frames(self):
333
+ if self._maps is None or self._pid != os.getpid():
334
+ self._maps = {c: np.memmap(self.paths[c], dtype=np.uint8, mode='r', shape=(self.total, *self.hw, 3))
335
+ for c in self.cameras}
336
+ self._pid = os.getpid()
337
+ return self._maps
338
+
339
+ def rows(self, i: int) -> np.ndarray:
340
+ return np.clip(np.arange(i - self.lead, i + self.horizon), self.begin[i], self.end[i] - 1)
341
+
342
+ def valid(self, i: int) -> np.ndarray:
343
+ rows = np.arange(i - self.lead, i + self.horizon)
344
+ return ((rows >= self.begin[i]) & (rows < self.end[i])).astype(np.float32)
345
+
346
+ def plain(self):
347
+ """The same items without augmentation (the preflight's reference read)."""
348
+ return ChunkDataset(self.lowdim, self.paths, self.cameras, self.hw, self.horizon, self.positions,
349
+ lead=self.lead)
350
+
351
+ def _rng(self):
352
+ if self.aug_seed is None or not self.body_dims:
353
+ return None
354
+ import torch
355
+ info = torch.utils.data.get_worker_info()
356
+ wid = info.id if info is not None else 0
357
+ key = (os.getpid(), wid)
358
+ if self._rng_key != key:
359
+ self._rng_obj = np.random.default_rng([int(self.aug_seed), int(torch.initial_seed()), int(wid)])
360
+ self._rng_key = key
361
+ return self._rng_obj
362
+
363
+ def _key(self, k):
364
+ """(item index, augmentation rng) of a sampler key: (k, draw) or a plain k (class docstring)."""
365
+ if isinstance(k, (tuple, list)):
366
+ k, draw = k
367
+ if self.aug_seed is not None and self.body_dims:
368
+ return int(k), np.random.default_rng([int(self.aug_seed), int(draw)])
369
+ return int(k), self._rng()
370
+
371
+ def _observation(self, i: int, rng=None):
372
+ """The cameras (n_cameras, h, w, 3) uint8 and the state of frame i, augmented when body_dims > 0."""
373
+ import torch
374
+ maps = self._frames()
375
+ images = torch.from_numpy(np.stack([maps[c][i] for c in self.cameras]))
376
+ state = self.lowdim['state'][i]
377
+ if self.body_dims:
378
+ augmentation = augmentation_module()
379
+ images, _ = augmentation.augment_frames_uint8(images, rng=rng)
380
+ state = augmentation.perturb_body(state, self.body_dims, rng=rng)
381
+ return images, torch.from_numpy(np.asarray(state, dtype=np.float32))
382
+
383
+ def __getitem__(self, k):
384
+ import torch
385
+ k, rng = self._key(k)
386
+ i = int(self.index[k])
387
+ images, state = self._observation(i, rng=rng)
388
+ rows = self.rows(i)
389
+ action = self.lowdim['action'][rows]
390
+ if self.lead and self.lowdim.get('history') is not None and self.lowdim['history'] is not self.lowdim['action']:
391
+ action = action.copy() # the rows before t are executed rows (the contract's history columns)
392
+ action[:self.lead] = self.lowdim['history'][rows[:self.lead]]
393
+ item = images, state, torch.from_numpy(action)
394
+ return (*item, torch.from_numpy(self.valid(i))) if self.lead else item
395
+
396
+
397
+ class FlashChunkDataset(ChunkDataset):
398
+ """FLASH training items (evaluation/baselines/flash.py) over every frame of the selected episodes as the anchor:
399
+ (images, state, poly, history, has_history[, dense, dense_valid]).
400
+
401
+ - images, state: the anchor frame's cameras and state44, augmented as ChunkDataset (spec v2) when body_dims > 0;
402
+ - poly (H_ext, action_dim): the action rows at `offsets` frames from the anchor (the polynomial's extended grid,
403
+ `stride` frames apart), clamped to the episode (FLASH's edge padding);
404
+ - history (n_history, action_dim), has_history: flash.history_rows over the `span` executed rows before the anchor
405
+ (rows before the episode start invalid), the same function the adapter applies to past_actions;
406
+ - dense (rows, action_dim), dense_valid: the recorded 30 Hz rows from the anchor (offline check only).
407
+
408
+ aug_seed: as ChunkDataset (the same seeded stream)."""
409
+
410
+ def __init__(self, lowdim, frames, cameras, hw, positions, *, offsets, stride, n_history, rows, body_dims=0,
411
+ aug_seed=None, with_dense=False):
412
+ super().__init__(lowdim, frames, cameras, hw, rows, positions, body_dims=body_dims)
413
+ self.offsets = np.asarray(offsets, dtype=np.int64)
414
+ self.stride, self.n_history, self.n_rows = int(stride), int(n_history), int(rows)
415
+ self.span = (self.n_history - 1) * self.stride + 1
416
+ self.aug_seed, self.with_dense = aug_seed, bool(with_dense)
417
+ start = np.zeros(self.total, np.int64)
418
+ for p in positions:
419
+ s, n = int(lowdim['starts'][p]), int(lowdim['lengths'][p])
420
+ start[s:s + n] = s
421
+ self.start = start
422
+
423
+ def plain(self):
424
+ return FlashChunkDataset(self.lowdim, self.paths, self.cameras, self.hw, self.positions, offsets=self.offsets,
425
+ stride=self.stride, n_history=self.n_history, rows=self.n_rows,
426
+ with_dense=self.with_dense)
427
+
428
+ def __getitem__(self, k):
429
+ import torch
430
+ from .flash import history_rows
431
+ k, rng = self._key(k)
432
+ i = int(self.index[k])
433
+ s0, e1 = int(self.start[i]), int(self.end[i])
434
+ images, state = self._observation(i, rng=rng)
435
+ action = self.lowdim['action']
436
+ poly = action[np.clip(i + self.offsets, s0, e1 - 1)]
437
+ past = i - self.span + np.arange(self.span)
438
+ executed = self.lowdim.get('history', action) # the measured hands under g1_sonic_cmd, as past_actions
439
+ history, has = history_rows(executed[np.maximum(past, s0)], past >= s0, self.stride, self.n_history)
440
+ out = [images, state, torch.from_numpy(np.ascontiguousarray(poly)), torch.from_numpy(history),
441
+ torch.tensor(bool(has))]
442
+ if self.with_dense:
443
+ idx = i + np.arange(self.n_rows)
444
+ out += [torch.from_numpy(np.ascontiguousarray(action[np.minimum(idx, e1 - 1)])),
445
+ torch.from_numpy(idx < e1)]
446
+ return tuple(out)
b8-table-wipe/b512-cont-20261117-stop50k/step-050000/training_records/code_hb_bai_433ba198_stopat39f9b83a/evaluation/baselines/flash.py ADDED
@@ -0,0 +1,412 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """FLASH (Bai et al., "FLASH: Efficient Visuomotor Policy via Sparse Sampling", NeurIPS 2026) behind the baselines
2
+ contract: history-to-future polynomial flow matching with a DiT backbone and one Euler step at inference.
3
+
4
+ Ported from NTUMARS/FLASH-Policy @ f47e490 (Apache-2.0): `roboverse_learn/il/policies/flash/flash_policy.py`
5
+ (`FlashDiTImagePolicy`: basis, least-squares and Tikhonov history fits, KKT C1 boundary constraint, loss, sampler),
6
+ `utils/models/flow_net.py` + `policies/dp/models/diffusion/positional_embedding.py` (the DiT and its torchtune RoPE,
7
+ which differs from the DextraVerse RoPE of nets.py), `utils/vision/multi_image_obs_encoder.py` (one ResNet18 per
8
+ camera, GroupNorm, ImageNet normalization of the range-normalized image) and `configs/policy_config/flash.yaml` +
9
+ `configs/train_config/default_train.yaml` (the defaults below). Architecture, initialization and loss are unchanged.
10
+
11
+ What the humanoid interface changes (owner decisions 2026-11-24, recorded in every checkpoint's config):
12
+
13
+ - **Action space and history.** FLASH fits its flow start to the measured history of the action quantity (Franka
14
+ joint positions). The G1 action76 is the SONIC motion token (64, a latent with no measured counterpart) plus the
15
+ measured INSPIRE openings (12). The history is therefore the *executed* action rows - the token sent at each frame
16
+ and the opening measured at it, the interface's `past_actions` - ending one frame before the query (row t-1: the
17
+ token of frame t is what the policy is asked for). Training reads the same dataset rows. `n_history` points at the
18
+ sampling stride; rows before the episode start repeat its first row (FLASH's edge padding); with no row at all (the
19
+ episode's first frame) the flow starts from the zero coefficients, in training as at deployment.
20
+ - **Sampling stride.** The model's points are `stride` dataset frames apart (30 Hz data: stride 2 = 67 ms, the paper's
21
+ 4 x 15 ms = 60 ms). Every dataset frame is an anchor (FLASH's converter keeps only every stride-th frame: one phase
22
+ of the same sparse data).
23
+ - **Observation.** The current ego_view and chest frames and state44 condition the DiT (n_obs 1); FLASH's 8-frame
24
+ observation history is not rendered by the benchmark runners. state44 is the low-dim encoder input as agent_pos is.
25
+ - **Output.** The polynomial is evaluated at every 30 Hz frame from the anchor (`rows` rows, row 0 = the query frame),
26
+ the analytic form of FLASH's continuous-time resampling, at exact frame times. FLASH's velocity feed-forward has no
27
+ channel in the interface (SONIC takes tokens) and is not produced.
28
+ - Polynomial fits run in float32 outside autocast (FLASH runs them inside its bf16 autocast); the encoder and the
29
+ DiT run under the trainer's bf16 autocast as upstream.
30
+ - Augmentation spec v2 replaces the native image augmentation (FLASH's random_crop is configured but inert without
31
+ crop_shape).
32
+ """
33
+ from __future__ import annotations
34
+
35
+ import copy
36
+
37
+ import numpy as np
38
+ import torch
39
+ import torch.nn as nn
40
+ import torch.nn.functional as F
41
+ import torchvision
42
+
43
+ from .nets import IMAGENET_MEAN, IMAGENET_STD, Mlp, SinusoidalPosEmb, replace_batchnorm_with_groupnorm
44
+
45
+ # configs/policy_config/flash.yaml (+ default_runner.yaml horizon 16 / n_obs 8 / n_action 8), owner 2026-11-24 stride 2
46
+ FLASH_DEFAULTS = dict(stride=2, n_history=8, n_action=8, rows=16, poly_order=6, fit_pad=1, boundary_constraint=True,
47
+ poly_prefix=1, poly_suffix=1, history_noise_std=0.5, history_reg_lambda=0.1,
48
+ consistency_weight=1.0, solver='euler')
49
+ # PolicyConfig fields of a FLASH run (flash.yaml + default_train.yaml): DiT 512 x 4 x 8, dropout 0, time embedding
50
+ # 256, one inference step, ResNet18 from scratch with GroupNorm, one per camera
51
+ FLASH_POLICY_FIELDS = dict(hidden_dim=512, num_layers=4, num_heads=8, mlp_ratio=4.0, dropout=0.0, time_embed_dim=256,
52
+ num_inference_steps=1, backbone='resnet18', backbone_weights=None, backbone_norm='group')
53
+
54
+
55
+ def flash_settings(cfg) -> dict:
56
+ """The FLASH settings of a PolicyConfig (cfg.extra['flash'] over the defaults); unknown keys are an error."""
57
+ given = dict((cfg.extra or {}).get('flash', {}))
58
+ unknown = sorted(set(given) - set(FLASH_DEFAULTS))
59
+ if unknown:
60
+ raise KeyError(f'unknown FLASH settings {unknown}; known: {sorted(FLASH_DEFAULTS)}')
61
+ out = dict(FLASH_DEFAULTS, **given)
62
+ if out['solver'] not in ('euler', 'midpoint'):
63
+ raise ValueError(f"solver {out['solver']!r}")
64
+ if out['poly_prefix'] is None or int(out['poly_prefix']) < 0:
65
+ raise ValueError('this port implements poly_prefix >= 0 (flash.yaml: 1)')
66
+ return out
67
+
68
+
69
+ # --- networks: utils/models/flow_net.py and positional_embedding.py of FLASH-Policy ------------------------------
70
+ class RotaryPosEmbFlash(nn.Module):
71
+ """torchtune RoPE as FLASH builds it: `dim` = the model width, its dim/2 frequencies split over the heads, pairs
72
+ interleaved (x[..., 0::2], x[..., 1::2])."""
73
+
74
+ def __init__(self, dim: int, max_seq_len: int = 256, base: int = 10_000):
75
+ super().__init__()
76
+ self.dim, self.base, self.max_seq_len = dim, base, max_seq_len
77
+ theta = 1.0 / (base ** (torch.arange(0, dim, 2)[: (dim // 2)].float() / dim))
78
+ self.register_buffer('theta', theta, persistent=False)
79
+ seq_idx = torch.arange(max_seq_len, dtype=theta.dtype)
80
+ idx_theta = torch.einsum('i, j -> ij', seq_idx, theta).float()
81
+ self.register_buffer('cache', torch.stack([torch.cos(idx_theta), torch.sin(idx_theta)], dim=-1),
82
+ persistent=False)
83
+
84
+ def forward(self, x): # x: (B, heads, S, head_dim)
85
+ x = x.permute(0, 2, 1, 3)
86
+ B, S, heads, head_dim = x.size()
87
+ rope = self.cache[:S].view(1, S, heads, head_dim // 2, 2)
88
+ xs = x.float().reshape(*x.shape[:-1], head_dim // 2, 2)
89
+ out = torch.stack([xs[..., 0] * rope[..., 0] - xs[..., 1] * rope[..., 1],
90
+ xs[..., 1] * rope[..., 0] + xs[..., 0] * rope[..., 1]], -1)
91
+ return out.flatten(3).permute(0, 2, 1, 3).type_as(x)
92
+
93
+
94
+ class FlashAttention(nn.Module):
95
+ def __init__(self, dim, num_heads=8, qkv_bias=True, attn_drop=0.0, proj_drop=0.0, max_seq_len=256, qk_norm=True):
96
+ super().__init__()
97
+ assert dim % num_heads == 0, 'dim should be divisible by num_heads'
98
+ self.num_heads, self.head_dim = num_heads, dim // num_heads
99
+ self.attn_drop = attn_drop
100
+ self.proj_drop = nn.Dropout(proj_drop)
101
+ self.qkv = nn.Linear(dim, dim * 3, bias=qkv_bias)
102
+ self.q_norm = nn.LayerNorm(self.head_dim) if qk_norm else nn.Identity()
103
+ self.k_norm = nn.LayerNorm(self.head_dim) if qk_norm else nn.Identity()
104
+ self.proj = nn.Linear(dim, dim)
105
+ self.rope = RotaryPosEmbFlash(dim, max_seq_len=max_seq_len)
106
+
107
+ def forward(self, x):
108
+ B, S, C = x.shape
109
+ q, k, v = self.qkv(x).reshape(B, S, 3, self.num_heads, self.head_dim).permute(2, 0, 3, 1, 4).unbind(0)
110
+ q, k = self.rope(self.q_norm(q)), self.rope(self.k_norm(k))
111
+ x = F.scaled_dot_product_attention(q, k, v, dropout_p=self.attn_drop if self.training else 0.0)
112
+ return self.proj_drop(self.proj(x.transpose(1, 2).reshape(B, S, C)))
113
+
114
+
115
+ class FlashAdaLNBlock(nn.Module):
116
+ def __init__(self, dim, num_heads, mlp_ratio=4.0, dropout=0.0, max_seq_len=256):
117
+ super().__init__()
118
+ self.norm1 = nn.LayerNorm(dim, elementwise_affine=False, eps=1e-6)
119
+ self.attn = FlashAttention(dim, num_heads=num_heads, attn_drop=dropout, proj_drop=dropout,
120
+ max_seq_len=max_seq_len)
121
+ self.norm2 = nn.LayerNorm(dim, elementwise_affine=False, eps=1e-6)
122
+ self.mlp = Mlp(in_features=dim, hidden_features=int(dim * mlp_ratio),
123
+ act_layer=lambda: nn.GELU(approximate='tanh'), drop=0)
124
+ self.ada_ln = nn.Sequential(nn.SiLU(), nn.Linear(dim, 6 * dim))
125
+ self.dim = dim
126
+ nn.init.constant_(self.ada_ln[-1].weight, 0)
127
+ nn.init.constant_(self.ada_ln[-1].bias, 0)
128
+
129
+ def forward(self, x, t, c):
130
+ B = x.shape[0]
131
+ gamma1, gamma2, scale1, scale2, shift1, shift2 = self.ada_ln(F.silu(t + c)).view(B, 6, 1, self.dim).unbind(1)
132
+ x = x + self.attn(self.norm1(x).mul(scale1.add(1)).add_(shift1)).mul_(gamma1)
133
+ return x + self.mlp(self.norm2(x).mul(scale2.add(1)).add_(shift2)).mul_(gamma2)
134
+
135
+
136
+ class FlashFlowTransformer(nn.Module):
137
+ """FLASH's FlowTransformer: AdaLN DiT over the C coefficient rows (tokens of width action_dim)."""
138
+
139
+ def __init__(self, input_dim, condition_dim, hidden_dim, output_dim, num_layers, num_heads, mlp_ratio=4.0,
140
+ dropout=0.1, time_embed_dim=256, max_seq_len=256):
141
+ super().__init__()
142
+ self.input_proj = nn.Linear(input_dim, hidden_dim)
143
+ self.time_embed = nn.Sequential(SinusoidalPosEmb(time_embed_dim), nn.Linear(time_embed_dim, time_embed_dim * 4),
144
+ nn.Mish(), nn.Linear(time_embed_dim * 4, hidden_dim))
145
+ self.cond_embed = nn.Linear(condition_dim, hidden_dim)
146
+ self.transformer_blocks = nn.ModuleList(
147
+ [FlashAdaLNBlock(hidden_dim, num_heads, mlp_ratio=mlp_ratio, dropout=dropout, max_seq_len=max_seq_len)
148
+ for _ in range(num_layers)])
149
+ self.norm = nn.LayerNorm(hidden_dim)
150
+ self.out_proj = nn.Linear(hidden_dim, output_dim)
151
+
152
+ def basic_init(module):
153
+ if isinstance(module, nn.Linear):
154
+ nn.init.xavier_uniform_(module.weight)
155
+ if module.bias is not None:
156
+ nn.init.constant_(module.bias, 0)
157
+
158
+ self.apply(basic_init)
159
+ nn.init.normal_(self.time_embed[1].weight, std=0.02)
160
+ nn.init.normal_(self.time_embed[3].weight, std=0.02)
161
+
162
+ def forward(self, x, t, global_cond):
163
+ if not torch.is_tensor(t):
164
+ t = torch.tensor(t, device=x.device)
165
+ if t.ndim == 0:
166
+ t = t.expand(x.shape[0])
167
+ x = self.input_proj(x)
168
+ t = self.time_embed(t)
169
+ c = self.cond_embed(global_cond)
170
+ for block in self.transformer_blocks:
171
+ x = block(x, t, c)
172
+ return self.out_proj(self.norm(x))
173
+
174
+
175
+ class FlashObsEncoder(nn.Module):
176
+ """FLASH's MultiImageObsEncoder (share_rgb_model False, use_group_norm, imagenet_norm, no resize / crop): one
177
+ torchvision ResNet (classifier removed) per camera, every copy deep-copied from one initialization, BatchNorm
178
+ replaced by GroupNorm(C // 16) after the copy; each [0, 1] image goes through FLASH's range normalizer (x 2 - 1)
179
+ and then torchvision's ImageNet Normalize, as upstream composes them. Output: the cameras' pooled features in the
180
+ contract's camera order, then the normalized state. (B, n_cameras * 512 + state_dim)."""
181
+
182
+ def __init__(self, n_cameras, state_dim, backbone='resnet18', weights=None):
183
+ super().__init__()
184
+ base = getattr(torchvision.models, backbone)(weights=weights)
185
+ base.fc = nn.Identity()
186
+ self.rgb = nn.ModuleList([replace_batchnorm_with_groupnorm(copy.deepcopy(base)) for _ in range(n_cameras)])
187
+ self.n_cameras, self.state_dim = int(n_cameras), int(state_dim)
188
+ self.register_buffer('mean', torch.tensor(IMAGENET_MEAN).view(1, 3, 1, 1), persistent=False)
189
+ self.register_buffer('std', torch.tensor(IMAGENET_STD).view(1, 3, 1, 1), persistent=False)
190
+ self.feature_dim = self.n_cameras * (512 if backbone in ('resnet18', 'resnet34') else 2048) + self.state_dim
191
+
192
+ def forward(self, images, state):
193
+ """images (B, n_cameras, 3, H, W) in [0, 1]; state (B, state_dim) normalized."""
194
+ x = images * 2.0 - 1.0 # get_image_range_normalizer: [0, 1] -> [-1, 1]
195
+ feats = [net((x[:, i] - self.mean) / self.std) for i, net in enumerate(self.rgb)]
196
+ return torch.cat([*feats, state], dim=-1)
197
+
198
+
199
+ # --- the policy ---------------------------------------------------------------------------------------------------
200
+ def legendre_basis(s: torch.Tensor, degree: int):
201
+ """Shifted Legendre basis on s in [0, 1] and its first / second derivatives (FLASH's _build_legendre_basis)."""
202
+ x = 2 * s - 1
203
+ H, C = len(s), degree + 1
204
+ P = torch.zeros(H, C, dtype=s.dtype)
205
+ dP = torch.zeros(H, C, dtype=s.dtype)
206
+ d2P = torch.zeros(H, C, dtype=s.dtype)
207
+ P[:, 0] = 1.0
208
+ if C > 1:
209
+ P[:, 1] = x
210
+ dP[:, 1] = 1.0
211
+ for n in range(1, C - 1):
212
+ P[:, n + 1] = ((2 * n + 1) * x * P[:, n] - n * P[:, n - 1]) / (n + 1)
213
+ dP[:, n + 1] = ((2 * n + 1) * (P[:, n] + x * dP[:, n]) - n * dP[:, n - 1]) / (n + 1)
214
+ d2P[:, n + 1] = ((2 * n + 1) * (2 * dP[:, n] + x * d2P[:, n]) - n * d2P[:, n - 1]) / (n + 1)
215
+ return P, 2 * dP, 4 * d2P
216
+
217
+
218
+ def history_rows(rows, valid, stride: int, n_history: int):
219
+ """The FLASH history of one query from its executed rows.
220
+
221
+ rows (N, D) and valid (N,): consecutive frames ending at the frame before the query (row N - 1 = t - 1), a valid
222
+ contiguous suffix (the interface's past_actions / history_valid; the dataset's rows before an anchor). Returns
223
+ (history (n_history, D) float32 at frames t-1-(n_history-1-j)*stride, has_history bool): a point before the first
224
+ valid row repeats that row (FLASH's edge padding); with no valid row has_history is False (zero start)."""
225
+ rows = np.asarray(rows, dtype=np.float32)
226
+ valid = np.asarray(valid, dtype=bool).reshape(-1)
227
+ span = (n_history - 1) * stride + 1
228
+ if len(rows) < span or len(valid) != len(rows):
229
+ raise ValueError(f'need >= {span} history rows (stride {stride} x {n_history} points), got {rows.shape}')
230
+ if not valid.any():
231
+ return np.zeros((n_history, rows.shape[1]), np.float32), False
232
+ first = int(np.argmax(valid))
233
+ if not valid[first:].all():
234
+ raise ValueError('history_valid must be a contiguous suffix')
235
+ idx = len(rows) - 1 - (n_history - 1 - np.arange(n_history)) * stride
236
+ return rows[np.maximum(idx, first)].copy(), True
237
+
238
+
239
+ class FlashPolicy(nn.Module):
240
+ """FLASH (FlashDiTImagePolicy) on the baselines contract.
241
+
242
+ Training: compute_loss(images, state, poly, history, has_history) with poly (B, H_ext, Da) the physical action
243
+ rows at the polynomial's extended grid (anchor index fit_pad + poly_prefix, `stride` frames apart, clamped at the
244
+ episode's ends), history (B, n_history, Da) from history_rows. Inference: predict(images, state, history,
245
+ has_history) -> the physical (B, rows, Da) chunk at 30 Hz from the query frame, and the normalized coefficients."""
246
+ name = 'flash'
247
+ backbone_prefix = 'obs_encoder.rgb.'
248
+
249
+ def __init__(self, cfg, init_weights=None):
250
+ super().__init__()
251
+ from .policies import Normalizer
252
+ self.cfg = cfg
253
+ self.state_norm = Normalizer(cfg.state_dim)
254
+ self.action_norm = Normalizer(cfg.action_dim)
255
+ f = self.flash = flash_settings(cfg)
256
+ self.stride, self.n_history, self.n_action = int(f['stride']), int(f['n_history']), int(f['n_action'])
257
+ self.rows, self.poly_order, self.fit_pad = int(f['rows']), int(f['poly_order']), int(f['fit_pad'])
258
+ self.prefix, self.suffix = int(f['poly_prefix']), int(f['poly_suffix'])
259
+ self.boundary_constraint = bool(f['boundary_constraint'])
260
+ self.history_noise_std = float(f['history_noise_std'])
261
+ self.history_reg_lambda = float(f['history_reg_lambda'])
262
+ self.consistency_weight = float(f['consistency_weight'])
263
+ self.solver = f['solver']
264
+ if cfg.horizon != self.rows:
265
+ raise ValueError(f'PolicyConfig.horizon {cfg.horizon} must equal the FLASH output rows {self.rows}')
266
+ C = self.num_coeff = self.poly_order + 1
267
+ H_poly = self.H_poly = self.prefix + self.n_action + self.suffix
268
+ H_ext = self.H_ext = H_poly + 2 * self.fit_pad
269
+ self.anchor = self.fit_pad + self.prefix # anchor index in the extended grid
270
+ last_dense = (self.rows - 1) / self.stride
271
+ if self.prefix + last_dense > H_poly - 1 + 1e-9:
272
+ raise ValueError(f'{self.rows} rows at stride {self.stride} reach past the fitted polynomial')
273
+
274
+ s_ext = torch.linspace(0.0, 1.0, H_ext, dtype=torch.float64)
275
+ s_mid = s_ext[self.fit_pad:self.fit_pad + H_poly] if self.fit_pad > 0 else s_ext
276
+ eval_ext, d1_ext, _ = legendre_basis(s_ext, self.poly_order)
277
+ StS = eval_ext.T @ eval_ext
278
+ lstsq = torch.linalg.solve(StS, eval_ext.T)
279
+ eval_mid, _, _ = legendre_basis(s_mid, self.poly_order)
280
+ coeff_scale = torch.norm(lstsq, dim=1).clamp(min=1e-8)
281
+ self.register_buffer('_lstsq_matrix', lstsq.float())
282
+ self.register_buffer('_coeff_scale', coeff_scale.float().view(1, -1, 1))
283
+ # history fit (flash_policy.py, poly_prefix branch): the first n_history rows of the core grid, Tikhonov
284
+ S_hist = eval_mid.double() if H_poly == self.n_history else eval_mid[:self.n_history, :].double()
285
+ StS_hist = S_hist.T @ S_hist
286
+ if self.history_reg_lambda > 0:
287
+ StS_hist = StS_hist + self.history_reg_lambda * torch.eye(C, dtype=torch.float64)
288
+ self.register_buffer('_history_lstsq_matrix', torch.linalg.solve(StS_hist, S_hist.T).float())
289
+ if self.boundary_constraint: # KKT C1 at the execution start and the next window's start
290
+ idx = [self.fit_pad + self.prefix, self.fit_pad + self.prefix + self.n_action]
291
+ if idx[1] >= H_ext:
292
+ raise ValueError(f'bc_overlap {idx[1]} >= H_ext {H_ext}: increase fit_pad')
293
+ A_pos, A_vel = eval_ext[idx, :], d1_ext[idx, :]
294
+ A = torch.cat([A_pos, A_vel], dim=0)
295
+ StS_inv_AT = torch.linalg.solve(StS, torch.eye(C, dtype=torch.float64)) @ A.T
296
+ self.register_buffer('_bc_eval_pos', A_pos.float())
297
+ self.register_buffer('_bc_eval_vel', A_vel.float())
298
+ self.register_buffer('_bc_correction', (StS_inv_AT @ torch.linalg.inv(A @ StS_inv_AT)).float())
299
+ self.register_buffer('_bc_pos_indices', torch.tensor(idx, dtype=torch.long))
300
+ # the 30 Hz output rows: frame k after the anchor sits at grid index anchor + k / stride
301
+ s_dense = torch.tensor([(self.anchor + k / self.stride) / (H_ext - 1) for k in range(self.rows)],
302
+ dtype=torch.float64)
303
+ self.register_buffer('_dense_eval_matrix', legendre_basis(s_dense, self.poly_order)[0].float())
304
+
305
+ self.obs_encoder = FlashObsEncoder(cfg.n_cameras, cfg.state_dim, backbone=cfg.backbone, weights=init_weights)
306
+ self.model = FlashFlowTransformer(input_dim=cfg.action_dim, condition_dim=self.obs_encoder.feature_dim,
307
+ hidden_dim=cfg.hidden_dim, output_dim=cfg.action_dim,
308
+ num_layers=cfg.num_layers, num_heads=cfg.num_heads, mlp_ratio=cfg.mlp_ratio,
309
+ dropout=cfg.dropout, time_embed_dim=cfg.time_embed_dim)
310
+
311
+ def fit_normalizers(self, stats: dict):
312
+ self.state_norm.fit(stats['state']['min'], stats['state']['max'])
313
+ self.action_norm.fit(stats['action']['min'], stats['action']['max'])
314
+
315
+ @property
316
+ def sampling_steps(self) -> int:
317
+ return int(self.cfg.num_inference_steps or 1)
318
+
319
+ @property
320
+ def history_span(self) -> int:
321
+ """Executed rows a query needs: (n_history - 1) * stride + 1."""
322
+ return (self.n_history - 1) * self.stride + 1
323
+
324
+ def extended_offsets(self) -> np.ndarray:
325
+ """Frame offsets from the anchor of the extended polynomial grid (for the training targets)."""
326
+ return (np.arange(self.H_ext) - self.anchor) * self.stride
327
+
328
+ # polynomial operations, float32 and outside autocast ----------------------------------------------------------
329
+ def _to_coeff(self, traj_n):
330
+ return torch.einsum('ch,bhd->bcd', self._lstsq_matrix, traj_n) / self._coeff_scale
331
+
332
+ def _history_coeff(self, history, has_history):
333
+ with torch.autocast(history.device.type, enabled=False):
334
+ h = torch.einsum('ch,bhd->bcd', self._history_lstsq_matrix, self.action_norm.normalize(history.float()))
335
+ h = h / self._coeff_scale
336
+ return torch.where(has_history.view(-1, 1, 1).bool(), h, torch.zeros_like(h))
337
+
338
+ def _apply_boundary_constraint(self, norm_coeff, traj_n):
339
+ raw = norm_coeff * self._coeff_scale
340
+ idx, H = self._bc_pos_indices, traj_n.shape[1]
341
+ cur_pos = torch.einsum('kc,bcd->bkd', self._bc_eval_pos, raw)
342
+ tgt_pos = traj_n[:, idx, :]
343
+ vel = []
344
+ for i in idx.tolist():
345
+ if i + 1 < H:
346
+ v = (traj_n[:, i + 1] - traj_n[:, i - 1]) * (H - 1) / 2
347
+ elif i >= 2:
348
+ v = (3 * traj_n[:, i] - 4 * traj_n[:, i - 1] + traj_n[:, i - 2]) * (H - 1) / 2
349
+ else:
350
+ v = (traj_n[:, i] - traj_n[:, i - 1]) * (H - 1)
351
+ vel.append(v)
352
+ tgt_vel = torch.stack(vel, dim=1)
353
+ cur_vel = torch.einsum('kc,bcd->bkd', self._bc_eval_vel, raw)
354
+ residual = torch.cat([cur_pos - tgt_pos, cur_vel - tgt_vel], dim=1)
355
+ return (raw - torch.einsum('ck,bkd->bcd', self._bc_correction, residual)) / self._coeff_scale
356
+
357
+ def target_coeff(self, poly):
358
+ with torch.autocast(poly.device.type, enabled=False):
359
+ traj_n = self.action_norm.normalize(poly.float())
360
+ coeff = self._to_coeff(traj_n)
361
+ if self.boundary_constraint:
362
+ coeff = self._apply_boundary_constraint(coeff, traj_n)
363
+ return coeff
364
+
365
+ def dense_from_coeff(self, norm_coeff):
366
+ """(B, rows, Da) physical actions at the 30 Hz frames from the anchor."""
367
+ with torch.autocast(norm_coeff.device.type, enabled=False):
368
+ raw = norm_coeff.float() * self._coeff_scale
369
+ return self.action_norm.unnormalize(torch.einsum('hc,bcd->bhd', self._dense_eval_matrix, raw))
370
+
371
+ def condition(self, images, state):
372
+ return self.obs_encoder(images, self.state_norm.normalize(state))
373
+
374
+ # training and inference ------------------------------------------------------------------------------------------
375
+ def compute_loss(self, images, state, poly, history, has_history):
376
+ target = self.target_coeff(poly)
377
+ hist = self._history_coeff(history, has_history)
378
+ if self.training and self.history_noise_std > 0:
379
+ hist = hist + torch.randn_like(hist) * self.history_noise_std
380
+ cond = self.condition(images, state)
381
+ t = torch.rand(target.shape[0], device=target.device)
382
+ te = t.view(-1, 1, 1)
383
+ x_t = (1 - te) * hist + te * target
384
+ loss_fm = F.mse_loss(self.model(x_t, t, cond).float(), target - hist)
385
+ loss, metrics = loss_fm, dict(fm=float(loss_fm.detach()))
386
+ if self.consistency_weight > 0:
387
+ v0 = self.model(hist, torch.zeros_like(t), cond).float()
388
+ loss_c = F.mse_loss(hist + v0, target)
389
+ loss = loss + self.consistency_weight * loss_c
390
+ metrics['consistency'] = float(loss_c.detach())
391
+ return loss, metrics
392
+
393
+ @torch.no_grad()
394
+ def predict_coeff(self, images, state, history, has_history):
395
+ cond = self.condition(images, state)
396
+ x = self._history_coeff(history, has_history)
397
+ times = torch.linspace(0, 1.0, self.sampling_steps + 1)
398
+ for i in range(self.sampling_steps):
399
+ t0 = times[i].view(1).expand(x.shape[0]).to(x.device)
400
+ t1 = times[i + 1].view(1).expand(x.shape[0]).to(x.device)
401
+ dt = (t1 - t0).view(-1, 1, 1)
402
+ if self.solver == 'euler':
403
+ x = x + dt * self.model(x, t0, cond).float()
404
+ else:
405
+ x_mid = x + self.model(x, t0, cond).float() * dt / 2
406
+ x = x + dt * self.model(x_mid, t0 + (t1 - t0) / 2, cond).float()
407
+ return x
408
+
409
+ @torch.no_grad()
410
+ def predict(self, images, state, history, has_history, generator=None): # noqa: ARG002 - deterministic
411
+ coeff = self.predict_coeff(images, state, history, has_history)
412
+ return self.dense_from_coeff(coeff), coeff
b8-table-wipe/b512-cont-20261117-stop50k/step-050000/training_records/code_hb_bai_433ba198_stopat39f9b83a/evaluation/baselines/fm_dit_v2.py ADDED
@@ -0,0 +1,99 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """FM-DiT v2: the flow-matching DiT of NTUMARS/FLASH-Policy @ f47e490 behind the baselines contract (owner 2026-11-25).
2
+
3
+ Not the `fm_dit` baseline of policies.py (FM-DiT v1, ported from DextraVerse's IL core), which stays unchanged for the
4
+ checkpoints trained with it. The owner asked for this second implementation after the v1 checkpoints reached 1 success
5
+ in all their closed-loop evaluations; if v2 scores higher under the same training and evaluation, v1 is retired.
6
+
7
+ Ported from `roboverse_learn/il/policies/fm/fm_dit_image_policy.py` (`FlowMatchingDiTImagePolicy`) with
8
+ `configs/policy_config/fm_dit.yaml` and `configs/train_config/default_train.yaml`, FLASH-Policy's own FM-DiT baseline.
9
+ Its network is FLASH's (flow_net.FlowTransformer with the torchtune RoPE, MultiImageObsEncoder), so this module
10
+ reuses flash.py's port of them; only the flow and the sampler differ from FLASH:
11
+
12
+ - loss: x_t = (1 - t) noise + t a with t ~ U(0, 1) and noise ~ N(0, I) over the whole normalized chunk; MSE of the
13
+ DiT's output against a - noise (obs_as_global_cond: no inpainting mask, every element counts);
14
+ - sampling: num_inference_steps 10 midpoint steps from noise (20 DiT calls), t = 0 -> 1;
15
+ - fm_dit.yaml: DiT 512 wide, 4 blocks, 8 heads, mlp ratio 4, dropout 0.1, time embedding 256; one ResNet18 per camera
16
+ from scratch with GroupNorm, ImageNet normalization of the range-normalized image; the state joins the image
17
+ features as the low-dim input (agent_pos), as in FLASH's encoder;
18
+ - default_train.yaml: seed 42, AdamW lr 1e-4 (betas 0.95 / 0.999, weight decay 1e-6), 500 warm-up steps then
19
+ diffusers' cosine, Diffusion Policy's EMAModel (power 0.75, max 0.9999), the encoder at the full learning rate
20
+ (train.py FM_DIT_V2_TRAINING).
21
+
22
+ What the humanoid interface changes, as for FLASH (flash.py, owner 2026-11-24/25: aligned with FLASH's port):
23
+ one observation frame (the current ego_view and chest frames and state44; the runners render no 8-frame history),
24
+ 16 rows of action76 at 30 Hz from the query frame (row 0 = the query frame, the LeRobot rows t..t+15, as every
25
+ baseline), the augmentation spec v2 in place of the native random_crop (inert upstream without crop_shape), the
26
+ benchmark's batch 512 on one GPU. The runners re-query after at most 12 rows (FLASH-Policy executes 8 of 16).
27
+ """
28
+ from __future__ import annotations
29
+
30
+ import torch
31
+ import torch.nn as nn
32
+ import torch.nn.functional as F
33
+
34
+ from .flash import FlashFlowTransformer, FlashObsEncoder
35
+
36
+ # fm_dit.yaml: the PolicyConfig fields of an FM-DiT v2 run
37
+ FM_DIT_V2_POLICY_FIELDS = dict(hidden_dim=512, num_layers=4, num_heads=8, mlp_ratio=4.0, dropout=0.1,
38
+ time_embed_dim=256, num_inference_steps=10, backbone='resnet18',
39
+ backbone_weights=None, backbone_norm='group')
40
+ UPSTREAM = 'NTUMARS/FLASH-Policy@f47e490 roboverse_learn/il/policies/fm/fm_dit_image_policy.py (fm_dit.yaml)'
41
+
42
+
43
+ class FMDiTv2Policy(nn.Module):
44
+ """FLASH-Policy's FlowMatchingDiTImagePolicy on the baselines contract (module docstring). The policies.BasePolicy
45
+ contract (an nn.Module, as flash.FlashPolicy, so that policies.py can register it without an import cycle)."""
46
+ name = 'fm_dit_v2'
47
+ backbone_prefix = 'obs_encoder.rgb.'
48
+ lead_rows = 0
49
+
50
+ def __init__(self, cfg, init_weights=None):
51
+ super().__init__()
52
+ from .policies import Normalizer
53
+ self.cfg = cfg
54
+ self.state_norm = Normalizer(cfg.state_dim)
55
+ self.action_norm = Normalizer(cfg.action_dim)
56
+ self.obs_encoder = FlashObsEncoder(cfg.n_cameras, cfg.state_dim, backbone=cfg.backbone, weights=init_weights)
57
+ # fm_dit_image_policy.py: max_seq_len = horizon (the RoPE cache covers the action tokens)
58
+ self.model = FlashFlowTransformer(input_dim=cfg.action_dim, condition_dim=self.obs_encoder.feature_dim,
59
+ hidden_dim=cfg.hidden_dim, output_dim=cfg.action_dim,
60
+ num_layers=cfg.num_layers, num_heads=cfg.num_heads,
61
+ mlp_ratio=cfg.mlp_ratio, dropout=cfg.dropout,
62
+ time_embed_dim=cfg.time_embed_dim, max_seq_len=cfg.horizon)
63
+
64
+ def fit_normalizers(self, stats: dict):
65
+ """LinearNormalizer 'limits' (upstream's default): state and action min / max to [-1, 1]."""
66
+ self.state_norm.fit(stats['state']['min'], stats['state']['max'])
67
+ self.action_norm.fit(stats['action']['min'], stats['action']['max'])
68
+
69
+ @property
70
+ def sampling_steps(self) -> int:
71
+ return int(self.cfg.num_inference_steps or 10)
72
+
73
+ def condition(self, images, state):
74
+ return self.obs_encoder(images, self.state_norm.normalize(state))
75
+
76
+ def compute_loss(self, images, state, action):
77
+ cond = self.condition(images, state)
78
+ target = self.action_norm.normalize(action.float())
79
+ noise = torch.randn_like(target)
80
+ t = torch.rand(target.shape[0], device=target.device)
81
+ te = t.view(-1, 1, 1)
82
+ x_t = (1 - te) * noise + te * target
83
+ loss = F.mse_loss(self.model(x_t, t, cond).float(), target - noise)
84
+ return loss, dict(fm=float(loss.detach()))
85
+
86
+ @torch.no_grad()
87
+ def predict(self, images, state, generator=None):
88
+ cond = self.condition(images, state)
89
+ B, steps = images.shape[0], self.sampling_steps
90
+ x = torch.randn((B, self.cfg.horizon, self.cfg.action_dim), device=images.device, dtype=torch.float32,
91
+ generator=generator)
92
+ times = torch.linspace(0, 1.0, steps + 1)
93
+ for i in range(steps): # conditional_sample: the midpoint rule
94
+ t0 = times[i].view(1).expand(B).to(images.device)
95
+ t1 = times[i + 1].view(1).expand(B).to(images.device)
96
+ dt = (t1 - t0).view(-1, 1, 1)
97
+ x_mid = x + self.model(x, t0, cond).float() * dt / 2
98
+ x = x + dt * self.model(x_mid, t0 + (t1 - t0) / 2, cond).float()
99
+ return self.action_norm.unnormalize(x), x
b8-table-wipe/b512-cont-20261117-stop50k/step-050000/training_records/code_hb_bai_433ba198_stopat39f9b83a/evaluation/baselines/inloop.py ADDED
@@ -0,0 +1,117 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """In-training open-loop action MSE of the baselines (owner 2026-11-22: every training of every model measures it while
2
+ it trains; HumanWAM `hb_training/REPRODUCIBILITY.md` section 6).
3
+
4
+ The protocol code is HumanWAM's `hb_training/eval-action-mse` (`hb_inloop_core.InLoop` and `hb_eval_common`), used
5
+ unmodified from the directory given to train.py as --inloop-code; its cache lives under $HB_EVAL_CACHE (default
6
+ $G/eval-action-mse/cache) and is built by its `build_cache.py <task> train10`. Per evaluation: the queries every 16
7
+ frames of the task's `heldout` episodes (`train10` when it has none), the first 16 predicted rows against the
8
+ recorded ones, nMSE over the training-frame std (constant dims excluded), batches of 8 queries seeded
9
+ 1234 + 1000 rank + batch index, every HB_INLOOP_EVERY (250) steps; one json line per evaluation in
10
+ <run>/logs/inloop-mse.jsonl and `HB_INLOOP` lines in the log. Training RNG and module modes are restored after each.
11
+
12
+ The evaluated weights are the ones the run saves (the EMA). Inputs as at deployment: each camera resized like the
13
+ training cache (data.resize_frame), state44, and for FLASH the cached past actions (the up to 16 recorded rows before
14
+ the query: the eval protocol's `past_action`) through the same history rule as the adapter (runtime.BaselinePolicy).
15
+ Before the first step the cache is checked against the run's data: the cached state and action rows of every cached
16
+ episode that the run loaded must equal the run's rows bit for bit.
17
+ """
18
+ from __future__ import annotations
19
+
20
+ import os
21
+ from pathlib import Path
22
+ import sys
23
+
24
+ import numpy as np
25
+
26
+ from .data import resize_frame
27
+
28
+
29
+ def install(code_dir, task, run_dir, get_model, contract, cameras, hw, lowdim, policy_name, lowdim_loader=None):
30
+ """The InLoop object of this run (its evaluate(step, model) is called by train.py), after the cache check."""
31
+ code_dir = Path(code_dir).expanduser().resolve()
32
+ if not (code_dir / 'hb_inloop_core.py').exists():
33
+ raise FileNotFoundError(f'{code_dir}: no hb_inloop_core.py (HumanWAM hb_training/eval-action-mse)')
34
+ if str(code_dir) not in sys.path:
35
+ sys.path.insert(0, str(code_dir))
36
+ import hb_inloop_core as core
37
+ E = core.E
38
+ if core.EVERY <= 0:
39
+ print(f'HB_INLOOP {policy_name} disabled: HB_INLOOP_EVERY={core.EVERY}', flush=True)
40
+ return None
41
+ if task not in E.TASKS:
42
+ raise KeyError(f'task {task!r} is not registered in {code_dir}/hb_eval_common.py TASKS')
43
+ split = core.pick_split(task)
44
+ meta = E.load_meta(task, split)
45
+ lay = E.LAYOUTS[meta['layout']]
46
+ if (lay['state_dim'], lay['action_dim']) != (contract.state_dim, contract.action_dim):
47
+ raise ValueError(f"eval layout {meta['layout']} {lay['state_dim']}/{lay['action_dim']} vs contract "
48
+ f'{contract.name} {contract.state_dim}/{contract.action_dim}')
49
+ missing = [c for c in cameras if c not in meta['cams']]
50
+ if missing:
51
+ raise KeyError(f"cameras {missing} not in the eval cache {meta['cams']}")
52
+ def check(rows, what):
53
+ done = []
54
+ for ep in meta['episodes']: # the cache holds this run's data
55
+ if ep not in rows['episodes']:
56
+ continue
57
+ p = rows['episodes'].index(ep)
58
+ s, n = int(rows['starts'][p]), int(rows['lengths'][p])
59
+ with np.load(E.split_dir(task, split) / f'ep_{ep:06d}.npz') as z:
60
+ same = (np.array_equal(z['state'], rows['state'][s:s + n])
61
+ and np.array_equal(z['action'], rows['action'][s:s + n]))
62
+ if not same:
63
+ raise ValueError(f'eval cache {task}/{split} episode {ep} differs from {what} '
64
+ f'(cache source {meta.get("source")})')
65
+ done.append(ep)
66
+ return done
67
+
68
+ checked = check(lowdim, 'the training data')
69
+ if not checked and lowdim_loader is not None:
70
+ # a held-out split: its episodes are not trained on, so they are checked against the same dataset read
71
+ # through the same contract (2026-11-24, B7 black lead-drop b7td: train 0-99, held out 100-106)
72
+ checked = check(lowdim_loader(list(meta['episodes'])), "this run's dataset (held-out episodes)")
73
+ if not checked:
74
+ raise ValueError(f'no cached episode of {task}/{split} is in this run\'s data: cannot check the cache')
75
+
76
+ import torch
77
+
78
+ def predict(batch, seed):
79
+ model = get_model()
80
+ device = next(model.parameters()).device
81
+ frames = np.stack([np.stack([resize_frame(q['images'][c], hw) for c in cameras]) for q in batch])
82
+ images = torch.from_numpy(frames).to(device).permute(0, 1, 4, 2, 3).float().div_(255.)
83
+ state = torch.from_numpy(np.stack([q['state'] for q in batch]).astype(np.float32)).to(device)
84
+ generator = torch.Generator(device=device)
85
+ generator.manual_seed(int(seed))
86
+ extra = ()
87
+ if policy_name == 'flash':
88
+ from .flash import history_rows
89
+ span, hist, has = model.history_span, [], []
90
+ for q in batch:
91
+ past = np.asarray(q['past_action'], np.float32).reshape(-1, contract.action_dim)
92
+ rows = np.zeros((max(span, len(past)), contract.action_dim), np.float32)
93
+ valid = np.zeros(len(rows), bool)
94
+ if len(past):
95
+ rows[-len(past):], valid[-len(past):] = past, True
96
+ h, ok = history_rows(rows[-span:], valid[-span:], model.stride, model.n_history)
97
+ hist.append(h)
98
+ has.append(ok)
99
+ extra = (torch.from_numpy(np.stack(hist)).to(device), torch.tensor(has, device=device))
100
+ kwargs = {}
101
+ if getattr(model, 'lead_rows', 0): # the ODE policies start from the executed row before (BOS without one)
102
+ prev = [np.asarray(q.get('past_action', ()), np.float32).reshape(-1, contract.action_dim) for q in batch]
103
+ kwargs = dict(previous=torch.from_numpy(np.stack([p[-1] if len(p) else np.zeros(contract.action_dim,
104
+ np.float32)
105
+ for p in prev])).to(device),
106
+ has_previous=torch.tensor([len(p) > 0 for p in prev], device=device))
107
+ pred, _ = model.predict(images, state, *extra, generator=generator, **kwargs)
108
+ return pred.float().cpu().numpy()
109
+
110
+ info = dict(weights='ema', policy=policy_name, cache_checked_episodes=checked,
111
+ inloop_code=str(code_dir), cache=str(E.split_dir(task, split)))
112
+ loop = core.InLoop(policy_name, task, split, Path(run_dir) / 'logs' / 'inloop-mse.jsonl', predict,
113
+ cams=list(cameras), info=info)
114
+ loop.every = core.EVERY
115
+ loop.say(f'{policy_name} installed: task {task} split {split}, every {core.EVERY} steps, cache checked on '
116
+ f'episodes {checked}, code {code_dir}, G={os.environ.get("G", "<default>")}')
117
+ return loop
b8-table-wipe/b512-cont-20261117-stop50k/step-050000/training_records/code_hb_bai_433ba198_stopat39f9b83a/evaluation/baselines/nets.py ADDED
@@ -0,0 +1,212 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Networks of the FM-DiT and DP (DDPM-DiT) baselines: the AdaLN DiT action backbone and the camera + state encoder.
2
+
3
+ Ported from DextraVerse's imitation-learning core (`dextraverse/algorithms/il/models/nets/dit.py`, `layers.py`,
4
+ `positional_embedding.py`, `vision/backbones.py`, `vision/encoder.py`), unchanged in architecture and initialization.
5
+ Left out: the ROVE improvement embedding, the spatial-softmax / R3M / tactile options and the inpainting path (the
6
+ baselines always condition through the global observation feature). Added: the ResNet's normalization choice
7
+ (`get_resnet`): DextraVerse's GroupNorm for a backbone trained from scratch, or BatchNorm frozen at the pretrained
8
+ statistics (the DETR / ACT practice) for an ImageNet-initialized backbone that is fine-tuned with the policy.
9
+ """
10
+ from __future__ import annotations
11
+
12
+ import math
13
+
14
+ import torch
15
+ import torch.nn as nn
16
+ import torch.nn.functional as F
17
+ import torchvision
18
+
19
+ IMAGENET_MEAN = (0.485, 0.456, 0.406)
20
+ IMAGENET_STD = (0.229, 0.224, 0.225)
21
+
22
+
23
+ class SinusoidalPosEmb(nn.Module):
24
+ def __init__(self, dim):
25
+ super().__init__()
26
+ self.dim = dim
27
+
28
+ def forward(self, x):
29
+ half_dim = self.dim // 2
30
+ emb = math.log(10000) / (half_dim - 1)
31
+ emb = torch.exp(torch.arange(half_dim, device=x.device) * -emb)
32
+ emb = x[:, None] * emb[None, :]
33
+ return torch.cat((emb.sin(), emb.cos()), dim=-1)
34
+
35
+
36
+ class RotaryPosEmb(nn.Module):
37
+ """Rotary position embedding over each attention head's (S, head_dim) slice."""
38
+
39
+ def __init__(self, dim):
40
+ super().__init__()
41
+ self.dim = dim
42
+ self.register_buffer('inv_freq', 1.0 / (10000 ** (torch.arange(0, dim, 2).float() / dim)))
43
+
44
+ def forward(self, x): # x: (B, heads, S, head_dim)
45
+ t = torch.arange(x.shape[-2], device=x.device, dtype=self.inv_freq.dtype)
46
+ freqs = torch.outer(t, self.inv_freq.to(x.device))
47
+ emb = torch.cat([freqs, freqs], dim=-1)
48
+ cos, sin = emb.cos()[None, None], emb.sin()[None, None]
49
+ x1, x2 = x[..., : x.shape[-1] // 2], x[..., x.shape[-1] // 2:]
50
+ return x * cos + torch.cat([-x2, x1], dim=-1) * sin
51
+
52
+
53
+ class Mlp(nn.Module):
54
+ """The ViT MLP (timm.layers.Mlp) as DextraVerse's nets/layers.py."""
55
+
56
+ def __init__(self, in_features, hidden_features=None, out_features=None, act_layer=nn.GELU, drop=0.0):
57
+ super().__init__()
58
+ out_features = out_features or in_features
59
+ hidden_features = hidden_features or in_features
60
+ self.fc1 = nn.Linear(in_features, hidden_features)
61
+ self.act = act_layer()
62
+ self.drop1 = nn.Dropout(drop)
63
+ self.norm = nn.Identity()
64
+ self.fc2 = nn.Linear(hidden_features, out_features)
65
+ self.drop2 = nn.Dropout(drop)
66
+
67
+ def forward(self, x):
68
+ return self.drop2(self.fc2(self.norm(self.drop1(self.act(self.fc1(x))))))
69
+
70
+
71
+ class Attention(nn.Module):
72
+ def __init__(self, dim, num_heads=8, qkv_bias=True, attn_drop=0.0, proj_drop=0.0, qk_norm=True):
73
+ super().__init__()
74
+ assert dim % num_heads == 0, 'dim should be divisible by num_heads'
75
+ self.num_heads = num_heads
76
+ self.head_dim = dim // num_heads
77
+ self.attn_drop = attn_drop
78
+ self.proj_drop = nn.Dropout(proj_drop)
79
+ self.qkv = nn.Linear(dim, dim * 3, bias=qkv_bias)
80
+ self.q_norm = nn.LayerNorm(self.head_dim) if qk_norm else nn.Identity()
81
+ self.k_norm = nn.LayerNorm(self.head_dim) if qk_norm else nn.Identity()
82
+ self.proj = nn.Linear(dim, dim)
83
+ self.rope = RotaryPosEmb(self.head_dim)
84
+
85
+ def forward(self, x):
86
+ B, S, C = x.shape
87
+ qkv = self.qkv(x).reshape(B, S, 3, self.num_heads, self.head_dim).permute(2, 0, 3, 1, 4)
88
+ q, k, v = qkv.unbind(0)
89
+ q, k = self.rope(self.q_norm(q)), self.rope(self.k_norm(k))
90
+ x = F.scaled_dot_product_attention(q, k, v, dropout_p=self.attn_drop if self.training else 0.0)
91
+ return self.proj_drop(self.proj(x.transpose(1, 2).reshape(B, S, C)))
92
+
93
+
94
+ class AdaLNBlock(nn.Module):
95
+ """Adaptive-LayerNorm transformer block as in DiT (Peebles et al. 2022)."""
96
+
97
+ def __init__(self, dim, num_heads, mlp_ratio=4.0, dropout=0.0):
98
+ super().__init__()
99
+ self.norm1 = nn.LayerNorm(dim, elementwise_affine=False, eps=1e-6)
100
+ self.attn = Attention(dim, num_heads=num_heads, attn_drop=dropout, proj_drop=dropout)
101
+ self.norm2 = nn.LayerNorm(dim, elementwise_affine=False, eps=1e-6)
102
+ self.mlp = Mlp(in_features=dim, hidden_features=int(dim * mlp_ratio),
103
+ act_layer=lambda: nn.GELU(approximate='tanh'), drop=0)
104
+ self.ada_ln = nn.Sequential(nn.SiLU(), nn.Linear(dim, 6 * dim))
105
+ self.dim = dim
106
+ nn.init.constant_(self.ada_ln[-1].weight, 0)
107
+ nn.init.constant_(self.ada_ln[-1].bias, 0)
108
+
109
+ def forward(self, x, t, c):
110
+ B = x.shape[0]
111
+ gamma1, gamma2, scale1, scale2, shift1, shift2 = self.ada_ln(F.silu(t + c)).view(B, 6, 1, self.dim).unbind(1)
112
+ x = x + self.attn(self.norm1(x).mul(scale1.add(1)).add_(shift1)).mul_(gamma1)
113
+ return x + self.mlp(self.norm2(x).mul(scale2.add(1)).add_(shift2)).mul_(gamma2)
114
+
115
+
116
+ class FlowTransformer(nn.Module):
117
+ """DiT action backbone: AdaLN blocks over the H action tokens, conditioned on time_embed(t) + cond_embed(obs).
118
+
119
+ As DextraVerse, the generic Xavier initialization runs after the blocks' zero init of their AdaLN projection, so
120
+ it is not the full AdaLN-Zero recipe (kept: it is the reference's training behaviour)."""
121
+
122
+ def __init__(self, input_dim, condition_dim, hidden_dim, output_dim, num_layers, num_heads, mlp_ratio=4.0,
123
+ dropout=0.1, time_embed_dim=256):
124
+ super().__init__()
125
+ self.input_proj = nn.Linear(input_dim, hidden_dim)
126
+ self.time_embed = nn.Sequential(SinusoidalPosEmb(time_embed_dim), nn.Linear(time_embed_dim, time_embed_dim * 4),
127
+ nn.Mish(), nn.Linear(time_embed_dim * 4, hidden_dim))
128
+ self.cond_embed = nn.Linear(condition_dim, hidden_dim)
129
+ self.transformer_blocks = nn.ModuleList(
130
+ [AdaLNBlock(hidden_dim, num_heads, mlp_ratio=mlp_ratio, dropout=dropout) for _ in range(num_layers)])
131
+ self.norm = nn.LayerNorm(hidden_dim)
132
+ self.out_proj = nn.Linear(hidden_dim, output_dim)
133
+
134
+ def basic_init(module):
135
+ if isinstance(module, nn.Linear):
136
+ nn.init.xavier_uniform_(module.weight)
137
+ if module.bias is not None:
138
+ nn.init.constant_(module.bias, 0)
139
+
140
+ self.apply(basic_init)
141
+ nn.init.normal_(self.time_embed[1].weight, std=0.02)
142
+ nn.init.normal_(self.time_embed[3].weight, std=0.02)
143
+
144
+ def forward(self, x, t, global_cond):
145
+ if not torch.is_tensor(t):
146
+ t = torch.tensor(t, device=x.device)
147
+ if t.ndim == 0:
148
+ t = t.expand(x.shape[0])
149
+ x = self.input_proj(x)
150
+ t = self.time_embed(t)
151
+ c = self.cond_embed(global_cond)
152
+ for block in self.transformer_blocks:
153
+ x = block(x, t, c)
154
+ return self.out_proj(self.norm(x))
155
+
156
+
157
+ def replace_batchnorm_with_groupnorm(module: nn.Module) -> nn.Module:
158
+ """DextraVerse's use_group_norm: every BatchNorm2d becomes GroupNorm(num_features // 16 groups)."""
159
+ for name, child in module.named_children():
160
+ if isinstance(child, nn.BatchNorm2d):
161
+ setattr(module, name, nn.GroupNorm(num_groups=child.num_features // 16, num_channels=child.num_features))
162
+ else:
163
+ replace_batchnorm_with_groupnorm(child)
164
+ return module
165
+
166
+
167
+ NORMS = ('group', 'frozen_bn')
168
+
169
+
170
+ def get_resnet(name='resnet18', weights=None, norm='group') -> nn.Module:
171
+ """A torchvision ResNet with its classifier removed: (N, 3, H, W) -> (N, 512) globally pooled.
172
+
173
+ weights: torchvision weights name (e.g. 'IMAGENET1K_V1') to initialize from, or None (random initialization;
174
+ a checkpoint load supplies every weight). norm: 'group' replaces every BatchNorm with GroupNorm (DextraVerse's
175
+ use_group_norm, for training from scratch: pretrained BatchNorm statistics and affine are dropped); 'frozen_bn'
176
+ keeps BatchNorm frozen at its (pretrained) running statistics and affine, the convolutions fine-tune."""
177
+ if norm == 'frozen_bn':
178
+ from .act_nets import FrozenBatchNorm2d
179
+ resnet = getattr(torchvision.models, name)(weights=weights, norm_layer=FrozenBatchNorm2d)
180
+ elif norm == 'group':
181
+ resnet = replace_batchnorm_with_groupnorm(getattr(torchvision.models, name)(weights=weights))
182
+ else:
183
+ raise ValueError(f'norm must be one of {NORMS}, got {norm!r}')
184
+ resnet.fc = nn.Identity()
185
+ return resnet
186
+
187
+
188
+ class ImageStateEncoder(nn.Module):
189
+ """DextraVerse MultiImageObsEncoder as configured for FM-DiT / DDPM-DiT: one ResNet shared by every camera
190
+ (share_rgb_model; `get_resnet` weights and norm), ImageNet normalization of the [0, 1] images, the pooled features
191
+ of each camera in the contract's camera order, then the normalized state. shared=False gives every camera its own
192
+ ResNet (share_rgb_model False, the ODE policy's encoder; `rgb` is then a ModuleList in camera order).
193
+ Output (B, n_cameras * 512 + state_dim)."""
194
+
195
+ def __init__(self, n_cameras, state_dim, backbone='resnet18', weights=None, norm='group', shared=True):
196
+ super().__init__()
197
+ self.n_cameras, self.state_dim, self.shared = int(n_cameras), int(state_dim), bool(shared)
198
+ self.rgb = (get_resnet(backbone, weights=weights, norm=norm) if self.shared else
199
+ nn.ModuleList([get_resnet(backbone, weights=weights, norm=norm) for _ in range(self.n_cameras)]))
200
+ self.register_buffer('mean', torch.tensor(IMAGENET_MEAN).view(1, 3, 1, 1), persistent=False)
201
+ self.register_buffer('std', torch.tensor(IMAGENET_STD).view(1, 3, 1, 1), persistent=False)
202
+ self.feature_dim = self.n_cameras * (512 if backbone in ('resnet18', 'resnet34') else 2048) + self.state_dim
203
+
204
+ def forward(self, images, state):
205
+ """images (B, n_cameras, 3, H, W) in [0, 1]; state (B, state_dim) normalized."""
206
+ B = images.shape[0]
207
+ if self.shared:
208
+ x = (images.flatten(0, 1) - self.mean) / self.std
209
+ features = self.rgb(x).reshape(B, -1) # camera features side by side, in camera order
210
+ else:
211
+ features = torch.cat([net((images[:, i] - self.mean) / self.std) for i, net in enumerate(self.rgb)], dim=-1)
212
+ return torch.cat([features, state], dim=-1)
b8-table-wipe/b512-cont-20261117-stop50k/step-050000/training_records/code_hb_bai_433ba198_stopat39f9b83a/evaluation/baselines/ode_nets.py ADDED
@@ -0,0 +1,181 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Vector fields of the ODE policy baselines (ODE-MLP, ODE-DiT).
2
+
3
+ Ported from ODE Policy (Jindou Jia et al., https://github.com/NTUMARS/ODE-POLICY, branch main @cea26d94, Apache-2.0):
4
+ `ode_policy/policies/ode/ode_image_policy.py` (`_FiLMLayer`, `VectorField`, `DiTVectorField`) and the DiT parts it
5
+ uses, `ode_policy/utils/models/flow_net.py` (`Attention`, `AdaLNBlock`), `ode_policy/utils/models/layers.py` (`Mlp`)
6
+ and `ode_policy/policies/dp/models/diffusion/positional_embedding.py` (`RotaryPosEmb`, torchtune's interleaved RoPE
7
+ over the full width, which differs from the DextraVerse RoPE of nets.py). Architectures and initializations are
8
+ unchanged. Left out: the gripper-only dropout pass (`drop_first`; the benchmark's actions have no binary gripper).
9
+
10
+ Both fields are autonomous (no time input): f(a, s | c) depends only on where the action state `a` is, the
11
+ proprioception `s` (when the field reads it) and the per-chunk condition `c`; the output layer starts at zero, so an
12
+ untrained policy holds its start action.
13
+ """
14
+ from __future__ import annotations
15
+
16
+ import torch
17
+ import torch.nn as nn
18
+ import torch.nn.functional as F
19
+
20
+
21
+ class FiLMLayer(nn.Module):
22
+ def __init__(self, dim, cond_dim):
23
+ super().__init__()
24
+ self.lin = nn.Linear(dim, dim)
25
+ self.film = nn.Linear(cond_dim, 2 * dim)
26
+
27
+ def forward(self, h, c=None, gb=None):
28
+ g, b = gb if gb is not None else self.film(c).chunk(2, dim=-1)
29
+ return h + F.silu(self.lin(h) * (1 + g) + b)
30
+
31
+
32
+ class VectorField(nn.Module):
33
+ """ODE-MLP: f(a, s | c), a FiLM-modulated residual MLP. Training-only dropout on the hidden units keeps one mask
34
+ per sample for every field call until reset_dropout(), so a whole integrated chunk sees one thinned field."""
35
+
36
+ def __init__(self, cond_dim, state_dim, hidden_dim, num_layers, out_dim, pose_dim, dropout=0.0):
37
+ super().__init__()
38
+ self.dropout, self._masks = float(dropout), None
39
+ self.inp = nn.Linear(pose_dim + state_dim, hidden_dim)
40
+ self.layers = nn.ModuleList([FiLMLayer(hidden_dim, cond_dim) for _ in range(num_layers)])
41
+ self.out = nn.Linear(hidden_dim, out_dim)
42
+ self.feat_dim = hidden_dim
43
+ nn.init.zeros_(self.out.weight)
44
+ nn.init.zeros_(self.out.bias)
45
+
46
+ def precompute(self, c):
47
+ """FiLM scale/shift depend on c only; computed once per integration."""
48
+ return [layer.film(c).chunk(2, dim=-1) for layer in self.layers]
49
+
50
+ def reset_dropout(self):
51
+ self._masks = None
52
+
53
+ def forward(self, a, s, c, film=None):
54
+ drop = self.training and self.dropout > 0
55
+ h = self.inp(torch.cat([a, s], dim=-1))
56
+ if drop and (self._masks is None or self._masks[0].shape != h.shape):
57
+ keep = 1.0 - self.dropout
58
+ self._masks = [torch.bernoulli(torch.full_like(h, keep)) / keep for _ in self.layers]
59
+ for i, layer in enumerate(self.layers):
60
+ h = layer(h, c, None if film is None else film[i])
61
+ if drop:
62
+ h = h * self._masks[i]
63
+ return self.out(h)
64
+
65
+
66
+ class RotaryPosEmb(nn.Module):
67
+ """Rotary positional embedding (torchtune), built over the full width `dim` and applied to the heads' slices."""
68
+
69
+ def __init__(self, dim: int, max_seq_len: int = 256, base: int = 10_000):
70
+ super().__init__()
71
+ self.dim, self.base, self.max_seq_len = dim, base, max_seq_len
72
+ theta = 1.0 / (base ** (torch.arange(0, dim, 2)[: (dim // 2)].float() / dim))
73
+ self.register_buffer('theta', theta, persistent=False)
74
+ seq_idx = torch.arange(max_seq_len, dtype=theta.dtype)
75
+ idx_theta = torch.einsum('i, j -> ij', seq_idx, theta).float()
76
+ self.register_buffer('cache', torch.stack([torch.cos(idx_theta), torch.sin(idx_theta)], dim=-1),
77
+ persistent=False)
78
+
79
+ def forward(self, x):
80
+ """x (B, num_heads, S, head_dim) -> the same shape."""
81
+ x = x.permute(0, 2, 1, 3) # (B, S, num_heads, head_dim)
82
+ B, S, num_heads, head_dim = x.size()
83
+ rope_cache = self.cache[:S]
84
+ xshaped = x.float().reshape(*x.shape[:-1], head_dim // 2, 2)
85
+ rope_cache = rope_cache.view(1, S, num_heads, head_dim // 2, 2)
86
+ x_out = torch.stack([xshaped[..., 0] * rope_cache[..., 0] - xshaped[..., 1] * rope_cache[..., 1],
87
+ xshaped[..., 1] * rope_cache[..., 0] + xshaped[..., 0] * rope_cache[..., 1]], -1)
88
+ return x_out.flatten(3).permute(0, 2, 1, 3).type_as(x)
89
+
90
+
91
+ class Attention(nn.Module):
92
+ def __init__(self, dim, num_heads=8, qkv_bias=True, attn_drop=0., proj_drop=0., max_seq_len=64, qk_norm=True):
93
+ super().__init__()
94
+ assert dim % num_heads == 0, 'dim should be divisible by num_heads'
95
+ self.num_heads = num_heads
96
+ self.head_dim = dim // num_heads
97
+ self.attn_drop = attn_drop
98
+ self.proj_drop = nn.Dropout(proj_drop)
99
+ self.qkv = nn.Linear(dim, dim * 3, bias=qkv_bias)
100
+ self.q_norm = nn.LayerNorm(self.head_dim) if qk_norm else nn.Identity()
101
+ self.k_norm = nn.LayerNorm(self.head_dim) if qk_norm else nn.Identity()
102
+ self.proj = nn.Linear(dim, dim)
103
+ self.rope = RotaryPosEmb(dim, max_seq_len=max_seq_len)
104
+
105
+ def forward(self, x, mask=None):
106
+ B, S, C = x.shape
107
+ qkv = self.qkv(x).reshape(B, S, 3, self.num_heads, self.head_dim).permute(2, 0, 3, 1, 4)
108
+ q, k, v = qkv.unbind(0)
109
+ q, k = self.rope(self.q_norm(q)), self.rope(self.k_norm(k))
110
+ if self.training:
111
+ x = F.scaled_dot_product_attention(q, k, v, attn_mask=mask, dropout_p=self.attn_drop)
112
+ else:
113
+ x = F.scaled_dot_product_attention(q, k, v)
114
+ return self.proj_drop(self.proj(x.transpose(1, 2).reshape(B, S, C)))
115
+
116
+
117
+ class Mlp(nn.Module):
118
+ """The ViT MLP (timm.layers.Mlp) as ODE Policy's utils/models/layers.py, linear layers only."""
119
+
120
+ def __init__(self, in_features, hidden_features=None, out_features=None, act_layer=nn.GELU, drop=0.):
121
+ super().__init__()
122
+ out_features = out_features or in_features
123
+ hidden_features = hidden_features or in_features
124
+ self.fc1 = nn.Linear(in_features, hidden_features)
125
+ self.act = act_layer()
126
+ self.drop1 = nn.Dropout(drop)
127
+ self.norm = nn.Identity()
128
+ self.fc2 = nn.Linear(hidden_features, out_features)
129
+ self.drop2 = nn.Dropout(drop)
130
+
131
+ def forward(self, x):
132
+ return self.drop2(self.fc2(self.norm(self.drop1(self.act(self.fc1(x))))))
133
+
134
+
135
+ class AdaLNBlock(nn.Module):
136
+ """Adaptive-LayerNorm transformer block as in DiT (Peebles et al. 2022); ada_ln starts at zero (adaLN-zero)."""
137
+
138
+ def __init__(self, dim, num_heads, mlp_ratio=4., dropout=0.):
139
+ super().__init__()
140
+ self.norm1 = nn.LayerNorm(dim, elementwise_affine=False, eps=1e-6)
141
+ self.attn = Attention(dim, num_heads=num_heads, attn_drop=dropout, proj_drop=dropout)
142
+ self.norm2 = nn.LayerNorm(dim, elementwise_affine=False, eps=1e-6)
143
+ self.mlp = Mlp(in_features=dim, hidden_features=int(dim * mlp_ratio),
144
+ act_layer=lambda: nn.GELU(approximate='tanh'), drop=0)
145
+ self.ada_ln = nn.Sequential(nn.SiLU(), nn.Linear(dim, 6 * dim))
146
+ self.dim = dim
147
+ nn.init.constant_(self.ada_ln[-1].weight, 0)
148
+ nn.init.constant_(self.ada_ln[-1].bias, 0)
149
+
150
+
151
+ class DiTVectorField(nn.Module):
152
+ """ODE-DiT: the vector field built from DiT blocks. [a, s] is projected to n_tokens tokens; every block's
153
+ LayerNorm scales/shifts/gates are regressed from the condition c (no time input: the field is autonomous); the
154
+ tokens are pooled for the output. Same interface and zero-initialized output as VectorField."""
155
+
156
+ def __init__(self, cond_dim, state_dim, hidden_dim, num_layers, out_dim, pose_dim, num_heads=8, n_tokens=4,
157
+ mlp_ratio=4.0):
158
+ super().__init__()
159
+ self.n_tokens, self.hidden_dim, self.feat_dim = n_tokens, hidden_dim, hidden_dim
160
+ self.inp = nn.Linear(pose_dim + state_dim, n_tokens * hidden_dim)
161
+ self.pos = nn.Parameter(torch.zeros(1, n_tokens, hidden_dim))
162
+ self.cond = nn.Linear(cond_dim, hidden_dim)
163
+ self.blocks = nn.ModuleList([AdaLNBlock(hidden_dim, num_heads, mlp_ratio) for _ in range(num_layers)])
164
+ self.norm = nn.LayerNorm(hidden_dim)
165
+ self.out = nn.Linear(hidden_dim, out_dim)
166
+ nn.init.zeros_(self.out.weight)
167
+ nn.init.zeros_(self.out.bias)
168
+
169
+ def precompute(self, c):
170
+ """The adaLN scales/shifts/gates depend on c only: computed once per integration."""
171
+ cc = F.silu(self.cond(c))
172
+ return [blk.ada_ln(cc).view(c.shape[0], 6, 1, self.hidden_dim).unbind(1) for blk in self.blocks]
173
+
174
+ def forward(self, a, s, c, film=None):
175
+ B = a.shape[0]
176
+ x = self.inp(torch.cat([a, s], dim=-1)).view(B, self.n_tokens, self.hidden_dim) + self.pos
177
+ mods = self.precompute(c) if film is None else film
178
+ for blk, (g1, g2, sc1, sc2, sh1, sh2) in zip(self.blocks, mods):
179
+ x = x + blk.attn(blk.norm1(x) * (1 + sc1) + sh1) * g1
180
+ x = x + blk.mlp(blk.norm2(x) * (1 + sc2) + sh2) * g2
181
+ return self.out(self.norm(x).mean(dim=1))
b8-table-wipe/b512-cont-20261117-stop50k/step-050000/training_records/code_hb_bai_433ba198_stopat39f9b83a/evaluation/baselines/policies.py ADDED
@@ -0,0 +1,459 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """The baseline policies behind one contract; the first three ported from DextraVerse's imitation-learning core:
2
+
3
+ - `fm_dit`, `FMDiTPolicy` (reference: dextraverse/algorithms/il/models/fm_dit.py + fm_base.py): flow matching, MSE on
4
+ the velocity `a - noise`; sampled with 10 midpoint steps from noise (20 DiT calls);
5
+ - `dp`, `DPPolicy` (ddpm_dit.py + ddpm_base.py: Diffusion Policy with a DiT backbone): DDPM epsilon MSE over 100
6
+ steps; sampled with the 100 DDPM steps;
7
+ - `act`, `ACTPolicy` (act.py + nets/act/): L1 + `kl_weight` x KL of the CVAE; decoded from the zero latent in one pass;
8
+ - `flash`, `flash.FlashPolicy` (NTUMARS/FLASH-Policy @ f47e490): polynomial-coefficient flow from the fitted history
9
+ of the executed actions to the future, one Euler step; its contract adds the history (flash.py's docstring).
10
+ - `fm_dit_v2`, `fm_dit_v2.FMDiTv2Policy` (FLASH-Policy @ f47e490's own FM-DiT, owner 2026-11-25): flow matching from
11
+ noise as `fm_dit`, on FLASH's networks (DiT 512, one from-scratch GroupNorm ResNet18 per camera) and recipe; a
12
+ separate entry: `fm_dit` (v1) keeps its checkpoints and behaviour (fm_dit_v2.py's docstring).
13
+
14
+ Two follow ODE Policy's G1 port (Jia et al., github.com/NTUMARS/ODE-POLICY branch real-g1 @fd8bec47, maintained in
15
+ HumanWAM as packages/ode_g1: model.py `SonicLatentODE`, data.py), with its GR00T backbone replaced by ODE Policy's own
16
+ image encoder (ode_policy main @cea26d94, ode.yaml), each in its authors' configuration (not aligned with the others):
17
+
18
+ - `ode_mlp`, `ODEPolicy`: the body part of the action (G1: the SONIC motion token) is an ODE state, db/dt =
19
+ f(b, s | c) with a FiLM residual MLP field, integrated with Euler one row per step from the body row executed at t-1;
20
+ the hands are decoded from c; masked MSE of the integrated path and the hands;
21
+ - `ode_dit`, `ODEDiTPolicy`: the same with ODE Policy's DiT (adaLN) field (ode_dit.yaml).
22
+
23
+ Contract (every policy): `compute_loss(images, state, action) -> (loss, metrics)` and
24
+ `predict(images, state, generator) -> (action, normalized action)`; images (B, n_cameras, 3, H, W) float in [0, 1],
25
+ state (B, state_dim) and action (B, lead_rows + horizon, action_dim) in physical units. Each policy owns its
26
+ `Normalizer` (DextraVerse's LinearNormalizer 'limits' mode: state and action to [-1, 1] per dimension, constant
27
+ dimensions shifted to 0), saved in its state dict. One observation frame (n_obs_steps 1: the current images and
28
+ state); the chunk's row 0 is the action of the observation's own frame (the LeRobot rows t..t+horizon-1). A policy
29
+ with `lead_rows` 1 (the ODE policies) also reads the row before, t-1, and the rows' validity (ChunkDataset `lead`),
30
+ and its `predict` takes `previous`, the action row executed at t-1. The ODE policies normalize with their own bounds
31
+ (q01 / q99, the DFX6 hands fixed at [0, 1], clipped to [-5, 5]). The configuration that builds a policy is a plain
32
+ dict (`PolicyConfig` fields), stored in the checkpoint.
33
+
34
+ The ResNet18 of FM-DiT, DP and ACT starts from torchvision's ImageNet-1k weights (`backbone_weights` 'IMAGENET1K_V1',
35
+ the default since 2026-11-16) and is fine-tuned with the policy, its BatchNorm frozen at the pretrained statistics
36
+ (`backbone_norm` 'frozen_bn', as ACT always does); `backbone_weights` None trains from scratch with DextraVerse's
37
+ GroupNorm encoder (FM-DiT, DP) or ACT's frozen-BatchNorm one. The ODE policies default to ODE Policy's encoder: one
38
+ ResNet18 per camera, from scratch, GroupNorm. A checkpoint load builds the structure without fetching any weights.
39
+ """
40
+ from __future__ import annotations
41
+
42
+ from dataclasses import asdict, dataclass, field, replace
43
+
44
+ import torch
45
+ import torch.nn as nn
46
+ import torch.nn.functional as F
47
+
48
+ from .act_nets import DETRVAE, Transformer, build_backbone, build_style_encoder, kl_divergence
49
+ from .nets import IMAGENET_MEAN, IMAGENET_STD, FlowTransformer, ImageStateEncoder
50
+ from .ode_nets import DiTVectorField, VectorField
51
+
52
+ ODE_POLICIES = ('ode_mlp', 'ode_dit')
53
+ # Defaults that differ by policy. horizon and backbone_weights resolve in PolicyConfig; backbone_lr_scale (and amp)
54
+ # are the training script's. The ODE policies: 16-row chunks (the G1 port's H16; its deployment re-plans about 4 rows
55
+ # before a chunk ends, as the benchmark clients' query every 12 rows), ODE Policy's encoder from scratch at the full
56
+ # learning rate (ode.yaml, default_train.yaml). Mixed precision as the G1 port: the encoder under bf16 autocast, the
57
+ # ODE head in FP32.
58
+ # The training recipe of ODE Policy's default_train.yaml (the same NTUMARS trainer as FLASH's): seed 42, lr 1e-4 at
59
+ # the benchmark's batch 512 without batch scaling (as every model of the protocol, HumanWAM REPRODUCIBILITY.md
60
+ # section 4), 500-step warm-up then diffusers' cosine, Diffusion Policy's EMAModel as upstream counts it.
61
+ POLICY_DEFAULTS = {name: dict(horizon=16, backbone_weights=None, backbone_lr_scale=1.0, seed=42,
62
+ schedule='diffusers_cosine', ema_schedule='diffusion_policy_emamodel')
63
+ for name in ODE_POLICIES}
64
+
65
+
66
+ @dataclass
67
+ class PolicyConfig:
68
+ """Everything that builds a policy (stored in the checkpoint's config.json). Model defaults are DextraVerse's
69
+ configs/algorithm/il/model/{fm_dit,ddpm_dit,act}.yaml and, for the ODE policies (`ode_*` fields), ODE Policy's G1
70
+ port (HumanWAM packages/ode_g1 configs/g1.yaml `head`) and ode_dit.yaml for the DiT field."""
71
+ policy: str
72
+ n_cameras: int
73
+ state_dim: int
74
+ action_dim: int
75
+ horizon: int | None = None # None: the policy's default (POLICY_DEFAULTS, else 16)
76
+ backbone: str = 'resnet18'
77
+ # torchvision weights to initialize from; None = from scratch; 'default': IMAGENET1K_V1, the ODE policies None
78
+ backbone_weights: str | None = 'default'
79
+ backbone_norm: str | None = None # 'frozen_bn' or 'group'; None: frozen_bn when pretrained or ACT, else group
80
+ # FM-DiT / DP (DiT backbone)
81
+ hidden_dim: int = 384
82
+ num_layers: int = 4
83
+ num_heads: int = 8
84
+ mlp_ratio: float = 4.0
85
+ dropout: float = 0.1
86
+ time_embed_dim: int = 128
87
+ num_inference_steps: int | None = None # None: FM-DiT 10 midpoint steps, DP every training timestep (100)
88
+ # DP noise schedule (diffusers DDPMScheduler)
89
+ num_train_timesteps: int = 100
90
+ beta_schedule: str = 'squaredcos_cap_v2'
91
+ prediction_type: str = 'epsilon'
92
+ clip_sample: bool = True
93
+ # ACT
94
+ act_hidden_dim: int = 512
95
+ dim_feedforward: int = 3200
96
+ enc_layers: int = 4
97
+ dec_layers: int = 7
98
+ nheads: int = 8
99
+ latent_dim: int = 32
100
+ kl_weight: float = 10.0
101
+ # ODE policies (G1 port, configs/g1.yaml head: width 512, 4 FiLM layers, cond 512, field_scale 1). ode_body_dim:
102
+ # the leading action columns integrated as the ODE state, the rest decoded from the condition (G1: the token 64 and
103
+ # the DFX6 12; train.py sets it to the contract's first action group, H2: body_target 31). ODE-DiT: ODE Policy's
104
+ # DiT field, 512 wide, 4 blocks, 8 heads, 4 tokens (ode_dit.yaml).
105
+ ode_body_dim: int | None = None
106
+ ode_width: int = 512
107
+ ode_layers: int = 4
108
+ ode_cond_dim: int = 512
109
+ ode_field_scale: float = 1.0
110
+ ode_dit_hidden: int = 512
111
+ ode_dit_layers: int = 4
112
+ ode_dit_heads: int = 8
113
+ ode_dit_tokens: int = 4
114
+ extra: dict = field(default_factory=dict)
115
+
116
+ def __post_init__(self):
117
+ defaults = POLICY_DEFAULTS.get(self.policy, {})
118
+ if self.horizon is None:
119
+ self.horizon = int(defaults.get('horizon', 16))
120
+ if self.backbone_weights == 'default':
121
+ self.backbone_weights = defaults.get('backbone_weights', 'IMAGENET1K_V1')
122
+ if self.backbone_norm is None:
123
+ self.backbone_norm = 'frozen_bn' if self.backbone_weights or self.policy == 'act' else 'group'
124
+ if self.policy == 'act' and self.backbone_norm != 'frozen_bn':
125
+ raise ValueError("ACT's backbone keeps frozen BatchNorm (backbone_norm 'frozen_bn')")
126
+
127
+ @classmethod
128
+ def from_dict(cls, data: dict) -> PolicyConfig:
129
+ known = {k: v for k, v in data.items() if k in cls.__dataclass_fields__}
130
+ return cls(**known)
131
+
132
+ def to_dict(self) -> dict:
133
+ return asdict(self)
134
+
135
+
136
+ class Normalizer(nn.Module):
137
+ """Per-dimension affine map to [-1, 1] from the training data's min/max (DextraVerse LinearNormalizer, mode
138
+ 'limits', fit_offset, range_eps 1e-4): x_n = x * scale + offset; a dimension whose range is below range_eps gets
139
+ scale 1 and maps its value to 0."""
140
+
141
+ def __init__(self, dim: int):
142
+ super().__init__()
143
+ self.register_buffer('scale', torch.ones(dim))
144
+ self.register_buffer('offset', torch.zeros(dim))
145
+
146
+ @torch.no_grad()
147
+ def fit(self, minimum, maximum, range_eps=1e-4):
148
+ lo = torch.as_tensor(minimum, dtype=torch.float32)
149
+ hi = torch.as_tensor(maximum, dtype=torch.float32)
150
+ span = hi - lo
151
+ ignore = span < range_eps
152
+ span[ignore] = 2.0
153
+ scale = 2.0 / span
154
+ offset = -1.0 - scale * lo
155
+ offset[ignore] = -lo[ignore]
156
+ self.scale.copy_(scale)
157
+ self.offset.copy_(offset)
158
+
159
+ def normalize(self, x):
160
+ return x * self.scale + self.offset
161
+
162
+ def unnormalize(self, x):
163
+ return (x - self.offset) / self.scale
164
+
165
+
166
+ class BasePolicy(nn.Module):
167
+ name = ''
168
+ backbone_prefix = '' # state-dict prefix of the image backbone (its own learning rate in training)
169
+ lead_rows = 0 # action rows before the observation's frame that a training item carries (ODE: 1, the start)
170
+
171
+ def __init__(self, cfg: PolicyConfig, init_weights=None):
172
+ super().__init__()
173
+ self.cfg = cfg
174
+ self.state_norm = Normalizer(cfg.state_dim)
175
+ self.action_norm = Normalizer(cfg.action_dim)
176
+
177
+ def fit_normalizers(self, stats: dict):
178
+ self.state_norm.fit(stats['state']['min'], stats['state']['max'])
179
+ self.action_norm.fit(stats['action']['min'], stats['action']['max'])
180
+
181
+ @property
182
+ def sampling_steps(self) -> int:
183
+ return 1
184
+
185
+ def compute_loss(self, images, state, action):
186
+ raise NotImplementedError
187
+
188
+ def predict(self, images, state, generator=None):
189
+ raise NotImplementedError
190
+
191
+
192
+ class DiTPolicy(BasePolicy):
193
+ """Shared by FM-DiT and DP: the shared-ResNet image + state encoder and the AdaLN DiT over the action chunk
194
+ (global observation conditioning, DextraVerse obs_as_global_cond)."""
195
+ backbone_prefix = 'obs_encoder.rgb.'
196
+
197
+ def __init__(self, cfg: PolicyConfig, init_weights=None):
198
+ super().__init__(cfg)
199
+ self.obs_encoder = ImageStateEncoder(cfg.n_cameras, cfg.state_dim, backbone=cfg.backbone,
200
+ weights=init_weights, norm=cfg.backbone_norm)
201
+ self.model = FlowTransformer(input_dim=cfg.action_dim, condition_dim=self.obs_encoder.feature_dim,
202
+ hidden_dim=cfg.hidden_dim, output_dim=cfg.action_dim, num_layers=cfg.num_layers,
203
+ num_heads=cfg.num_heads, mlp_ratio=cfg.mlp_ratio, dropout=cfg.dropout,
204
+ time_embed_dim=cfg.time_embed_dim)
205
+
206
+ def condition(self, images, state):
207
+ return self.obs_encoder(images, self.state_norm.normalize(state))
208
+
209
+
210
+ class FMDiTPolicy(DiTPolicy):
211
+ """Flow-matching DiT (DextraVerse FlowMatchingDiTImagePolicy): x_t = (1 - t) noise + t a, t ~ U(0, 1), the DiT
212
+ regresses the velocity a - noise; sampling integrates t = 0 -> 1 with the midpoint rule."""
213
+ name = 'fm_dit'
214
+
215
+ @property
216
+ def sampling_steps(self) -> int:
217
+ return int(self.cfg.num_inference_steps or 10)
218
+
219
+ def compute_loss(self, images, state, action):
220
+ cond = self.condition(images, state)
221
+ target = self.action_norm.normalize(action)
222
+ noise = torch.randn_like(target)
223
+ t = torch.rand(target.shape[0], device=target.device)
224
+ te = t.view(-1, 1, 1)
225
+ x_t = (1 - te) * noise + te * target
226
+ loss = F.mse_loss(self.model(x_t, t, cond), target - noise)
227
+ return loss, dict(fm=float(loss.detach()))
228
+
229
+ @torch.no_grad()
230
+ def predict(self, images, state, generator=None):
231
+ cond = self.condition(images, state)
232
+ B, steps = images.shape[0], self.sampling_steps
233
+ x = torch.randn((B, self.cfg.horizon, self.cfg.action_dim), device=cond.device, dtype=cond.dtype,
234
+ generator=generator)
235
+ times = torch.linspace(0, 1.0, steps + 1, device=cond.device)
236
+ for i in range(steps):
237
+ t0 = times[i].view(1).expand(B)
238
+ t1 = times[i + 1].view(1).expand(B)
239
+ dt = (t1 - t0).view(-1, 1, 1)
240
+ x_mid = x + self.model(x, t0, cond) * dt / 2
241
+ x = x + dt * self.model(x_mid, t0 + (t1 - t0) / 2, cond)
242
+ return self.action_norm.unnormalize(x), x
243
+
244
+
245
+ class DPPolicy(DiTPolicy):
246
+ """Diffusion Policy with the DiT backbone (DextraVerse DiffusionDiTImagePolicy, ddpm_dit.yaml): DDPM with 100
247
+ training steps, squaredcos_cap_v2 betas, fixed_small variance, clipped samples, epsilon prediction; sampled with
248
+ every training step (100 DiT calls)."""
249
+ name = 'dp'
250
+
251
+ def __init__(self, cfg: PolicyConfig, init_weights=None):
252
+ super().__init__(cfg, init_weights)
253
+ from diffusers.schedulers.scheduling_ddpm import DDPMScheduler
254
+ self.noise_scheduler = DDPMScheduler(num_train_timesteps=cfg.num_train_timesteps, beta_start=0.0001,
255
+ beta_end=0.02, beta_schedule=cfg.beta_schedule,
256
+ variance_type='fixed_small', clip_sample=cfg.clip_sample,
257
+ prediction_type=cfg.prediction_type)
258
+
259
+ @property
260
+ def sampling_steps(self) -> int:
261
+ return int(self.cfg.num_inference_steps or self.cfg.num_train_timesteps)
262
+
263
+ def compute_loss(self, images, state, action):
264
+ cond = self.condition(images, state)
265
+ target = self.action_norm.normalize(action)
266
+ noise = torch.randn_like(target)
267
+ t = torch.randint(0, self.noise_scheduler.config.num_train_timesteps, (target.shape[0],),
268
+ device=target.device).long()
269
+ noisy = self.noise_scheduler.add_noise(target, noise, t)
270
+ pred = self.model(noisy, t, cond)
271
+ goal = noise if self.cfg.prediction_type == 'epsilon' else target
272
+ loss = F.mse_loss(pred, goal)
273
+ return loss, dict(ddpm=float(loss.detach()))
274
+
275
+ @torch.no_grad()
276
+ def predict(self, images, state, generator=None):
277
+ cond = self.condition(images, state)
278
+ scheduler = self.noise_scheduler
279
+ x = torch.randn((images.shape[0], self.cfg.horizon, self.cfg.action_dim), device=cond.device,
280
+ dtype=cond.dtype, generator=generator)
281
+ scheduler.set_timesteps(self.sampling_steps, device=cond.device)
282
+ for t in scheduler.timesteps:
283
+ x = scheduler.step(self.model(x, t.to(cond.device), cond), t, x, generator=generator).prev_sample
284
+ return self.action_norm.unnormalize(x), x
285
+
286
+
287
+ class ACTPolicy(BasePolicy):
288
+ """ACT (DextraVerse ACTImagePolicy, act.yaml): ImageNet-normalized cameras through one ResNet with frozen
289
+ BatchNorm (spatial tokens, no pooling), the normalized state as qpos, a CVAE style encoder over the action chunk in
290
+ training, the DETR decoder with `horizon` queries; loss L1 + kl_weight x KL; inference decodes from the zero
291
+ latent (deterministic)."""
292
+ name = 'act'
293
+ backbone_prefix = 'model.backbone.'
294
+
295
+ def __init__(self, cfg: PolicyConfig, init_weights=None):
296
+ super().__init__(cfg)
297
+ transformer = Transformer(d_model=cfg.act_hidden_dim, nhead=cfg.nheads, num_encoder_layers=cfg.enc_layers,
298
+ num_decoder_layers=cfg.dec_layers, dim_feedforward=cfg.dim_feedforward,
299
+ dropout=cfg.dropout, return_intermediate_dec=False)
300
+ self.model = DETRVAE(build_backbone(cfg.backbone, hidden_dim=cfg.act_hidden_dim, weights=init_weights),
301
+ transformer,
302
+ build_style_encoder(cfg.act_hidden_dim, cfg.nheads, cfg.dim_feedforward, cfg.enc_layers,
303
+ cfg.dropout),
304
+ qpos_dim=cfg.state_dim, action_dim=cfg.action_dim, num_queries=cfg.horizon,
305
+ latent_dim=cfg.latent_dim)
306
+ self.register_buffer('mean', torch.tensor(IMAGENET_MEAN).view(1, 1, 3, 1, 1), persistent=False)
307
+ self.register_buffer('std', torch.tensor(IMAGENET_STD).view(1, 1, 3, 1, 1), persistent=False)
308
+
309
+ def compute_loss(self, images, state, action):
310
+ target = self.action_norm.normalize(action)
311
+ a_hat, (mu, logvar) = self.model(self.state_norm.normalize(state), (images - self.mean) / self.std,
312
+ actions=target)
313
+ l1 = F.l1_loss(a_hat, target)
314
+ kl = kl_divergence(mu, logvar)
315
+ return l1 + self.cfg.kl_weight * kl, dict(l1=float(l1.detach()), kl=float(kl.detach()))
316
+
317
+ @torch.no_grad()
318
+ def predict(self, images, state, generator=None): # noqa: ARG002 - deterministic (zero latent)
319
+ a_hat, _ = self.model(self.state_norm.normalize(state), (images - self.mean) / self.std)
320
+ return self.action_norm.unnormalize(a_hat), a_hat
321
+
322
+
323
+ class ODEPolicy(BasePolicy):
324
+ """ODE policy as ODE Policy's G1 port (`SonicLatentODE`): the body part b of the action row (the first
325
+ ode_body_dim columns; G1 the SONIC motion token 64) is integrated with Euler, one row per unit of time,
326
+ b_{k+1} = b_k + field_scale * f(b_k, s | c), from b_0 = the body row before the chunk; the remaining columns (G1:
327
+ the measured DFX6 12) are decoded from c for every row (linear, SiLU, linear; continuous, no sigmoid). c =
328
+ Linear(LayerNorm(image features)): one ResNet18 per view (ODE Policy's encoder, in place of the G1 port's GR00T
329
+ reader); the state enters the field only, never the condition or the hands.
330
+
331
+ Normalization (the G1 port's): per-dimension q01 / q99 of the training rows to [-1, 1], the UNIT_RANGE columns
332
+ (DFX6) fixed at [0, 1], constant dimensions shifted to 0, clipped to [-5, 5]; the executed body row at inference is
333
+ not clipped (a carried endpoint may leave the interval). Start: training teacher-forces b_0 = the recorded body row
334
+ t-1, the normalized-zero BOS at an episode's first frame; execution starts from the body part of the row executed
335
+ at t-1 (the interface's past_actions[-1]), BOS without one. Loss: masked MSE in normalized units (rows past the
336
+ episode's end left out), body and hands weighted by their widths. The ODE head runs in FP32 (the encoder under the
337
+ caller's autocast). Deterministic; no start perturbation (the G1 port's)."""
338
+ name = 'ode_mlp'
339
+ field_arch = 'mlp'
340
+ backbone_prefix = 'obs_encoder.rgb.'
341
+ lead_rows = 1
342
+ CLIP = 5.0
343
+
344
+ def __init__(self, cfg: PolicyConfig, init_weights=None):
345
+ super().__init__(cfg)
346
+ if cfg.ode_body_dim is None or not 0 < cfg.ode_body_dim <= cfg.action_dim:
347
+ raise ValueError(f'ode_body_dim must be in 1..{cfg.action_dim}, got {cfg.ode_body_dim}')
348
+ body, hands = cfg.ode_body_dim, cfg.action_dim - cfg.ode_body_dim
349
+ self.obs_encoder = ImageStateEncoder(cfg.n_cameras, 0, backbone=cfg.backbone, weights=init_weights,
350
+ norm=cfg.backbone_norm, shared=False) # images only
351
+ self.context_norm = nn.LayerNorm(self.obs_encoder.feature_dim)
352
+ self.context_proj = nn.Linear(self.obs_encoder.feature_dim, cfg.ode_cond_dim)
353
+ if self.field_arch == 'dit':
354
+ self.field = DiTVectorField(cfg.ode_cond_dim, cfg.state_dim, cfg.ode_dit_hidden, cfg.ode_dit_layers, body,
355
+ body, num_heads=cfg.ode_dit_heads, n_tokens=cfg.ode_dit_tokens)
356
+ else:
357
+ self.field = VectorField(cfg.ode_cond_dim, cfg.state_dim, cfg.ode_width, cfg.ode_layers, body, body)
358
+ self.hand_hidden = nn.Linear(cfg.ode_cond_dim, cfg.ode_cond_dim)
359
+ self.hand_output = nn.Linear(cfg.ode_cond_dim, cfg.horizon * hands) if hands else None
360
+
361
+ def fit_normalizers(self, stats: dict):
362
+ """The G1 port's bounds: q01 / q99 (from stats, else min / max), the stats' unit_dims fixed at [0, 1]."""
363
+ for key, norm in (('state', self.state_norm), ('action', self.action_norm)):
364
+ entry = stats[key]
365
+ lo = torch.as_tensor(entry.get('q01', entry['min']), dtype=torch.float64).clone()
366
+ hi = torch.as_tensor(entry.get('q99', entry['max']), dtype=torch.float64).clone()
367
+ unit = torch.as_tensor(entry.get('unit_dims', []), dtype=torch.long)
368
+ lo[unit], hi[unit] = 0.0, 1.0
369
+ norm.fit(lo, hi)
370
+
371
+ @property
372
+ def sampling_steps(self) -> int:
373
+ """Euler steps (field calls) per query."""
374
+ return int(self.cfg.horizon)
375
+
376
+ def features(self, images):
377
+ return self.obs_encoder(images, images.new_zeros(images.shape[0], 0))
378
+
379
+ def head(self, features, s, b0, n_steps):
380
+ """FP32: (body path (B, n_steps, body), hands (B, n_steps, hands)) in normalized units."""
381
+ cfg = self.cfg
382
+ c = self.context_proj(self.context_norm(features.float()))
383
+ film = self.field.precompute(c) # c is fixed over the chunk
384
+ b, path = b0, []
385
+ for _ in range(n_steps): # Euler, dt = one row
386
+ b = b + cfg.ode_field_scale * self.field(b, s, c, film)
387
+ path.append(b)
388
+ path = torch.stack(path, dim=1)
389
+ hands = cfg.action_dim - cfg.ode_body_dim
390
+ if not hands:
391
+ return path, path[..., :0]
392
+ out = self.hand_output(F.silu(self.hand_hidden(c))).view(c.shape[0], cfg.horizon, hands)
393
+ return path, out[:, :n_steps]
394
+
395
+ def compute_loss(self, images, state, action, valid=None):
396
+ cfg = self.cfg
397
+ H, body = cfg.horizon, cfg.ode_body_dim
398
+ if action.shape[1] != H + 1:
399
+ raise ValueError(f'the ODE policy trains on the row before + {H} rows, got {action.shape[1]} rows')
400
+ valid = torch.ones(action.shape[:2], device=action.device) if valid is None else valid.to(action.device)
401
+ features = self.features(images)
402
+ with torch.autocast(device_type=images.device.type, enabled=False):
403
+ s = self.state_norm.normalize(state.float()).clamp(-self.CLIP, self.CLIP)
404
+ nact = self.action_norm.normalize(action.float()).clamp(-self.CLIP, self.CLIP)
405
+ b0 = nact[:, 0, :body] * valid[:, :1].float() # BOS (normalized zero) at an episode's first frame
406
+ path, hands = self.head(features, s, b0, H)
407
+ target, mask = nact[:, 1:], valid[:, 1:, None].float()
408
+
409
+ def masked(pred, goal):
410
+ m = mask.expand_as(goal)
411
+ return ((pred - goal).square() * m).sum() / m.sum().clamp_min(1)
412
+
413
+ body_loss = masked(path, target[..., :body])
414
+ hand_loss = masked(hands, target[..., body:]) if hands.shape[-1] else body_loss.new_zeros(())
415
+ loss = (body * body_loss + (cfg.action_dim - body) * hand_loss) / cfg.action_dim
416
+ return loss, dict(body=float(body_loss.detach()), hand=float(hand_loss.detach()))
417
+
418
+ @torch.no_grad()
419
+ def predict(self, images, state, generator=None, previous=None, has_previous=None): # noqa: ARG002
420
+ """previous: (B, action_dim) physical, the row executed at t-1 (its body part is the start); None, or a False
421
+ in has_previous (B,), starts from the BOS."""
422
+ cfg = self.cfg
423
+ features = self.features(images)
424
+ with torch.autocast(device_type=images.device.type, enabled=False):
425
+ s = self.state_norm.normalize(state.float()).clamp(-self.CLIP, self.CLIP)
426
+ b0 = features.new_zeros(images.shape[0], cfg.ode_body_dim, dtype=torch.float32)
427
+ if previous is not None:
428
+ start = self.action_norm.normalize(previous.to(device=images.device, dtype=torch.float32))
429
+ keep = (torch.ones(images.shape[0], device=images.device) if has_previous is None else
430
+ has_previous.to(images.device).float())
431
+ b0 = start[:, :cfg.ode_body_dim] * keep[:, None] # unclipped carry
432
+ path, hands = self.head(features, s, b0, cfg.horizon)
433
+ raw = torch.cat([path, hands], dim=-1)
434
+ return self.action_norm.unnormalize(raw), raw
435
+
436
+
437
+ class ODEDiTPolicy(ODEPolicy):
438
+ """ODE-DiT: the ODE policy with ODE Policy's DiT (adaLN) vector field (ode_dit.yaml) over [b, s]."""
439
+ name = 'ode_dit'
440
+ field_arch = 'dit'
441
+
442
+
443
+ from .flash import FlashPolicy # noqa: E402 - FLASH (flash.py) builds on this module's Normalizer and nets.py
444
+ from .fm_dit_v2 import FMDiTv2Policy # noqa: E402 - FM-DiT v2 (FLASH-Policy's FM-DiT) builds on flash.py's networks
445
+
446
+ POLICIES = {cls.name: cls for cls in (FMDiTPolicy, DPPolicy, ACTPolicy, FlashPolicy, ODEPolicy, ODEDiTPolicy,
447
+ FMDiTv2Policy)}
448
+ LABELS = {'fm_dit': 'FM-DiT', 'dp': 'DP (DDPM-DiT)', 'act': 'ACT', 'flash': 'FLASH', 'ode_mlp': 'ODE-MLP',
449
+ 'ode_dit': 'ODE-DiT', 'fm_dit_v2': 'FM-DiT v2'}
450
+
451
+
452
+ def build_policy(cfg: PolicyConfig | dict, pretrained: bool = True) -> BasePolicy:
453
+ """The policy of `cfg`; pretrained=True initializes the backbone from cfg.backbone_weights (training),
454
+ False builds the same structure with random weights (a checkpoint load, which must not download anything)."""
455
+ cfg = cfg if isinstance(cfg, PolicyConfig) else PolicyConfig.from_dict(cfg)
456
+ if cfg.policy not in POLICIES:
457
+ raise KeyError(f'unknown baseline {cfg.policy!r}; one of {sorted(POLICIES)}')
458
+ cfg = replace(cfg) # a copy (resolved backbone_norm)
459
+ return POLICIES[cfg.policy](cfg, init_weights=cfg.backbone_weights if pretrained else None)
b8-table-wipe/b512-cont-20261117-stop50k/step-050000/training_records/code_hb_bai_433ba198_stopat39f9b83a/evaluation/baselines/requirements.lock.txt ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # pip freeze of the hb-baselines training environment (2026-11-27, Python 3.12.12, NAS
2
+ # preflight-20261104T1648Z/policies-20261109/envs/hb-baselines, used by the A800 trainings). The Aliyun DSW copy
3
+ # /root/.venvs/hb-baselines (Python 3.12.1, pillow 12.3.0) trained the 2026-11-24..26 DSW runs.
4
+ anyio==4.16.0
5
+ av==15.1.0
6
+ certifi==2026.11.20
7
+ charset-normalizer==3.5.3
8
+ click==8.5.1
9
+ diffusers==0.35.1
10
+ filelock==4.3.1
11
+ fsspec==2026.9.0
12
+ h11==0.16.0
13
+ hf-xet==1.8.0
14
+ httpcore2==2.16.2
15
+ httpx2==2.16.2
16
+ huggingface_hub==2.4.0
17
+ idna==3.20
18
+ importlib_metadata==10.2.0
19
+ iniconfig==2.3.1
20
+ Jinja2==3.1.6
21
+ lazy-importer==0.1.0
22
+ MarkupSafe==3.0.4
23
+ mpmath==1.3.0
24
+ networkx==3.7
25
+ numpy==2.2.6
26
+ nvidia-cublas-cu12==12.8.4.1
27
+ nvidia-cuda-cupti-cu12==12.8.90
28
+ nvidia-cuda-nvrtc-cu12==12.8.93
29
+ nvidia-cuda-runtime-cu12==12.8.90
30
+ nvidia-cudnn-cu12==9.10.2.21
31
+ nvidia-cufft-cu12==11.3.3.83
32
+ nvidia-cufile-cu12==1.13.1.3
33
+ nvidia-curand-cu12==10.3.9.90
34
+ nvidia-cusolver-cu12==11.7.3.90
35
+ nvidia-cusparse-cu12==12.5.8.93
36
+ nvidia-cusparselt-cu12==0.7.1
37
+ nvidia-nccl-cu12==2.27.5
38
+ nvidia-nvjitlink-cu12==12.8.93
39
+ nvidia-nvshmem-cu12==3.3.20
40
+ nvidia-nvtx-cu12==12.8.90
41
+ opencv-python-headless==4.11.0.86
42
+ packaging==26.4
43
+ pillow==13.0.0
44
+ pluggy==1.7.0
45
+ pyarrow==23.0.1
46
+ Pygments==2.21.0
47
+ pytest==8.4.2
48
+ PyYAML==6.0.4
49
+ regex==2026.11.19
50
+ requests==2.34.2
51
+ safetensors==0.8.0
52
+ setuptools==84.2.1
53
+ sympy==1.14.0
54
+ torch==2.9.0+cu128
55
+ torchvision==0.24.0+cu128
56
+ tqdm==4.70.1
57
+ triton==3.5.0
58
+ truststore==0.10.5
59
+ typing_extensions==4.16.0
60
+ urllib3==2.8.0
61
+ zipp==4.1.2
b8-table-wipe/b512-cont-20261117-stop50k/step-050000/training_records/code_hb_bai_433ba198_stopat39f9b83a/evaluation/baselines/requirements.txt ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Environment of the FM-DiT / DP / ACT baselines (training and the policy server), Python 3.12, CUDA 12.8 wheels:
2
+ # uv venv <env> --python 3.12
3
+ # uv pip install --python <env>/bin/python -r evaluation/baselines/requirements.txt \
4
+ # --extra-index-url https://download.pytorch.org/whl/cu128 --index-strategy unsafe-best-match
5
+ # The full pinned set of the training environment (the A800 / NAS env, Python 3.12.12): requirements.lock.txt
6
+ # (HumanWAM hb_training/envs/hb-baselines.txt). Each run records its versions in config.json training.environment.
7
+ torch==2.9.0+cu128
8
+ torchvision==0.24.0+cu128
9
+ diffusers==0.35.1
10
+ av==15.1.0
11
+ pyarrow==23.0.1
12
+ numpy==2.2.6
13
+ opencv-python-headless==4.11.0.86
14
+ pytest==8.4.2
15
+ pillow==13.0.0 # the JPEG effect of the augmentation spec v2 depends on it (owner 2026-11-27: pin every version that changes the numerics)
b8-table-wipe/b512-cont-20261117-stop50k/step-050000/training_records/code_hb_bai_433ba198_stopat39f9b83a/evaluation/baselines/runtime.py ADDED
@@ -0,0 +1,179 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Checkpoints and inference of the baselines.
2
+
3
+ A checkpoint is a directory written by train.py (`<run>/checkpoints/step-NNNNNN/`, `final` links the last one):
4
+
5
+ - `model.pt`: torch.save of {format, config (the config.json text), state_dict}: the EMA weights (or the raw ones when
6
+ EMA is off) with the policy's state and action normalizers, loaded strictly with `weights_only=True`;
7
+ - `config.json`: the policy configuration, the contract (robot, cameras, state and action columns), the image size,
8
+ the training task text, dataset, episodes, recipe and statistics;
9
+ - `protocol.json`: model.pt's size and SHA-256.
10
+
11
+ `BaselinePolicy.predict` takes the live frames of the checkpoint's cameras (any size; resized with data.resize_frame,
12
+ as the training cache), the physical state of the contract, a seed and, for a policy that starts from it (the ODE
13
+ policies, `uses_previous`), the action row executed at the frame before; it returns the physical (horizon,
14
+ action_dim) chunk with its normalized form; row 0 is the action of the observation's frame.
15
+ """
16
+ from __future__ import annotations
17
+
18
+ import hashlib
19
+ import json
20
+ from pathlib import Path
21
+
22
+ import numpy as np
23
+
24
+ FORMAT = 'hb_baselines/1'
25
+
26
+
27
+ def sha256(path) -> str:
28
+ digest = hashlib.sha256()
29
+ with Path(path).open('rb') as stream:
30
+ for block in iter(lambda: stream.read(16 << 20), b''):
31
+ digest.update(block)
32
+ return digest.hexdigest()
33
+
34
+
35
+ def save_checkpoint(folder, policy, config: dict):
36
+ """Write model.pt, config.json and protocol.json of `policy` (an nn.Module) into `folder`."""
37
+ import torch
38
+ folder = Path(folder)
39
+ folder.mkdir(parents=True, exist_ok=True)
40
+ text = json.dumps(dict(config, format=FORMAT), indent=1)
41
+ state = {k: v.detach().cpu().contiguous() for k, v in policy.state_dict().items()}
42
+ torch.save(dict(format=FORMAT, config=text, state_dict=state), folder / 'model.pt.tmp')
43
+ (folder / 'model.pt.tmp').replace(folder / 'model.pt')
44
+ (folder / 'config.json').write_text(text)
45
+ tr, ds = config.get('training') or {}, config.get('dataset') or {}
46
+ # HumanWAM hb_training/REPRODUCIBILITY.md section 8 (2026-11-27): what the checkpoint is, beside config.json
47
+ summary = dict(task=config.get('task'), dataset_id=config.get('dataset_id'),
48
+ episodes=len(ds.get('train_episodes') or []), frames=ds.get('train_frames'), fps=ds.get('fps'),
49
+ steps=tr.get('steps'), total_steps=tr.get('total_steps'), save_steps=tr.get('save_steps'),
50
+ global_batch=tr.get('batch_size'), per_gpu_batch=tr.get('batch_size'), num_gpus=1,
51
+ gradient_accumulation_steps=1, lr=tr.get('lr'), warmup=tr.get('warmup'),
52
+ schedule=tr.get('schedule'), seed=tr.get('seed'), aug_seed=tr.get('aug_seed'),
53
+ code_commit=config.get('code_commit'), code_dirty=tr.get('code_dirty'),
54
+ environment=tr.get('environment'), continuation=tr.get('continuation'),
55
+ protocol_deviations=tr.get('protocol_deviations'), protocol_exceptions=tr.get('protocol_exceptions'))
56
+ (folder / 'protocol.json').write_text(json.dumps(dict(
57
+ format=FORMAT, step=config.get('step'), policy=config['policy']['policy'], **summary,
58
+ files={'model.pt': dict(bytes=(folder / 'model.pt').stat().st_size, sha256=sha256(folder / 'model.pt'))}),
59
+ indent=1, default=str))
60
+
61
+
62
+ def load_checkpoint(folder, device='cpu', verify=True):
63
+ """(policy in eval mode on `device`, config dict) of a checkpoint directory."""
64
+ import torch
65
+ from .policies import build_policy
66
+ folder = Path(folder)
67
+ if verify:
68
+ protocol = json.loads((folder / 'protocol.json').read_text())
69
+ entry = protocol['files']['model.pt']
70
+ if (folder / 'model.pt').stat().st_size != entry['bytes']:
71
+ raise ValueError(f'{folder}/model.pt differs from protocol.json')
72
+ payload = torch.load(folder / 'model.pt', map_location='cpu', weights_only=True)
73
+ if payload.get('format') != FORMAT:
74
+ raise ValueError(f"{folder}: format {payload.get('format')!r}, expected {FORMAT}")
75
+ config = json.loads(payload['config'])
76
+ if json.loads((folder / 'config.json').read_text()) != config:
77
+ raise ValueError(f'{folder}: config.json differs from the one inside model.pt')
78
+ policy = build_policy(config['policy'], pretrained=False) # every weight comes from model.pt
79
+ policy.load_state_dict(payload['state_dict'], strict=True)
80
+ return policy.to(device).eval(), config
81
+
82
+
83
+ class BaselinePolicy:
84
+ """A loaded checkpoint for closed-loop inference (one request at a time)."""
85
+
86
+ def __init__(self, checkpoint, device='cuda:0', policy: str | None = None, robot: str | None = None):
87
+ import torch
88
+ self.torch = torch
89
+ self.device = torch.device(device)
90
+ self.model, self.config = load_checkpoint(checkpoint, device=self.device)
91
+ self.checkpoint = str(Path(checkpoint).resolve())
92
+ name, contract = self.config['policy']['policy'], self.config['contract']
93
+ if policy is not None and name != policy:
94
+ raise ValueError(f'{checkpoint} is a {name!r} checkpoint, not {policy!r}')
95
+ if robot is not None and contract['robot'] != robot:
96
+ raise ValueError(f"{checkpoint} was trained for {contract['robot']!r} ({contract['name']}), not {robot!r}")
97
+ self.name, self.contract = name, contract
98
+ self.cameras = tuple(contract['cameras'])
99
+ self.image_hw = tuple(self.config['image_hw'])
100
+ self.horizon = int(self.config['policy']['horizon'])
101
+ self.state_dim, self.action_dim = int(contract['state_dim']), int(contract['action_dim'])
102
+ self.sampling_steps = int(self.model.sampling_steps)
103
+ self.task_text = self.config.get('task_text')
104
+ self.uses_previous = bool(getattr(self.model, 'lead_rows', 0))
105
+
106
+ def info(self) -> dict:
107
+ out = dict(model=self.name, checkpoint=self.checkpoint, step=self.config.get('step'),
108
+ contract=self.contract['name'], views=list(self.cameras), image_hw=list(self.image_hw),
109
+ action_chunk=self.horizon, action_dim=self.action_dim, state_dim=self.state_dim,
110
+ sampling_steps=self.sampling_steps, task_text=self.task_text,
111
+ training_data=self.config.get('dataset', {}).get('name'))
112
+ if self.name == 'flash':
113
+ out['flash'] = dict(self.model.flash, history_rows=self.model.history_span)
114
+ if self.uses_previous:
115
+ out['starts_from'] = 'the body part of the row executed at t-1, else the normalized-zero BOS'
116
+ return out
117
+
118
+ def history(self, past_actions, history_valid):
119
+ """FLASH: (history (1, n_history, Da), has_history (1,)) tensors from the executed rows before the query
120
+ (past_actions (N, Da) oldest first, row N-1 = frame t-1; history_valid (N,) a contiguous valid suffix)."""
121
+ from .flash import history_rows
122
+ torch, span = self.torch, self.model.history_span
123
+ rows = np.asarray(past_actions, np.float32)
124
+ valid = np.asarray(history_valid, np.float32).reshape(-1) > 0.5
125
+ if rows.ndim != 2 or rows.shape[1] != self.action_dim or len(valid) != len(rows):
126
+ raise ValueError(f'past_actions {rows.shape} / history_valid {valid.shape}: '
127
+ f'expected (N, {self.action_dim})')
128
+ if len(rows) < span: # fewer rows than the history reaches back: the missing older rows are invalid
129
+ pad = span - len(rows)
130
+ rows = np.concatenate([np.zeros((pad, rows.shape[1]), np.float32), rows])
131
+ valid = np.concatenate([np.zeros(pad, bool), valid])
132
+ hist, has = history_rows(rows[-span:], valid[-span:], self.model.stride, self.model.n_history)
133
+ return (torch.from_numpy(hist)[None].to(self.device),
134
+ torch.tensor([bool(has)], device=self.device))
135
+
136
+ def images_tensor(self, images: dict):
137
+ from .data import resize_frame
138
+ missing = [c for c in self.cameras if c not in images]
139
+ if missing:
140
+ raise KeyError(f'missing cameras {missing}; the checkpoint reads {list(self.cameras)}')
141
+ frames = np.stack([resize_frame(np.asarray(images[c]), self.image_hw) for c in self.cameras])
142
+ x = self.torch.from_numpy(frames).to(self.device).permute(0, 3, 1, 2).float().div_(255.)
143
+ return x.unsqueeze(0) # (1, n_cameras, 3, h, w)
144
+
145
+ def predict(self, images: dict, state, seed: int = 0, previous=None, past_actions=None, history_valid=None):
146
+ """(action (horizon, action_dim) float32 physical, normalized form (FLASH: the polynomial coefficients)).
147
+ The ODE policies (`uses_previous`) start from `previous`, the physical action row executed at the frame before
148
+ (else the last row of past_actions when history_valid marks it; with neither, their BOS). FLASH needs
149
+ past_actions / history_valid (the interface's executed rows before the query). The others ignore all three."""
150
+ torch = self.torch
151
+ state = np.asarray(state, np.float32).reshape(-1)
152
+ if state.shape != (self.state_dim,) or not np.isfinite(state).all():
153
+ raise ValueError(f'expected a finite state of {self.state_dim} values, got {state.shape}')
154
+ args, kwargs = (), {}
155
+ if self.uses_previous:
156
+ if previous is None and past_actions is not None and history_valid is not None:
157
+ valid = np.asarray(history_valid, np.float32).reshape(-1)
158
+ if len(valid) and valid[-1] > 0.5:
159
+ previous = np.asarray(past_actions, np.float32)[-1]
160
+ if previous is not None:
161
+ previous = np.asarray(previous, np.float32).reshape(-1)
162
+ if previous.shape != (self.action_dim,) or not np.isfinite(previous).all():
163
+ raise ValueError(f'expected a finite previous action row of {self.action_dim} values, '
164
+ f'got {previous.shape}')
165
+ kwargs['previous'] = torch.from_numpy(previous)[None].to(self.device)
166
+ if self.name == 'flash':
167
+ if past_actions is None or history_valid is None:
168
+ raise ValueError('FLASH needs past_actions and history_valid (the executed rows before the query)')
169
+ args = self.history(past_actions, history_valid)
170
+ generator = torch.Generator(device=self.device)
171
+ generator.manual_seed(int(seed) % (2 ** 63 - 1))
172
+ with torch.inference_mode():
173
+ action, raw = self.model.predict(self.images_tensor(images),
174
+ torch.from_numpy(state)[None].to(self.device), *args,
175
+ generator=generator, **kwargs)
176
+ action = action[0].float().cpu().numpy()
177
+ if action.shape != (self.horizon, self.action_dim) or not np.isfinite(action).all():
178
+ raise ValueError(f'invalid prediction {action.shape}')
179
+ return np.ascontiguousarray(action, np.float32), raw[0].float().cpu().numpy().astype(np.float32)
b8-table-wipe/b512-cont-20261117-stop50k/step-050000/training_records/code_hb_bai_433ba198_stopat39f9b83a/evaluation/baselines/train.py ADDED
@@ -0,0 +1,974 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Train an FM-DiT, DP (DDPM-DiT), ACT, FLASH, ODE-MLP or ODE-DiT baseline on a task's LeRobot v2.1 expert dataset.
2
+
3
+ <baselines env>/bin/python -I evaluation/baselines/train.py --policy fm_dit --contract h2_sharpa \\
4
+ --dataset data/h2_pour_water/h2_pour_water_r1/lerobot --out <run dir> --steps 60000
5
+
6
+ The recipe is DextraVerse's shared IL recipe (configs/algorithm/il/train.yaml; runners/train_dex_flow_matching.py):
7
+ AdamW (lr 1e-4, betas 0.95/0.999, weight decay 1e-6), cosine decay (here after a 500-step linear warm-up, as
8
+ Diffusion Policy), whole-policy EMA (Diffusion Policy's warm-up schedule, max decay 0.9999) whose weights are the
9
+ saved checkpoint, batch 64, one observation frame and 16-row chunks. Added for the humanoid views: frames resized
10
+ to 168x224 (the 480x640 aspect). bf16 autocast on CUDA.
11
+
12
+ FM-DiT v2 (--policy fm_dit_v2, evaluation/baselines/fm_dit_v2.py; owner 2026-11-25) is FLASH-Policy's own FM-DiT:
13
+ fm_dit.yaml's networks and the FLASH recipe below (FM_DIT_V2_TRAINING), on the plain 16-row chunks of every baseline;
14
+ it requires the in-training MSE as FLASH does. `--policy fm_dit` (v1, DextraVerse's) is unchanged.
15
+
16
+ FLASH (--policy flash, evaluation/baselines/flash.py) keeps its upstream recipe (FLASH-Policy f47e490,
17
+ default_train.yaml + flash.yaml) where the defaults differ: seed 42 (upstream's; the protocol keeps each model's
18
+ official seed), ResNet18 from scratch with GroupNorm trained at the full learning rate (--backbone-weights none,
19
+ --backbone-lr-scale 1), diffusers' cosine schedule with a 500-step warm-up, Diffusion Policy's EMAModel decay as
20
+ upstream counts it, and its own items (FlashChunkDataset: the polynomial targets at the sampling stride, the executed
21
+ history). --flash KEY=VALUE changes a FLASH setting (flash.FLASH_DEFAULTS: stride, n_history, ...). Its augmentation
22
+ stream is seeded from the training seed, as every model's (ChunkDataset aug_seed; logged as HB_AUG_SEED=<seed>).
23
+
24
+ ODE-MLP / ODE-DiT (--policy ode_mlp / ode_dit, policies.ODEPolicy) keep their G1 port's choices
25
+ (policies.POLICY_DEFAULTS): 16-row chunks, the ODE head in FP32, their own normalization bounds (q01 / q99 of the
26
+ training rows, the DFX6 hands fixed at [0, 1]: stats q01 / q99 / unit_dims), the body part = the contract's first
27
+ action group, the encoder from scratch at the full learning rate, seed 42 (ODE Policy's default_train.yaml, whose
28
+ optimizer, schedule and EMA are the recipe above). Their items carry the row before t and the rows' validity
29
+ (ChunkDataset lead 1).
30
+
31
+ Augmentation (2026-11-16): the Humanoid Benchmark spec v2 (docs/augmentation_v2.md, evaluation/augmentation), the
32
+ same for every model of the benchmark, is on by default (--augmentation hb-v2): per training item one hb_aug_v2 call
33
+ on the cached 168x224 frames of all cameras (colour shared, geometry / light patches / white balance per camera, one
34
+ of the 15 effects boosted 1.5 x) and the per-sample joint bias (+-2 deg) + noise (0.25 deg, clipped 3 sigma) on the
35
+ body joint angles of the raw state (G1 29, H2 31), before the policy's normalizers; actions untouched. The native
36
+ random shift is off (--shift 0; a shift with hb-v2 is refused). Before the first step a preflight reads training items
37
+ through the augmented and the plain path and checks the state width (G1 44 / H2 78, no velocity), that only the body
38
+ joints move and by at most 2.75 deg, that the action rows (and FLASH's history) are bit-identical, that the images
39
+ change, and that the offline-check items are deterministic; it is stored in run.json (--preflight-only stops after it).
40
+ --augmentation none is an explicit exception to the spec, recorded in run.json and the checkpoints. The ResNet18
41
+ starts from torchvision's ImageNet-1k weights (--backbone-weights IMAGENET1K_V1, downloaded once to the torch hub
42
+ cache) and is fine-tuned at 0.1 x the learning rate (--backbone-lr-scale, the DETR practice) with its BatchNorm
43
+ frozen; --backbone-weights none trains it from scratch (DextraVerse's GroupNorm encoder for FM-DiT and DP).
44
+
45
+ In-training MSE (owner 2026-11-22, HumanWAM hb_training/REPRODUCIBILITY.md section 6): --inloop-task <key> with
46
+ --inloop-code <HumanWAM hb_training/eval-action-mse> evaluates the saved (EMA) weights every HB_INLOOP_EVERY (250)
47
+ steps on the protocol's cached episodes (inloop.py) into <out>/logs/inloop-mse.jsonl. FLASH refuses to train without
48
+ it unless --allow-no-inloop (an exception to the protocol, recorded in run.json); so do the ODE policies.
49
+
50
+ Writes into --out: run.json (arguments), train_log.jsonl, checkpoints/step-NNNNNN/ at the save points (runtime.py
51
+ format; owner 2026-11-27, every small model: 6 checkpoints spread evenly over the run's steps, each rounded to the
52
+ in-training MSE's 250-step grid, the last one at the end; save_points()), checkpoints/final -> the last one, and
53
+ train_state.pt (optimizer, schedule, EMA, step) that
54
+ --resume continues from (an interrupted run: the same schedule, not a continuation). --stop-at TOTAL ends the run early
55
+ at that total step (owner 2026-11-30, a fixed-step early stop): one extra checkpoint and train_state.pt there,
56
+ stopped.json instead of complete.json; the learning-rate curve and the other save points stay those of --steps, so a
57
+ later --resume without --stop-at continues the same run. Each save also measures the EMA
58
+ policy offline on fixed frames (held-out episodes with --val-episodes, else training frames): normalized-action MSE
59
+ overall and per action group.
60
+
61
+ Protocol and reproducibility (owner 2026-11-27, aligned with HumanWAM hb_training/protocol.yaml): the batch, steps
62
+ (long tasks x2), warm-up, workers and seed default to the protocol recipe of the policy (PROTOCOL_RECIPES); another
63
+ value, --save-every, a dataset not at 30 Hz or training without the in-training MSE (now required for every model) is
64
+ refused unless --protocol-exception / --allow-no-inloop records the owner's decision; uncommitted changes under
65
+ evaluation/ are refused unless --allow-dirty-tree. The order is EpochSampler's (epoch e: default_rng([seed, 1, e])),
66
+ each item augmented with default_rng([aug_seed, draw]) (its position in the run's stream), so worker count and an
67
+ interruption change nothing: train_state.pt keeps the torch / CUDA / numpy / python random states and --resume
68
+ continues bit-exactly. config.json and each protocol.json record the task, the dataset id (--dataset-id REPO@COMMIT
69
+ or inferred from <name>-<commit>/data), the save points, the environment (Python, torch, torchvision, numpy, Pillow,
70
+ CUDA, cuDNN, GPU, driver), the sha256 of hb_aug_v2.py and of the in-training MSE code, and the deviations.
71
+
72
+ Continuation (owner 2026-11-27, HumanWAM hb_training/protocol.yaml interface.continuation, as FastWAM's
73
+ hb_fastwam_cont.py): --init-from <run>/checkpoints/step-NNNNNN into a new --out loads that run's weights only (raw policy
74
+ and EMA from its train_state.pt when written at that step, else the saved EMA weights for both), then trains --steps
75
+ more steps with a fresh AdamW and schedule: peak --lr = 0.3 x the original peak (a peak equal to or above it is
76
+ refused without --continuation-exception; owner 2026-11-28: the long FM-DiT v1 continuations to the scaled step
77
+ count use the from-scratch peak and warm-up), --warmup = 5 % of --steps, then the policy's cosine. Same policy configuration, data, augmentation and seed
78
+ (checked). Checkpoints are named by the total step (e.g. a 12000-step run continued 2000 steps saves step-014000);
79
+ train_log, in-training MSE and the EMA decay also count the total steps; config.json training.continuation records
80
+ the source checkpoint (path, step, model.pt sha256, code commit) and the continuation's learning rate.
81
+ Owner 2026-11-28: with --continuation-exception a g1_sonic_dfx6 run (measured hands) may be continued as g1_sonic_cmd
82
+ (the commanded hands; same state, cameras and 76 values): the weights are loaded, then the state and action normalizers
83
+ are re-fit on this run's data (its config.json stats). A source checkpoint written by the collaborator's own
84
+ --init-from runs (028df1bb format: training.init_from.step) counts that parent step into the total.
85
+ """
86
+ from __future__ import annotations
87
+
88
+ import argparse
89
+ import copy
90
+ from datetime import datetime, timezone
91
+ import json
92
+ import math
93
+ import os
94
+ from pathlib import Path
95
+ import subprocess
96
+ import sys
97
+ import time
98
+
99
+ import numpy as np
100
+
101
+ HERE = Path(__file__).resolve().parent
102
+ REPO = HERE.parents[1]
103
+ if str(HERE.parent) not in sys.path:
104
+ sys.path.insert(0, str(HERE.parent))
105
+
106
+ from baselines.data import (CONTRACTS, ChunkDataset, FlashChunkDataset, LeRobotDataset, # noqa: E402
107
+ augmentation_module, frame_cache, load_lowdim, parse_episodes, statistics,
108
+ unit_range_dims)
109
+ from baselines.flash import FLASH_DEFAULTS, FLASH_POLICY_FIELDS # noqa: E402
110
+ from baselines.fm_dit_v2 import FM_DIT_V2_POLICY_FIELDS, UPSTREAM as FM_DIT_V2_UPSTREAM # noqa: E402
111
+ from baselines.policies import ODE_POLICIES, POLICIES, POLICY_DEFAULTS, PolicyConfig, build_policy # noqa: E402
112
+ from baselines.runtime import save_checkpoint # noqa: E402
113
+
114
+ DEFAULTS = dict(lr=1e-4, betas=(0.95, 0.999), weight_decay=1e-6, warmup=500, ema=0.9999, batch_size=64,
115
+ horizon=16, backbone_weights='IMAGENET1K_V1', backbone_lr_scale=0.1, seed=0, amp=True)
116
+ # FLASH-Policy f47e490 default_train.yaml / flash.yaml where they differ from DEFAULTS
117
+ FLASH_TRAINING = dict(seed=42, backbone_weights=None, backbone_lr_scale=1.0, schedule='diffusers_cosine',
118
+ ema_schedule='diffusion_policy_emamodel')
119
+ # FM-DiT v2 (fm_dit_v2.py): FLASH-Policy's FM-DiT trains with the same default_train.yaml
120
+ FM_DIT_V2_TRAINING = dict(FLASH_TRAINING)
121
+ # HumanWAM hb_training/protocol.yaml models.* (owner 2026-11-27: hb_baselines trains exactly the protocol's recipe; any
122
+ # other value is refused unless --protocol-exception records the owner's decision): the global batch (1 GPU), the
123
+ # steps of a training from scratch (long tasks x LONG_TASKS), the warm-up and the DataLoader workers. FM-DiT v1 and DP
124
+ # have no registered recipe (the collaborator's; FM-DiT v1 is superseded by v2): only the batch is checked for them.
125
+ PROTOCOL_RECIPES = {
126
+ 'act': dict(batch_size=512, steps=4000, warmup=200, workers=32),
127
+ 'flash': dict(batch_size=512, steps=12000, warmup=500, workers=40),
128
+ 'fm_dit_v2': dict(batch_size=512, steps=12000, warmup=500, workers=32),
129
+ 'ode_mlp': dict(batch_size=512, steps=5000, warmup=500, workers=32),
130
+ 'ode_dit': dict(batch_size=512, steps=5000, warmup=500, workers=32),
131
+ 'fm_dit': dict(batch_size=512),
132
+ 'dp': dict(batch_size=512),
133
+ }
134
+ LONG_TASKS = {'c6': 2} # protocol.yaml interface.long_task_step_factor (A14 is not doubled)
135
+ DATASET_FPS = 30 # every dataset, training and evaluation (owner 2026-11-26)
136
+
137
+
138
+ def training_defaults(policy: str) -> dict:
139
+ """DEFAULTS with the policy's own: FLASH_TRAINING (flash), FM_DIT_V2_TRAINING (fm_dit_v2),
140
+ policies.POLICY_DEFAULTS (the ODE policies)."""
141
+ # FM-DiT v1: seed 42 for every training from 2026-11-27 (owner: one seed per model, kept on every training;
142
+ # FM-DiT uses 42 as fm_dit_v2 / FLASH; its published seed-0 folders stay as recorded)
143
+ own = {'flash': FLASH_TRAINING, 'fm_dit_v2': FM_DIT_V2_TRAINING, 'fm_dit': dict(seed=42)}.get(policy, {})
144
+ return dict(DEFAULTS, **own, **POLICY_DEFAULTS.get(policy, {}))
145
+
146
+
147
+ def policy_default(policy: str, key: str):
148
+ """The training default of `key` for `policy`."""
149
+ return training_defaults(policy)[key]
150
+
151
+
152
+ def same_policy_config(saved: dict, current: dict) -> bool:
153
+ """A saved policy configuration matches the current one; a field added to PolicyConfig after the save (absent
154
+ from it) matches when the current value is that field's default (e.g. the ode_* fields for an older FM-DiT run)."""
155
+ from dataclasses import MISSING, fields
156
+ defaults = {f.name: f.default for f in fields(PolicyConfig) if f.default is not MISSING}
157
+ return all(saved[k] == v if k in saved else (k in defaults and defaults[k] == v) for k, v in current.items()) \
158
+ and set(saved) <= set(current)
159
+
160
+
161
+ def git_commit():
162
+ """The code's commit: git HEAD, or outside a checkout (a tree copied file by file, e.g. onto the A800 NAS, which
163
+ cannot reach the private repository) the commit in <repo>/HB_CODE_COMMIT that the copier wrote and checked."""
164
+ try:
165
+ return subprocess.run(['git', '-C', str(REPO), 'rev-parse', 'HEAD'], capture_output=True, text=True,
166
+ check=True).stdout.strip()
167
+ except Exception: # noqa: BLE001 - outside a checkout
168
+ import re
169
+ try:
170
+ m = re.search(r'\b[0-9a-f]{7,40}\b', (REPO / 'HB_CODE_COMMIT').read_text())
171
+ except OSError:
172
+ return None
173
+ return m.group(0) if m else None
174
+
175
+
176
+ def git_dirty():
177
+ """The uncommitted changes of the code a run trains with (evaluation/), [] when clean, None outside a checkout:
178
+ the recorded code_commit is that code only when the tree is clean."""
179
+ try:
180
+ out = subprocess.run(['git', '-C', str(REPO), 'status', '--porcelain', '--', 'evaluation'],
181
+ capture_output=True, text=True, check=True).stdout
182
+ except Exception: # noqa: BLE001 - outside a checkout
183
+ return None
184
+ return [line[3:] for line in out.splitlines() if line.strip()]
185
+
186
+
187
+ def file_sha256(path):
188
+ import hashlib
189
+ try:
190
+ return hashlib.sha256(Path(path).read_bytes()).hexdigest()
191
+ except OSError:
192
+ return None
193
+
194
+
195
+ def environment(device):
196
+ """The versions that change the numerics (REPRODUCIBILITY.md principle 5): Python, torch, torchvision, numpy,
197
+ Pillow (the JPEG effect of the augmentation), CUDA, cuDNN, the GPU and its driver."""
198
+ import platform
199
+ import torch
200
+ env = dict(python=platform.python_version(), torch=torch.__version__, numpy=np.__version__,
201
+ cuda=torch.version.cuda,
202
+ cudnn=torch.backends.cudnn.version() if torch.backends.cudnn.is_available() else None)
203
+ for name, module in (('torchvision', 'torchvision'), ('pillow', 'PIL')):
204
+ try:
205
+ env[name] = __import__(module).__version__
206
+ except Exception: # noqa: BLE001
207
+ env[name] = None
208
+ if device.type == 'cuda':
209
+ env['gpu'] = torch.cuda.get_device_name(device)
210
+ try:
211
+ env['driver'] = subprocess.run(['nvidia-smi', '--query-gpu=driver_version', '--format=csv,noheader',
212
+ '-i', str(device.index or 0)], capture_output=True, text=True,
213
+ timeout=20).stdout.strip() or None
214
+ except Exception: # noqa: BLE001
215
+ env['driver'] = None
216
+ return env
217
+
218
+
219
+ class EpochSampler:
220
+ """The training order (owner 2026-11-27, aligned with HumanWAM's resumable runs): epoch e is the permutation
221
+ numpy default_rng([seed, 1, e]) of the items, cut to whole batches (drop_last); each item comes with its draw
222
+ number (its position in the whole run's stream, e * batches_per_epoch * batch + j), which seeds its augmentation
223
+ (ChunkDataset: default_rng([aug_seed, draw])). Order and augmentations are thus a function of the seed and the
224
+ step only (not of the worker count or of an interruption): start_step skips the batches already trained."""
225
+
226
+ def __init__(self, n, batch_size, seed, start_step=0):
227
+ self.n, self.batch, self.seed = int(n), int(batch_size), int(seed)
228
+ self.per_epoch = self.n // self.batch
229
+ if self.per_epoch < 1:
230
+ raise SystemExit(f'{n} training items: fewer than one batch of {batch_size}')
231
+ self.epoch, self.offset = divmod(int(start_step), self.per_epoch)
232
+
233
+ def __len__(self):
234
+ return (self.per_epoch - self.offset) * self.batch
235
+
236
+ def __iter__(self):
237
+ perm = np.random.default_rng([self.seed, 1, self.epoch]).permutation(self.n)
238
+ base = self.epoch * self.per_epoch * self.batch
239
+ start = self.offset * self.batch
240
+ self.epoch, self.offset = self.epoch + 1, 0
241
+ for j in range(start, self.per_epoch * self.batch):
242
+ yield int(perm[j]), base + j
243
+
244
+
245
+ def rng_state():
246
+ import random
247
+ import torch
248
+ return dict(torch=torch.get_rng_state(), cuda=torch.cuda.get_rng_state_all() if torch.cuda.is_available() else None,
249
+ numpy=np.random.get_state(), python=random.getstate())
250
+
251
+
252
+ def set_rng_state(state):
253
+ import random
254
+ import torch
255
+ torch.set_rng_state(state['torch'])
256
+ if state.get('cuda') is not None and torch.cuda.is_available():
257
+ torch.cuda.set_rng_state_all(state['cuda'])
258
+ np.random.set_state(state['numpy'])
259
+ random.setstate(state['python'])
260
+
261
+
262
+ def parse_hw(text):
263
+ h, w = text.lower().split('x')
264
+ return int(h), int(w)
265
+
266
+
267
+ def random_shift(images, pad):
268
+ """DrQ random shift: replicate-pad by `pad` pixels and crop back at a random offset per sample.
269
+ images (B, N, 3, H, W) float."""
270
+ import torch
271
+ import torch.nn.functional as F
272
+ if pad <= 0:
273
+ return images
274
+ B, N, C, H, W = images.shape
275
+ x = F.pad(images.reshape(B * N, C, H, W), (pad,) * 4, mode='replicate')
276
+ oy = torch.randint(0, 2 * pad + 1, (B * N,), device=images.device)
277
+ ox = torch.randint(0, 2 * pad + 1, (B * N,), device=images.device)
278
+ rows = (oy[:, None] + torch.arange(H, device=images.device)[None])[:, None, :, None].expand(-1, C, -1, W + 2 * pad)
279
+ x = x.gather(2, rows)
280
+ cols = (ox[:, None] + torch.arange(W, device=images.device)[None])[:, None, None, :].expand(-1, C, H, -1)
281
+ return x.gather(3, cols).reshape(B, N, C, H, W)
282
+
283
+
284
+ class EMA:
285
+ """Diffusion Policy's EMAModel schedule: decay = min(max_decay, 1 - (1 + step) ** -0.75), parameters averaged,
286
+ buffers (normalizers) copied. schedule 'diffusion_policy_emamodel' counts the steps as upstream's EMAModel does
287
+ (decay 0 for the first two updates, then 1 - (step - 1) ** -0.75; FLASH)."""
288
+
289
+ def __init__(self, model, max_decay, schedule='hb'):
290
+ self.model = copy.deepcopy(model).eval().requires_grad_(False)
291
+ self.max_decay = float(max_decay)
292
+ self.schedule = schedule
293
+
294
+ def decay(self, step):
295
+ if self.schedule == 'diffusion_policy_emamodel':
296
+ return 0.0 if step <= 2 else min(self.max_decay, max(0.0, 1 - (step - 1) ** -0.75))
297
+ return 0.0 if step <= 0 else min(self.max_decay, max(0.0, 1 - (1 + step) ** -0.75))
298
+
299
+ def update(self, model, step):
300
+ import torch
301
+ decay = self.decay(step)
302
+ with torch.no_grad():
303
+ for e, p in zip(self.model.parameters(), model.parameters()):
304
+ e.mul_(decay).add_(p.detach(), alpha=1 - decay)
305
+ for e, b in zip(self.model.buffers(), model.buffers()):
306
+ e.copy_(b)
307
+ return decay
308
+
309
+
310
+ def preflight(train_set, eval_set, contract, samples=64, seed=0) -> dict:
311
+ """Training items of `train_set` (augmented unless its body_dims is 0) against the same frames read without
312
+ augmentation, and two reads of the offline-check items; raises on any violation of docs/augmentation_v2.md.
313
+ Items are (images, state, *labels): every label (action rows; FLASH's polynomial rows and history) must be
314
+ bit-identical to the plain read."""
315
+ import torch
316
+ plain = train_set.plain() # the same frames without augmentation
317
+ picks = np.random.default_rng(seed).choice(len(plain), size=min(samples, len(plain)), replace=False)
318
+ nb, sd = train_set.body_dims, contract.state_dim
319
+ limit = augmentation_module().max_body_offset_rad() * (1 + 1e-5)
320
+ images_changed = body_moved = 0
321
+ worst = 0.0
322
+ for k in picks:
323
+ (im, st, *lab), (im0, st0, *lab0) = train_set[int(k)], plain[int(k)]
324
+ if st.shape != (sd,) or st0.shape != (sd,) or [x.shape for x in lab] != [x.shape for x in lab0]:
325
+ raise SystemExit(f'preflight: state {tuple(st.shape)} / labels {[tuple(x.shape) for x in lab]}, '
326
+ f'expected ({sd},)')
327
+ if not all(torch.equal(a, b) for a, b in zip(lab, lab0)):
328
+ raise SystemExit('preflight: an action label differs from the recorded data')
329
+ if not torch.equal(st[nb:], st0[nb:]):
330
+ raise SystemExit(f'preflight: a state value past the {nb} body joints changed')
331
+ delta = (st[:nb].double() - st0[:nb].double()).abs()
332
+ if nb:
333
+ worst = max(worst, float(delta.max()))
334
+ if worst > limit:
335
+ raise SystemExit(f'preflight: a body joint moved {math.degrees(worst):.3f} deg (> 2.75)')
336
+ body_moved += int((delta > 0).sum())
337
+ images_changed += int(not torch.equal(im, im0))
338
+ n = len(picks)
339
+ moved = body_moved / max(1, n * nb)
340
+ if nb and (images_changed < 0.9 * n or moved < 0.95):
341
+ raise SystemExit(f'preflight: augmentation inactive ({images_changed}/{n} images changed, {moved:.3f} of the '
342
+ 'body joint values moved)')
343
+ if not nb and (images_changed or worst):
344
+ raise SystemExit('preflight: items changed with the augmentation off')
345
+ eval_picks = np.random.default_rng(seed + 1).choice(len(eval_set), size=min(8, len(eval_set)), replace=False)
346
+ for k in eval_picks:
347
+ a, b = eval_set[int(k)], eval_set[int(k)]
348
+ if eval_set.body_dims or not all(torch.equal(x, y) for x, y in zip(a, b)):
349
+ raise SystemExit('preflight: the offline-check items are not deterministic')
350
+ return dict(samples=n, state_dim=sd, body_dims=nb, images_changed=images_changed,
351
+ body_values_moved=round(moved, 4),
352
+ max_body_offset_deg=round(math.degrees(worst), 4), actions_bit_identical=True,
353
+ non_body_state_bit_identical=True, eval_items_deterministic=len(eval_picks))
354
+
355
+
356
+ def offline_eval(policy, dataset, samples, device, groups):
357
+ """Normalized-action MSE of policy.predict on fixed dataset items (seeded), overall and per action group. FLASH:
358
+ its 30 Hz output rows against the recorded rows from the anchor (rows past the episode's end left out). A policy
359
+ with lead rows (ODE) starts from the recorded row before the frame (its BOS at an episode's first frame), as from
360
+ the executed row in closed loop, and is scored on the valid rows."""
361
+ import torch
362
+ policy.eval()
363
+ errs, masks = [], []
364
+ generator = torch.Generator(device=device)
365
+ generator.manual_seed(0)
366
+ lead = int(getattr(policy, 'lead_rows', 0))
367
+ for start in range(0, len(samples), 32):
368
+ batch = [dataset[int(k)] for k in samples[start:start + 32]]
369
+ images = torch.stack([b[0] for b in batch]).to(device).permute(0, 1, 4, 2, 3).float().div_(255.)
370
+ state = torch.stack([b[1] for b in batch]).to(device)
371
+ if policy.name == 'flash':
372
+ hist = torch.stack([b[3] for b in batch]).to(device)
373
+ has = torch.stack([b[4] for b in batch]).to(device)
374
+ target = torch.stack([b[5] for b in batch]).to(device)
375
+ valid = torch.stack([b[6] for b in batch]).numpy()
376
+ pred, _ = policy.predict(images, state, hist, has, generator=generator)
377
+ raw = policy.action_norm.normalize(pred.float())
378
+ elif lead:
379
+ rows = torch.stack([b[2] for b in batch]).to(device)
380
+ row_valid = torch.stack([b[3] for b in batch])
381
+ previous, target = rows[:, lead - 1], rows[:, lead:]
382
+ valid = (row_valid[:, lead:] > 0).numpy()
383
+ _, raw = policy.predict(images, state, generator=generator, previous=previous,
384
+ has_previous=(row_valid[:, lead - 1] > 0).to(device))
385
+ else:
386
+ target = torch.stack([b[2] for b in batch]).to(device)
387
+ valid = np.ones(target.shape[:2], bool)
388
+ _, raw = policy.predict(images, state, generator=generator)
389
+ errs.append((raw.float() - policy.action_norm.normalize(target)).pow(2).cpu().numpy())
390
+ masks.append(valid)
391
+ err, mask = np.concatenate(errs), np.concatenate(masks) # (S, horizon, action_dim), (S, horizon)
392
+ rows = err[mask]
393
+ out = dict(mse=float(rows.mean()), mse_row0=float(err[:, 0][mask[:, 0]].mean()))
394
+ offset = 0
395
+ for column, start, end in groups:
396
+ out[f'mse_{column.split(".")[-1]}'] = float(rows[:, offset:offset + end - start].mean())
397
+ offset += end - start
398
+ return out
399
+
400
+
401
+ SAVE_COUNT = 6 # owner 2026-11-27: small models keep 6 checkpoints per training, spread evenly over its steps
402
+ SAVE_GRID = 250 # the in-training MSE's interval: every save point has its nMSE
403
+
404
+
405
+ def save_points(steps: int, every=None) -> list:
406
+ """The run's own steps (1..steps) at which it saves: k * steps / 6 for k = 1..6 rounded to the 250-step grid
407
+ (the last one is always `steps`); with `every` (a recorded deviation) every multiple of it and the end."""
408
+ if every:
409
+ return sorted({*range(every, steps + 1, every), steps})
410
+ if steps < SAVE_COUNT * SAVE_GRID:
411
+ return sorted({max(1, round(k * steps / SAVE_COUNT)) for k in range(1, SAVE_COUNT + 1)})
412
+ return sorted({min(steps, max(SAVE_GRID, SAVE_GRID * round(k * steps / SAVE_COUNT / SAVE_GRID)))
413
+ for k in range(1, SAVE_COUNT)} | {steps})
414
+
415
+
416
+ def init_continuation(args, policy, ema, pcfg, contract, cameras, hw, augmentation, train_episodes, out, stats):
417
+ """--init-from (owner 2026-11-27: aligned with HumanWAM's continuation, hb_training/protocol.yaml
418
+ interface.continuation and fastwam_tools/hb_fastwam_cont.py): load only the weights of a finished run's checkpoint
419
+ into the freshly built policy (and EMA) before training; the optimizer and the schedule start new. The run it
420
+ continues must have the same policy configuration, contract, cameras, image size, augmentation and training
421
+ episodes, and the continuation's peak learning rate must be below the original one (REPRODUCIBILITY.md: a
422
+ continuation never reuses the original peak) unless --continuation-exception records the owner's decision (owner
423
+ 2026-11-28: long FM-DiT v1 continuations use the from-scratch peak). Returns (record for config.training.continuation, original steps)."""
424
+ import torch
425
+ from baselines.runtime import sha256 as file_sha256
426
+ src = args.init_from.expanduser().resolve()
427
+ if not (src / 'model.pt').is_file() or not (src / 'config.json').is_file():
428
+ raise SystemExit(f'--init-from {src}: not a checkpoint folder (model.pt, config.json)')
429
+ if src.parent.parent == out:
430
+ raise SystemExit('--init-from: give the continuation its own --out (the original run stays as it is)')
431
+ before = json.loads((src / 'config.json').read_text())
432
+ problems = []
433
+ if not same_policy_config(before['policy'], pcfg.to_dict()):
434
+ problems.append('policy configuration')
435
+ hands_switch = False # owner 2026-11-28: a measured-hand G1 run continued on the commanded hands
436
+ if before['contract'] != contract.to_dict(cameras):
437
+ saved_c, want_c = before['contract'], contract.to_dict(cameras)
438
+ same_io = all(saved_c.get(k) == want_c.get(k) for k in ('robot', 'cameras', 'state', 'state_dim', 'action_dim',
439
+ 'action_space', 'body_dims'))
440
+ if (saved_c.get('name'), want_c['name']) == ('g1_sonic_dfx6', 'g1_sonic_cmd') and same_io and args.continuation_exception:
441
+ hands_switch = True
442
+ else:
443
+ problems.append('contract / cameras')
444
+ if list(before['image_hw']) != list(hw):
445
+ problems.append('image size')
446
+ if (before['training'].get('augmentation') or {}).get('version') != augmentation.get('version') \
447
+ or before['training'].get('shift_px') != args.shift:
448
+ problems.append('augmentation')
449
+ if list(before['dataset']['train_episodes']) != list(train_episodes):
450
+ problems.append('training episodes')
451
+ if problems:
452
+ raise SystemExit(f'--init-from {src}: the run differs in {", ".join(problems)}; a continuation trains the '
453
+ 'same model on the same data')
454
+ original_lr = float(before['training']['lr'])
455
+ if not args.lr < original_lr and not args.continuation_exception:
456
+ raise SystemExit(f'--init-from: --lr {args.lr} must be below the original peak {original_lr} (the protocol: '
457
+ f'0.3 x, i.e. {0.3 * original_lr:g})')
458
+ step0 = int(before['step'])
459
+ parent = (before['training'].get('init_from') or {}) if not before['training'].get('continuation') else {}
460
+ if isinstance(parent, dict) and parent.get('step') is not None:
461
+ # a checkpoint of the collaborator's own --init-from runs (028df1bb format): its 'step' counts that run only
462
+ step0 += int(parent['step'])
463
+ state_file = src.parent.parent / 'train_state.pt'
464
+ saved = torch.load(state_file, map_location='cpu', weights_only=False) if state_file.is_file() else None
465
+ total_saved = None # the total step train_state.pt was written at (its 'step' counts the run's own steps)
466
+ if saved is not None:
467
+ c = (saved['config'].get('training') or {}).get('continuation') or {}
468
+ total_saved = int(c.get('init_step', 0)) + int(saved['step'])
469
+ if saved is not None and total_saved == step0:
470
+ policy.load_state_dict(saved['policy'], strict=True)
471
+ if ema is not None:
472
+ if saved.get('ema') is None:
473
+ raise SystemExit(f'--init-from: {state_file} has no EMA weights')
474
+ ema.model.load_state_dict(saved['ema'], strict=True)
475
+ weights = f'raw policy and EMA from {state_file} (written at step {step0})'
476
+ else:
477
+ payload = torch.load(src / 'model.pt', map_location='cpu', weights_only=True)
478
+ policy.load_state_dict(payload['state_dict'], strict=True)
479
+ if ema is not None:
480
+ ema.model.load_state_dict(payload['state_dict'], strict=True)
481
+ weights = (f'the saved {before.get("weights", "ema")} weights of {src.name} for the policy and its EMA '
482
+ f'(no train_state.pt written at step {step0})')
483
+ if hands_switch: # the action normalizer follows this run's (commanded-hand) data, as its config.json stats
484
+ policy.fit_normalizers(stats)
485
+ if ema is not None:
486
+ ema.model.fit_normalizers(stats)
487
+ policy.to(next(policy.parameters()).device)
488
+ record = dict(init_from=str(src), init_step=step0, init_weights=weights, init_model_sha256=file_sha256(src / 'model.pt'),
489
+ init_code_commit=before.get('code_commit'), original_peak_lr=original_lr, peak_lr=args.lr,
490
+ peak_lr_factor=round(args.lr / original_lr, 6), warmup_steps=args.warmup,
491
+ warmup_ratio=round(args.warmup / max(1, args.steps), 6), more_steps=args.steps,
492
+ total_steps=step0 + args.steps, optimizer='fresh AdamW (same groups, betas, weight decay)',
493
+ schedule='fresh: warm-up then the policy\'s cosine over the continuation steps',
494
+ ema_decay_steps='total steps (the EMA keeps averaging as in the original run)',
495
+ init_contract=before['contract'].get('name'),
496
+ hands_switch=('measured -> commanded hands (owner 2026-11-28); state and action normalizers '
497
+ 're-fit on the data of this run') if hands_switch else None)
498
+ print(json.dumps(dict(event='continuation', **record)), flush=True)
499
+ return record, step0
500
+
501
+
502
+ def main():
503
+ p = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter)
504
+ p.add_argument('--policy', choices=sorted(POLICIES), required=True)
505
+ p.add_argument('--dataset', type=Path, required=True, help='LeRobot v2.1 dataset directory')
506
+ p.add_argument('--contract', choices=sorted(CONTRACTS), required=True)
507
+ p.add_argument('--cameras', help='comma-separated cameras (default: the contract\'s)')
508
+ p.add_argument('--episodes', help="episodes to use, e.g. '0:100' (default: all)")
509
+ p.add_argument('--val-episodes', type=int, default=0, help='hold out the last N of them for the offline check')
510
+ p.add_argument('--out', type=Path, required=True)
511
+ p.add_argument('--steps', type=int, default=None,
512
+ help="training steps (default: the protocol recipe's, long tasks x2; with --init-from 2000)")
513
+ p.add_argument('--batch-size', type=int, default=None, help="batch (default: the protocol recipe's, 512)")
514
+ p.add_argument('--dataset-id', metavar='REPO@COMMIT',
515
+ help='the HF dataset and revision the --dataset directory holds (recorded; default: inferred from '
516
+ 'a directory named <name>-<commit>/data)')
517
+ p.add_argument('--allow-dirty-tree', action='store_true',
518
+ help='train with uncommitted changes under evaluation/ (recorded; otherwise refused)')
519
+ p.add_argument('--lr', type=float, default=None,
520
+ help=f"peak learning rate (default {DEFAULTS['lr']}; with --init-from 0.3 x the original peak)")
521
+ p.add_argument('--weight-decay', type=float, default=DEFAULTS['weight_decay'])
522
+ p.add_argument('--warmup', type=int, default=None,
523
+ help=f"warm-up steps (default {DEFAULTS['warmup']}; with --init-from 5 %% of --steps)")
524
+ p.add_argument('--ema', type=float, default=DEFAULTS['ema'], help='max EMA decay; 0 saves the raw weights')
525
+ p.add_argument('--horizon', type=int, default=None,
526
+ help="action rows per chunk (default: the policy's; 16; FLASH: --flash rows)")
527
+ p.add_argument('--image-size', default='168x224', help='HxW of the policy images')
528
+ p.add_argument('--augmentation', choices=['hb-v2', 'none'], default='hb-v2',
529
+ help='training augmentation: the benchmark spec v2 (default; docs/augmentation_v2.md) or none '
530
+ '(an explicit exception, recorded in run.json)')
531
+ p.add_argument('--shift', type=int, default=0,
532
+ help='native random-shift augmentation in pixels (default 0: off; only with --augmentation none)')
533
+ p.add_argument('--preflight-only', action='store_true', help='run the data preflight, write run.json and stop')
534
+ p.add_argument('--backbone-weights', default=None,
535
+ help="torchvision weights the ResNet18 starts from (default IMAGENET1K_V1; FLASH, ODE: none); "
536
+ "'none': from scratch")
537
+ p.add_argument('--backbone-lr-scale', type=float, default=None,
538
+ help='learning rate of the image backbone relative to --lr (default 0.1; FLASH, ODE: 1)')
539
+ p.add_argument('--model', action='append', default=[], metavar='KEY=VALUE',
540
+ help='override a PolicyConfig field (JSON value), e.g. num_layers=6; repeatable')
541
+ p.add_argument('--flash', action='append', default=[], metavar='KEY=VALUE',
542
+ help='FLASH setting (JSON value), e.g. stride=2; repeatable (flash.FLASH_DEFAULTS)')
543
+ p.add_argument('--cache-dir', type=Path, default=Path('~/hb_models/baselines/cache'))
544
+ p.add_argument('--workers', type=int, default=None,
545
+ help='DataLoader workers (and frame-cache decoders); the v2 augmentation costs ~17 ms of one CPU '
546
+ "core per item, so 8 workers feed only ~6 steps/s at batch 64 (default: the protocol "
547
+ "recipe's)")
548
+ p.add_argument('--prefetch', type=int, default=2, help='batches prefetched per worker')
549
+ p.add_argument('--save-every', type=int, default=None,
550
+ help="save every N steps instead of the protocol's 6 even save points (owner 2026-11-27); a "
551
+ 'deviation: needs --protocol-exception')
552
+ p.add_argument('--log-every', type=int, default=100)
553
+ p.add_argument('--eval-samples', type=int, default=256)
554
+ p.add_argument('--seed', type=int, default=None,
555
+ help='training seed (default: the model\'s one fixed seed: ACT, DP 0; FM-DiT v1 / v2, FLASH, ODE 42; '
556
+ 'another value needs --protocol-exception)')
557
+ p.add_argument('--device', default='cuda:0')
558
+ p.add_argument('--no-amp', action='store_true')
559
+ p.add_argument('--resume', action='store_true', help='continue from <out>/train_state.pt')
560
+ p.add_argument('--stop-at', type=int, metavar='TOTAL_STEP',
561
+ help='end the run at this TOTAL step (original + continuation steps; owner 2026-11-30): save a '
562
+ 'checkpoint and train_state.pt there and write stopped.json. The learning-rate curve and the '
563
+ "other save points stay those of --steps (an early stop at a fixed step, not a shorter "
564
+ 'schedule); the run can be resumed later with the same arguments')
565
+ p.add_argument('--init-from', type=Path, metavar='CHECKPOINT',
566
+ help='continuation of a finished run (HumanWAM hb_training/protocol.yaml interface.continuation: '
567
+ 'weights only): its checkpoint folder <run>/checkpoints/step-NNNNNN. Loads the raw policy and '
568
+ 'its EMA from <run>/train_state.pt when that was written at the same step (else the saved '
569
+ 'EMA weights for both); a fresh AdamW and schedule run --steps MORE steps with peak --lr '
570
+ '(the protocol: 0.3 x the original peak) and --warmup (5 %% of --steps). Checkpoints, logs, '
571
+ 'the in-training MSE and the EMA decay count the total steps (original + continuation). '
572
+ 'Use a new --out.')
573
+ p.add_argument('--protocol-exception', metavar='TEXT', action='append', default=[],
574
+ help="a setting other than the protocol's (e.g. --save-every): the owner's decision, recorded "
575
+ 'verbatim in run.json and config.json (repeatable)')
576
+ p.add_argument('--continuation-exception', metavar='TEXT',
577
+ help='--init-from with a peak learning rate, warm-up or step count other than the protocol\'s '
578
+ '(0.3 x, 5 %%, 2000 or, long tasks, 4000 steps): the owner\'s decision, recorded verbatim')
579
+ p.add_argument('--inloop-task', help='in-training MSE: the task key of HumanWAM eval-action-mse hb_eval_common')
580
+ p.add_argument('--inloop-code', type=Path, help='in-training MSE: HumanWAM hb_training/eval-action-mse')
581
+ p.add_argument('--allow-no-inloop', action='store_true',
582
+ help='train without the in-training MSE (every model needs it, owner 2026-11-22/27; an exception '
583
+ 'to the protocol, recorded)')
584
+ args = p.parse_args()
585
+ recipe = PROTOCOL_RECIPES.get(args.policy, {})
586
+ factor = LONG_TASKS.get(args.inloop_task, 1)
587
+ given = dict(warmup=args.warmup, seed=args.seed)
588
+ args.batch_size = recipe.get('batch_size', DEFAULTS['batch_size']) if args.batch_size is None else args.batch_size
589
+ args.workers = recipe.get('workers', 32) if args.workers is None else args.workers
590
+ if args.steps is None:
591
+ args.steps = (2000 * factor if args.init_from else
592
+ recipe['steps'] * factor if 'steps' in recipe else 60000)
593
+ if args.warmup is None and not args.init_from and 'warmup' in recipe:
594
+ args.warmup = recipe['warmup']
595
+ want_seed = training_defaults(args.policy)['seed']
596
+ deviations = [f'{k} {v} (protocol {w})' for k, v, w in (
597
+ ('batch_size', args.batch_size, recipe.get('batch_size')),
598
+ ('steps', args.steps, None if args.init_from or 'steps' not in recipe else recipe['steps'] * factor),
599
+ ('warmup', given['warmup'], None if args.init_from else recipe.get('warmup')),
600
+ ('workers', args.workers, recipe.get('workers')),
601
+ ('seed', given['seed'], want_seed)) if w is not None and v is not None and v != w]
602
+ if args.save_every:
603
+ deviations.append(f'save_every {args.save_every} (protocol: 6 even save points)')
604
+ if deviations and not args.protocol_exception:
605
+ raise SystemExit(f"{args.policy}: {', '.join(deviations)} differ from the protocol (HumanWAM "
606
+ "hb_training/protocol.yaml); pass --protocol-exception with the owner's decision")
607
+ continuation_protocol = None
608
+ if args.init_from: # HumanWAM protocol.yaml interface.continuation
609
+ original_lr = float(json.loads((args.init_from.expanduser() / 'config.json').read_text())['training']['lr'])
610
+ want = dict(lr=0.3 * original_lr, warmup=round(0.05 * args.steps), steps=(2000, 4000))
611
+ args.lr = want['lr'] if args.lr is None else args.lr
612
+ args.warmup = want['warmup'] if args.warmup is None else args.warmup
613
+ off = [f'{k} {v}' for k, v, ok in (('lr', args.lr, math.isclose(args.lr, want['lr'], rel_tol=1e-6)),
614
+ ('warmup', args.warmup, args.warmup == want['warmup']),
615
+ ('steps', args.steps, args.steps in want['steps'])) if not ok]
616
+ if off and not args.continuation_exception:
617
+ raise SystemExit(f"--init-from: {', '.join(off)} differ from the protocol's continuation (lr "
618
+ f"{want['lr']:g} = 0.3 x {original_lr:g}, warm-up {want['warmup']} = 5 % of --steps, "
619
+ '2000 steps, long tasks 4000); pass --continuation-exception with the owner\'s decision')
620
+ continuation_protocol = dict(peak_lr_factor=0.3, warmup_ratio=0.05, steps=list(want['steps']),
621
+ deviations=off, exception=args.continuation_exception)
622
+ elif args.continuation_exception:
623
+ raise SystemExit('--continuation-exception goes with --init-from')
624
+ args.lr = DEFAULTS['lr'] if args.lr is None else args.lr
625
+ args.warmup = DEFAULTS['warmup'] if args.warmup is None else args.warmup
626
+
627
+ flash = args.policy == 'flash'
628
+ ode = args.policy in ODE_POLICIES
629
+ fm2 = args.policy == 'fm_dit_v2'
630
+ defaults = training_defaults(args.policy)
631
+ horizon = defaults['horizon'] if args.horizon is None else args.horizon
632
+ lead = int(getattr(POLICIES[args.policy], 'lead_rows', 0)) # FlashPolicy has none (no lead rows)
633
+ seed = defaults['seed'] if args.seed is None else args.seed
634
+ backbone_weights = defaults['backbone_weights'] if args.backbone_weights is None else args.backbone_weights
635
+ backbone_lr_scale = defaults['backbone_lr_scale'] if args.backbone_lr_scale is None else args.backbone_lr_scale
636
+ if not args.inloop_task and not args.allow_no_inloop:
637
+ raise SystemExit(f'{args.policy}: the protocol requires the in-training MSE for every model (--inloop-task, '
638
+ '--inloop-code), or --allow-no-inloop as a recorded exception')
639
+ dirty = git_dirty()
640
+ if dirty and not args.allow_dirty_tree:
641
+ raise SystemExit(f'uncommitted changes under evaluation/ ({", ".join(dirty[:5])}): the recorded code_commit '
642
+ 'would not be the code trained; commit them or pass --allow-dirty-tree (recorded)')
643
+ if bool(args.inloop_task) != bool(args.inloop_code):
644
+ raise SystemExit('--inloop-task and --inloop-code go together')
645
+
646
+ out = args.out.expanduser().resolve()
647
+ out.mkdir(parents=True, exist_ok=True)
648
+ contract = CONTRACTS[args.contract]
649
+ aug = augmentation_module()
650
+ aug.check_state_layout(contract.robot, contract.state_dim, [column for column, _, _ in contract.state])
651
+ hb_aug = args.augmentation == 'hb-v2'
652
+ if hb_aug and args.shift:
653
+ raise SystemExit('--shift is the native random shift, which the augmentation spec v2 turns off '
654
+ '(docs/augmentation_v2.md); use it only with --augmentation none')
655
+ if contract.body_dims != aug.BODY_JOINTS[contract.robot]:
656
+ raise SystemExit(f'contract {contract.name}: body_dims {contract.body_dims}, the spec perturbs '
657
+ f'{aug.BODY_JOINTS[contract.robot]} body joints')
658
+ augmentation = (aug.describe(contract.robot, contract.body_dims) if hb_aug else
659
+ dict(version=None, exception='--augmentation none (not the benchmark default)'))
660
+ cameras = tuple(args.cameras.split(',')) if args.cameras else contract.cameras
661
+ hw = parse_hw(args.image_size)
662
+ dataset = LeRobotDataset(args.dataset)
663
+ dataset.check_contract(contract, cameras)
664
+ if dataset.fps != DATASET_FPS and not args.protocol_exception:
665
+ raise SystemExit(f'{dataset.root}: {dataset.fps} Hz; every dataset, training and evaluation is {DATASET_FPS} '
666
+ "Hz (owner 2026-11-26); pass --protocol-exception with the owner's decision")
667
+ dataset_id = args.dataset_id
668
+ if dataset_id is None:
669
+ import re
670
+ root = Path(dataset.root)
671
+ m = re.fullmatch(r'(.+)-([0-9a-f]{7,40})', (root.parent if root.name == 'data' else root).name)
672
+ dataset_id = f'{m.group(1)}@{m.group(2)} (inferred from the directory name)' if m else None
673
+ if dataset_id is None:
674
+ raise SystemExit(f'{dataset.root}: give --dataset-id REPO@COMMIT (the HF dataset and revision it holds)')
675
+ episodes = parse_episodes(args.episodes, dataset.lengths)
676
+ if not 0 <= args.val_episodes < len(episodes):
677
+ raise SystemExit('--val-episodes must leave training episodes')
678
+ lowdim = load_lowdim(dataset, contract, episodes)
679
+ if len(lowdim['tasks']) != 1:
680
+ raise SystemExit(f"the baselines take no language: one task per dataset, found {lowdim['tasks']}")
681
+ n_train = len(episodes) - args.val_episodes
682
+ train_pos, val_pos = list(range(n_train)), list(range(n_train, len(episodes)))
683
+ train_rows = np.concatenate([np.arange(s, s + n) for s, n in
684
+ zip(lowdim['starts'][:n_train], lowdim['lengths'][:n_train])])
685
+ stats = statistics(lowdim, train_rows, quantiles=ode)
686
+ if ode: # the G1 port's normalization: the DFX6 values fixed at [0, 1]
687
+ for key, dims in unit_range_dims(contract).items():
688
+ stats[key]['unit_dims'] = dims
689
+ frames = frame_cache(dataset, lowdim, cameras, hw, args.cache_dir, workers=args.workers)
690
+
691
+ overrides = {k: json.loads(v) for k, v in (item.split('=', 1) for item in args.model)}
692
+ base = dict(policy=args.policy, n_cameras=len(cameras), state_dim=contract.state_dim,
693
+ action_dim=contract.action_dim, horizon=horizon)
694
+ if ode: # the body part integrated as the ODE state: the contract's first action group (G1 token 64, H2 body 31)
695
+ _, first, last = contract.action[0]
696
+ overrides.setdefault('ode_body_dim', last - first)
697
+ if flash:
698
+ settings = dict(FLASH_DEFAULTS, **{k: json.loads(v) for k, v in (i.split('=', 1) for i in args.flash)})
699
+ if args.horizon is not None and args.horizon != settings['rows']:
700
+ raise SystemExit('FLASH: the output rows are --flash rows=N, not --horizon')
701
+ base.update(FLASH_POLICY_FIELDS, horizon=int(settings['rows']), extra=dict(flash=settings))
702
+ elif args.flash:
703
+ raise SystemExit('--flash applies to --policy flash only')
704
+ if fm2:
705
+ base.update(FM_DIT_V2_POLICY_FIELDS)
706
+ weights = None if str(backbone_weights).lower() in ('none', '') else backbone_weights
707
+ pcfg = PolicyConfig.from_dict({**base, 'backbone_weights': weights, **overrides})
708
+ aug_seed = seed if hb_aug else None # every model: the seeded augmentation stream (REPRODUCIBILITY.md section 3)
709
+ if flash:
710
+ from baselines.flash import FlashPolicy, flash_settings
711
+ fs = flash_settings(pcfg)
712
+ H_ext = fs['poly_prefix'] + fs['n_action'] + fs['poly_suffix'] + 2 * fs['fit_pad']
713
+ offsets = (np.arange(H_ext) - (fs['fit_pad'] + fs['poly_prefix'])) * fs['stride']
714
+ kw = dict(offsets=offsets, stride=fs['stride'], n_history=fs['n_history'], rows=fs['rows'])
715
+ train_set = FlashChunkDataset(lowdim, frames, cameras, hw, train_pos,
716
+ body_dims=contract.body_dims if hb_aug else 0, aug_seed=aug_seed, **kw)
717
+ eval_set = FlashChunkDataset(lowdim, frames, cameras, hw, val_pos or train_pos, with_dense=True, **kw)
718
+ assert FlashPolicy.name == 'flash'
719
+ else:
720
+ train_set = ChunkDataset(lowdim, frames, cameras, hw, horizon, train_pos,
721
+ body_dims=contract.body_dims if hb_aug else 0, lead=lead, aug_seed=aug_seed)
722
+ eval_set = ChunkDataset(lowdim, frames, cameras, hw, horizon, val_pos or train_pos,
723
+ lead=lead) # never augmented
724
+ print(f'HB_AUG_SEED={aug_seed}', file=sys.stderr, flush=True)
725
+ checks = preflight(train_set, eval_set, contract, seed=seed)
726
+ print(json.dumps(dict(event='preflight', augmentation=augmentation.get('version'), **checks)), flush=True)
727
+ if args.save_every and not args.protocol_exception:
728
+ raise SystemExit('--save-every: the protocol saves 6 checkpoints spread evenly over the steps (owner '
729
+ "2026-11-27); pass --protocol-exception with the owner's decision to save otherwise")
730
+ save_at = set(save_points(args.steps, args.save_every))
731
+ print(json.dumps(dict(event='save_points', steps=sorted(save_at))), flush=True)
732
+ layout = dict(nodes=1, gpus=1, per_gpu_batch=args.batch_size, global_batch=args.batch_size,
733
+ gradient_accumulation=1, num_workers=args.workers, prefetch=args.prefetch)
734
+ if args.preflight_only:
735
+ (out / 'run.json').write_text(json.dumps(dict(
736
+ argv=sys.argv, started=datetime.now().isoformat(timespec='seconds'), host=os.uname().nodename,
737
+ contract=contract.to_dict(cameras), image_hw=list(hw), augmentation=augmentation, preflight=checks,
738
+ shift_px=args.shift, seed=seed, aug_seed=aug_seed, layout=layout, policy=pcfg.to_dict(),
739
+ code_commit=git_commit()), indent=1, default=str))
740
+ return
741
+
742
+ import torch
743
+ torch.manual_seed(seed)
744
+ np.random.seed(seed)
745
+ device = torch.device(args.device)
746
+ policy = build_policy(pcfg)
747
+ policy.fit_normalizers(stats)
748
+ policy.to(device)
749
+ ema = EMA(policy, args.ema, defaults.get('ema_schedule', 'hb')) if args.ema > 0 else None
750
+ named = list(policy.named_parameters())
751
+ backbone = [p for n, p in named if n.startswith(policy.backbone_prefix)]
752
+ rest = [p for n, p in named if not n.startswith(policy.backbone_prefix)]
753
+ if not backbone:
754
+ raise SystemExit(f'no backbone parameters under {policy.backbone_prefix!r}')
755
+ optimizer = torch.optim.AdamW([dict(params=rest), dict(params=backbone, lr=args.lr * backbone_lr_scale)],
756
+ lr=args.lr, betas=DEFAULTS['betas'], weight_decay=args.weight_decay)
757
+ schedule = defaults.get('schedule', 'hb')
758
+
759
+ def lr_lambda(step):
760
+ if schedule == 'diffusers_cosine': # diffusers get_cosine_schedule_with_warmup (FLASH's lr_scheduler)
761
+ if step < args.warmup:
762
+ return step / max(1, args.warmup)
763
+ progress = (step - args.warmup) / max(1, args.steps - args.warmup)
764
+ return max(0.0, 0.5 * (1.0 + math.cos(math.pi * progress)))
765
+ if step < args.warmup:
766
+ return (step + 1) / max(1, args.warmup)
767
+ return 0.5 * (1 + math.cos(math.pi * min(1.0, (step - args.warmup) / max(1, args.steps - args.warmup))))
768
+
769
+ scheduler = torch.optim.lr_scheduler.LambdaLR(optimizer, lr_lambda)
770
+ step = 0
771
+ step0 = 0 # continuation: the steps of the run it starts from (0 for a training from scratch)
772
+ continuation = None
773
+ state_path = out / 'train_state.pt'
774
+ resuming = args.resume and state_path.exists()
775
+ resume_rng = None
776
+ if args.init_from and not resuming:
777
+ continuation, step0 = init_continuation(args, policy, ema, pcfg, contract, cameras, hw, augmentation,
778
+ episodes[:n_train], out, stats)
779
+ continuation['protocol'] = continuation_protocol
780
+ if resuming:
781
+ saved = torch.load(state_path, map_location='cpu', weights_only=False)
782
+ if not same_policy_config(saved['config']['policy'], pcfg.to_dict()):
783
+ raise SystemExit('train_state.pt was written for another policy configuration')
784
+ before = saved['config'].get('training', {})
785
+ if (before.get('augmentation') or {}).get('version') != augmentation.get('version') \
786
+ or before.get('shift_px') != args.shift:
787
+ raise SystemExit('train_state.pt was trained with another augmentation (version / --shift); resuming '
788
+ 'would change it mid-run')
789
+ policy.load_state_dict(saved['policy'])
790
+ optimizer.load_state_dict(saved['optimizer'])
791
+ scheduler.load_state_dict(saved['scheduler'])
792
+ if ema is not None:
793
+ ema.model.load_state_dict(saved['ema'])
794
+ step = int(saved['step'])
795
+ continuation = before.get('continuation')
796
+ if bool(continuation) != bool(args.init_from) or (
797
+ continuation and Path(continuation['init_from']) != args.init_from.expanduser().resolve()):
798
+ raise SystemExit('--resume: give the same --init-from as the interrupted run (none for a run from '
799
+ 'scratch)')
800
+ step0 = int(continuation['init_step']) if continuation else 0
801
+ resume_rng = saved.get('rng')
802
+ if resume_rng is None:
803
+ print('HB_RESUME no random state in train_state.pt (written before 2026-11-27): the streams restart',
804
+ flush=True)
805
+ print(json.dumps(dict(event='resumed', step=step0 + step, local_step=step)), flush=True)
806
+ stop_local = None
807
+ if args.stop_at is not None: # owner 2026-11-30: a fixed-step early stop; the schedule stays that of --steps
808
+ stop_local = args.stop_at - step0
809
+ if not step < stop_local <= args.steps:
810
+ raise SystemExit(f'--stop-at {args.stop_at}: must lie after the current total step {step0 + step} and at or '
811
+ f'before the end of the schedule {step0 + args.steps}')
812
+ save_at.add(stop_local)
813
+ print(json.dumps(dict(event='stop_at', step=args.stop_at, local_step=stop_local)), flush=True)
814
+ end = stop_local or args.steps
815
+
816
+ inloop = None
817
+ if args.inloop_task:
818
+ # one GPU: hb_inloop_core shards by RANK / WORLD_SIZE, which a DLC node sets for its own launcher
819
+ for key, value in (('RANK', '0'), ('WORLD_SIZE', '1'), ('LOCAL_RANK', '0')):
820
+ if os.environ.get(key, value) != value:
821
+ print(f'HB_INLOOP {key}={os.environ[key]} -> {value} (one-GPU training)', flush=True)
822
+ os.environ[key] = value
823
+ from baselines import inloop as inloop_mod
824
+ inloop = inloop_mod.install(args.inloop_code, args.inloop_task, out,
825
+ lambda: ema.model if ema is not None else policy, contract, cameras, hw, lowdim,
826
+ args.policy, lowdim_loader=lambda eps: load_lowdim(dataset, contract, eps))
827
+ else:
828
+ print(f'HB_INLOOP {args.policy} disabled: no --inloop-task', flush=True)
829
+
830
+ samples = np.random.default_rng(1).choice(len(eval_set), size=min(args.eval_samples, len(eval_set)), replace=False)
831
+ training = dict(steps=args.steps, batch_size=args.batch_size, lr=args.lr, betas=list(DEFAULTS['betas']),
832
+ weight_decay=args.weight_decay, warmup=args.warmup,
833
+ schedule='linear warm-up + cosine' if schedule == 'hb' else schedule,
834
+ backbone_lr_scale=backbone_lr_scale,
835
+ ema=args.ema, shift_px=args.shift, amp=(not args.no_amp) and bool(defaults['amp']), seed=seed,
836
+ augmentation=augmentation, preflight=checks, aug_seed=aug_seed, layout=layout,
837
+ continuation=continuation, total_steps=step0 + args.steps,
838
+ save_steps=[step0 + k for k in sorted(save_at)],
839
+ save_rule=(f'every {args.save_every} steps (exception)' if args.save_every else
840
+ f'{SAVE_COUNT} checkpoints spread evenly over the steps on the {SAVE_GRID}-step grid '
841
+ '(owner 2026-11-27)'),
842
+ protocol_exceptions=args.protocol_exception, stop_at=args.stop_at)
843
+ training.update(ema_schedule=defaults.get('ema_schedule', 'hb'),
844
+ inloop=dict(task=args.inloop_task, code=str(args.inloop_code) if args.inloop_code else None,
845
+ every=int(os.environ.get('HB_INLOOP_EVERY', '250')) if args.inloop_task else 0,
846
+ exception=None if args.inloop_task else '--allow-no-inloop',
847
+ code_sha256={f: file_sha256(Path(args.inloop_code) / f) for f in
848
+ ('hb_inloop_core.py', 'hb_eval_common.py')} if args.inloop_code else None))
849
+ training.update(protocol_recipe=dict(recipe, long_task_factor=factor), protocol_deviations=deviations,
850
+ environment=environment(device), code_dirty=dirty, allow_dirty_tree=args.allow_dirty_tree,
851
+ augmentation_sha256=file_sha256(HERE.parent / 'augmentation' / 'hb_aug_v2.py'),
852
+ order='EpochSampler: default_rng([seed, 1, epoch]) permutation; augmentation default_rng([aug_seed, '
853
+ 'draw])')
854
+ if flash:
855
+ training.update(upstream='NTUMARS/FLASH-Policy@f47e490')
856
+ if fm2:
857
+ training.update(upstream=FM_DIT_V2_UPSTREAM)
858
+ if ode:
859
+ training.update(upstream='NTUMARS/ODE-POLICY real-g1@fd8bec47 (G1 port, HumanWAM packages/ode_g1) + '
860
+ 'main@cea26d94 (encoder, ode_dit field, default_train.yaml)')
861
+ config = dict(
862
+ policy=pcfg.to_dict(), contract=contract.to_dict(cameras), image_hw=list(hw), task_text=lowdim['tasks'][0],
863
+ dataset=dict(name=dataset.name,
864
+ root=str(dataset.root), robot_type=dataset.info.get('robot_type'), fps=dataset.fps,
865
+ episodes=episodes, train_episodes=episodes[:n_train], val_episodes=episodes[n_train:],
866
+ train_frames=int(len(train_set)),
867
+ git_commit=dataset.info.get('script_config', {}).get('git_commit')),
868
+ training=training, stats=stats, code_commit=git_commit(), task=args.inloop_task, dataset_id=dataset_id)
869
+ run = dict(argv=sys.argv, started=datetime.now().isoformat(timespec='seconds'), host=os.uname().nodename,
870
+ torch=torch.__version__, **config)
871
+ (out / 'run.json').write_text(json.dumps(run, indent=1, default=str))
872
+ sampler = EpochSampler(len(train_set), args.batch_size, seed, start_step=step)
873
+ # its own generator: creating the iterator (here and after a --resume) must not draw from the global stream that
874
+ # the model's noise and dropout use, or a resumed run would be one draw off
875
+ loader = torch.utils.data.DataLoader(train_set, batch_size=args.batch_size, sampler=sampler, drop_last=True,
876
+ generator=torch.Generator().manual_seed(seed),
877
+ num_workers=args.workers, pin_memory=True, persistent_workers=True,
878
+ prefetch_factor=args.prefetch)
879
+ params = sum(x.numel() for x in policy.parameters())
880
+ print(json.dumps(dict(event='start', policy=args.policy, params=params,
881
+ backbone_params=sum(x.numel() for x in backbone), backbone_weights=pcfg.backbone_weights,
882
+ backbone_norm=pcfg.backbone_norm, train_frames=len(train_set), steps=args.steps,
883
+ from_step=step0 + step, total_steps=step0 + args.steps, cameras=list(cameras), hw=list(hw),
884
+ seed=seed)), flush=True)
885
+ log = (out / 'train_log.jsonl').open('a')
886
+ amp = (not args.no_amp) and device.type == 'cuda' and bool(defaults['amp'])
887
+
888
+ def save(step): # step: this run's own steps; checkpoints are named and stamped with the total
889
+ total = step0 + step
890
+ folder = out / f'checkpoints/step-{total:06d}'
891
+ model = ema.model if ema is not None else policy
892
+ metrics = offline_eval(model, eval_set, samples, device, contract.action)
893
+ save_checkpoint(folder, model, dict(config, step=total, weights='ema' if ema is not None else 'raw',
894
+ offline_eval=dict(metrics, samples=len(samples),
895
+ frames='val' if val_pos else 'train')))
896
+ final = out / 'checkpoints/final'
897
+ if final.is_symlink() or final.exists():
898
+ final.unlink()
899
+ final.symlink_to(folder.name)
900
+ torch.save(dict(policy=policy.state_dict(), optimizer=optimizer.state_dict(), scheduler=scheduler.state_dict(),
901
+ ema=None if ema is None else ema.model.state_dict(), step=step, config=config,
902
+ rng=rng_state()),
903
+ out / 'train_state.pt.tmp')
904
+ (out / 'train_state.pt.tmp').replace(state_path)
905
+ record = dict(event='save', step=total, checkpoint=str(folder), **metrics)
906
+ print(json.dumps(record), flush=True)
907
+ log.write(json.dumps(record) + '\n')
908
+ log.flush()
909
+ policy.train()
910
+
911
+ if resume_rng is not None: # the interrupted run's random streams (model noise, dropout) at its last save
912
+ set_rng_state(resume_rng)
913
+ policy.train()
914
+ t0, data_s, acc = time.monotonic(), 0.0, {}
915
+ while step < end:
916
+ tick = time.monotonic()
917
+ for images, *labels in loader:
918
+ data_s += time.monotonic() - tick
919
+ images = images.to(device, non_blocking=True).permute(0, 1, 4, 2, 3).float().div_(255.)
920
+ images = random_shift(images, args.shift)
921
+ labels = [x.to(device, non_blocking=True) for x in labels]
922
+ with torch.autocast(device.type, dtype=torch.bfloat16, enabled=amp):
923
+ loss, metrics = policy.compute_loss(images, *labels)
924
+ optimizer.zero_grad(set_to_none=True)
925
+ loss.backward()
926
+ optimizer.step()
927
+ scheduler.step()
928
+ step += 1
929
+ decay = ema.update(policy, step0 + step) if ema is not None else 0.0
930
+ for k, v in dict(metrics, loss=float(loss.detach())).items():
931
+ acc[k] = acc.get(k, 0.0) + v
932
+ if step % args.log_every == 0:
933
+ elapsed = time.monotonic() - t0
934
+ record = dict(event='train', step=step0 + step, lr=scheduler.get_last_lr()[0],
935
+ backbone_lr=scheduler.get_last_lr()[1], ema_decay=round(decay, 6),
936
+ it_s=round(args.log_every / elapsed, 2), data_frac=round(data_s / elapsed, 3),
937
+ **{k: v / args.log_every for k, v in acc.items()})
938
+ print(json.dumps(record), flush=True)
939
+ log.write(json.dumps(record) + '\n')
940
+ log.flush()
941
+ t0, data_s, acc = time.monotonic(), 0.0, {}
942
+ if inloop is not None and (step0 + step) % inloop.every == 0:
943
+ inloop.evaluate(step0 + step, ema.model if ema is not None else policy)
944
+ policy.train()
945
+ if step in save_at:
946
+ save(step)
947
+ if step >= end:
948
+ break
949
+ tick = time.monotonic()
950
+ log.close()
951
+ if stop_local is not None and step >= stop_local and step < args.steps:
952
+ (out / 'stopped.json').write_text(json.dumps(dict(
953
+ run=out.name, policy=args.policy, stopped_at=step0 + step, local_step=step, schedule_steps=args.steps,
954
+ schedule_total_steps=step0 + args.steps, reason='--stop-at (owner 2026-11-30: a fixed-step early stop; the '
955
+ 'learning-rate curve is that of --steps, not rescheduled)', checkpoint=f'checkpoints/step-{step0 + step:06d}',
956
+ resumable='train_state.pt at this step: --resume with the same arguments (without --stop-at) continues',
957
+ code_commit=config['code_commit'], stopped_utc=datetime.now(timezone.utc).strftime('%Y-%m-%dT%H:%M:%SZ')),
958
+ indent=1))
959
+ print(json.dumps(dict(event='stopped', step=step0 + step, checkpoint=str(out / 'checkpoints/final'))),
960
+ flush=True)
961
+ if step >= args.steps: # as HumanWAM's launchers (e.g. fastwam_cont.sh): what the finished run is
962
+ c = continuation or {}
963
+ (out / 'complete.json').write_text(json.dumps(dict(
964
+ run=out.name, policy=args.policy, contract=contract.name, steps=args.steps, total_steps_after=step0 + step,
965
+ per_gpu_batch=args.batch_size, global_batch=args.batch_size, gradient_accumulation_steps=1,
966
+ save_steps=[step0 + k for k in sorted(save_at)], seed=seed, aug_seed=aug_seed, peak_lr=args.lr, warmup=args.warmup,
967
+ continued_from=c.get('init_from'), continued_from_step=c.get('init_step'),
968
+ continuation=continuation, code_commit=config['code_commit'],
969
+ finished_utc=datetime.now(timezone.utc).strftime('%Y-%m-%dT%H:%M:%SZ')), indent=1))
970
+ print(json.dumps(dict(event='done', step=step0 + step, checkpoint=str(out / 'checkpoints/final'))), flush=True)
971
+
972
+
973
+ if __name__ == '__main__':
974
+ main()
b8-table-wipe/b512-cont-20261117-stop50k/step-050000/training_records/launch.sh ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash
2
+ # launch.sh (2026-11-30 flash30k, mlp2): FM-DiT v1 b8 from step 6000 (--init-from the staged A800 start), schedule 60000 more steps (66000 total), stopped at the total step 50000; card 3 (4090D 24 GB). Tree /root/code/hb_bai_433ba198_stopat39f9b83a
3
+ # (= bai 433ba198 + the train.py part of bai 39f9b83a, --stop-at; see HB_CODE_COMMIT there). Waits until the card has
4
+ # >= 21000 MiB free (3 checks 30 s apart), then trains. Start: setsid nohup bash launch.sh > launch.out 2>&1 < /dev/null &
5
+ set -u
6
+ RUN=/root/hb_runs/flash30k/runs/b8-fm_dit-b512-cont60k-total66k
7
+ CARD=3
8
+ mkdir -p $RUN
9
+ ok=0
10
+ while [ $ok -lt 3 ]; do
11
+ f=$(nvidia-smi -i $CARD --query-gpu=memory.free --format=csv,noheader,nounits | tr -d ' ')
12
+ if [ "$f" -ge 21000 ]; then ok=$((ok+1)); else ok=0; fi
13
+ echo "$(date -u +%FT%TZ) card $CARD free ${f} MiB ok=$ok" >> $RUN/wait.log
14
+ [ $ok -lt 3 ] && sleep 30
15
+ done
16
+ echo "$(date -u +%FT%TZ) starting" >> $RUN/wait.log
17
+ cd /root/code/hb_bai_433ba198_stopat39f9b83a
18
+ export PYTORCH_CUDA_ALLOC_CONF=expandable_segments:True CUDA_DEVICE_ORDER=PCI_BUS_ID CUDA_VISIBLE_DEVICES=$CARD
19
+ export G=/root/hb_runs/flash30k/policies HB_EVAL_CACHE=/root/hb_runs/flash30k/policies/eval-action-mse/cache
20
+ exec taskset -c 135-179 /root/.venvs/hb-baselines-p13/bin/python -I evaluation/baselines/train.py \
21
+ --policy fm_dit --contract g1_sonic_cmd --dataset /root/hb_data/b8-table-wipe-expert-v1-3b2e6180 --dataset-id humanoid-benchmark/b8-table-wipe-expert-v1@3b2e6180508f84f70fda8b33cd3e41c14225f0b5 --steps 60000 --batch-size 512 --seed 42 --workers 32 --log-every 50 --cache-dir /dev/shm/hb_flash30k_cache --inloop-task b8c --inloop-code /root/hb_runs/flash30k/policies/eval-action-mse --init-from /root/hb_runs/flash30k/staging/fm_b8_init_source/checkpoints/step-006000 --lr 1e-4 --warmup 500 --continuation-exception 'owner 2026-11-28: 续训的步数比较多的就不需要去降低学习率的峰值。我觉得学习率峰值可以跟从头训一样去安排; FM-DiT v1 base 58000 (collaborator'"'"'s A17 80000 steps on 751.84 frames/episode); measured -> commanded hands (owner: 续训时改成学指令手,肯定要这么做)' --protocol-exception 'owner 2026-11-28: FM-DiT v1 base steps 58000 (HumanWAM bai a7c875b); steps = ceil1000(58000 x 614.98 frames per episode / 544.33) = 66000; continued from step 6000 to 66000; commanded hands (owner 2026-11-27)' --protocol-exception 'owner 2026-11-30: FM-DiT 照原学习率曲线训到累计 50000 步截停(「行,截停」): --stop-at 50000, the learning-rate curve that of --steps; code = Humanoid_benchmark bai 433ba198 + stop-at patch (the evaluation/baselines/train.py part of bai 39f9b83a, git diff 39f9b83a^ 39f9b83a -- evaluation/baselines/train.py, sha256 db0911a84ba7a847befd22955ac99a9c04c2307a97f696be4e73da510fc19977); trained on the MLP 4090D (24 GB, one card, batch 512, same recipe as the A800)' --out /root/hb_runs/flash30k/runs/b8-fm_dit-b512-cont60k-total66k --stop-at 50000 >> $RUN/train.log 2>&1
b8-table-wipe/b512-cont-20261117-stop50k/step-050000/training_records/logs/inloop-mse.jsonl ADDED
The diff for this file is too large to render. See raw diff
 
b8-table-wipe/b512-cont-20261117-stop50k/step-050000/training_records/pip_freeze_hb-baselines.txt ADDED
File without changes
b8-table-wipe/b512-cont-20261117-stop50k/step-050000/training_records/run.json ADDED
@@ -0,0 +1,1036 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "argv": [
3
+ "evaluation/baselines/train.py",
4
+ "--policy",
5
+ "fm_dit",
6
+ "--contract",
7
+ "g1_sonic_cmd",
8
+ "--dataset",
9
+ "/root/hb_data/b8-table-wipe-expert-v1-3b2e6180",
10
+ "--dataset-id",
11
+ "humanoid-benchmark/b8-table-wipe-expert-v1@3b2e6180508f84f70fda8b33cd3e41c14225f0b5",
12
+ "--steps",
13
+ "60000",
14
+ "--batch-size",
15
+ "512",
16
+ "--seed",
17
+ "42",
18
+ "--workers",
19
+ "32",
20
+ "--log-every",
21
+ "50",
22
+ "--cache-dir",
23
+ "/dev/shm/hb_flash30k_cache",
24
+ "--inloop-task",
25
+ "b8c",
26
+ "--inloop-code",
27
+ "/root/hb_runs/flash30k/policies/eval-action-mse",
28
+ "--init-from",
29
+ "/root/hb_runs/flash30k/staging/fm_b8_init_source/checkpoints/step-006000",
30
+ "--lr",
31
+ "1e-4",
32
+ "--warmup",
33
+ "500",
34
+ "--continuation-exception",
35
+ "owner 2026-11-28: \u7eed\u8bad\u7684\u6b65\u6570\u6bd4\u8f83\u591a\u7684\u5c31\u4e0d\u9700\u8981\u53bb\u964d\u4f4e\u5b66\u4e60\u7387\u7684\u5cf0\u503c\u3002\u6211\u89c9\u5f97\u5b66\u4e60\u7387\u5cf0\u503c\u53ef\u4ee5\u8ddf\u4ece\u5934\u8bad\u4e00\u6837\u53bb\u5b89\u6392; FM-DiT v1 base 58000 (collaborator's A17 80000 steps on 751.84 frames/episode); measured -> commanded hands (owner: \u7eed\u8bad\u65f6\u6539\u6210\u5b66\u6307\u4ee4\u624b\uff0c\u80af\u5b9a\u8981\u8fd9\u4e48\u505a)",
36
+ "--protocol-exception",
37
+ "owner 2026-11-28: FM-DiT v1 base steps 58000 (HumanWAM bai a7c875b); steps = ceil1000(58000 x 614.98 frames per episode / 544.33) = 66000; continued from step 6000 to 66000; commanded hands (owner 2026-11-27)",
38
+ "--protocol-exception",
39
+ "owner 2026-11-30: FM-DiT \u7167\u539f\u5b66\u4e60\u7387\u66f2\u7ebf\u8bad\u5230\u7d2f\u8ba1 50000 \u6b65\u622a\u505c\uff08\u300c\u884c\uff0c\u622a\u505c\u300d\uff09: --stop-at 50000, the learning-rate curve that of --steps; code = Humanoid_benchmark bai 433ba198 + stop-at patch (the evaluation/baselines/train.py part of bai 39f9b83a, git diff 39f9b83a^ 39f9b83a -- evaluation/baselines/train.py, sha256 db0911a84ba7a847befd22955ac99a9c04c2307a97f696be4e73da510fc19977); trained on the MLP 4090D (24 GB, one card, batch 512, same recipe as the A800)",
40
+ "--out",
41
+ "/root/hb_runs/flash30k/runs/b8-fm_dit-b512-cont60k-total66k",
42
+ "--stop-at",
43
+ "50000"
44
+ ],
45
+ "started": "2026-11-30T06:44:14",
46
+ "host": "devbox-5b3dc49d-4ec2-4fa8-bd10-e5a569cfc34a-7",
47
+ "torch": "2.9.0+cu128",
48
+ "policy": {
49
+ "policy": "fm_dit",
50
+ "n_cameras": 2,
51
+ "state_dim": 44,
52
+ "action_dim": 76,
53
+ "horizon": 16,
54
+ "backbone": "resnet18",
55
+ "backbone_weights": "IMAGENET1K_V1",
56
+ "backbone_norm": "frozen_bn",
57
+ "hidden_dim": 384,
58
+ "num_layers": 4,
59
+ "num_heads": 8,
60
+ "mlp_ratio": 4.0,
61
+ "dropout": 0.1,
62
+ "time_embed_dim": 128,
63
+ "num_inference_steps": null,
64
+ "num_train_timesteps": 100,
65
+ "beta_schedule": "squaredcos_cap_v2",
66
+ "prediction_type": "epsilon",
67
+ "clip_sample": true,
68
+ "act_hidden_dim": 512,
69
+ "dim_feedforward": 3200,
70
+ "enc_layers": 4,
71
+ "dec_layers": 7,
72
+ "nheads": 8,
73
+ "latent_dim": 32,
74
+ "kl_weight": 10.0,
75
+ "ode_body_dim": null,
76
+ "ode_width": 512,
77
+ "ode_layers": 4,
78
+ "ode_cond_dim": 512,
79
+ "ode_field_scale": 1.0,
80
+ "ode_dit_hidden": 512,
81
+ "ode_dit_layers": 4,
82
+ "ode_dit_heads": 8,
83
+ "ode_dit_tokens": 4,
84
+ "extra": {}
85
+ },
86
+ "contract": {
87
+ "name": "g1_sonic_cmd",
88
+ "robot": "g1",
89
+ "cameras": [
90
+ "ego_view",
91
+ "chest"
92
+ ],
93
+ "state": [
94
+ [
95
+ "observation.state",
96
+ 0,
97
+ 29
98
+ ],
99
+ [
100
+ "observation.inspire_left_hand_state",
101
+ 0,
102
+ 6
103
+ ],
104
+ [
105
+ "observation.inspire_right_hand_state",
106
+ 0,
107
+ 6
108
+ ],
109
+ [
110
+ "observation.projected_gravity",
111
+ 0,
112
+ 3
113
+ ]
114
+ ],
115
+ "action": [
116
+ [
117
+ "action.motion_token",
118
+ 0,
119
+ 64
120
+ ],
121
+ [
122
+ "teleop.inspire_left_hand_cmd",
123
+ 0,
124
+ 6
125
+ ],
126
+ [
127
+ "teleop.inspire_right_hand_cmd",
128
+ 0,
129
+ 6
130
+ ]
131
+ ],
132
+ "state_dim": 44,
133
+ "action_dim": 76,
134
+ "action_space": "sonic_dfx6",
135
+ "body_dims": 29,
136
+ "history": [
137
+ [
138
+ "action.motion_token",
139
+ 0,
140
+ 64
141
+ ],
142
+ [
143
+ "observation.inspire_left_hand_state",
144
+ 0,
145
+ 6
146
+ ],
147
+ [
148
+ "observation.inspire_right_hand_state",
149
+ 0,
150
+ 6
151
+ ]
152
+ ]
153
+ },
154
+ "image_hw": [
155
+ 168,
156
+ 224
157
+ ],
158
+ "task_text": "Approach the flat block with a naturally aligned wrist, stop before closing the hand, wipe sideways at a top-view 45-degree heading, then set the block on the tabletop and release it.",
159
+ "dataset": {
160
+ "name": "b8-table-wipe-expert-v1-3b2e6180",
161
+ "root": "/root/hb_data/b8-table-wipe-expert-v1-3b2e6180",
162
+ "robot_type": null,
163
+ "fps": 30.0,
164
+ "episodes": [
165
+ 0,
166
+ 1,
167
+ 2,
168
+ 3,
169
+ 4,
170
+ 5,
171
+ 6,
172
+ 7,
173
+ 8,
174
+ 9,
175
+ 10,
176
+ 11,
177
+ 12,
178
+ 13,
179
+ 14,
180
+ 15,
181
+ 16,
182
+ 17,
183
+ 18,
184
+ 19,
185
+ 20,
186
+ 21,
187
+ 22,
188
+ 23,
189
+ 24,
190
+ 25,
191
+ 26,
192
+ 27,
193
+ 28,
194
+ 29,
195
+ 30,
196
+ 31,
197
+ 32,
198
+ 33,
199
+ 34,
200
+ 35,
201
+ 36,
202
+ 37,
203
+ 38,
204
+ 39,
205
+ 40,
206
+ 41,
207
+ 42,
208
+ 43,
209
+ 44,
210
+ 45,
211
+ 46,
212
+ 47,
213
+ 48,
214
+ 49,
215
+ 50,
216
+ 51,
217
+ 52,
218
+ 53,
219
+ 54,
220
+ 55,
221
+ 56,
222
+ 57,
223
+ 58,
224
+ 59,
225
+ 60,
226
+ 61,
227
+ 62,
228
+ 63,
229
+ 64,
230
+ 65,
231
+ 66,
232
+ 67,
233
+ 68,
234
+ 69,
235
+ 70,
236
+ 71,
237
+ 72,
238
+ 73,
239
+ 74,
240
+ 75,
241
+ 76,
242
+ 77,
243
+ 78,
244
+ 79,
245
+ 80,
246
+ 81,
247
+ 82,
248
+ 83,
249
+ 84,
250
+ 85,
251
+ 86,
252
+ 87,
253
+ 88,
254
+ 89,
255
+ 90,
256
+ 91,
257
+ 92,
258
+ 93,
259
+ 94,
260
+ 95,
261
+ 96,
262
+ 97,
263
+ 98,
264
+ 99
265
+ ],
266
+ "train_episodes": [
267
+ 0,
268
+ 1,
269
+ 2,
270
+ 3,
271
+ 4,
272
+ 5,
273
+ 6,
274
+ 7,
275
+ 8,
276
+ 9,
277
+ 10,
278
+ 11,
279
+ 12,
280
+ 13,
281
+ 14,
282
+ 15,
283
+ 16,
284
+ 17,
285
+ 18,
286
+ 19,
287
+ 20,
288
+ 21,
289
+ 22,
290
+ 23,
291
+ 24,
292
+ 25,
293
+ 26,
294
+ 27,
295
+ 28,
296
+ 29,
297
+ 30,
298
+ 31,
299
+ 32,
300
+ 33,
301
+ 34,
302
+ 35,
303
+ 36,
304
+ 37,
305
+ 38,
306
+ 39,
307
+ 40,
308
+ 41,
309
+ 42,
310
+ 43,
311
+ 44,
312
+ 45,
313
+ 46,
314
+ 47,
315
+ 48,
316
+ 49,
317
+ 50,
318
+ 51,
319
+ 52,
320
+ 53,
321
+ 54,
322
+ 55,
323
+ 56,
324
+ 57,
325
+ 58,
326
+ 59,
327
+ 60,
328
+ 61,
329
+ 62,
330
+ 63,
331
+ 64,
332
+ 65,
333
+ 66,
334
+ 67,
335
+ 68,
336
+ 69,
337
+ 70,
338
+ 71,
339
+ 72,
340
+ 73,
341
+ 74,
342
+ 75,
343
+ 76,
344
+ 77,
345
+ 78,
346
+ 79,
347
+ 80,
348
+ 81,
349
+ 82,
350
+ 83,
351
+ 84,
352
+ 85,
353
+ 86,
354
+ 87,
355
+ 88,
356
+ 89,
357
+ 90,
358
+ 91,
359
+ 92,
360
+ 93,
361
+ 94,
362
+ 95,
363
+ 96,
364
+ 97,
365
+ 98,
366
+ 99
367
+ ],
368
+ "val_episodes": [],
369
+ "train_frames": 61498,
370
+ "git_commit": null
371
+ },
372
+ "training": {
373
+ "steps": 60000,
374
+ "batch_size": 512,
375
+ "lr": 0.0001,
376
+ "betas": [
377
+ 0.95,
378
+ 0.999
379
+ ],
380
+ "weight_decay": 1e-06,
381
+ "warmup": 500,
382
+ "schedule": "linear warm-up + cosine",
383
+ "backbone_lr_scale": 0.1,
384
+ "ema": 0.9999,
385
+ "shift_px": 0,
386
+ "amp": true,
387
+ "seed": 42,
388
+ "augmentation": {
389
+ "spec": "docs/augmentation_v2.md",
390
+ "version": "hb-aug-v2-20261109",
391
+ "implementation": "evaluation/augmentation/hb_aug_v2.py",
392
+ "visual": {
393
+ "effects": [
394
+ "exposure",
395
+ "contrast",
396
+ "saturation",
397
+ "hue",
398
+ "gamma",
399
+ "temperature",
400
+ "rotation_crop",
401
+ "noise",
402
+ "gaussian_blur",
403
+ "jpeg",
404
+ "motion_blur",
405
+ "sharpen",
406
+ "defocus",
407
+ "light_shadow",
408
+ "wb_channel"
409
+ ],
410
+ "boosted_per_sample": 1,
411
+ "boost": 1.5,
412
+ "pixel_scale": "H / 224",
413
+ "future_targets": "none (one observation frame)"
414
+ },
415
+ "proprio": {
416
+ "robot": "g1",
417
+ "body_dims": 29,
418
+ "bias_deg": 2.0,
419
+ "bias_scope": "per_sample",
420
+ "noise_deg": 0.25,
421
+ "noise_clip_sigma": 3,
422
+ "delay_probability": 0.0,
423
+ "history_drop_probability": 0.0,
424
+ "velocity": false
425
+ },
426
+ "native_image_augmentation": "off",
427
+ "evaluation": "off"
428
+ },
429
+ "preflight": {
430
+ "samples": 64,
431
+ "state_dim": 44,
432
+ "body_dims": 29,
433
+ "images_changed": 64,
434
+ "body_values_moved": 1.0,
435
+ "max_body_offset_deg": 2.5908,
436
+ "actions_bit_identical": true,
437
+ "non_body_state_bit_identical": true,
438
+ "eval_items_deterministic": 8
439
+ },
440
+ "aug_seed": 42,
441
+ "layout": {
442
+ "nodes": 1,
443
+ "gpus": 1,
444
+ "per_gpu_batch": 512,
445
+ "global_batch": 512,
446
+ "gradient_accumulation": 1,
447
+ "num_workers": 32,
448
+ "prefetch": 2
449
+ },
450
+ "continuation": {
451
+ "init_from": "/root/hb_runs/flash30k/staging/fm_b8_init_source/checkpoints/step-006000",
452
+ "init_step": 6000,
453
+ "init_weights": "raw policy and EMA from /root/hb_runs/flash30k/staging/fm_b8_init_source/train_state.pt (written at step 6000)",
454
+ "init_model_sha256": "49f877e3a020061ca3fd91b94f178596a9348d02548e116ea261eeecb5675ed8",
455
+ "init_code_commit": "028df1bb7024fb1e3d176de7e60c84d3333cd97f",
456
+ "original_peak_lr": 0.0001,
457
+ "peak_lr": 0.0001,
458
+ "peak_lr_factor": 1.0,
459
+ "warmup_steps": 500,
460
+ "warmup_ratio": 0.008333,
461
+ "more_steps": 60000,
462
+ "total_steps": 66000,
463
+ "optimizer": "fresh AdamW (same groups, betas, weight decay)",
464
+ "schedule": "fresh: warm-up then the policy's cosine over the continuation steps",
465
+ "ema_decay_steps": "total steps (the EMA keeps averaging as in the original run)",
466
+ "init_contract": "g1_sonic_dfx6",
467
+ "hands_switch": "measured -> commanded hands (owner 2026-11-28); state and action normalizers re-fit on the data of this run",
468
+ "protocol": {
469
+ "peak_lr_factor": 0.3,
470
+ "warmup_ratio": 0.05,
471
+ "steps": [
472
+ 2000,
473
+ 4000
474
+ ],
475
+ "deviations": [
476
+ "lr 0.0001",
477
+ "warmup 500",
478
+ "steps 60000"
479
+ ],
480
+ "exception": "owner 2026-11-28: \u7eed\u8bad\u7684\u6b65\u6570\u6bd4\u8f83\u591a\u7684\u5c31\u4e0d\u9700\u8981\u53bb\u964d\u4f4e\u5b66\u4e60\u7387\u7684\u5cf0\u503c\u3002\u6211\u89c9\u5f97\u5b66\u4e60\u7387\u5cf0\u503c\u53ef\u4ee5\u8ddf\u4ece\u5934\u8bad\u4e00\u6837\u53bb\u5b89\u6392; FM-DiT v1 base 58000 (collaborator's A17 80000 steps on 751.84 frames/episode); measured -> commanded hands (owner: \u7eed\u8bad\u65f6\u6539\u6210\u5b66\u6307\u4ee4\u624b\uff0c\u80af\u5b9a\u8981\u8fd9\u4e48\u505a)"
481
+ }
482
+ },
483
+ "total_steps": 66000,
484
+ "save_steps": [
485
+ 16000,
486
+ 26000,
487
+ 36000,
488
+ 46000,
489
+ 50000,
490
+ 56000,
491
+ 66000
492
+ ],
493
+ "save_rule": "6 checkpoints spread evenly over the steps on the 250-step grid (owner 2026-11-27)",
494
+ "protocol_exceptions": [
495
+ "owner 2026-11-28: FM-DiT v1 base steps 58000 (HumanWAM bai a7c875b); steps = ceil1000(58000 x 614.98 frames per episode / 544.33) = 66000; continued from step 6000 to 66000; commanded hands (owner 2026-11-27)",
496
+ "owner 2026-11-30: FM-DiT \u7167\u539f\u5b66\u4e60\u7387\u66f2\u7ebf\u8bad\u5230\u7d2f\u8ba1 50000 \u6b65\u622a\u505c\uff08\u300c\u884c\uff0c\u622a\u505c\u300d\uff09: --stop-at 50000, the learning-rate curve that of --steps; code = Humanoid_benchmark bai 433ba198 + stop-at patch (the evaluation/baselines/train.py part of bai 39f9b83a, git diff 39f9b83a^ 39f9b83a -- evaluation/baselines/train.py, sha256 db0911a84ba7a847befd22955ac99a9c04c2307a97f696be4e73da510fc19977); trained on the MLP 4090D (24 GB, one card, batch 512, same recipe as the A800)"
497
+ ],
498
+ "stop_at": 50000,
499
+ "ema_schedule": "hb",
500
+ "inloop": {
501
+ "task": "b8c",
502
+ "code": "/root/hb_runs/flash30k/policies/eval-action-mse",
503
+ "every": 250,
504
+ "exception": null,
505
+ "code_sha256": {
506
+ "hb_inloop_core.py": "154fa6d905e32d61c0def546caf6979c3a148b7bef0c1284e773b9051dddce97",
507
+ "hb_eval_common.py": "d89b1bfc1ac03d489b6ba2ac7c61eab3f318023ec37677dd5ee02b93d851d6ac"
508
+ }
509
+ },
510
+ "protocol_recipe": {
511
+ "batch_size": 512,
512
+ "long_task_factor": 1
513
+ },
514
+ "protocol_deviations": [],
515
+ "environment": {
516
+ "python": "3.12.1",
517
+ "torch": "2.9.0+cu128",
518
+ "numpy": "2.2.6",
519
+ "cuda": "12.8",
520
+ "cudnn": 91002,
521
+ "torchvision": "0.24.0+cu128",
522
+ "pillow": "13.0.0",
523
+ "gpu": "NVIDIA GeForce RTX 4090 D",
524
+ "driver": "595.58.03"
525
+ },
526
+ "code_dirty": null,
527
+ "allow_dirty_tree": false,
528
+ "augmentation_sha256": "9f7713cea4f846efcfc924234267ced48210357f419d67915c10b504316bedde",
529
+ "order": "EpochSampler: default_rng([seed, 1, epoch]) permutation; augmentation default_rng([aug_seed, draw])"
530
+ },
531
+ "stats": {
532
+ "state": {
533
+ "min": [
534
+ -0.2515260875225067,
535
+ -0.03310006856918335,
536
+ -0.08915279805660248,
537
+ 0.14301416277885437,
538
+ -0.18305416405200958,
539
+ -0.10634835064411163,
540
+ -0.2634684145450592,
541
+ -0.05348178371787071,
542
+ -0.21431514620780945,
543
+ 0.13807232677936554,
544
+ -0.2242385447025299,
545
+ -0.09678935259580612,
546
+ -0.18892650306224823,
547
+ -0.10323800146579742,
548
+ -0.09472811967134476,
549
+ -0.2798849642276764,
550
+ 0.1722967028617859,
551
+ -1.1891459226608276,
552
+ 0.3821650445461273,
553
+ -0.5277573466300964,
554
+ -0.1239900067448616,
555
+ -0.025756916031241417,
556
+ -1.5671592950820923,
557
+ -1.708814024925232,
558
+ -0.94542396068573,
559
+ -0.8548623323440552,
560
+ -0.9579849243164062,
561
+ -0.9779664278030396,
562
+ -0.5873764157295227,
563
+ 0.9998621344566345,
564
+ 0.9998221397399902,
565
+ 0.9998023509979248,
566
+ 0.9998185634613037,
567
+ 0.9975361227989197,
568
+ 0.9988760948181152,
569
+ 0.360027939081192,
570
+ 0.4790782630443573,
571
+ 0.5461887717247009,
572
+ 0.48382189869880676,
573
+ 0.6635858416557312,
574
+ 0.0,
575
+ -0.10022255033254623,
576
+ -0.03946204483509064,
577
+ -1.0
578
+ ],
579
+ "max": [
580
+ 0.00482684513553977,
581
+ 0.13756881654262543,
582
+ 0.2979176640510559,
583
+ 0.3711587190628052,
584
+ 0.031152762472629547,
585
+ 0.010087746195495129,
586
+ 0.019378269091248512,
587
+ 0.1355365365743637,
588
+ 0.182325080037117,
589
+ 0.4443013668060303,
590
+ -0.05482839047908783,
591
+ 0.011374615132808685,
592
+ 0.165291890501976,
593
+ 0.05307222157716751,
594
+ 0.177412211894989,
595
+ 0.22115345299243927,
596
+ 0.6989883780479431,
597
+ -0.3335850238800049,
598
+ 1.1546826362609863,
599
+ 0.28441083431243896,
600
+ 0.08963758498430252,
601
+ 0.3550512492656708,
602
+ 1.1140739917755127,
603
+ -0.22596199810504913,
604
+ 1.7804871797561646,
605
+ 1.2184052467346191,
606
+ 1.2347023487091064,
607
+ 1.5067987442016602,
608
+ 1.0105962753295898,
609
+ 1.0,
610
+ 1.0,
611
+ 1.0,
612
+ 1.0,
613
+ 0.9982408285140991,
614
+ 0.9999225735664368,
615
+ 1.0,
616
+ 1.0,
617
+ 1.0,
618
+ 0.9999973177909851,
619
+ 1.0,
620
+ 1.0,
621
+ 0.038201265037059784,
622
+ 0.023285934701561928,
623
+ -0.9949650168418884
624
+ ],
625
+ "mean": [
626
+ -0.07244415528619287,
627
+ 0.016438895257606716,
628
+ -0.03188766069938736,
629
+ 0.19652274108921836,
630
+ -0.09995080381043964,
631
+ -0.0335864852112993,
632
+ -0.06201331924385435,
633
+ 0.0041316509641342114,
634
+ -0.07562538691067132,
635
+ 0.22342829523439264,
636
+ -0.13939505500881355,
637
+ -0.02568257955335654,
638
+ 0.020507808718722174,
639
+ 0.0030919114143910654,
640
+ 0.11976549024164236,
641
+ -0.04130542899628228,
642
+ 0.27413152575942573,
643
+ -0.667075950232086,
644
+ 0.9776525052369189,
645
+ -0.15594609082852004,
646
+ -0.04114803172895316,
647
+ 0.07066678088305102,
648
+ -0.44530701068620304,
649
+ -0.7956643808095055,
650
+ 0.6432070891275159,
651
+ 0.07140851169135853,
652
+ -0.22403887370387132,
653
+ 0.19658286211869352,
654
+ 0.3118955244879216,
655
+ 0.9999827171293537,
656
+ 0.999982850921418,
657
+ 0.9999830789480982,
658
+ 0.9999811406495951,
659
+ 0.9977658298817017,
660
+ 0.9997360855995177,
661
+ 0.7778945983312991,
662
+ 0.8171959691692932,
663
+ 0.8399288212288848,
664
+ 0.8394280370284749,
665
+ 0.8745686375938581,
666
+ 0.12291562838728093,
667
+ -0.023435156143715264,
668
+ -0.004820223051842413,
669
+ -0.999617456030026
670
+ ],
671
+ "std": [
672
+ 0.045712745420827386,
673
+ 0.013154301249487431,
674
+ 0.02405439153160751,
675
+ 0.0422870935042734,
676
+ 0.01604373013239405,
677
+ 0.010666838959405088,
678
+ 0.0447255039612766,
679
+ 0.014369854397034587,
680
+ 0.025451572022126993,
681
+ 0.05279699313574748,
682
+ 0.02213303083995789,
683
+ 0.011183898115253933,
684
+ 0.07041149453770397,
685
+ 0.015833724218855847,
686
+ 0.039560888033149964,
687
+ 0.08342761969885264,
688
+ 0.0587237913039723,
689
+ 0.22301655606787774,
690
+ 0.08125572382728762,
691
+ 0.1281115145665045,
692
+ 0.03600107397023974,
693
+ 0.04123008646611267,
694
+ 0.5831912382159029,
695
+ 0.23706341250281637,
696
+ 0.5432748450536339,
697
+ 0.504036388323598,
698
+ 0.31188020039153314,
699
+ 0.3436391052756804,
700
+ 0.26504982482523237,
701
+ 1.8214790335763182e-05,
702
+ 2.3385127857745866e-05,
703
+ 2.5684815254370892e-05,
704
+ 2.368414515012511e-05,
705
+ 7.802892144541008e-05,
706
+ 6.03931448414821e-05,
707
+ 0.2307055833669559,
708
+ 0.1900819078013402,
709
+ 0.16354430170740317,
710
+ 0.16593648793853702,
711
+ 0.1286487353890603,
712
+ 0.3083183803524622,
713
+ 0.013093107258771247,
714
+ 0.004580775936054731,
715
+ 0.0002959946385408924
716
+ ]
717
+ },
718
+ "action": {
719
+ "min": [
720
+ 0.0,
721
+ -0.375,
722
+ -0.4375,
723
+ -0.125,
724
+ -0.375,
725
+ -0.3125,
726
+ -0.375,
727
+ -0.3125,
728
+ -0.25,
729
+ -0.25,
730
+ -0.5625,
731
+ -0.1875,
732
+ -0.125,
733
+ -0.3125,
734
+ -0.125,
735
+ -0.25,
736
+ -0.125,
737
+ -0.1875,
738
+ -0.5,
739
+ -0.25,
740
+ -0.1875,
741
+ -0.5625,
742
+ -0.25,
743
+ -0.375,
744
+ -0.4375,
745
+ -0.0625,
746
+ -0.375,
747
+ -0.375,
748
+ -0.3125,
749
+ -0.3125,
750
+ 0.0,
751
+ 0.125,
752
+ -0.3125,
753
+ 0.0,
754
+ 0.125,
755
+ -0.4375,
756
+ -0.1875,
757
+ -0.4375,
758
+ -0.25,
759
+ -0.1875,
760
+ -0.4375,
761
+ -0.375,
762
+ -0.1875,
763
+ -0.0625,
764
+ -0.3125,
765
+ -0.25,
766
+ -0.1875,
767
+ -0.3125,
768
+ -0.3125,
769
+ -0.5625,
770
+ -0.125,
771
+ -0.125,
772
+ -0.4375,
773
+ -0.5,
774
+ -0.1875,
775
+ -0.25,
776
+ -0.375,
777
+ -0.0625,
778
+ -0.4375,
779
+ -0.25,
780
+ -0.4375,
781
+ 0.0625,
782
+ -0.25,
783
+ 0.0,
784
+ 1.0,
785
+ 1.0,
786
+ 1.0,
787
+ 1.0,
788
+ 1.0,
789
+ 1.0,
790
+ 0.36000001430511475,
791
+ 0.36000001430511475,
792
+ 0.36000001430511475,
793
+ 0.36000001430511475,
794
+ 0.36000001430511475,
795
+ 0.0
796
+ ],
797
+ "max": [
798
+ 0.375,
799
+ 0.25,
800
+ 0.25,
801
+ 0.1875,
802
+ 0.1875,
803
+ 0.1875,
804
+ 0.25,
805
+ 0.25,
806
+ 0.1875,
807
+ 0.125,
808
+ 0.0625,
809
+ 0.1875,
810
+ 0.5,
811
+ 0.1875,
812
+ 0.25,
813
+ 0.0625,
814
+ 0.3125,
815
+ 0.5,
816
+ 0.1875,
817
+ 0.25,
818
+ 0.25,
819
+ 0.0625,
820
+ 0.4375,
821
+ 0.25,
822
+ 0.0,
823
+ 0.4375,
824
+ 0.0,
825
+ 0.1875,
826
+ 0.1875,
827
+ 0.1875,
828
+ 0.4375,
829
+ 0.5,
830
+ 0.3125,
831
+ 0.3125,
832
+ 0.3125,
833
+ 0.0625,
834
+ 0.1875,
835
+ 0.3125,
836
+ 0.1875,
837
+ 0.25,
838
+ 0.0,
839
+ 0.25,
840
+ 0.125,
841
+ 0.5,
842
+ 0.125,
843
+ 0.5,
844
+ 0.4375,
845
+ 0.4375,
846
+ 0.4375,
847
+ 0.0,
848
+ 0.125,
849
+ 0.25,
850
+ 0.5,
851
+ -0.0625,
852
+ 0.125,
853
+ 0.4375,
854
+ 0.5,
855
+ 0.3125,
856
+ 0.125,
857
+ 0.125,
858
+ 0.125,
859
+ 0.5,
860
+ 0.125,
861
+ 0.6875,
862
+ 1.0,
863
+ 1.0,
864
+ 1.0,
865
+ 1.0,
866
+ 1.0,
867
+ 1.0,
868
+ 1.0,
869
+ 1.0,
870
+ 1.0,
871
+ 1.0,
872
+ 1.0,
873
+ 1.0
874
+ ],
875
+ "mean": [
876
+ 0.2026803717194055,
877
+ -0.07236617450974016,
878
+ -0.02242552603336694,
879
+ 0.02358918176200852,
880
+ -0.12101816319229894,
881
+ -0.10377979771699893,
882
+ -0.04818144492503821,
883
+ -0.09367987576831767,
884
+ -0.015672257634394615,
885
+ -0.07295460827994406,
886
+ -0.28937628052944814,
887
+ 0.023045464893167257,
888
+ 0.12778362710982472,
889
+ -0.014680355458714104,
890
+ 0.047179379817229826,
891
+ -0.12413716706234348,
892
+ 0.0648974356889655,
893
+ 0.1738440680997756,
894
+ -0.1366050521968194,
895
+ 0.05253626134183226,
896
+ 0.005097726755341637,
897
+ -0.21554664379329408,
898
+ 0.09576226056131906,
899
+ -0.11485841002959446,
900
+ -0.21714120784415752,
901
+ 0.25317489999674786,
902
+ -0.23478507431135973,
903
+ -0.10450746365735471,
904
+ -0.049666249308920614,
905
+ -0.03343909558034407,
906
+ 0.2612117467234707,
907
+ 0.28021846238902076,
908
+ 0.013058351491105402,
909
+ 0.14741942827409021,
910
+ 0.23094043708738496,
911
+ -0.2599698364174445,
912
+ 0.054112532114865525,
913
+ -0.18685465380988,
914
+ -0.021627735861328823,
915
+ -0.045454730235129595,
916
+ -0.261119264041107,
917
+ -0.09780399362580897,
918
+ -0.03171647858466942,
919
+ 0.30728844840482616,
920
+ -0.13527167550164232,
921
+ 0.061584319815278545,
922
+ 0.07089966340368792,
923
+ 0.06740158216527367,
924
+ 0.18057091287521546,
925
+ -0.27359832840092363,
926
+ -0.01098104816416794,
927
+ 0.03545237243487593,
928
+ 0.1730208705974178,
929
+ -0.26741316790789943,
930
+ -0.03493507918956714,
931
+ 0.1694120133988097,
932
+ 0.01502691144427461,
933
+ 0.05571421021821848,
934
+ -0.22518415233015707,
935
+ -0.05392248528407428,
936
+ -0.1961598344661615,
937
+ 0.3429247699112166,
938
+ -0.04006126215486683,
939
+ 0.40486580864418353,
940
+ 1.0,
941
+ 1.0,
942
+ 1.0,
943
+ 1.0,
944
+ 1.0,
945
+ 1.0,
946
+ 0.7644257025600019,
947
+ 0.7644257025600019,
948
+ 0.7644257025600019,
949
+ 0.7644257025600019,
950
+ 0.7659686295247596,
951
+ 0.13423402414162272
952
+ ],
953
+ "std": [
954
+ 0.07423638798986239,
955
+ 0.10276070894626457,
956
+ 0.11812702387971753,
957
+ 0.05957396656117891,
958
+ 0.1218417031488596,
959
+ 0.08063836551976374,
960
+ 0.1020635000819969,
961
+ 0.10540346375069484,
962
+ 0.08296831170197061,
963
+ 0.05989282207073844,
964
+ 0.131405419274155,
965
+ 0.07688508477180626,
966
+ 0.15530657456533145,
967
+ 0.09090021877289593,
968
+ 0.07144535330531092,
969
+ 0.07721423672952077,
970
+ 0.061937753226413185,
971
+ 0.12535445915332458,
972
+ 0.1406645362754369,
973
+ 0.09610483490082063,
974
+ 0.0892112540257282,
975
+ 0.10101183108941218,
976
+ 0.14459992137856284,
977
+ 0.09259695505428482,
978
+ 0.07250089525780803,
979
+ 0.07751064616894329,
980
+ 0.09003536032570492,
981
+ 0.08768655804866919,
982
+ 0.0793513264967945,
983
+ 0.0799717022695259,
984
+ 0.08767655242632699,
985
+ 0.06686962750120226,
986
+ 0.11139553980852172,
987
+ 0.05962527954838032,
988
+ 0.03113638664810605,
989
+ 0.1104336480130166,
990
+ 0.0900293543854962,
991
+ 0.17353368370821917,
992
+ 0.06621053001132303,
993
+ 0.07044267349366652,
994
+ 0.07468062148900616,
995
+ 0.13559357690832427,
996
+ 0.051673248141484364,
997
+ 0.11970962808802042,
998
+ 0.09873016730126778,
999
+ 0.1482997857923691,
1000
+ 0.14644960009292055,
1001
+ 0.12362418143308783,
1002
+ 0.14892813932159055,
1003
+ 0.1264928491368565,
1004
+ 0.04485723360367807,
1005
+ 0.06556638017875786,
1006
+ 0.23014907315132233,
1007
+ 0.07366488770406758,
1008
+ 0.05520901424631441,
1009
+ 0.1518289001396863,
1010
+ 0.1840720418570084,
1011
+ 0.05832378814080937,
1012
+ 0.11903714776197126,
1013
+ 0.05677283141546173,
1014
+ 0.09207849117719222,
1015
+ 0.09729334507011746,
1016
+ 0.0780996197326025,
1017
+ 0.16351388381996734,
1018
+ 0.0,
1019
+ 0.0,
1020
+ 0.0,
1021
+ 0.0,
1022
+ 0.0,
1023
+ 0.0,
1024
+ 0.24588449589222341,
1025
+ 0.24588449589222341,
1026
+ 0.24588449589222341,
1027
+ 0.24588449589222341,
1028
+ 0.24578410015930552,
1029
+ 0.3348986548442017
1030
+ ]
1031
+ }
1032
+ },
1033
+ "code_commit": "433ba198964eb54173f2beb5085ba96f7fab0f9e",
1034
+ "task": "b8c",
1035
+ "dataset_id": "humanoid-benchmark/b8-table-wipe-expert-v1@3b2e6180508f84f70fda8b33cd3e41c14225f0b5"
1036
+ }
b8-table-wipe/b512-cont-20261117-stop50k/step-050000/training_records/stopat_39f9b83a_train.diff ADDED
@@ -0,0 +1,84 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ diff --git a/evaluation/baselines/train.py b/evaluation/baselines/train.py
2
+ index bb5b697e..e15afeaf 100644
3
+ --- a/evaluation/baselines/train.py
4
+ +++ b/evaluation/baselines/train.py
5
+ @@ -55,7 +55,10 @@ Writes into --out: run.json (arguments), train_log.jsonl, checkpoints/step-NNNNN
6
+ format; owner 2026-11-27, every small model: 6 checkpoints spread evenly over the run's steps, each rounded to the
7
+ in-training MSE's 250-step grid, the last one at the end; save_points()), checkpoints/final -> the last one, and
8
+ train_state.pt (optimizer, schedule, EMA, step) that
9
+ ---resume continues from (an interrupted run: the same schedule, not a continuation). Each save also measures the EMA
10
+ +--resume continues from (an interrupted run: the same schedule, not a continuation). --stop-at TOTAL ends the run early
11
+ +at that total step (owner 2026-11-30, a fixed-step early stop): one extra checkpoint and train_state.pt there,
12
+ +stopped.json instead of complete.json; the learning-rate curve and the other save points stay those of --steps, so a
13
+ +later --resume without --stop-at continues the same run. Each save also measures the EMA
14
+ policy offline on fixed frames (held-out episodes with --val-episodes, else training frames): normalized-action MSE
15
+ overall and per action group.
16
+
17
+ @@ -618,6 +621,11 @@ def main():
18
+ p.add_argument('--device', default='cuda:0')
19
+ p.add_argument('--no-amp', action='store_true')
20
+ p.add_argument('--resume', action='store_true', help='continue from <out>/train_state.pt')
21
+ + p.add_argument('--stop-at', type=int, metavar='TOTAL_STEP',
22
+ + help='end the run at this TOTAL step (original + continuation steps; owner 2026-11-30): save a '
23
+ + 'checkpoint and train_state.pt there and write stopped.json. The learning-rate curve and the '
24
+ + "other save points stay those of --steps (an early stop at a fixed step, not a shorter "
25
+ + 'schedule); the run can be resumed later with the same arguments')
26
+ p.add_argument('--init-from', type=Path, metavar='CHECKPOINT',
27
+ help='continuation of a finished run (HumanWAM hb_training/protocol.yaml interface.continuation: '
28
+ 'weights only): its checkpoint folder <run>/checkpoints/step-NNNNNN. Loads the raw policy and '
29
+ @@ -877,6 +885,15 @@ def main():
30
+ print('HB_RESUME no random state in train_state.pt (written before 2026-11-27): the streams restart',
31
+ flush=True)
32
+ print(json.dumps(dict(event='resumed', step=step0 + step, local_step=step)), flush=True)
33
+ + stop_local = None
34
+ + if args.stop_at is not None: # owner 2026-11-30: a fixed-step early stop; the schedule stays that of --steps
35
+ + stop_local = args.stop_at - step0
36
+ + if not step < stop_local <= args.steps:
37
+ + raise SystemExit(f'--stop-at {args.stop_at}: must lie after the current total step {step0 + step} and at or '
38
+ + f'before the end of the schedule {step0 + args.steps}')
39
+ + save_at.add(stop_local)
40
+ + print(json.dumps(dict(event='stop_at', step=args.stop_at, local_step=stop_local)), flush=True)
41
+ + end = stop_local or args.steps
42
+
43
+ inloop = None
44
+ if args.inloop_task:
45
+ @@ -904,7 +921,7 @@ def main():
46
+ save_rule=(f'every {args.save_every} steps (exception)' if args.save_every else
47
+ f'{SAVE_COUNT} checkpoints spread evenly over the steps on the {SAVE_GRID}-step grid '
48
+ '(owner 2026-11-27)'),
49
+ - protocol_exceptions=args.protocol_exception)
50
+ + protocol_exceptions=args.protocol_exception, stop_at=args.stop_at)
51
+ training.update(ema_schedule=defaults.get('ema_schedule', 'hb'),
52
+ inloop=dict(task=args.inloop_task, code=str(args.inloop_code) if args.inloop_code else None,
53
+ every=int(os.environ.get('HB_INLOOP_EVERY', '250')) if args.inloop_task else 0,
54
+ @@ -977,7 +994,7 @@ def main():
55
+ set_rng_state(resume_rng)
56
+ policy.train()
57
+ t0, data_s, acc = time.monotonic(), 0.0, {}
58
+ - while step < args.steps:
59
+ + while step < end:
60
+ tick = time.monotonic()
61
+ for images, *labels in loader:
62
+ data_s += time.monotonic() - tick
63
+ @@ -1009,10 +1026,20 @@ def main():
64
+ policy.train()
65
+ if step in save_at:
66
+ save(step)
67
+ - if step >= args.steps:
68
+ + if step >= end:
69
+ break
70
+ tick = time.monotonic()
71
+ log.close()
72
+ + if stop_local is not None and step >= stop_local and step < args.steps:
73
+ + (out / 'stopped.json').write_text(json.dumps(dict(
74
+ + run=out.name, policy=args.policy, stopped_at=step0 + step, local_step=step, schedule_steps=args.steps,
75
+ + schedule_total_steps=step0 + args.steps, reason='--stop-at (owner 2026-11-30: a fixed-step early stop; the '
76
+ + 'learning-rate curve is that of --steps, not rescheduled)', checkpoint=f'checkpoints/step-{step0 + step:06d}',
77
+ + resumable='train_state.pt at this step: --resume with the same arguments (without --stop-at) continues',
78
+ + code_commit=config['code_commit'], stopped_utc=datetime.now(timezone.utc).strftime('%Y-%m-%dT%H:%M:%SZ')),
79
+ + indent=1))
80
+ + print(json.dumps(dict(event='stopped', step=step0 + step, checkpoint=str(out / 'checkpoints/final'))),
81
+ + flush=True)
82
+ if step >= args.steps: # as HumanWAM's launchers (e.g. fastwam_cont.sh): what the finished run is
83
+ c = continuation or {}
84
+ (out / 'complete.json').write_text(json.dumps(dict(
b8-table-wipe/b512-cont-20261117-stop50k/step-050000/training_records/stopped.json ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "run": "b8-fm_dit-b512-cont60k-total66k",
3
+ "policy": "fm_dit",
4
+ "stopped_at": 50000,
5
+ "local_step": 44000,
6
+ "schedule_steps": 60000,
7
+ "schedule_total_steps": 66000,
8
+ "reason": "--stop-at (owner 2026-11-30: a fixed-step early stop; the learning-rate curve is that of --steps, not rescheduled)",
9
+ "checkpoint": "checkpoints/step-050000",
10
+ "resumable": "train_state.pt at this step: --resume with the same arguments (without --stop-at) continues",
11
+ "code_commit": "433ba198964eb54173f2beb5085ba96f7fab0f9e",
12
+ "stopped_utc": "2026-11-30T16:33:10Z"
13
+ }
b8-table-wipe/b512-cont-20261117-stop50k/step-050000/training_records/train.log ADDED
The diff for this file is too large to render. See raw diff
 
b8-table-wipe/b512-cont-20261117-stop50k/step-050000/training_records/train_log.jsonl ADDED
The diff for this file is too large to render. See raw diff