Cion-lab commited on
Commit
1742ac7
·
verified ·
1 Parent(s): 972b64f

p6_harness_probe: does lm-eval 0.4.13 resolve on transformers 5.0.0, and what do the 9 task configs declare (configs only, no eval data)

Browse files
Files changed (1) hide show
  1. kernels/p6_harness_probe.py +101 -0
kernels/p6_harness_probe.py ADDED
@@ -0,0 +1,101 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Phase 6 pre-flight on free CPU: does the pinned harness work on this image, and what does it declare?
2
+
3
+ The unknown this closes is not the model's score but the toolchain: `lm-eval` 0.4.13 was pinned in 2024 and
4
+ the Kaggle image ships transformers 5.0.0, a combination nobody here has run (docs/05 §7 flagged it, §5 of
5
+ the plan refuses to discover it after six billed GPU hours). It also checks the three things E-045/E-046
6
+ rely on and that E-045 could only reason about: the real shape of `--tasks list` output that the new
7
+ hard-failing guard parses, which `num_fewshot` each pinned task actually declares, and the exact
8
+ `<metric>,<split>` key names that `PRIMARY_METRIC` promises to read out of results.json.
9
+
10
+ **No eval data is touched here, and none can be.** Everything read comes from the tasks' YAML configs:
11
+ `TaskManager.include_task` builds a task object from its config, and `datasets.load_dataset` is not called
12
+ until a request is made — no model is loaded, no split is downloaded, no item is read (§3.3).
13
+ """
14
+ import json
15
+ import os
16
+ import re
17
+ import subprocess
18
+ import sys
19
+
20
+ os.chdir("/kaggle/working")
21
+ PIN = "0.4.13"
22
+ TASKS = ["arc_challenge", "arc_easy", "hellaswag", "mmlu", "piqa", "truthfulqa_mc1",
23
+ "truthfulqa_mc2", "winogrande", "gsm8k"]
24
+ PRIMARY_METRIC = {"arc_challenge": "acc,none", "arc_easy": "acc,none", "hellaswag": "acc,none",
25
+ "mmlu": "acc,none", "piqa": "acc,none", "truthfulqa_mc1": "acc,none",
26
+ "truthfulqa_mc2": "acc,none", "winogrande": "acc,none",
27
+ "gsm8k": "exact_match,flexible-extract"}
28
+
29
+
30
+ def sh(argv, label, timeout=1800):
31
+ print("=== " + label, flush=True)
32
+ p = subprocess.run(argv, capture_output=True, text=True, timeout=timeout)
33
+ out = (p.stdout or "") + (p.stderr or "")
34
+ print(label, "rc", p.returncode, "lines", len(out.splitlines()), flush=True)
35
+ return p.returncode, out
36
+
37
+
38
+ rc, v = sh([sys.executable, "-c", "import transformers, os; print(transformers.__version__, "
39
+ "os.path.dirname(transformers.__file__))"], "transformers")
40
+ print(" |", v.strip()[:200], flush=True)
41
+ tf_ver = v.split()[0] if v.split() else "?"
42
+
43
+ rc, out = sh([sys.executable, "-m", "pip", "install", "--user", "--quiet", "--no-deps",
44
+ "lm-eval==" + PIN], "pip_install")
45
+ rc, v2 = sh([sys.executable, "-c", "import transformers, os; print(transformers.__version__, "
46
+ "os.path.dirname(transformers.__file__))"], "transformers_after")
47
+ print(" |", v2.strip()[:200], flush=True)
48
+ assert tf_ver == v2.split()[0], "installing the harness moved transformers: %s -> %s" % (tf_ver, v2)
49
+
50
+ rc, listed = sh([sys.executable, "-m", "lm_eval", "--tasks", "list"], "tasks_list", 900)
51
+ # The same expression run_benchmarks.py uses, evaluated here against the real output so the guard is known
52
+ # to parse something rather than assumed (E-045/6 became a hard failure on the strength of a guess).
53
+ ids = set(re.findall(r"^\s*(?:-\s*)?([a-z][a-z0-9_]{2,})\s*$", listed, re.M))
54
+ print("PARSED_IDS", len(ids), "| requested present:",
55
+ {t: (t in ids) for t in TASKS}, flush=True)
56
+ print("SAMPLE_RAW", repr(listed[-600:]), flush=True)
57
+
58
+ probe = r"""
59
+ import json, sys, warnings
60
+ warnings.filterwarnings("ignore")
61
+ from lm_eval.tasks import TaskManager
62
+ tm = TaskManager()
63
+ out = {}
64
+ for t in %r:
65
+ rec = {"registered": t in tm.task_index}
66
+ try:
67
+ cfg = tm.task_index[t]
68
+ rec["num_fewshot"] = cfg.get("num_fewshot")
69
+ rec["metric_list"] = [m.get("metric_uri") if isinstance(m, dict) else m
70
+ for m in (cfg.get("metric_list") or [])]
71
+ rec["aggregation"] = [m.get("aggregation") for m in (cfg.get("metric_list") or [])
72
+ if isinstance(m, dict)]
73
+ rec["dataset_path"] = cfg.get("dataset_path")
74
+ rec["dataset_name"] = cfg.get("dataset_name")
75
+ rec["test_split"] = cfg.get("test_split")
76
+ rec["validation_split"] = cfg.get("validation_split")
77
+ rec["fewshot_split"] = cfg.get("fewshot_split")
78
+ except Exception as e:
79
+ rec["error"] = "%s: %s" % (type(e).__name__, str(e)[:200])
80
+ out[t] = rec
81
+ print("TASKCONFIG", json.dumps(out, default=str))
82
+ """ % (TASKS,)
83
+ open("taskconfig.py", "w").write(probe)
84
+ rc, tc = sh([sys.executable, "taskconfig.py"], "task_configs", 900)
85
+ line = next((l for l in tc.splitlines() if l.startswith("TASKCONFIG ")), "")
86
+ cfgs = json.loads(line[len("TASKCONFIG "):]) if line else {}
87
+ for t in TASKS:
88
+ c = cfgs.get(t, {})
89
+ m = PRIMARY_METRIC[t]
90
+ metrics = c.get("metric_list") or []
91
+ print("TASK %-16s fewshot=%-5s split=%-12s metric %s declared=%s" % (
92
+ t, c.get("num_fewshot"), c.get("test_split"), m, m in metrics), flush=True)
93
+
94
+ print("HARNESS_PROBE_JSON", json.dumps({
95
+ "lm_eval_pin": PIN, "transformers": tf_ver, "tasks_listed": len(ids),
96
+ "all_requested_present": all(t in ids for t in TASKS),
97
+ "configs": cfgs, "primary_metric_declared": {t: PRIMARY_METRIC[t] in (cfgs.get(t) or {}).get(
98
+ "metric_list", []) for t in TASKS}}, default=str), flush=True)
99
+ ok = all(t in ids for t in TASKS) and bool(cfgs)
100
+ print("VERDICT P6_HARNESS_PROBE", "OK" if ok else "PROBLEM", "tasks_parsed", len(ids), flush=True)
101
+ raise SystemExit(0 if ok else 6)