Cion-lab commited on
Commit
ad9e5a2
·
verified ·
1 Parent(s): 1a8377a

run_benchmarks: install with deps, ask the task registry via the API, refuse a row whose primary metric key is absent (E-047/E-048)

Browse files
Files changed (1) hide show
  1. eval/run_benchmarks.py +35 -16
eval/run_benchmarks.py CHANGED
@@ -137,10 +137,12 @@ def install_harness():
137
  print("lm_eval %r is not the pin %s -- installing it as a user package" % (have, PINNED_LM_EVAL),
138
  flush=True)
139
  before = check_transformers("before install")
140
- # --no-deps deliberately. A dependency-resolving install can drop a different transformers into
141
- # ~/.local, where it shadows the image's copy on sys.path -- the exact thing this file's header says it
142
- # avoids, and it would move the harness pin silently (review finding C4).
143
- rc, _ = sh([sys.executable, "-m", "pip", "install", "--user", "--quiet", "--no-deps",
 
 
144
  "lm-eval==%s" % PINNED_LM_EVAL], "pip_lm_eval", 1800)
145
  if rc != 0:
146
  raise SystemExit("could not install the pinned harness; refusing to eval on a different one")
@@ -270,20 +272,31 @@ def main():
270
  shutil.rmtree(root, ignore_errors=True)
271
  os.makedirs(root, exist_ok=True)
272
 
273
- # Confirm the task ids resolve before any GPU time goes into them: one typo among nine would otherwise
274
- # fail the all-or-nothing smoke gate and yield no table at all (C5; §2 says to confirm with --tasks list).
275
- rc, out = sh([sys.executable, "-m", "lm_eval", "--tasks", "list"], "list_tasks", 900)
276
- # 0.4.13 prints " - <id>" bullets; the old pattern required the id to end the line and matched
277
- # nothing, then `listed and ...` voided the whole check, and the script went ahead and spent GPU hours
278
- # on ids the harness may not know. An unparseable listing is now a hard failure, not a shrug (E-045/6).
279
- listed = set(re.findall(r"^\s*(?:-\s*)?([a-z][a-z0-9_]{2,})\s*$", out, re.M))
280
- if len(listed) < 50:
281
- raise SystemExit("could not read the harness task list (%d ids parsed); refusing to run %s "
282
- "unverified -- %r" % (len(listed), PINNED_LM_EVAL, out[-500:]))
283
- unknown = [t for t in TASKS if t not in listed]
 
 
 
 
 
 
 
 
 
 
 
284
  if unknown:
285
  raise SystemExit("these task ids do not resolve in lm-eval %s: %s" % (ver, unknown))
286
- print("task ids checked against the harness:", len(TASKS), "requested,", len(listed), "ids listed",
287
  flush=True)
288
 
289
  smoke = {}
@@ -314,6 +327,12 @@ def main():
314
  "dataset_path": h.get("dataset_path"), "split": h.get("split"),
315
  "results_file": h.get("file"), "primary_metric": PRIMARY_METRIC[t],
316
  "primary": (h.get("rows") or {}).get(PRIMARY_METRIC[t])}
 
 
 
 
 
 
317
  if rc != 0 or not h.get("rows"):
318
  # A cell pushed as `rows: {}` reads as "scored zero" to anyone holding only the JSON.
319
  rec[key]["status"] = "FAILED rc=%s rows=%s" % (rc, len(h.get("rows") or {}))
 
137
  print("lm_eval %r is not the pin %s -- installing it as a user package" % (have, PINNED_LM_EVAL),
138
  flush=True)
139
  before = check_transformers("before install")
140
+ # Deps ARE installed, and that is measured, not assumed: --no-deps left the harness unimportable
141
+ # (`lm_eval/api/metrics.py:11` does `import sacrebleu` at module scope; probe v1, E-047), while a
142
+ # resolving install moved exactly two packages -- evaluate 0.4.6 and sacrebleu 2.6.0, both new and
143
+ # both into ~/.local -- and left transformers at 5.0.0 in the image (probe v2). The assertion below
144
+ # is what actually protects the pin; the flag only protected a fear.
145
+ rc, _ = sh([sys.executable, "-m", "pip", "install", "--user", "--quiet",
146
  "lm-eval==%s" % PINNED_LM_EVAL], "pip_lm_eval", 1800)
147
  if rc != 0:
148
  raise SystemExit("could not install the pinned harness; refusing to eval on a different one")
 
272
  shutil.rmtree(root, ignore_errors=True)
273
  os.makedirs(root, exist_ok=True)
274
 
275
+ # Confirm the task ids resolve before any GPU time goes into them (C5). `lm_eval --tasks list` is NOT
276
+ # how: 0.4.13's CLI sends the word to task resolution and raises `Tasks not found: list` (E-048), so
277
+ # the registry is asked directly. Either route is fine for a human; only the API is a check.
278
+ rc, out = sh([sys.executable, "-c",
279
+ "from lm_eval.tasks import TaskManager;"
280
+ "import json,sys;"
281
+ "tm=TaskManager();"
282
+ "print(json.dumps({'n': len(tm.task_index),"
283
+ " 'present': {t: (t in tm.task_index) for t in %r}}))" % (TASKS,)],
284
+ "list_tasks", 900)
285
+ listed = {}
286
+ for line in (out or "").splitlines():
287
+ if line.startswith("{"):
288
+ try:
289
+ listed = json.loads(line)
290
+ except Exception:
291
+ listed = {}
292
+ break
293
+ if not listed or listed.get("n", 0) < 50:
294
+ raise SystemExit("could not read the harness task registry; refusing to run %s unverified -- %r"
295
+ % (PINNED_LM_EVAL, (out or "")[-500:]))
296
+ unknown = [t for t in TASKS if not listed["present"].get(t)]
297
  if unknown:
298
  raise SystemExit("these task ids do not resolve in lm-eval %s: %s" % (ver, unknown))
299
+ print("task ids checked against the harness:", len(TASKS), "requested,", listed["n"], "registered",
300
  flush=True)
301
 
302
  smoke = {}
 
327
  "dataset_path": h.get("dataset_path"), "split": h.get("split"),
328
  "results_file": h.get("file"), "primary_metric": PRIMARY_METRIC[t],
329
  "primary": (h.get("rows") or {}).get(PRIMARY_METRIC[t])}
330
+ if PRIMARY_METRIC[t] not in (h.get("rows") or {}):
331
+ # The metric name is the one docs/05 §2 froze; if the harness writes a different key, the
332
+ # row must say so rather than publish a score of None (E-048 -- reading it out of the
333
+ # pinned YAMLs proved awkward, so it is asserted against the artifact that matters).
334
+ rec[key]["status"] = "PRIMARY METRIC %r ABSENT, have %s" % (
335
+ PRIMARY_METRIC[t], sorted(h.get("rows") or {})[:8])
336
  if rc != 0 or not h.get("rows"):
337
  # A cell pushed as `rows: {}` reads as "scored zero" to anyone holding only the JSON.
338
  rec[key]["status"] = "FAILED rc=%s rows=%s" % (rc, len(h.get("rows") or {}))