""" Build an eval-time T= variant of a loop model (config-only clone; weights identical). For the P2 T-sweep (does entity tracking degrade monotonically as inference iterations grow?). Usage: python make_t_variant.py e.g. python make_t_variant.py loop2_full 2 -> hf_loop2_T2 (legacy naming, frozen) python make_t_variant.py loop2_full_s1 4 -> hf_loop2_T4_s1 (legacy naming, frozen) python make_t_variant.py bind1_tt1_s0 2 -> hf_bind1_tt1_s0_ti2 (new naming, NAMING.md) Legacy 'full' tags keep the baked 'full'->'T' replacement; everything else gets the new-generation `_ti` suffix so physical == logical name (fill_meta/oracle tooling relies on it). """ import os, sys, json, shutil _ROOT = os.environ.get("BABYLM_ROOT", os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) WORK = os.environ.get("BABYLM_WORK", os.path.join(_ROOT, "alaya-strict-small")) srctag = sys.argv[1]; T = int(sys.argv[2]) src = os.path.join(WORK, "hf_" + srctag) assert os.path.exists(src), f"{src} missing (export the loop model first)" name = ("hf_" + srctag.replace("full", f"T{T}")) if "full" in srctag else f"hf_{srctag}_ti{T}" dst = os.path.join(WORK, name) if os.path.exists(dst): shutil.rmtree(dst) shutil.copytree(src, dst) p = os.path.join(dst, "config.json") c = json.load(open(p, encoding="utf-8")); c["T"] = T json.dump(c, open(p, "w", encoding="utf-8"), indent=2) print(f"built {dst} (T={T})")