#!/usr/bin/env python3 """The two eval drivers must keep the contracts that make them work at all. `evals/mmlu.py` and `evals/humaneval.py` exist because the image's own invocations do not run: `run_eval --eval-name mmlu` shells out to an `sgl-eval` binary the image does not ship, and its HumanEval path needs a `human_eval` package that is not there and then dies in `os.fork`, because the image's filelock refuses one. Both failures print a traceback and an empty score, which reads exactly like a model that scored nothing, and that is how two runs were lost on 2026-09-18. So three things have to stay true, and none of them is visible from reading a score: the drivers print a line a caller can grep, HumanEval never forks and asks for one sample per task (at temperature 0 the harness default of five would mostly repeat one answer), and MMLU pulls the dataset the published numbers were measured against. A stub `sglang` on the path lets all three be checked here, with no image, no network and no engine. The stub tree is laid out as the pinned images are: `simple_eval_common` and `simple_eval_humaneval`, and no `simple_eval_mmlu`, which SGLang removed (sgl-project/sglang#41215) after the MMLU driver was written against it. A stub of that module kept these tests green while the driver died on its import in both pinned images (found 2026-10-20): the class now lives in the driver, and a stub pandas hands it a small dataset. """ import random import json import os import pathlib import shutil import subprocess import sys import tempfile import unittest REPO = pathlib.Path(__file__).resolve().parents[1] EVALS = REPO / "evals" STUB_COMMON = ''' import json, os class ChatCompletionSampler: def __init__(self, **kw): self.kw = kw with open(os.environ["STUB_SAMPLER_LOG"], "w") as f: json.dump(kw, f, default=str) def _pack_message(self, content, role): return {"content": content, "role": role} def __call__(self, messages): # answers A, and keeps what it was asked, in order with open(os.environ["STUB_ASKED"], "a") as f: f.write(messages[0]["content"] + "\\n") return "Answer: A" # simple-evals' own pattern and the result types the MMLU class reads ANSWER_PATTERN_MULTICHOICE = r"(?i)Answer[ \\t]*:[ \\t]*([A-D])" HTML_JINJA = "" SamplerBase = object class Eval: pass class EvalResult: def __init__(self, score, metrics): self.score, self.metrics = score, metrics class SingleEvalResult: def __init__(self, html, score, metrics, convo): self.score, self.metrics = score, metrics def format_multichoice_question(row): return row["Question"] class _Template: def render(self, **kw): return "" class _Env: def from_string(self, text): return _Template() jinja_env = _Env() def map_with_progress(fn, xs, num_threads): call = json.load(open(os.environ["STUB_LOG"])) call.update(num_examples=len(xs), num_threads=num_threads) json.dump(call, open(os.environ["STUB_LOG"], "w")) return [fn(x) for x in xs] def aggregate_results(results): return EvalResult(sum(r.score for r in results) / len(results), {}) ''' # MMLU's dataset as the class reads it: forty questions of four subjects, every # other one answered A STUB_PANDAS = ''' import json, os ROWS = [{"Question": "q%d" % i, "Answer": "AB"[i % 2], "Subject": ["anatomy", "astronomy", "philosophy", "sociology"][i % 4]} for i in range(40)] class _Row(dict): def to_dict(self): return dict(self) class _Frame: def iterrows(self): return enumerate(_Row(r) for r in ROWS) def read_csv(filename, **kw): json.dump({"filename": filename}, open(os.environ["STUB_LOG"], "w")) return _Frame() ''' ROWS = [{"Question": "q%d" % i, "Answer": "AB"[i % 2], "Subject": ["anatomy", "astronomy", "philosophy", "sociology"][i % 4]} for i in range(40)] STUB_HUMANEVAL = ''' import json, multiprocessing, os class _Result: score = 0.75 metrics = {"pass@1": 0.75} class HumanEval: def __init__(self, num_examples, num_threads, num_samples_per_task=5, ks_passes=(1, 2, 5)): with open(os.environ["STUB_LOG"], "w") as f: json.dump({"num_examples": num_examples, "num_threads": num_threads, "samples_per_task": num_samples_per_task, "ks": list(ks_passes), "start_method": multiprocessing.get_start_method(allow_none=True)}, f) def __call__(self, sampler): return _Result() ''' class EvalDrivers(unittest.TestCase): def setUp(self): self.tmp = pathlib.Path(tempfile.mkdtemp(prefix="eval-drivers-")) self.addCleanup(shutil.rmtree, self.tmp, ignore_errors=True) pkg = self.tmp / "sglang" / "test" pkg.mkdir(parents=True) (self.tmp / "sglang" / "__init__.py").write_text("") (pkg / "__init__.py").write_text("") (pkg / "simple_eval_common.py").write_text(STUB_COMMON) (pkg / "simple_eval_humaneval.py").write_text(STUB_HUMANEVAL) (self.tmp / "pandas.py").write_text(STUB_PANDAS) self.log = self.tmp / "call.json" self.sampler_log = self.tmp / "sampler.json" self.asked = self.tmp / "asked.txt" def run_driver(self, name, *args): r = subprocess.run([sys.executable, str(EVALS / name), *args], capture_output=True, text=True, timeout=120, env=dict(os.environ, PYTHONPATH=str(self.tmp), STUB_LOG=str(self.log), STUB_SAMPLER_LOG=str(self.sampler_log), STUB_ASKED=str(self.asked), OPENAI_API_KEY="k")) self.assertEqual(r.returncode, 0, r.stdout + r.stderr) return r.stdout, json.loads(self.log.read_text()) def test_mmlu_prints_a_score_a_caller_can_grep(self): """Every caller of these drivers reads one line: `'score': `, here the share of the questions asked whose answer is A, the stub sampler's.""" out, _ = self.run_driver("mmlu.py", "m", "7", "3") drawn = random.Random(0).sample(ROWS, 7) self.assertIn(f"'score': {sum(r['Answer'] == 'A' for r in drawn) / 7}", out) def test_mmlu_asks_the_questions_the_published_numbers_were_asked(self): """The questions SGLang's class drew, with its seed and in its order: another draw is another 500 questions behind the same name.""" self.run_driver("mmlu.py", "m", "7", "3") self.assertEqual(self.asked.read_text().split(), [r["Question"] for r in random.Random(0).sample(ROWS, 7)]) def test_mmlu_asks_for_the_dataset_the_numbers_were_measured_against(self): """A different CSV is a different benchmark wearing the same name.""" _, call = self.run_driver("mmlu.py", "m", "7", "3") self.assertEqual(call["filename"], "https://openaipublic.blob.core.windows.net/simple-evals/mmlu.csv") self.assertEqual((call["num_examples"], call["num_threads"]), (7, 3)) def test_humaneval_never_forks(self): """The image's filelock refuses os.fork, and human_eval forks per problem.""" _, call = self.run_driver("humaneval.py", "m", "4", "2") self.assertEqual(call["start_method"], "spawn") def test_humaneval_asks_for_one_sample_per_task(self): """At temperature 0 the harness default of five measures pass@1 five times.""" _, call = self.run_driver("humaneval.py", "m", "4", "2") self.assertEqual(call["samples_per_task"], 1) self.assertEqual(call["ks"], [1]) def test_humaneval_prints_a_score_a_caller_can_grep(self): out, _ = self.run_driver("humaneval.py", "m", "4", "2") self.assertIn("'score': 0.75", out) def test_both_take_an_optional_base_url(self): """The fourth argument is how these point at a proxy or another box, and it has to reach the sampler: only the score line was checked, so a driver that ignored it passed (found in review, 2026-09-24).""" for name in ("mmlu.py", "humaneval.py"): with self.subTest(driver=name): out, _ = self.run_driver(name, "m", "2", "1", "http://127.0.0.1:1/v1") self.assertIn("'score':", out) kw = json.loads(self.sampler_log.read_text()) self.assertEqual(kw["base_url"], "http://127.0.0.1:1/v1") self.run_driver(name, "m", "2", "1") kw = json.loads(self.sampler_log.read_text()) self.assertEqual(kw["base_url"], "http://127.0.0.1:30000/v1") def test_both_sample_the_model_they_are_given_at_temperature_zero(self): """The published scores are greedy: a sampler at 0.7 measures something else.""" for name in ("mmlu.py", "humaneval.py"): with self.subTest(driver=name): self.run_driver(name, "my-model", "2", "1") kw = json.loads(self.sampler_log.read_text()) self.assertEqual((kw["model"], kw["temperature"]), ("my-model", 0.0)) class TheReadme(unittest.TestCase): def test_the_commands_run_the_image_the_lane_serves(self): """They ran lmsysorg/sglang:latest, a 30 GB pull of an engine nothing was measured on (found in review, 2026-09-24): the image comes from the running container.""" text = (REPO / "evals" / "README.md").read_text() block = text.split("```bash", 1)[1].split("```", 1)[0] self.assertNotIn("sglang:latest", block) runs = [c for c in block.split("docker run")[1:]] self.assertEqual(len(runs), 2, block) for cmd in runs: self.assertIn('"$IMG" /d.py', cmd) self.assertIn("docker inspect -f '{{.Config.Image}}' qwen38-flash", block) self.assertIn("docker inspect -f '{{.Config.Image}}' qwen38-sglang", block) def test_no_claim_that_greedy_samples_are_identical(self): """LEAN.md measured two distinct outputs in five identical temperature-0 calls; the driver and this README said the five were the same answer (found in review, 2026-09-24).""" self.assertIn("two distinct outputs", (REPO / "LEAN.md").read_text()) for f in ("evals/humaneval.py", "evals/README.md", "BENCHMARKS.md"): text = " ".join((REPO / f).read_text().split()) self.assertNotIn("five are the same answer", text, f) self.assertNotIn("the same answer five times", text, f) if __name__ == "__main__": unittest.main(verbosity=2)