#!/usr/bin/env python """HF_PUSH_ALL (reopen 2026-11-22): v5 archive-only real families -> scratch/hf_push/v5_map.tsv for rli14/rsm_real_checkpoints. hf_path = path under runs/ (same layout as the rest of that repo). Final-checkpoint rule (owner addendum): - runs/real_cooking_v5/rsm//: highest ckpt_s.pt (else ckpt.pt), + history.json / *calib*.json, + any file a doc names (DOC_NAMED). Skip intermediate ckpt_s*, ckpt.pt (resumable), ckpt_best.pt, wandb/. - runs/cooking_v5_rw_*/policy// and runs/cooking_v5_expert_suboptimal/policy/S0B_seed1/: highest model_epoch_.pth over the whole run dir (timestamp dirs + rolling/; non-rolling copy preferred on ties), + the config.json of the timestamp dir that holds it (or the newest one). - skip anything whose source is already in rli14/rsm_cooking_v5_checkpoints (status/real/hf_upload_stamps.json srcs). Read-only on runs/. Run as a CPU job (archive stats).""" import os, re, json, glob ROOT = "/proj/dmfexp/zwhong/rsm_rise"; R = ROOT + "/runs" DOC_NAMED = ["real_cooking_v5/rsm/R_M_simband/ckpt_s50000.pt", "real_cooking_v5/rsm/R_M_ft_v0lit/ckpt.pt", "real_cooking_v5/rsm/R_D8_W3072/ckpt.pt", "real_cooking_v5/rsm/R_M_long/ckpt_s150000.pt"] st = json.load(open(ROOT + "/status/real/hf_upload_stamps.json")) present = {os.path.realpath(v["src"]) for v in st.values() if isinstance(v, dict) and "src" in v} rows, seen, skipped = [], set(), [] def add(rel, kind): src = os.path.join(R, rel); real = os.path.realpath(src) if rel in seen or not os.path.isfile(real): return if real in present or os.path.realpath(src) in present or src in present: skipped.append(rel); return seen.add(rel); rows.append((rel, src, os.path.getsize(real), "", "", kind)) # --- RSM successor runs for d in sorted(glob.glob(R + "/real_cooking_v5/rsm/*/")): rel = os.path.relpath(d, R); fs = os.listdir(d) steps = [(int(m.group(1)), f) for f in fs for m in [re.fullmatch(r"ckpt_s(\d+)\.pt", f)] if m] if steps: add(f"{rel}/{max(steps)[1]}", "rsm_final") elif "ckpt.pt" in fs: add(f"{rel}/ckpt.pt", "rsm_final") for f in fs: if f == "history.json" or (f.endswith(".json") and "calib" in f): add(f"{rel}/{f}", "sidecar") for p in DOC_NAMED: add(p, "rsm_doc_named") # --- robomimic actor runs pol = sorted(glob.glob(R + "/cooking_v5_rw_*/policy/*/")) + [R + "/cooking_v5_expert_suboptimal/policy/S0B_seed1/"] for d in pol: best = None for dd, dn, fn in os.walk(d, followlinks=False): dn[:] = [x for x in dn if x not in ("wandb", "videos", "logs") and not x.startswith("replay_")] for f in fn: m = re.fullmatch(r"model_epoch_(\d+)(?:_.*)?\.pth", f) if not m: continue key = (int(m.group(1)), "/rolling" not in dd, dd) if best is None or key > best[0]: best = (key, os.path.join(dd, f)) if best is None: print("NO CKPT", d); continue add(os.path.relpath(best[1], R), "actor_final") rd = os.path.dirname(os.path.dirname(best[1])) cfg = os.path.join(rd, "config.json") if not os.path.isfile(cfg): cs = sorted(glob.glob(d + "/*/*/config.json")) cfg = cs[-1] if cs else None if cfg: add(os.path.relpath(cfg, R), "sidecar") md = os.path.join(os.path.dirname(cfg), "metadata.json") if os.path.isfile(md): add(os.path.relpath(md, R), "sidecar") with open(ROOT + "/scratch/hf_push/v5_map.tsv", "w") as f: f.write("hf_path\tsource_path\tbytes\tn_cells\texample_cell\tkind\n") for r in rows: f.write("\t".join(map(str, r)) + "\n") by = {} for r in rows: k = r[0].split("/")[0]; by.setdefault(k, [0, 0]); by[k][0] += 1; by[k][1] += r[2] for k, v in by.items(): print(k, v[0], "files", round(v[1] / 2**30, 2), "GiB") print("skipped (already in v5 repo):", skipped) print("TOTAL", len(rows), "files", round(sum(r[2] for r in rows) / 2**30, 2), "GiB")