STAR-future commited on
Commit
762a3c3
·
verified ·
1 Parent(s): 331f621

H6 mode + parametric bpb dir

Browse files
Files changed (1) hide show
  1. tools/colab_k3pass.py +50 -0
tools/colab_k3pass.py CHANGED
@@ -223,3 +223,53 @@ if MODE == "sealed":
223
  print("sealed eval exit", rc, flush=True)
224
  if rc == 0 and os.environ.get("K3P_BPB", "1") != "0": # bits-per-byte comparison with open models, same VM
225
  exec(open(hf_hub_download(REPO, "tools/colab_bpb_compare.py", token=TOK, force_download=True)).read())
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
223
  print("sealed eval exit", rc, flush=True)
224
  if rc == 0 and os.environ.get("K3P_BPB", "1") != "0": # bits-per-byte comparison with open models, same VM
225
  exec(open(hf_hub_download(REPO, "tools/colab_bpb_compare.py", token=TOK, force_download=True)).read())
226
+
227
+
228
+ # 2026-11-24: H6 on the SAME VM that ran K3P=sealed and K3P=train4 (out_sealed and out_train4 are local).
229
+ # Trains a larger specialisation than F1 (head LoRA r256 + layer-92 tail LoRA r128 + LoRA on the 128 hottest routed
230
+ # experts, incl. new ones when they are hot) on caches train2 + train3 + train4 (~3.2 M tokens), then judges it on the
231
+ # sealed holdout against Trinity and the base model. Prereg: 16_EVIDENCE/TRINITY/H6_PREREG_2026-11-24.md.
232
+ if MODE == "h6":
233
+ import shutil
234
+ from huggingface_hub import snapshot_download
235
+ for need in ("out_sealed", "out_train4"):
236
+ if not (W / need / "summary.json").exists():
237
+ raise SystemExit(f"H6 needs {need} on this VM (run K3P=sealed and K3P=train4 first)")
238
+ if (W / "work_train4").exists(): # regenerable work files: free the scratch disk
239
+ shutil.rmtree((W / "work_train4").resolve(), ignore_errors=True)
240
+ scratch = Path("/mnt/local-scratch") if Path("/mnt/local-scratch").exists() else W
241
+ for m in ("train2", "train3"):
242
+ dst = W / f"out_{m}"
243
+ if not (dst / "summary.json").exists():
244
+ dl = scratch / f"dl_{m}"
245
+ snapshot_download(f"STAR-future/Trinity-k3cache-{m}", repo_type="dataset", token=TOK, allow_patterns=[f"{m}/*"],
246
+ local_dir=str(dl), max_workers=8)
247
+ if not dst.exists():
248
+ dst.symlink_to(dl / m)
249
+ if json.loads((dst / "summary.json").read_text()).get("layers_run") != 93:
250
+ raise SystemExit(f"cache {m} is not a 93-layer pass")
251
+ (W / "trinity_full_tail_wsp.py").write_bytes(Path(hf_hub_download(REPO, "tools/trinity_full_tail_wsp.py", token=TOK,
252
+ force_download=True)).read_bytes())
253
+ h6 = W / "h6"
254
+ if not (h6 / "full_tail_wsp.pt").exists():
255
+ rc = run([sys.executable, "-u", str(W / "trinity_full_tail_wsp.py"), "train", "--cache", str(W / "out_train2"),
256
+ str(W / "out_train3"), str(W / "out_train4"), "--out", str(h6), "--domains", "chips,space",
257
+ "--head-rank", "256", "--head-alpha", "256", "--tail-rank", "128", "--tail-alpha", "128",
258
+ "--k", "128", "--routed-rank", "16", "--routed-alpha", "16", "--lr", "1.5e-4", "--epochs", "3.0",
259
+ "--kl", "6.0", "--block-size", "256"], "h6_train.log")
260
+ if rc != 0:
261
+ raise SystemExit(f"H6 training failed ({rc})")
262
+ for f in h6.glob("*"):
263
+ if f.is_file():
264
+ api.upload_file(path_or_fileobj=str(f), path_in_repo=f"eval/h6/{f.name}", repo_id=REPO,
265
+ commit_message=f"H6 trained specialisation: {f.name}")
266
+ rc = run([sys.executable, "-u", str(W / "trinity_full_tail_wsp.py"), "eval", "--cache", str(W / "out_sealed"),
267
+ "--trained", str(h6 / "full_tail_wsp.pt"), "--out", str(W / "h6_sealed")], "h6_sealed_eval.log")
268
+ for f in (W / "h6_sealed").glob("*"):
269
+ if f.is_file():
270
+ api.upload_file(path_or_fileobj=str(f), path_in_repo=f"eval/h6_sealed/{f.name}", repo_id=REPO,
271
+ commit_message=f"H6 sealed holdout: {f.name}")
272
+ print("h6 sealed eval exit", rc, flush=True)
273
+ if rc == 0 and os.environ.get("K3P_BPB", "1") != "0":
274
+ os.environ["BPB_DIR"] = "h6_sealed"
275
+ exec(open(hf_hub_download(REPO, "tools/colab_bpb_compare.py", token=TOK, force_download=True)).read())