Two-seed verdict (seed 2000 independently re-run): GeCO beats the FM-loss baseline by +0.064 AUROC [+0.033, +0.095]; review folder; corrected step-size account
Browse filesFiles changed (12)
- README.md+31-21
- code/experiments/lerobot/eval_variant.py+4-1
- code/experiments/lerobot/geco_object_fix.pyAdded+150
- code/experiments/lerobot/run.py+28-6
- code/experiments/lerobot/variants.py+36-10
- index.html
- logs/G0_s2000_20261202T122643Z/eval_libero_goal.logAdded
- logs/G0_s2000_20261202T122643Z/eval_libero_spatial.logAdded
- logs/G0_s2000_20261202T122643Z/train.logAdded
- logs/G2_s2000_20261202T122643Z/eval_libero_goal_k10_e.logAdded
- logs/G2_s2000_20261202T122643Z/eval_libero_spatial_k10_e.logAdded
- logs/G2_s2000_20261202T122643Z/train.logAdded
23 unmodified lines242526272829303132333435363738394041424344454647484950515253545556575859606162635 unmodified lines697071727374757677784 unmodified lines8384858687888910 unmodified lines10010110210310410510623 unmodified linesa non-VLA policy (a DiT-style transformer on frozen DINOv2 + T5 features). We test the claim on a VLA, SmolVLA, withthe paper's own VLA recipe (fixed time input t = 0).## Verdict: verified on a VLA, with a smaller margin than the paper**On SmolVLA, GeCO's final residual is a working OOD detector and beats the flow-matching-loss baseline**: closed-loopAUROC **0.83 [0.79, 0.87]** against **0.79 [0.75, 0.82]**, and at the same 90% ID retention it flags 44% of OODplanning calls against 27%. This holds once SmolVLA's padded action dimensions are handled and with the paper's VLAstep sizes (App. E), which our tuning on in-distribution data alone also selects. The paper's own model is notreleased, so its exact 0.93 vs 0.53 was not tested. On a VLA the baseline is much stronger (its pretrainedvision-language backbone already reacts to unseen scenes and instructions), so the margin is about 0.05 rather than0.40 and the two intervals overlap. Offline, on demonstration frames, GeCO reaches 0.93 against 0.87.**See it:** the [report](index.html) has the figures and annotated example rollouts (successes, failures, caught andmissed OOD episodes); the [rollout gallery](episodes.html) shows all 200 episodes of the final policy.| Closed loop, LIBERO-Goal (ID) vs LIBERO-Spatial (OOD), K_max = 10 | AUROC [95% CI] | equal-weight AUROC | OOD flagged at 90% ID kept | Goal success ||---|---|---|---|---|| Paper: GeCO | 0.93 | — | 82.4-84.0% | — || Paper: baseline (FM loss, t = 1) | 0.53 | — | 14.4% (at 27.8% ID kept) | — || **Ours: GeCO (G2: padded dims at 0, App. E step sizes)** | **0.832 [0.790, 0.867]** | 0.857 | **44.0%** | 82% || **Ours: baseline (G0: FM loss, t = 1)** | **0.787 [0.754, 0.822]** | 0.813 | 27.3% | 84% || Ours: GeCO, G1 (padding leaks), App. E step sizes | 0.798 [0.765, 0.841] | 0.832 | 26.2% | 59% || Ours: GeCO, G2, App. A.3 step sizes | 0.440 [0.402, 0.490] | 0.466 | 5.5% | 79% || Ours: GeCO, G1, App. A.3 step sizes (first run) | 0.455 [0.390, 0.525] | 0.505 | 0.0% | 73% || Ours: GeCO, G1, App. A.3, K_max 30 / 100 | 0.657 / 0.752 | 0.715 / 0.757 | 2.9% / 14.3% | 74% / 55% |AUROC: 20 planning calls sampled per episode as in the paper (all calls when fewer), 95% interval from a bootstrapover episodes (2,000 resamples, the subsample redrawn each time); equal-weight AUROC gives every episode the sameweight. 100 ID and 100 OOD episodes per row. Neither policy solves any Spatial episode (expected: unseen layouts andinstructions). The paper's absolute filter thresholds (App. D) flag every episode in every run: our residuals live ona different scale (50 x 7 chunk), so Time Saved is not comparable and not claimed.## How we got there: two problems, found by an independent reviewOur first run reported AUROC 0.455 and the verdict "falsified". An independent review of this Space by another agent(Lor), run in its own environment, re-derived every number and pointed at two causes. We checked both:1. **Step sizes (the main one).** The paper never states the step sizes for Table 5. We had used App. A.3's generalschedule (0.1, then 0.05, then 0.02); App. E's VLA schedule starts at 0.25 and decays to 0.02. With A.3's small5 unmodified linesevery step: the residual after 10 steps drops from ≈ 16.5 to ≈ 2.8 on ID frames, the field at the expert chunkseparates the suites (AUROC 0.96 vs 0.82), and task success recovers (59% → 82%).**Choosing the step sizes without peeking.** We swept 16 schedules on G2 offline (`results/G2_*/geco_diagnose_schede_sweep.json`) and picked the one that brings the optimised chunk closest to the expert's on**in-distribution frames only**. It selected App. E's schedule itself (distance 10.02; next 10.05). Its OOD AUROC wasread only afterwards. Any schedule whose early steps are about 0.1 or larger scores 0.87-0.94 offline; App. A.3's isthe outlier (0.49). Choosing by the OOD column would have inflated the result.## What is different from the paper (scale and setup)4 unmodified lines| Training | not stated for this policy (LIBERO policies: 30k steps) | **10k steps**, batch 16 (≈ 3 epochs of LIBERO-Goal), one seed per model || Action chunk | 16 (8 executed) | 50 (10 executed) || Episodes per suite | 500 | **100** (10 per task) || Step sizes η_k | **not stated for Table 5**. App. A.3 (general sampler): 0.1 / 0.05 / 0.02 / 0.01, K_max 30, τ 0.4. App. E (real-robot VLA): 0.25 decaying to 0.02 (law not given), K_max 10, τ 1.5 | App. E with a geometric decay over 10 steps (selected by our ID-only sweep); A.3 also reported || K_max for OOD | 10 (Sec. 4.3) | 10; 30 and 100 as diagnostics || α₀ (onset of the target decay) | **conflicting**: App. A.4 says 0.1; Sec. 4.4 / Table 6 call α = 0.8 best | 0.1 (App. A.4) || Padded action dims | none | SmolVLA pads 7 → 32; G2 holds the padded dims at 0 (train and inference) |10 unmodified lines| `code/experiments/lerobot/` | the implementation: `variants.py` (`patch_geco` with `zero_pad`, `geco_step_sizes`, `patch_fm_score`), `run.py` (runs G0, G1, G2), `train_variant.py`, `eval_variant.py`, `geco_diagnose.py` (offline diagnosis and sweep), `geco_report.py`, `modal/app.py` || `code/src/behavior_course/metrics/geco.py` | AUROC (plain and equal-weight), operating point, bootstrap, App. D filters, Time Saved || `code/experiments/lerobot/modal/requirements.txt` | **environment**: exact package versions (lerobot 0.7.0, torch 2.11.0+cu128, Python 3.12); the Modal image is defined in `modal/app.py` || `results/` | per run and setting: `eval_info.json` (success), `ood_scores.json` (one score per planning call; G2 also every step), `run.json` (exact commands), `geco_diagnose*.json`, `geco_report.json` || `logs/` | full output of every run, including failures: a missing LIBERO config crashed the first evaluations; a dropped client connection stopped two Modal runs, which were resumed from checkpoints; smoke runs in `logs/smoke/` |Hardware: Modal, L40S for training (≈ 50 min per model), L4 for evaluation and diagnosis. Personal data (email,23 unmodified lines2425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970715 unmodified lines77787980818283848586874 unmodified lines9293949596979810 unmodified lines10911011111211311411511623 unmodified linesa non-VLA policy (a DiT-style transformer on frozen DINOv2 + T5 features). We test the claim on a VLA, SmolVLA, withthe paper's own VLA recipe (fixed time input t = 0).## Verdict: verified on a VLA, with a much smaller margin than the paper**Over two independently trained seeds, GeCO's final residual beats the flow-matching-loss baseline as an OODdetector on SmolVLA by +0.064 AUROC [+0.033, +0.095]** (paired over the same starting scenes), and at the same 90% IDretention it flags 21 points more OOD planning calls [+9, +32]. This holds once SmolVLA's padded action dimensionsare handled and with the paper's VLA step sizes (App. E). The paper's own model is not released, so its exact 0.93vs 0.53 was not tested. On a VLA the baseline is much stronger (its pretrained vision-language backbone alreadyreacts to unseen scenes and instructions), so the margin is about 0.06 rather than 0.40, and the paper's onlinefilters and adaptive early stopping do not carry over (the stopping threshold never fires on our scale).| Closed loop, LIBERO-Goal (ID) vs LIBERO-Spatial (OOD), K_max = 10 | AUROC [95% CI] | equal-weight AUROC | OOD flagged at 90% ID kept | Goal success ||---|---|---|---|---|| Paper: GeCO | 0.93 | — | 82.4-84.0% | — || Paper: baseline (FM loss, t = 1) | 0.53 | — | 14.4% (at 27.8% ID kept) | — || **Ours, seed 1000: GeCO (G2: padded dims at 0, App. E step sizes)** | **0.832 [0.790, 0.867]** | 0.857 | **44.0%** | 82% || **Ours, seed 1000: baseline (G0: FM loss, t = 1)** | **0.787 [0.754, 0.822]** | 0.813 | 27.3% | 84% || **Seed 2000 (independent re-run): GeCO G2** | **0.849 [0.810, 0.885]** | 0.869 | **50.8%** | 80% || **Seed 2000 (independent re-run): baseline G0** | **0.761 [0.726, 0.798]** | 0.791 | 24.5% | 83% || G2 − G0, paired: seed 1000 / seed 2000 / mean of both | +0.045 [−0.003, +0.086] / +0.088 [+0.041, +0.131] / **+0.064 [+0.033, +0.095]** | | +17 / +26 / **+21** pts | || Ours: GeCO, G1 (padding leaks), App. E step sizes | 0.798 [0.765, 0.841] | 0.832 | 26.2% | 59% || Ours: GeCO, G2, App. A.3 step sizes | 0.440 [0.402, 0.490] | 0.466 | 5.5% | 79% || Ours: GeCO, G1, App. A.3 step sizes (first run) | 0.455 [0.390, 0.525] | 0.505 | 0.0% | 73% || Ours: GeCO, G1, App. A.3, K_max 30 / 100 | 0.657 / 0.752 | 0.715 / 0.757 | 2.9% / 14.3% | 74% / 55% |The seed-2000 runs were trained and evaluated by a second agent (Lor) on its own GPUs from the published code only,which also confirms the code reproduces. The paired interval resamples the same episode indices for both models; themean-of-seeds interval covers episode noise given these four trained models, not between-seed variation (the gapmoved from 0.045 to 0.088 between seeds). Four GeCO configurations were compared before choosing G2 with App. Estep sizes as the headline; seed 2000 re-tests that configuration after the choice. Scripts and outputs:`review/` (paired and pooled bootstraps, the full review).AUROC: 20 planning calls sampled per episode as in the paper (all calls when fewer), 95% interval from a bootstrapover episodes (2,000 resamples, the subsample redrawn each time); equal-weight AUROC gives every episode the sameweight. 100 ID and 100 OOD episodes per row. Neither policy solves any Spatial episode (expected: unseen layouts andinstructions). The paper's absolute filter thresholds (App. D) flag every episode in every run: our residuals live ona different scale (50 x 7 chunk), so Time Saved is not comparable and not claimed.## How we got there: an independent review, two problems, a second seedOur first run reported AUROC 0.455 and the verdict "falsified". An independent review of this Space by another agent(Lor), run in its own environment, re-derived every number and pointed at two causes. We checked both, and asecond review then ran the paired test and the second seed above:1. **Step sizes (the main one).** The paper never states the step sizes for Table 5. We had used App. A.3's generalschedule (0.1, then 0.05, then 0.02); App. E's VLA schedule starts at 0.25 and decays to 0.02. With A.3's small5 unmodified linesevery step: the residual after 10 steps drops from ≈ 16.5 to ≈ 2.8 on ID frames, the field at the expert chunkseparates the suites (AUROC 0.96 vs 0.82), and task success recovers (59% → 82%).**Checking the step-size choice without peeking.** We evaluated App. E's schedule because it is the paper's only VLAsetting; the closed-loop runs with it were launched before any sweep. Afterwards, to check that choice, we swept 16schedules on G2 offline (`results/G2_*/geco_diagnose_schede_sweep.json`) and ranked them by how close the optimisedchunk ends to the expert's on **in-distribution frames only**. App. E's schedule came first, but only narrowly(distance 10.02; next 10.05, a 0.3% difference), so the sweep confirms the choice rather than making it. Any schedule whose early steps are about 0.1 or larger scores 0.87-0.94 offline; App. A.3's isthe outlier (0.49). Choosing by the OOD column would have inflated the result.## What is different from the paper (scale and setup)4 unmodified lines| Training | not stated for this policy (LIBERO policies: 30k steps) | **10k steps**, batch 16 (≈ 3 epochs of LIBERO-Goal), one seed per model || Action chunk | 16 (8 executed) | 50 (10 executed) || Episodes per suite | 500 | **100** (10 per task) || Step sizes η_k | **not stated for Table 5**. App. A.3 (general sampler): 0.1 / 0.05 / 0.02 / 0.01, K_max 30, τ 0.4. App. E (real-robot VLA): 0.25 decaying to 0.02 (law not given), K_max 10, τ 1.5 | App. E with a geometric decay over 10 steps (the paper's VLA setting; ranked first, narrowly, by a later ID-only sweep); A.3 also reported || K_max for OOD | 10 (Sec. 4.3) | 10; 30 and 100 as diagnostics || α₀ (onset of the target decay) | **conflicting**: App. A.4 says 0.1; Sec. 4.4 / Table 6 call α = 0.8 best | 0.1 (App. A.4) || Padded action dims | none | SmolVLA pads 7 → 32; G2 holds the padded dims at 0 (train and inference) |10 unmodified lines| `code/experiments/lerobot/` | the implementation: `variants.py` (`patch_geco` with `zero_pad`, `geco_step_sizes`, `patch_fm_score`), `run.py` (runs G0, G1, G2), `train_variant.py`, `eval_variant.py`, `geco_diagnose.py` (offline diagnosis and sweep), `geco_report.py`, `modal/app.py` || `code/src/behavior_course/metrics/geco.py` | AUROC (plain and equal-weight), operating point, bootstrap, App. D filters, Time Saved || `code/experiments/lerobot/modal/requirements.txt` | **environment**: exact package versions (lerobot 0.7.0, torch 2.11.0+cu128, Python 3.12); the Modal image is defined in `modal/app.py` || `review/` | the independent review: `REVIEW.md`, `SEED2000.md`, `paired_bootstrap.py`, `pooled_seeds.py` and their JSON outputs, logs of the seed-2000 runs || `results/` | per run and setting (G0, G1, G2 at seed 1000; G0, G2 at seed 2000): `eval_info.json` (success), `ood_scores.json` (one score per planning call; G2 also every step), `run.json` (exact commands), `geco_diagnose*.json`, `geco_report.json` || `logs/` | full output of every run, including failures: a missing LIBERO config crashed the first evaluations; a dropped client connection stopped two Modal runs, which were resumed from checkpoints; smoke runs in `logs/smoke/` |Hardware: Modal, L40S for training (≈ 50 min per model), L4 for evaluation and diagnosis. Personal data (email,
36 unmodified lines37383940414224 unmodified lines6768697071727336 unmodified linesap.add_argument("--geco", action="store_true")ap.add_argument("--geco-kmax", type=int, default=10, help="App. D uses K_max = 10 for the OOD experiment")ap.add_argument("--geco-zero-pad", action="store_true", help="must match training")ap.add_argument("--geco-schedule", default="a3", help="step sizes: a3 (App. A.3), e (App. E), geom:F:L:N, const:V")ap.add_argument("--fm-score", action="store_true")a, rest = ap.parse_known_args()24 unmodified linesimport atexitimport jsonout = Path(next(r.split("=", 1)[1] for r in rest if r.startswith("--output_dir=")))ost = V.patch_geco(k_max=a.geco_kmax, zero_pad=a.geco_zero_pad, schedule=a.geco_schedule) if a.geco else V.patch_fm_score()def dump():out.mkdir(parents=True, exist_ok=True)36 unmodified lines373839404142434424 unmodified lines697071727374757636 unmodified linesap.add_argument("--geco", action="store_true")ap.add_argument("--geco-kmax", type=int, default=10, help="App. D uses K_max = 10 for the OOD experiment")ap.add_argument("--geco-zero-pad", action="store_true", help="must match training")ap.add_argument("--geco-starts", type=int, default=1, help="best of N noise draws (lowest final residual)")ap.add_argument("--geco-warm", action="store_true", help="start each call from the previous chunk, shifted")ap.add_argument("--geco-schedule", default="a3", help="step sizes: a3 (App. A.3), e (App. E), geom:F:L:N, const:V")ap.add_argument("--fm-score", action="store_true")a, rest = ap.parse_known_args()24 unmodified linesimport atexitimport jsonout = Path(next(r.split("=", 1)[1] for r in rest if r.startswith("--output_dir=")))ost = V.patch_geco(k_max=a.geco_kmax, zero_pad=a.geco_zero_pad, schedule=a.geco_schedule,starts=a.geco_starts, warm=a.geco_warm) if a.geco else V.patch_fm_score()def dump():out.mkdir(parents=True, exist_ok=True)
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150#!/usr/bin/env python3"""Why does GeCO (run G3) fail on LIBERO-Object, and do inference-only fixes help? Offline, on demonstration frames.
envs/lerobot/.venv/bin/python experiments/lerobot/geco_object_fix.py --geco RUN_FOLDER --ref RUN_FOLDER [--frames 320]
G3 (GeCO, padded dims at 0, App. E step sizes) reaches LIBERO-Object items far less often than A3 (standard SmolVLA)and often moves to the basket with an empty gripper. Hypothesis: mode averaging. The ten Object tasks share theirending (the basket) but not their beginning (which item, where), and GeCO's optimisation may settle on the shared,averaged plan. This script scores planned chunks at the START of Object demonstrations (the first quarter of eachepisode, where the item has to be chosen) against the expert's chunk:
dist10 distance to the expert over the first 10 actions (the ones executed), normalised action space cos_xyz cosine between the planned and the expert's net hand displacement over those 10 actions task_r2 share of the variance of the planned displacement explained by the task (expert: its own value); low = the plan barely depends on which item was asked for (averaging)
for A3 and for several GeCO samplers: the deployed one, best of N starts (lowest final residual, GeCO's ownscore), and smaller step sizes. All choices are made on these demonstration frames, never on test episodes."""import argparseimport importlib.utilimport jsonfrom pathlib import Path
import numpy as npimport torch
HERE = Path(__file__).resolve().parentspec = importlib.util.spec_from_file_location("geco_diagnose", HERE / "geco_diagnose.py")D = importlib.util.module_from_spec(spec)spec.loader.exec_module(D)V, REAL = D.V, D.REAL
def pick_object_frames(n: int, seed: int, desc_file: Path, start_frac: float = 0.25): from lerobot.datasets.lerobot_dataset import LeRobotDatasetMetadata m = LeRobotDatasetMetadata("HuggingFaceVLA/libero") tasks = json.loads(desc_file.read_text()) # libero_object_<i> -> text text2id = {t: int(k.rsplit("_", 1)[1]) for k, t in tasks.items()} eps = [e for e in m.episodes if e["tasks"][0] in text2id] rng = np.random.default_rng(seed) idx, tid = [], [] for e in rng.choice(eps, size=n, replace=True): lo, hi = e["dataset_from_index"], e["dataset_to_index"] top = lo + max(1, int((hi - lo) * start_frac)) idx.append(int(rng.integers(lo, min(top, max(lo + 1, hi - 50))))) tid.append(text2id[e["tasks"][0]]) print(len(eps), "Object episodes;", n, "frames from the first", f"{start_frac:.0%}", "of each", flush=True) return idx, np.array(tid), m.fps
@torch.no_grad()def geco_plan(m, S, args, noise, schedule: str, k_max: int, starts: int = 1): """GeCO optimisation with padded dims at 0; with starts > 1, keep the start with the lowest final residual.""" images, img_masks, lt, lm, state, _ = args pp, pkv = V._prefix_cache(m, S, images, img_masks, lt, lm, state) tin = torch.zeros(noise.shape[0], device="cuda") eta = V.geco_step_sizes(k_max, schedule) best_x, best_r = None, None for s in range(starts): g = torch.Generator(device="cuda").manual_seed(1000 + s) x = noise.clone() if s == 0 else torch.randn(noise.shape, generator=g, device="cuda") x[:, :, REAL:] = 0 for k in range(k_max): x = x - eta[k] * m.denoise_step(pp, pkv, x, tin) x[:, :, REAL:] = 0 r = m.denoise_step(pp, pkv, x, tin)[:, :, :REAL].flatten(1).norm(dim=1) if best_x is None: best_x, best_r = x, r else: better = r < best_r best_x[better], best_r[better] = x[better], r[better] return best_x
@torch.no_grad()def fm_plan(pol, args, noise): images, img_masks, lt, lm, state, _ = args return pol.model.sample_actions(images, img_masks, lt, lm, state, noise=noise)
def task_r2(disp, tid): """Share of the variance of the displacement vectors explained by the task (between-task / total).""" tot = ((disp - disp.mean(0)) ** 2).sum() between = sum((tid == t).sum() * ((disp[tid == t].mean(0) - disp.mean(0)) ** 2).sum() for t in np.unique(tid)) return float(between / tot) if tot > 0 else float("nan")
def main(): ap = argparse.ArgumentParser() ap.add_argument("--geco", required=True, help="GeCO run folder trained with padded dims at 0 (G3)") ap.add_argument("--ref", required=True, help="standard SmolVLA run folder on the same data (A3)") ap.add_argument("--frames", type=int, default=320) ap.add_argument("--batch", type=int, default=16) ap.add_argument("--seed", type=int, default=0) ap.add_argument("--out", default=None) ap.add_argument("--start-frac", type=float, default=0.25, help="frames from the first fraction of each episode") a = ap.parse_args() from lerobot.datasets.lerobot_dataset import LeRobotDataset S = V._vla() desc = Path(a.geco) / "eval_libero_object/task_descriptions.json" idx, tid, fps = pick_object_frames(a.frames, a.seed, desc, a.start_frac) ds = LeRobotDataset("HuggingFaceVLA/libero", delta_timestamps={"action": [i / fps for i in range(50)]}) geco, ref = D.load(Path(a.geco)), D.load(Path(a.ref)) methods = {"A3 (standard flow matching)": None, "G3 deployed: App. E, 10 steps": ("e", 10, 1), "G3 best of 8 starts (lowest residual)": ("e", 10, 8), "G3 steps 0.15 -> 0.02, 10 steps": ("geom:0.15:0.02:10", 10, 1), "G3 steps 0.10 -> 0.02, 10 steps": ("geom:0.1:0.02:10", 10, 1), "G3 constant 0.10, 20 steps": ("const:0.1", 20, 1)} plans = {k: [] for k in methods} expert = [] for i in range(0, len(idx), a.batch): items = [ds[j] for j in idx[i:i + a.batch]] raw = {k: (torch.stack([it[k] for it in items]) if torch.is_tensor(items[0][k]) else [it[k] for it in items]) for k in ("observation.images.image", "observation.images.image2", "observation.state", "action", "action_is_pad", "task")} cfg = geco[0].config g = torch.Generator(device="cuda").manual_seed(a.seed * 100_003 + idx[i]) noise = torch.randn((len(items), cfg.chunk_size, cfg.max_action_dim), generator=g, device="cuda") ga, ra = D.inputs(*geco, raw), D.inputs(*ref, raw) expert.append(ga[5][:, :, :REAL].cpu().numpy()) for name, spec_ in methods.items(): x = fm_plan(ref[0], ra, noise) if spec_ is None else geco_plan(geco[0].model, S, ga, noise, *spec_) plans[name].append(x[:, :, :REAL].float().cpu().numpy()) print(f"{i + len(items)}/{len(idx)}", flush=True) E = np.concatenate(expert) disp_e = E[:, :10, :3].sum(1) rows = {} grip_e = E[:, :10, 6] > 0 # gripper command sign over the executed actions (normalised space) print(f"\n{'sampler':40s} dist10 cos_xyz task_r2 grip_agree grip_dist (expert task_r2 {task_r2(disp_e, tid):.2f})") for name in methods: X = np.concatenate(plans[name]) d = np.linalg.norm((X[:, :10] - E[:, :10]).reshape(len(X), -1), axis=1) disp = X[:, :10, :3].sum(1) cos = (disp * disp_e).sum(1) / (np.linalg.norm(disp, axis=1) * np.linalg.norm(disp_e, axis=1) + 1e-9) ga = float(((X[:, :10, 6] > 0) == grip_e).mean()) gd = float(np.median(np.abs(X[:, :10, 6] - E[:, :10, 6]).mean(1))) rows[name] = {"dist10_median": float(np.median(d)), "cos_xyz_median": float(np.median(cos)), "task_r2": task_r2(disp, tid), "grip_agree": ga, "grip_dist_median": gd} print(f"{name:40s} {np.median(d):6.2f} {np.median(cos):6.2f} {rows[name]['task_r2']:6.2f} " f"{ga:8.3f} {gd:8.3f}") out = Path(a.out) if a.out else Path(a.geco) / "object_fix_offline.json" out.write_text(json.dumps({"frames": a.frames, "seed": a.seed, "start_frac": a.start_frac, "expert_task_r2": task_r2(disp_e, tid), "methods": rows}, indent=1)) print("wrote", out)
if __name__ == "__main__": main()182 unmodified lines18318418518618718818919019119219319419519619719819920020120220320420520620720820918 unmodified lines228229230231232233234235236237238239182 unmodified linessys.exit(f"{name} failed (rc={rc}) after {attempt + 1} attempts; see {run / f'{name}.log'}")def geco_kmax_phases(cmds, kmaxes, schedule="a3"):"""Extra GeCO evaluations of a trained G1/G2 folder with K_max = k iterations (the paper's App. D uses 10) and astep-size schedule ("a3" or "e", see variants.geco_step_sizes): phase eval_<suite>_k<k> (A.3) oreval_<suite>_k<k>_e (App. E), the same command with --geco-kmax/--geco-schedule and its own output folder."""extra, tag = [], "" if schedule == "a3" else f"_{schedule}"for k in kmaxes:for name, c in cmds:if name.startswith("eval_") and "--geco" in c and "_k" not in name:i = c.index("--geco")c2 = c[:i + 1] + ["--geco-kmax", str(k), "--geco-schedule", schedule] + c[i + 1:]c2 = [f"{x}_k{k}{tag}" if x.startswith("--output_dir=") else x for x in c2]extra.append((f"{name}_k{k}{tag}", c2))return extradef resume_run(run, max_retries, only=None, geco_kmax=(), geco_schedule="a3"):meta = json.loads((run / "run.json").read_text())wargs = RUNS[meta["run"]][2]cmds = list(meta["commands"].items())known = {n for n, _ in cmds}cmds += [(n, c) for n, c in geco_kmax_phases(cmds, geco_kmax, geco_schedule) if n not in known]meta["commands"] = dict(cmds)meta.setdefault("relaunches", []).append(f"{datetime.now(UTC):%Y-%m-%dT%H:%M:%SZ}")ensure_libero_config() # a fresh machine (a Modal eval container) has none: LIBERO would prompt and crash18 unmodified linesap.add_argument("--geco-kmax", default="", help="with --resume-run on a G1 folder: comma-separated K_max values; ""adds phases eval_<suite>_k<K> (GeCO sampler run for K iterations instead of 10)")ap.add_argument("--geco-schedule", default="a3", help="with --geco-kmax: step sizes (a3, e, geom:F:L:N, const:V)")ap.add_argument("--smoke", action="store_true")ap.add_argument("--dry-run", action="store_true")a = ap.parse_args()if a.resume_run:return resume_run(Path(a.resume_run).resolve(), a.max_retries, a.only and a.only.split(","),[int(k) for k in a.geco_kmax.split(",") if k], a.geco_schedule)if a.list or not a.run:for k, v in RUNS.items():print(f"{k:3} [{v[1]}] {v[0]:48} {v[5]}")182 unmodified lines18318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622718 unmodified lines246247248249250251252253254255256257258259260261182 unmodified linessys.exit(f"{name} failed (rc={rc}) after {attempt + 1} attempts; see {run / f'{name}.log'}")GECO_VARIANTS = {"": [], "best8": ["--geco-starts", "8"], "warm": ["--geco-warm"]}def geco_kmax_phases(cmds, kmaxes, schedule="a3", variant=""):"""Extra GeCO evaluations of a trained G1/G2 folder with K_max = k iterations (the paper's App. D uses 10) and astep-size schedule ("a3" or "e", see variants.geco_step_sizes): phase eval_<suite>_k<k> (A.3) oreval_<suite>_k<k>_e (App. E), the same command with --geco-kmax/--geco-schedule and its own output folder."""extra, tag = [], ("" if schedule == "a3" else f"_{schedule}") + (f"_{variant}" if variant else "")for k in kmaxes:for name, c in cmds:if name.startswith("eval_") and "--geco" in c and "_k" not in name:i = c.index("--geco")c2 = c[:i + 1] + ["--geco-kmax", str(k), "--geco-schedule", schedule, *GECO_VARIANTS[variant]] + c[i + 1:]c2 = [f"{x}_k{k}{tag}" if x.startswith("--output_dir=") else x for x in c2]extra.append((f"{name}_k{k}{tag}", c2))return extradef without_phases(cmds, flag):"""Re-evaluate a trained run with one inference patch switched off: phase eval_<suite>_no<flag>, the samecommand without `flag` (and its value, if it takes one) and with its own output folder."""tag, extra = flag.lstrip("-").replace("-", "_"), []for name, c in cmds:if name.startswith("eval_") and "_k" not in name and "_no" not in name and flag in c:i = c.index(flag)drop = 2 if i + 1 < len(c) and not c[i + 1].startswith("--") else 1c2 = [f"{x}_no{tag}" if x.startswith("--output_dir=") else x for x in c[:i] + c[i + drop:]]extra.append((f"{name}_no{tag}", c2))return extradef resume_run(run, max_retries, only=None, geco_kmax=(), geco_schedule="a3", geco_variant="", eval_without=None):meta = json.loads((run / "run.json").read_text())wargs = RUNS[meta["run"]][2]cmds = list(meta["commands"].items())known = {n for n, _ in cmds}cmds += [(n, c) for n, c in geco_kmax_phases(cmds, geco_kmax, geco_schedule, geco_variant) if n not in known]if eval_without:cmds += [(n, c) for n, c in without_phases(cmds, eval_without) if n not in known]meta["commands"] = dict(cmds)meta.setdefault("relaunches", []).append(f"{datetime.now(UTC):%Y-%m-%dT%H:%M:%SZ}")ensure_libero_config() # a fresh machine (a Modal eval container) has none: LIBERO would prompt and crash18 unmodified linesap.add_argument("--geco-kmax", default="", help="with --resume-run on a G1 folder: comma-separated K_max values; ""adds phases eval_<suite>_k<K> (GeCO sampler run for K iterations instead of 10)")ap.add_argument("--geco-schedule", default="a3", help="with --geco-kmax: step sizes (a3, e, geom:F:L:N, const:V)")ap.add_argument("--geco-variant", default="", choices=sorted(GECO_VARIANTS), help="with --geco-kmax: best8 or warm")ap.add_argument("--eval-without", default=None, metavar="FLAG", help="with --resume-run: add phases ""eval_<suite>_no<flag> that re-evaluate the trained run without one eval_variant patch; pass it with =, e.g. --eval-without=--inpaint")ap.add_argument("--smoke", action="store_true")ap.add_argument("--dry-run", action="store_true")a = ap.parse_args()if a.resume_run:return resume_run(Path(a.resume_run).resolve(), a.max_retries, a.only and a.only.split(","),[int(k) for k in a.geco_kmax.split(",") if k], a.geco_schedule, a.geco_variant,a.eval_without)if a.list or not a.run:for k, v in RUNS.items():print(f"{k:3} [{v[1]}] {v[0]:48} {v[5]}")
793 unmodified lines79479579679779879980080180280380480580680780880981081181281312 unmodified lines8268278288298308318328338348358368373 unmodified lines8418428438448458468474 unmodified lines852853854855856857858793 unmodified linesdef patch_geco(k_max: int = 10, tau: float | None = None, real_dims: int = 7, t_input: float = 0.0,lam: float = GECO_LAMBDA, alpha0: float = GECO_ALPHA0, zero_pad: bool = False, schedule: str = "a3"):"""GeCO on SmolVLA, train + infer. Training: γ ~ U(0,1), x = γ a + (1-γ) ε, target (ε - a) c(γ), fixed time input.Inference: a ← a - η_k f(a) from noise, stop when ‖f‖ (real dims, whole chunk) < τ or after k_max steps.Every planning call records its final residual norm ‖f(a_K)‖ (the OOD score of Eq. 6) and every step's ‖f(a_k)‖.zero_pad: SmolVLA pads actions from 7 to 32 dims and trains only the first 7. Without this flag the 25 paddeddims of x hold (1-γ) ε in training (a clean read-out of the noise level for a time-unconditional model) and aremoved by untrained outputs at inference. With it they are 0 in training and at every inference step."""import torchimport torch.nn.functional as FS = _vla()tau = geco_tau(50 * real_dims) if tau is None else taueta = geco_step_sizes(k_max, schedule)stats = {"episode": -1, "calls": []} # calls: [episode, final_norm, steps_used, [norm at each step]]def mask(x):if zero_pad:12 unmodified linesv = self.denoise_step(pp, pkv, x, torch.full((B,), t_input, dtype=torch.float32, device=dev))return F.mse_loss(target, v, reduction="none")def sample_actions(self, images, img_masks, lang_tokens, lang_masks, state, noise=None, **kw):B, dev = state.shape[0], state.devicex = mask(self.sample_noise((B, self.config.chunk_size, self.config.max_action_dim), dev) if noise is Noneelse noise.to(dev, torch.float32))pp, pkv = _prefix_cache(self, S, images, img_masks, lang_tokens, lang_masks, state)tin = torch.full((B,), t_input, dtype=torch.float32, device=dev)k, hist = 0, []while True:f = self.denoise_step(pp, pkv, x, tin)3 unmodified linesbreakx = mask(x - eta[k] * f)k += 1H = torch.stack(hist, 1).cpu()for b in range(B):stats["calls"].append([stats["episode"], float(r[b]), k, [round(float(v), 4) for v in H[b]]])return x4 unmodified linesS.VLAFlowMatching.sample_actions = sample_actions_episode_tracker(S, stats)print(f"[variants] GeCO: lambda={lam} alpha0={alpha0} t_input={t_input} k_max={k_max} tau={tau:.3f} "f"zero_pad={zero_pad} schedule={schedule} eta={[round(e, 4) for e in eta]}", flush=True)return stats793 unmodified lines79479579679779879980080180280380480580680780880981081181281381481581681781881912 unmodified lines8328338348358368378383 unmodified lines8428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718724 unmodified lines877878879880881882883884793 unmodified linesdef patch_geco(k_max: int = 10, tau: float | None = None, real_dims: int = 7, t_input: float = 0.0,lam: float = GECO_LAMBDA, alpha0: float = GECO_ALPHA0, zero_pad: bool = False, schedule: str = "a3",starts: int = 1, warm: bool = False, exec_steps: int = 10):"""GeCO on SmolVLA, train + infer. Training: γ ~ U(0,1), x = γ a + (1-γ) ε, target (ε - a) c(γ), fixed time input.Inference: a ← a - η_k f(a) from noise, stop when ‖f‖ (real dims, whole chunk) < τ or after k_max steps.Every planning call records its final residual norm ‖f(a_K)‖ (the OOD score of Eq. 6) and every step's ‖f(a_k)‖.zero_pad: SmolVLA pads actions from 7 to 32 dims and trains only the first 7. Without this flag the 25 paddeddims of x hold (1-γ) ε in training (a clean read-out of the noise level for a time-unconditional model) and aremoved by untrained outputs at inference. With it they are 0 in training and at every inference step.starts > 1: run the optimisation from that many noise draws and keep, per sample, the chunk with the lowest finalresidual (GeCO's own confidence). warm: start each planning call from the previous call's chunk shifted forward byexec_steps actions (the tail padded with its last action) instead of fresh noise; reset at every episode."""import torchimport torch.nn.functional as FS = _vla()tau = geco_tau(50 * real_dims) if tau is None else taueta = geco_step_sizes(k_max, schedule)stats = {"episode": -1, "calls": []} # calls: [episode, final_norm, steps_used, [norm at each step]]warm_state = {"episode": None, "x": None}def mask(x):if zero_pad:12 unmodified linesv = self.denoise_step(pp, pkv, x, torch.full((B,), t_input, dtype=torch.float32, device=dev))return F.mse_loss(target, v, reduction="none")def optimise(self, pp, pkv, x, tin, B):k, hist = 0, []while True:f = self.denoise_step(pp, pkv, x, tin)3 unmodified linesbreakx = mask(x - eta[k] * f)k += 1return x, r, k, torch.stack(hist, 1)def sample_actions(self, images, img_masks, lang_tokens, lang_masks, state, noise=None, **kw):B, dev = state.shape[0], state.deviceshape = (B, self.config.chunk_size, self.config.max_action_dim)pp, pkv = _prefix_cache(self, S, images, img_masks, lang_tokens, lang_masks, state)tin = torch.full((B,), t_input, dtype=torch.float32, device=dev)best = Nonefor s_ in range(starts):if warm and s_ == 0 and warm_state["episode"] == stats["episode"] and warm_state["x"] is not None \and warm_state["x"].shape == shape:prev = warm_state["x"]x0 = torch.cat([prev[:, exec_steps:], prev[:, -1:].expand(-1, exec_steps, -1)], 1)else:x0 = self.sample_noise(shape, dev) if (noise is None or s_ > 0) else noise.to(dev, torch.float32)out = optimise(self, pp, pkv, mask(x0), tin, B)if best is None:best = list(out)else:better = out[1] < best[1]best[0][better], best[1][better] = out[0][better], out[1][better]best[3] = torch.where(better[:, None], out[3], best[3]) if out[3].shape == best[3].shape else best[3]x, r, k, H = bestwarm_state["episode"], warm_state["x"] = stats["episode"], x.detach().clone()H = H.cpu()for b in range(B):stats["calls"].append([stats["episode"], float(r[b]), k, [round(float(v), 4) for v in H[b]]])return x4 unmodified linesS.VLAFlowMatching.sample_actions = sample_actions_episode_tracker(S, stats)print(f"[variants] GeCO: lambda={lam} alpha0={alpha0} t_input={t_input} k_max={k_max} tau={tau:.3f} "f"zero_pad={zero_pad} schedule={schedule} starts={starts} warm={warm} eta={[round(e, 4) for e in eta]}",flush=True)return stats
README.md+31-21
code/experiments/lerobot/eval_variant.py+4-1
code/experiments/lerobot/geco_object_fix.pyAdded+150
code/experiments/lerobot/run.py+28-6
code/experiments/lerobot/variants.py+36-10
index.html
logs/G0_s2000_20261202T122643Z/eval_libero_goal.logAdded
logs/G0_s2000_20261202T122643Z/eval_libero_spatial.logAdded
logs/G0_s2000_20261202T122643Z/train.logAdded
logs/G2_s2000_20261202T122643Z/eval_libero_goal_k10_e.logAdded
logs/G2_s2000_20261202T122643Z/eval_libero_spatial_k10_e.logAdded
logs/G2_s2000_20261202T122643Z/train.logAdded