STAR-future commited on
Commit
d0821e7
·
verified ·
1 Parent(s): 24dd681

tools/colab_k3pass.py

Browse files
Files changed (1) hide show
  1. tools/colab_k3pass.py +42 -0
tools/colab_k3pass.py CHANGED
@@ -172,3 +172,45 @@ elif MODE == "tail":
172
  up(W / "tail" / "verdict.raw.npz", "lb_tail_verdict.raw.npz")
173
  up(W / "tail" / "train_record.json", "lb_tail_train_record.json")
174
  up(W / "tail" / "layer92_trained.pt", "layer92_trained.pt")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
172
  up(W / "tail" / "verdict.raw.npz", "lb_tail_verdict.raw.npz")
173
  up(W / "tail" / "train_record.json", "lb_tail_train_record.json")
174
  up(W / "tail" / "layer92_trained.pt", "layer92_trained.pt")
175
+
176
+
177
+ # 2026-11-24: confirmatory evaluation of a trained specialisation on the SEALED holdout (61 sequences, Gemini custody,
178
+ # sha256 9d174d3f...). The texts come only from the private dataset; Trinity and the base model both run (base=True);
179
+ # no checkpoints and no cache upload (private quota is full and the cache stays on this VM); only aggregate verdict
180
+ # and per-token losses (numbers, no text) are published under eval/h5_sealed/.
181
+ if MODE == "sealed":
182
+ import torch
183
+ gpu_gb = torch.cuda.get_device_properties(0).total_memory / 2 ** 30
184
+ if gpu_gb < 39 and not os.environ.get("K3P_ALLOW_SMALL_GPU"):
185
+ raise SystemExit(f"GPU with {gpu_gb:.0f} GB: this pass needs an A100 (40/80 GB). Disconnect and retry later.")
186
+ src = Path(hf_hub_download("STAR-future/Trinity-k3cache", "eval-data/sealed_h2_holdout_61.jsonl", repo_type="dataset",
187
+ token=TOK, force_download=True))
188
+ import hashlib as _h
189
+ if _h.sha256(src.read_bytes()).hexdigest() != "9d174d3fc71accb0001cdab2a4293cfdd44663ff573362735cbe8956d2580dad":
190
+ raise SystemExit("sealed holdout file does not match its sealed sha256")
191
+ rows = []
192
+ for r in map(json.loads, src.read_text(encoding="utf-8").splitlines()):
193
+ st = "wikipedia" if r["set"].startswith("general") else r["set"].replace("h2_", "")
194
+ rows.append({"id": r["id"], "text": r["text"], "set": st, "role": "holdout", "base": True})
195
+ texts = W / "streams_sealed.jsonl"
196
+ texts.write_text("".join(json.dumps(r) + "\n" for r in rows), encoding="utf-8")
197
+ out = W / "out_sealed"
198
+ if not (out / "summary.json").exists():
199
+ rc = run([sys.executable, "-u", str(W / "k3pass.py"), "--texts", str(texts), "--work", str(W / "work_sealed"),
200
+ "--out", str(out), "--batch", "12" if gpu_gb > 60 else "8", "--layers", "-1",
201
+ "--ckpt-repo", "STAR-future/Trinity-k3ckpt-sealed", "--ckpt-every", "999"], "k3pass_sealed.log")
202
+ print("pass exit", rc, flush=True)
203
+ if json.loads((out / "summary.json").read_text()).get("layers_run") != 93:
204
+ raise SystemExit("sealed pass did not run all 93 layers: no verdict")
205
+ trained = os.environ.get("K3P_TRAINED", "eval/h4/F1_Arm3_HeadLoRA_full_tail_wsp.pt")
206
+ tp = Path(hf_hub_download(REPO, trained, token=TOK, force_download=True))
207
+ (W / "trinity_full_tail_wsp.py").write_bytes(Path(hf_hub_download(REPO, "tools/trinity_full_tail_wsp.py", token=TOK,
208
+ force_download=True)).read_bytes())
209
+ rc = run([sys.executable, "-u", str(W / "trinity_full_tail_wsp.py"), "eval", "--cache", str(out), "--trained", str(tp),
210
+ "--out", str(W / "h5_sealed")], "h5_sealed_eval.log")
211
+ for f in (W / "h5_sealed").glob("*"):
212
+ if f.is_file():
213
+ api.upload_file(path_or_fileobj=str(f), path_in_repo=f"eval/h5_sealed/{f.name}", repo_id=REPO,
214
+ commit_message=f"H5 sealed holdout: {f.name}")
215
+ up(out / "summary.json", "h5_sealed/k3pass_sealed_summary.json")
216
+ print("sealed eval exit", rc, flush=True)