File size: 2,235 Bytes
f80e81a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
"""Colab cell run AFTER a k3pass 'train2'/'train3' pass, in the same runtime (Colab disk /content/k3p/out_<mode>).
The private storage of STAR-future is full (2026-11-21), so the per-token cache of these PUBLIC CC0 texts goes to the
PUBLIC dataset STAR-future/Trinity-k3cache-<mode> (founder's decision, HUMAN_APPROVALS 2026-11-21). Holdouts stay private.

    import os; os.environ['K3P'] = 'train2'    # or 'train3'
    exec(open(h.hf_hub_download('STAR-future/Trinity', 'tools/colab_k3rescue_public.py', token=os.environ['HF_TOKEN'],
                                force_download=True)).read())
"""
import json
import os
import time
from pathlib import Path

from huggingface_hub import HfApi

api = HfApi(token=os.environ["HF_TOKEN"])
MODE = os.environ.get("K3P", "train2")
REPO = f"STAR-future/Trinity-k3cache-{MODE}"
NEEDED = ("summary.json", "x92.npy", "acc92.npy", "A92.npy", "Zm92.npy", "prefix92.npy", "target92.npy")
out = Path(f"/content/k3p/out_{MODE}")
summary = out / "summary.json"
if not summary.exists():
    raise SystemExit(f"no finished {MODE} pass in this runtime")
lr = json.loads(summary.read_text()).get("layers_run")
if lr != 93:
    raise SystemExit(f"{MODE} pass ran {lr} layers, not 93: nothing to rescue")
api.create_repo(REPO, repo_type="dataset", private=False, exist_ok=True)
have = set(api.list_repo_files(REPO, repo_type="dataset"))
for name in sorted(p.name for p in out.iterdir() if p.suffix in (".npy", ".json")):
    if f"{MODE}/{name}" in have:
        print("already there:", name)
        continue
    for attempt in range(4):
        try:
            api.upload_file(path_or_fileobj=str(out / name), path_in_repo=f"{MODE}/{name}", repo_id=REPO,
                            repo_type="dataset", commit_message=f"k3pass cache {MODE}: {name}")
            print("uploaded", name, round((out / name).stat().st_size / 2 ** 30, 2), "GiB", flush=True)
            break
        except Exception as e:  # noqa: BLE001
            print("retry", name, attempt, type(e).__name__, str(e)[:160], flush=True)
            time.sleep(30)
missing = [n for n in NEEDED if f"{MODE}/{n}" not in set(api.list_repo_files(REPO, repo_type="dataset"))]
print("MISSING:", missing if missing else "none", flush=True)