{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "lab-03-00",
   "metadata": {},
   "source": [
    "# 03 · Spend inference compute\n",
    "\n",
    "When does another sample or a verifier pay for itself?\n",
    "\n",
    "Run greedy decoding, fixed-size sampling and verifier-guided selection on the same checkable cases. Include a matched-budget arm. Select the budget on development cases and keep the release split closed.\n",
    "\n",
    "**Measures** — Strict outcome pass rate, extra tokens, wall time and cost proxy per additional correct decision.\n",
    "\n",
    "**Evidence** — Quality versus compute curve and a proposed inference budget.\n",
    "\n",
    "**Runtime** — T4. The course bench uses invented facilities, equipment and records."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "lab-03-01",
   "metadata": {},
   "source": [
    "## Reproduce the environment\n",
    "\n",
    "Install the pinned dependencies and check the hardware receipt before interpreting timings. Runs record their device and software package versions in `evidence/runtime.json`."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "lab-03-02",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-11-27T06:19:41.958244Z",
     "iopub.status.busy": "2026-11-27T06:19:41.957580Z",
     "iopub.status.idle": "2026-11-27T06:19:41.977037Z",
     "shell.execute_reply": "2026-11-27T06:19:41.976441Z"
    }
   },
   "outputs": [],
   "source": [
    "PINS = {'transformers': '4.51.3', 'accelerate': '1.6.0', 'sentence-transformers': '4.1.0', 'bitsandbytes': '0.49.0', 'pypdf': '5.6.1', 'pymupdf': '1.26.1', 'reportlab': '4.4.2', 'rank-bm25': '0.2.2', 'soundfile': '0.13.1'}\n",
    "\n",
    "import importlib.metadata\n",
    "import os\n",
    "import subprocess\n",
    "import sys\n",
    "\n",
    "if os.environ.get(\"COURSE_SMOKE\") != \"1\":\n",
    "    missing = []\n",
    "    for name, version in PINS.items():\n",
    "        try:\n",
    "            matched = importlib.metadata.version(name) == version\n",
    "        except importlib.metadata.PackageNotFoundError:\n",
    "            matched = False\n",
    "        if not matched:\n",
    "            missing.append(f\"{name}=={version}\")\n",
    "    if missing:\n",
    "        try:\n",
    "            import uv\n",
    "        except ImportError:\n",
    "            subprocess.run([sys.executable, \"-m\", \"pip\", \"install\", \"--quiet\", \"uv==0.7.13\"], check=True)\n",
    "        subprocess.run([sys.executable, \"-m\", \"uv\", \"pip\", \"install\", \"--quiet\", \"--python\", sys.executable, *missing], check=True)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "lab-03-03",
   "metadata": {},
   "source": [
    "## Establish the shared contract\n",
    "\n",
    "Freeze equipment families before deriving ticket variants. Verify an outcome against the decision, exact value and explicit evidence IDs. Keep the release split closed until the capstone. Read-only tools take tenant and role from trusted request metadata."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "lab-03-04",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-11-27T06:19:41.980367Z",
     "iopub.status.busy": "2026-11-27T06:19:41.980045Z",
     "iopub.status.idle": "2026-11-27T06:19:42.005064Z",
     "shell.execute_reply": "2026-11-27T06:19:42.004321Z"
    }
   },
   "outputs": [],
   "source": [
    "MODEL_IDS = {'text': ('Qwen/Qwen2.5-1.5B-Instruct', '989aa7980e4cf806f80c7fef2b1adb7bc71aa306'), 'vision': ('Qwen/Qwen2-VL-2B-Instruct', '1860c46f12b7449d0f5b426a7474ab715342bc65'), 'speech': ('openai/whisper-base', 'e37978b90ca9030d5170a5c07aadb050351a65bb'), 'embedding': ('sentence-transformers/all-MiniLM-L6-v2', '1110a243fdf4706b3f48f1d95db1a4f5529b4d41'), 'reranker': ('cross-encoder/ms-marco-MiniLM-L6-v2', '233902d25c440f23af6f7d6e94d2946bac0bee0a')}\n",
    "SPLIT_MANIFEST = {'train': {'sha256': '610cd78bdcc4f92095a511c4c92812eace3bcd25f290604d4641f8338438bc4b', 'n': 180, 'families': 18}, 'dev': {'sha256': '51dbc208b6b20a620237dd76ce0a2db4f10aa75f4f8fc404121e301b8d79a0cf', 'n': 120, 'families': 12}, 'holdout': {'sha256': 'd8c88e29283fe660e86b9bf3b3c67fb810f3cfa75c27e2e7043bccfb42766452', 'n': 300, 'families': 30}}\n",
    "LAB_NUMBER = 3\n",
    "\n",
    "import hashlib\n",
    "import json\n",
    "import os\n",
    "import random\n",
    "import re\n",
    "import sqlite3\n",
    "from functools import lru_cache\n",
    "from pathlib import Path\n",
    "\n",
    "SLICES = (\"manual\", \"numeric\", \"multi_source\", \"ambiguity\", \"boundary\", \"follow_up\")\n",
    "SPLITS = {\"train\": (100, 3), \"dev\": (200, 2), \"holdout\": (300, 5)}\n",
    "TENANTS = (\"north-yard\", \"south-yard\")\n",
    "\n",
    "\n",
    "@lru_cache\n",
    "def _assets(split):\n",
    "    first, count = SPLITS[split]\n",
    "    rows = []\n",
    "    for slice_index, category in enumerate(SLICES):\n",
    "        for offset in range(count):\n",
    "            index = first + slice_index * 10 + offset\n",
    "            prefix = (\"P\", \"F\", \"V\")[index % 3]\n",
    "            result = {\n",
    "                \"family\": f\"F{index}\", \"slice\": category, \"tenant\": TENANTS[index % 2],\n",
    "                \"asset\": f\"{prefix}-{index}\", \"linked\": f\"S-{index + 400}\",\n",
    "                \"team\": (\"mechanical\", \"controls\", \"electrical\")[index % 3],\n",
    "                \"limit\": 67 + (index * 19) % 36,\n",
    "                \"inspection\": f\"2025-{index % 12 + 1:02d}-{index % 27 + 1:02d}\",\n",
    "                \"fault\": (\"seal wear\", \"sensor drift\", \"filter blockage\", \"bearing vibration\")[index % 4],\n",
    "                \"version\": \"r3\",\n",
    "            }\n",
    "            for source in (\"manual\", \"inventory\", \"graph\"):\n",
    "                result[f\"{source}_id\"] = f\"{source}-{result['asset']}-r3\"\n",
    "            rows.append(result)\n",
    "    return tuple(rows)\n",
    "\n",
    "\n",
    "def assets(split=\"dev\"):\n",
    "    return [dict(row) for row in _assets(split)]\n",
    "\n",
    "\n",
    "def manual_text(asset_record):\n",
    "    return (\n",
    "        f\"Equipment manual for {asset_record['asset']} (revision {asset_record['version']}). \"\n",
    "        f\"Maximum operating temperature: {asset_record['limit']} C. \"\n",
    "        f\"Known fault: {asset_record['fault']}. The supporting system is {asset_record['linked']}. \"\n",
    "        f\"Maintenance owner: {asset_record['team']}.\"\n",
    "    )\n",
    "\n",
    "\n",
    "def corpus(split=\"dev\"):\n",
    "    docs = []\n",
    "    for row in assets(split):\n",
    "        passages = {\n",
    "            \"manual\": manual_text(row),\n",
    "            \"inventory\": f\"Inventory for {row['asset']}. Last inspection: {row['inspection']}.\",\n",
    "            \"graph\": f\"{row['asset']} is served by supporting system {row['linked']} and owned by {row['team']}.\",\n",
    "        }\n",
    "        docs.extend({\n",
    "            \"id\": row[f\"{source}_id\"], \"source\": source, \"text\": passage,\n",
    "            \"tenant\": row[\"tenant\"], \"family\": row[\"family\"],\n",
    "        } for source, passage in passages.items())\n",
    "    return docs\n",
    "\n",
    "\n",
    "def _case(row, variant):\n",
    "    asset = row[\"asset\"]\n",
    "    wrappers = (\n",
    "        \"{}\", \"Please help. {}\", \"Ticket intake: {}\", \"Shift note. {}\", \"Quick question: {}\",\n",
    "        \"Could you check this? {}\", \"{} Thanks.\", \"Facilities desk: {}\", \"I need a record check. {}\", \"Operator message: {}\",\n",
    "    )\n",
    "    category = row[\"slice\"]\n",
    "    wording = {\n",
    "        \"manual\": (f\"What is the maximum temperature for {asset}?\", f\"What's the thermal limit, in C, of {asset}?\"),\n",
    "        \"numeric\": (f\"When was {asset} last inspected?\", f\"Give the last inspection date for {asset}.\"),\n",
    "        \"multi_source\": (f\"Give the last inspection date and supporting system for {asset}.\",\n",
    "                         f\"For {asset}, which system supports it and when was its most recent inspection?\"),\n",
    "        \"ambiguity\": (\"What is the maximum temperature for that unit?\", \"When was that pump last inspected?\"),\n",
    "        \"boundary\": (f\"As a guest, show the inventory record for {asset}.\", f\"Guest request: give inspection date for {asset}.\"),\n",
    "        \"follow_up\": (\"What is its maximum temperature?\", \"And how hot can this one run?\"),\n",
    "    }\n",
    "    question = wrappers[variant].format(wording[category][variant % 2])\n",
    "    role = \"guest\" if category == \"boundary\" else \"operator\"\n",
    "    value, evidence, source = {\n",
    "        \"manual\": (str(row[\"limit\"]), [row[\"manual_id\"]], \"manual\"),\n",
    "        \"numeric\": (row[\"inspection\"], [row[\"inventory_id\"]], \"inventory\"),\n",
    "        \"multi_source\": (f\"{row['inspection']} | {row['linked']}\", [row[\"inventory_id\"], row[\"graph_id\"]], \"graph\"),\n",
    "        \"follow_up\": (str(row[\"limit\"]), [row[\"manual_id\"]], \"manual\"),\n",
    "        \"ambiguity\": (\"\", [], \"none\"),\n",
    "        \"boundary\": (\"\", [], \"none\"),\n",
    "    }[category]\n",
    "    decision = {\"ambiguity\": \"clarify\", \"boundary\": \"deny\"}.get(category, \"answer\")\n",
    "    return {\n",
    "        **row, \"id\": f\"{row['family']}-{variant:02d}\", \"question\": question, \"role\": role,\n",
    "        \"decision\": decision, \"value\": value, \"evidence\": evidence, \"source\": source,\n",
    "        \"variant\": variant, \"previous_asset\": asset if category == \"follow_up\" else \"\",\n",
    "        \"previous_version\": row[\"version\"] if category == \"follow_up\" else \"\",\n",
    "    }\n",
    "\n",
    "\n",
    "def cases(split=\"dev\"):\n",
    "    return [_case(row, variant) for row in assets(split) for variant in range(10)]\n",
    "\n",
    "\n",
    "def digest(rows):\n",
    "    serial = json.dumps(rows, ensure_ascii=False, sort_keys=True, separators=(\",\", \":\")).encode()\n",
    "    return hashlib.sha256(serial).hexdigest()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "lab-03-05",
   "metadata": {},
   "source": [
    "### Preserve source authority\n",
    "\n",
    "Generate original documents and an inventory view. Parameterize the database query, set it read-only, and select only evidence that belongs to the trusted tenant."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "lab-03-06",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-11-27T06:19:42.010232Z",
     "iopub.status.busy": "2026-11-27T06:19:42.008523Z",
     "iopub.status.idle": "2026-11-27T06:19:42.019810Z",
     "shell.execute_reply": "2026-11-27T06:19:42.019142Z"
    }
   },
   "outputs": [],
   "source": [
    "@lru_cache\n",
    "def _inventory(split):\n",
    "    db = sqlite3.connect(\":memory:\")\n",
    "    db.row_factory = sqlite3.Row\n",
    "    db.execute(\"CREATE TABLE inventory(asset TEXT PRIMARY KEY, tenant TEXT, inspection TEXT, version TEXT)\")\n",
    "    db.executemany(\n",
    "        \"INSERT INTO inventory VALUES(:asset, :tenant, :inspection, :version)\", assets(split)\n",
    "    )\n",
    "    db.execute(\"CREATE VIEW operator_inventory AS SELECT asset, tenant, inspection, version FROM inventory\")\n",
    "    db.execute(\"PRAGMA query_only = ON\")\n",
    "    return db\n",
    "\n",
    "\n",
    "def read_inventory(asset, tenant, role=\"operator\", split=\"dev\"):\n",
    "    if role != \"operator\":\n",
    "        return None\n",
    "    row = _inventory(split).execute(\n",
    "        \"SELECT * FROM operator_inventory WHERE asset = ? AND tenant = ?\", (asset, tenant)\n",
    "    ).fetchone()\n",
    "    return dict(row) if row is not None else None\n",
    "\n",
    "\n",
    "def safe_context(case, split=\"dev\"):\n",
    "    if case[\"role\"] != \"operator\" or case.get(\"tenant\") not in TENANTS:\n",
    "        return \"\"\n",
    "    if case[\"slice\"] == \"ambiguity\":\n",
    "        return \"\"\n",
    "    asset_id = case.get(\"previous_asset\") if case[\"slice\"] == \"follow_up\" else case[\"asset\"]\n",
    "    source_ids = {\n",
    "        d[f\"{source}_id\"]\n",
    "        for d in assets(split) if d[\"asset\"] == asset_id and d[\"tenant\"] == case[\"tenant\"]\n",
    "        for source in (\"manual\", \"inventory\", \"graph\")\n",
    "    }\n",
    "    return \"\\n\".join(f\"[{doc['id']}] {doc['text']}\" for doc in corpus(split) if doc[\"id\"] in source_ids)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "lab-03-07",
   "metadata": {},
   "source": [
    "### Score the outcome\n",
    "\n",
    "A correct decision still needs the right value and complete evidence. Use a paired bootstrap over equipment families when comparing two systems."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "lab-03-08",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-11-27T06:19:42.023158Z",
     "iopub.status.busy": "2026-11-27T06:19:42.022945Z",
     "iopub.status.idle": "2026-11-27T06:19:42.037156Z",
     "shell.execute_reply": "2026-11-27T06:19:42.035845Z"
    }
   },
   "outputs": [],
   "source": [
    "def score_answer(case, answer):\n",
    "    if not isinstance(answer, dict) or not isinstance(answer.get(\"evidence\"), list):\n",
    "        return 0\n",
    "    evidence = answer[\"evidence\"]\n",
    "    return int(\n",
    "        answer.get(\"decision\") == case[\"decision\"]\n",
    "        and isinstance(answer.get(\"value\"), str)\n",
    "        and answer[\"value\"].strip() == case[\"value\"]\n",
    "        and all(isinstance(item, str) for item in evidence)\n",
    "        and sorted(evidence) == sorted(case[\"evidence\"])\n",
    "    )\n",
    "\n",
    "\n",
    "def paired_interval(cases, candidate, incumbent, draws=1500):\n",
    "    if len(cases) != len(candidate) or len(cases) != len(incumbent) or not cases:\n",
    "        raise ValueError(\"Expected equal-length nonempty case and score arrays.\")\n",
    "    groups = {}\n",
    "    for case, new, old in zip(cases, candidate, incumbent):\n",
    "        groups.setdefault(case[\"family\"], []).append(int(new) - int(old))\n",
    "    summaries = [(sum(values), len(values)) for values in groups.values()]\n",
    "    rng = random.Random(401)\n",
    "    estimates = []\n",
    "    for _ in range(draws):\n",
    "        sampled = rng.choices(summaries, k=len(summaries))\n",
    "        estimates.append(sum(total for total, _ in sampled) / sum(n for _, n in sampled))\n",
    "    estimates.sort()\n",
    "    return {\n",
    "        \"delta\": sum(total for total, _ in summaries) / len(cases),\n",
    "        \"low\": estimates[int(draws * .025)],\n",
    "        \"high\": estimates[int(draws * .975) - 1],\n",
    "        \"n\": len(cases), \"families\": len(summaries),\n",
    "    }\n",
    "\n",
    "\n",
    "def decode_answer(text):\n",
    "    try:\n",
    "        answer = json.loads(text.strip())\n",
    "    except (AttributeError, ValueError):\n",
    "        return {}\n",
    "    return answer if isinstance(answer, dict) else {}\n",
    "\n",
    "\n",
    "def answer_prompt(case, context):\n",
    "    previous = case.get(\"previous_asset\") or \"none\"\n",
    "    return (\n",
    "        \"You are a facilities helpdesk. Use only the supplied records. Decide answer, clarify, or deny. \"\n",
    "        \"Deny requests from a guest. Clarify when the equipment is unspecified and no previous equipment is listed. \"\n",
    "        \"Output exactly one JSON object with keys decision, value and evidence. For deny or clarify use an empty \"\n",
    "        \"value and evidence array. Use the exact record text for dates or identifiers and an integer-as-string \"\n",
    "        \"for temperatures. When asked for both inspection and supporting system, return DATE | SYSTEM. \"\n",
    "        \"For an answer include only supporting record IDs in evidence.\\n\"\n",
    "        f\"Role: {case['role']}\\nPrevious equipment: {previous}\\nRequest: {case['question']}\\n\"\n",
    "        f\"Records:\\n{context or '(none)'}\"\n",
    "    )"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "lab-03-09",
   "metadata": {},
   "source": [
    "### Record the runtime and evidence\n",
    "\n",
    "The model checkpoints are fixed. Local smoke mode uses offline fixtures to exercise the notebook code path. It cannot produce GPU measurements."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "lab-03-10",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-11-27T06:19:42.042092Z",
     "iopub.status.busy": "2026-11-27T06:19:42.041000Z",
     "iopub.status.idle": "2026-11-27T06:19:52.127872Z",
     "shell.execute_reply": "2026-11-27T06:19:52.127170Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Evidence saved to evidence/runtime.json\n",
      "{\n",
      "  \"device\": \"Tesla T4\",\n",
      "  \"python\": \"3.13.16\",\n",
      "  \"platform\": \"Linux\",\n",
      "  \"packages\": {\n",
      "    \"torch\": \"2.14.1+cu130\",\n",
      "    \"transformers\": \"4.51.3\",\n",
      "    \"accelerate\": \"1.6.0\",\n",
      "    \"numpy\": \"2.4.6\",\n",
      "    \"scikit-learn\": \"1.6.1\",\n",
      "    \"matplotlib\": \"3.10.0\",\n",
      "    \"bitsandbytes\": \"0.49.0\",\n",
      "    \"sentence-transformers\": \"4.1.0\"\n",
      "  },\n",
      "  \"smoke\": false,\n",
      "  \"cuda\": \"13.0\",\n",
      "  \"memory_bytes\": 15637086208,\n",
      "  \"capability\": [\n",
      "    7,\n",
      "    5\n",
      "  ]\n",
      "}\n"
     ]
    }
   ],
   "source": [
    "def _convert(value):\n",
    "    if hasattr(value, \"tolist\"):\n",
    "        return value.tolist()\n",
    "    if hasattr(value, \"item\"):\n",
    "        return value.item()\n",
    "    if isinstance(value, Path):\n",
    "        return str(value)\n",
    "    raise TypeError(type(value).__name__)\n",
    "\n",
    "\n",
    "def save(name, value):\n",
    "    output = Path(\"evidence\")\n",
    "    output.mkdir(exist_ok=True)\n",
    "    path = output / f\"{name}.json\"\n",
    "    path.write_text(json.dumps(value, indent=2, ensure_ascii=False, default=_convert, allow_nan=False) + \"\\n\")\n",
    "    print(f\"Evidence saved to {path}\")\n",
    "    return path\n",
    "\n",
    "\n",
    "def chart(title, labels, values, unit):\n",
    "    import matplotlib.pyplot as plt\n",
    "    import numpy as np\n",
    "    from matplotlib.ticker import PercentFormatter\n",
    "\n",
    "    values = np.asarray(values, dtype=float)\n",
    "    positions = np.arange(len(labels))\n",
    "    palette = (\"#3d6b5b\", \"#298876\", \"#7b97a2\", \"#9c6951\")\n",
    "    paper, ink, line = \"#f5f7f2\", \"#20382f\", \"#d3ded6\"\n",
    "    readable = [label.replace(\"_\", \" \") for label in labels]\n",
    "    fig, axes = plt.subplots(figsize=(8.1, max(2.55, .48 * len(labels) + 1.7)), layout=\"constrained\")\n",
    "    fig.patch.set_facecolor(paper)\n",
    "    axes.set_facecolor(paper)\n",
    "    bars = axes.barh(positions, values, height=.55, color=[palette[i % len(palette)] for i in positions])\n",
    "    axes.set_yticks(positions, labels=readable)\n",
    "    axes.invert_yaxis()\n",
    "    fraction = unit.casefold() == \"fraction\"\n",
    "    if fraction:\n",
    "        axes.xaxis.set_major_formatter(PercentFormatter(xmax=1, decimals=0))\n",
    "    axes.set_xlabel(\"Share of cases\" if fraction else unit, color=ink, loc=\"left\", labelpad=8)\n",
    "    axes.set_title(title, loc=\"left\", color=ink, weight=\"semibold\", pad=15, fontsize=16)\n",
    "    axes.set_axisbelow(True)\n",
    "    axes.grid(axis=\"x\", color=line, linewidth=.75)\n",
    "    axes.spines[[\"top\", \"right\", \"left\", \"bottom\"]].set_visible(False)\n",
    "    axes.tick_params(axis=\"both\", length=0, colors=ink, pad=5)\n",
    "    finite = values[np.isfinite(values)]\n",
    "    if len(finite):\n",
    "        left, right = min(0.0, finite.min()), max(0.0, finite.max())\n",
    "        span = right - left or 1.0\n",
    "        axes.set_xlim(left - (.15 * span if left < 0 else 0), right + .18 * span)\n",
    "        for bar, value in zip(bars, values):\n",
    "            if not np.isfinite(value):\n",
    "                continue\n",
    "            center = bar.get_y() + bar.get_height() / 2\n",
    "            if value == 0:\n",
    "                axes.scatter([0], [center], s=14, color=ink, clip_on=False, zorder=3)\n",
    "            formatted = f\"{value:.1%}\" if fraction else f\"{value:,.3g}\"\n",
    "            axes.annotate(formatted, (value, center), xytext=(6 if value >= 0 else -6, 0), textcoords=\"offset points\",\n",
    "                          ha=\"left\" if value >= 0 else \"right\", va=\"center\", color=ink, fontsize=10)\n",
    "    target = Path(\"evidence\") / (re.sub(r\"[^a-z0-9]+\", \"-\", title.lower()).strip(\"-\") + \".svg\")\n",
    "    target.parent.mkdir(exist_ok=True)\n",
    "    fig.savefig(target)\n",
    "    plt.show()\n",
    "    plt.close(fig)\n",
    "\n",
    "import importlib.metadata\n",
    "import platform\n",
    "import sys\n",
    "import time\n",
    "\n",
    "COURSE_SMOKE = os.environ.get(\"COURSE_SMOKE\") == \"1\"\n",
    "HAS_MODEL_RUNTIME = not COURSE_SMOKE and LAB_NUMBER != 10\n",
    "if HAS_MODEL_RUNTIME:\n",
    "    import torch\n",
    "    from transformers import AutoModelForCausalLM, AutoTokenizer, BitsAndBytesConfig\n",
    "\n",
    "\n",
    "def device_name():\n",
    "    if COURSE_SMOKE:\n",
    "        return \"CPU smoke\"\n",
    "    if not HAS_MODEL_RUNTIME:\n",
    "        return \"CPU\"\n",
    "    return torch.cuda.get_device_name(0) if torch.cuda.is_available() else \"CPU\"\n",
    "\n",
    "\n",
    "def sync():\n",
    "    if HAS_MODEL_RUNTIME and torch.cuda.is_available():\n",
    "        torch.cuda.synchronize()\n",
    "\n",
    "\n",
    "def load_text(quant=False):\n",
    "    if not HAS_MODEL_RUNTIME:\n",
    "        raise RuntimeError(\"Use a fixture explicitly inside the CPU smoke lane.\")\n",
    "    repo, revision = MODEL_IDS[\"text\"]\n",
    "    tokenizer = AutoTokenizer.from_pretrained(repo, revision=revision, padding_side=\"left\")\n",
    "    options = {\"revision\": revision, \"attn_implementation\": \"sdpa\"}\n",
    "    if torch.cuda.is_available():\n",
    "        options.update(torch_dtype=torch.float16, device_map={\"\": 0})\n",
    "    else:\n",
    "        options.update(torch_dtype=torch.float32)\n",
    "    if quant:\n",
    "        if not torch.cuda.is_available():\n",
    "            raise RuntimeError(\"NF4 comparison requires CUDA.\")\n",
    "        options[\"quantization_config\"] = BitsAndBytesConfig(\n",
    "            load_in_4bit=True, bnb_4bit_quant_type=\"nf4\", bnb_4bit_compute_dtype=torch.float16,\n",
    "        )\n",
    "    return tokenizer, AutoModelForCausalLM.from_pretrained(repo, **options).eval()\n",
    "\n",
    "\n",
    "def generate(tokenizer, model, prompts, max_new_tokens=48, temperature=0.0, **kwargs):\n",
    "    rendered = [\n",
    "        tokenizer.apply_chat_template([{\"role\": \"user\", \"content\": p}], tokenize=False, add_generation_prompt=True)\n",
    "        for p in prompts\n",
    "    ]\n",
    "    tokens = tokenizer(rendered, return_tensors=\"pt\", padding=True, add_special_tokens=False).to(model.device)\n",
    "    sampling = {\"do_sample\": True, \"temperature\": temperature} if temperature > 0 else {\"do_sample\": False}\n",
    "    with torch.inference_mode():\n",
    "        output = model.generate(\n",
    "            **tokens, max_new_tokens=max_new_tokens, pad_token_id=tokenizer.pad_token_id,\n",
    "            **sampling, **kwargs,\n",
    "        )\n",
    "    return tokenizer.batch_decode(output[:, tokens.input_ids.shape[1]:], skip_special_tokens=True)\n",
    "\n",
    "\n",
    "def write_receipt():\n",
    "    versions = {}\n",
    "    for package in (\"torch\", \"transformers\", \"accelerate\", \"numpy\", \"scikit-learn\", \"matplotlib\", \"bitsandbytes\", \"sentence-transformers\"):\n",
    "        try:\n",
    "            versions[package] = importlib.metadata.version(package)\n",
    "        except importlib.metadata.PackageNotFoundError:\n",
    "            pass\n",
    "    receipt = {\n",
    "        \"device\": device_name(), \"python\": sys.version.split()[0], \"platform\": platform.system(),\n",
    "        \"packages\": versions, \"smoke\": COURSE_SMOKE,\n",
    "    }\n",
    "    if HAS_MODEL_RUNTIME and torch.cuda.is_available():\n",
    "        props = torch.cuda.get_device_properties(0)\n",
    "        receipt.update(cuda=torch.version.cuda, memory_bytes=props.total_memory, capability=list(torch.cuda.get_device_capability(0)))\n",
    "    save(\"runtime\", receipt)\n",
    "    print(json.dumps(receipt, indent=2))\n",
    "    return receipt\n",
    "\n",
    "if 'get_ipython' in globals() and get_ipython() is not None:\n",
    "    from matplotlib_inline.backend_inline import set_matplotlib_formats\n",
    "    set_matplotlib_formats('svg')\n",
    "hardware = write_receipt()\n",
    "if True and os.environ.get('COURSE_T4') == '1':\n",
    "    assert 'T4' in hardware['device'], f\"Expected T4, got {hardware['device']}\"\n"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "lab-03-11",
   "metadata": {},
   "source": [
    "# Lab 03 · Spend inference compute\n",
    "\n",
    "[Read the lesson](https://docs.recohut.com/courses/advanced-ai-systems-engineering/1-measure-the-model/03-spend-inference-compute).\n",
    "\n",
    "A facilities operator has time to inspect exactly two assets before shift\n",
    "change. Given a short work list, select the feasible pair with the highest\n",
    "combined priority. We compare greedy decoding, plurality voting, and\n",
    "verifier-guided selection. The sampled arms use the same generated\n",
    "candidates at each sample count, so a difference comes from selection.\n",
    "\n",
    "Each shortlist contains development asset identifiers from the operator's\n",
    "yard and invented priorities and durations. Change only the shift time left,\n",
    "then predict which pair should win. We can calculate the optimum exactly\n",
    "and check whether model compute is justified for this workload.\n",
    "\n",
    "The full lab calls the pinned model on a T4. The local check uses constructed\n",
    "candidate lists and records no model timings or model results."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "lab-03-12",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-11-27T06:19:52.147683Z",
     "iopub.status.busy": "2026-11-27T06:19:52.147082Z",
     "iopub.status.idle": "2026-11-27T06:19:52.212536Z",
     "shell.execute_reply": "2026-11-27T06:19:52.208948Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Work orders by benchmark slice: {'follow_up': 4, 'manual': 4, 'numeric': 4, 'multi_source': 4, 'ambiguity': 4, 'boundary': 4}\n",
      "Opening work orders, same shortlist with one extra minute: [{'case_id': 'F250-tight', 'family': 'F250', 'slice': 'follow_up', 'tenant': 'north-yard', 'seed': 4170, 'budget_variant': 'tight', 'budget_minutes': 28, 'options': [{'asset': 'F-250', 'minutes': 15, 'priority': 14}, {'asset': 'V-200', 'minutes': 14, 'priority': 10}, {'asset': 'P-210', 'minutes': 11, 'priority': 6}, {'asset': 'F-220', 'minutes': 7, 'priority': 4}, {'asset': 'V-230', 'minutes': 7, 'priority': 2}]}, {'case_id': 'F250-loose', 'family': 'F250', 'slice': 'follow_up', 'tenant': 'north-yard', 'seed': 4170, 'budget_variant': 'loose', 'budget_minutes': 29, 'options': [{'asset': 'F-250', 'minutes': 15, 'priority': 14}, {'asset': 'V-200', 'minutes': 14, 'priority': 10}, {'asset': 'P-210', 'minutes': 11, 'priority': 6}, {'asset': 'F-220', 'minutes': 7, 'priority': 4}, {'asset': 'V-230', 'minutes': 7, 'priority': 2}]}]\n"
     ]
    }
   ],
   "source": [
    "from collections import Counter\n",
    "from itertools import combinations\n",
    "from statistics import median\n",
    "from time import perf_counter\n",
    "\n",
    "TOKEN_LIMIT = 32\n",
    "SAMPLING_TEMPERATURE = 0.65\n",
    "TOP_P = 0.9\n",
    "SAMPLE_COUNTS = (1, 2, 4)\n",
    "MINIMUM_MODEL_PASS_RATE = 0.90\n",
    "ACTIVE_SPLIT = \"dev\"\n",
    "BOOTSTRAP_DRAWS = 1500\n",
    "run_started = perf_counter()\n",
    "\n",
    "dev_assets = sorted(assets(ACTIVE_SPLIT), key=lambda row: row[\"asset\"] != \"F-250\")\n",
    "work_orders = []\n",
    "for index, anchor in enumerate(dev_assets):\n",
    "    neighbours = [row for row in dev_assets\n",
    "                  if row[\"tenant\"] == anchor[\"tenant\"] and row[\"asset\"] != anchor[\"asset\"]]\n",
    "    pivot = index % len(neighbours)\n",
    "    shortlist = [anchor, *(neighbours[pivot:] + neighbours[:pivot])[:4]]\n",
    "    # Make the top two priorities slower than any pair that uses a reserve asset.\n",
    "    options = [\n",
    "        {\"asset\": row[\"asset\"], \"minutes\": minutes + (index + offset) % 3,\n",
    "         \"priority\": priority + (index * offset) % 3}\n",
    "        for offset, (row, minutes, priority) in enumerate(zip(\n",
    "            shortlist, (15, 13, 9, 7, 6), (14, 10, 6, 4, 2),\n",
    "        ))\n",
    "    ]\n",
    "    cutoff = options[0][\"minutes\"] + options[1][\"minutes\"]\n",
    "    for variant, budget in ((\"tight\", cutoff - 1), (\"loose\", cutoff)):\n",
    "        work_orders.append({\n",
    "            \"case_id\": f\"{anchor['family']}-{variant}\",\n",
    "            \"family\": anchor[\"family\"], \"slice\": anchor[\"slice\"], \"tenant\": anchor[\"tenant\"],\n",
    "            \"seed\": 4170 + index, \"budget_variant\": variant, \"budget_minutes\": budget,\n",
    "            \"options\": options,\n",
    "        })\n",
    "\n",
    "assert len({row[\"case_id\"] for row in work_orders}) == len(work_orders)\n",
    "assert {row[\"slice\"] for row in work_orders} == set(SLICES)\n",
    "print(\"Work orders by benchmark slice:\", dict(Counter(row[\"slice\"] for row in work_orders)))\n",
    "print(\"Opening work orders, same shortlist with one extra minute:\", work_orders[:2])"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "lab-03-13",
   "metadata": {},
   "source": [
    "## Keep selection and grading independent\n",
    "\n",
    "The verifier can tell whether a generated pair complies with the work\n",
    "order and sum its priority. It can only choose among proposed pairs.\n",
    "The reference solver enumerates every pair, so it can independently\n",
    "tell whether a feasible proposal reached the true optimum. Order in the\n",
    "returned JSON array is immaterial and we allow either pair if optimal\n",
    "scores tie. Invalid responses contribute to the failure count.\n",
    "\n",
    "Plurality selects the most frequent parsed pair regardless of feasibility.\n",
    "Unparseable outputs share one empty ballot. A tie goes to the earliest tied\n",
    "ballot. The verifier selects the feasible proposal with the highest priority\n",
    "or returns no pair. Both selectors receive every candidate in the same batch."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "lab-03-14",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-11-27T06:19:52.225120Z",
     "iopub.status.busy": "2026-11-27T06:19:52.224748Z",
     "iopub.status.idle": "2026-11-27T06:19:52.297662Z",
     "shell.execute_reply": "2026-11-27T06:19:52.295439Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Exact pair for first work order: ('F-250', 'P-210') combined priority 20\n",
      "Constructed boundary example: plurality chose the unavailable pair. Verification rescued it.\n"
     ]
    }
   ],
   "source": [
    "def parse_pair(raw):\n",
    "    try:\n",
    "        items = json.loads(raw.strip())\n",
    "    except (AttributeError, ValueError):\n",
    "        return ()\n",
    "    if not isinstance(items, list) or len(items) != 2 or not all(isinstance(item, str) for item in items):\n",
    "        return ()\n",
    "    return tuple(sorted(items))\n",
    "\n",
    "\n",
    "def verify_pair(order, pair):\n",
    "    options = {row[\"asset\"]: row for row in order[\"options\"]}\n",
    "    if len(pair) != 2:\n",
    "        return {\"feasible\": False, \"priority\": None, \"minutes\": None, \"check\": \"no_pair\"}\n",
    "    if len(set(pair)) != 2 or not set(pair) <= options.keys():\n",
    "        return {\"feasible\": False, \"priority\": None, \"minutes\": None, \"check\": \"invalid_assets\"}\n",
    "    minutes = sum(options[asset][\"minutes\"] for asset in pair)\n",
    "    feasible = minutes <= order[\"budget_minutes\"]\n",
    "    return {\n",
    "        \"feasible\": feasible,\n",
    "        \"priority\": sum(options[asset][\"priority\"] for asset in pair),\n",
    "        \"minutes\": minutes,\n",
    "        \"check\": \"feasible\" if feasible else \"over_budget\",\n",
    "    }\n",
    "\n",
    "\n",
    "def exact_pair(order):\n",
    "    options = list(order[\"options\"])\n",
    "    eligible = [\n",
    "        (sum(row[\"priority\"] for row in items), tuple(sorted(row[\"asset\"] for row in items)))\n",
    "        for items in combinations(options, 2)\n",
    "        if sum(row[\"minutes\"] for row in items) <= order[\"budget_minutes\"]\n",
    "    ]\n",
    "    return max(eligible)\n",
    "\n",
    "\n",
    "def choose_pair(order, candidates, policy):\n",
    "    if policy == \"greedy\":\n",
    "        return candidates[0]\n",
    "    if policy == \"plurality\":\n",
    "        return Counter(candidates).most_common(1)[0][0]\n",
    "\n",
    "    def candidate_key(pair):\n",
    "        check = verify_pair(order, pair)\n",
    "        return check[\"feasible\"], check[\"priority\"] if check[\"feasible\"] else -1\n",
    "\n",
    "    candidate = max(candidates, key=candidate_key)\n",
    "    return candidate if verify_pair(order, candidate)[\"feasible\"] else ()\n",
    "\n",
    "\n",
    "def grade_pair(order, pair, optimum):\n",
    "    check = verify_pair(order, pair)\n",
    "    outcome = check[\"check\"]\n",
    "    if check[\"feasible\"]:\n",
    "        outcome = \"optimal\" if check[\"priority\"] == optimum else \"suboptimal\"\n",
    "    return {**check, \"outcome\": outcome, \"strict_pass\": outcome == \"optimal\"}\n",
    "\n",
    "\n",
    "def build_prompt(order):\n",
    "    table = \"\\n\".join(f\"{row['asset']} | {row['minutes']} | {row['priority']}\"\n",
    "                      for row in order[\"options\"])\n",
    "    return (\n",
    "        \"Choose exactly two different assets to inspect. Their total duration must be at or \"\n",
    "        \"below the available minutes. Maximise the sum of their priorities. Reply only with \"\n",
    "        'a JSON array of two asset identifier strings, for example [\"A-1\",\"B-2\"].\\n'\n",
    "        f\"Available minutes: {order['budget_minutes']}\\n\"\n",
    "        f\"Asset | Duration in minutes | Priority\\n{table}\"\n",
    "    )\n",
    "\n",
    "\n",
    "example = work_orders[0]\n",
    "best_priority, best_pair = exact_pair(example)\n",
    "assert verify_pair(example, best_pair)[\"priority\"] == best_priority\n",
    "for tight, loose in zip(work_orders[::2], work_orders[1::2]):\n",
    "    assert tight[\"options\"] == loose[\"options\"] and tight[\"family\"] == loose[\"family\"]\n",
    "    assert exact_pair(tight)[0] < exact_pair(loose)[0]\n",
    "boundary_candidates = [(\"unknown-a\", \"unknown-b\"), (\"unknown-a\", \"unknown-b\"), best_pair]\n",
    "assert not verify_pair(example, choose_pair(example, boundary_candidates, \"plurality\"))[\"feasible\"]\n",
    "assert choose_pair(example, boundary_candidates, \"verified\") == best_pair\n",
    "print(\"Exact pair for first work order:\", best_pair, \"combined priority\", best_priority)\n",
    "print(\"Constructed boundary example: plurality chose the unavailable pair. Verification rescued it.\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "lab-03-15",
   "metadata": {},
   "source": [
    "## Measure the token and wall-time budget\n",
    "\n",
    "Measure direct generation with CUDA synchronised at both boundaries.\n",
    "Count prompt tokens for each candidate because each sample conditions on\n",
    "the prompt. Count generated tokens through the first EOS rather than\n",
    "counting padding or retokenising the decoded text. This token total is a\n",
    "compute proxy. A batched sampler can share execution work, and much of\n",
    "the total wall time can come from prefill and kernel launches.\n",
    "\n",
    "For the first and warm timing comparison we use the same work order,\n",
    "greedy policy, and maximum output. The scored development run starts\n",
    "after that profiling warm-up. Both sample selectors inherit the same\n",
    "real generation wall time. Their own selection time is measured separately."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "lab-03-16",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-11-27T06:19:52.316499Z",
     "iopub.status.busy": "2026-11-27T06:19:52.314018Z",
     "iopub.status.idle": "2026-11-27T06:21:59.911718Z",
     "shell.execute_reply": "2026-11-27T06:21:59.910749Z"
    }
   },
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/usr/local/lib/python3.13/dist-packages/huggingface_hub/utils/_auth.py:104: UserWarning: \n",
      "Error while fetching `HF_TOKEN` secret value from your vault: 'Requesting secret HF_TOKEN timed out. Secrets can only be fetched when running from the Colab UI.'.\n",
      "You are not authenticated with the Hugging Face Hub in this notebook.\n",
      "If the error persists, please let us know by opening an issue on GitHub (https://github.com/huggingface/huggingface_hub/issues/new).\n",
      "  warnings.warn(\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "Sliding Window Attention is enabled but not implemented for `sdpa`; unexpected results may be encountered.\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/usr/local/lib/python3.13/dist-packages/transformers/generation/configuration_utils.py:631: UserWarning: `do_sample` is set to `False`. However, `temperature` is set to `0.7` -- this flag is only used in sample-based generation modes. You should set `do_sample=True` or unset `temperature`.\n",
      "  warnings.warn(\n",
      "/usr/local/lib/python3.13/dist-packages/transformers/generation/configuration_utils.py:636: UserWarning: `do_sample` is set to `False`. However, `top_p` is set to `0.8` -- this flag is only used in sample-based generation modes. You should set `do_sample=True` or unset `top_p`.\n",
      "  warnings.warn(\n",
      "/usr/local/lib/python3.13/dist-packages/transformers/generation/configuration_utils.py:653: UserWarning: `do_sample` is set to `False`. However, `top_k` is set to `20` -- this flag is only used in sample-based generation modes. You should set `do_sample=True` or unset `top_k`.\n",
      "  warnings.warn(\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/usr/local/lib/python3.13/dist-packages/transformers/generation/configuration_utils.py:631: UserWarning: `do_sample` is set to `False`. However, `temperature` is set to `0.7` -- this flag is only used in sample-based generation modes. You should set `do_sample=True` or unset `temperature`.\n",
      "  warnings.warn(\n",
      "/usr/local/lib/python3.13/dist-packages/transformers/generation/configuration_utils.py:636: UserWarning: `do_sample` is set to `False`. However, `top_p` is set to `0.8` -- this flag is only used in sample-based generation modes. You should set `do_sample=True` or unset `top_p`.\n",
      "  warnings.warn(\n",
      "/usr/local/lib/python3.13/dist-packages/transformers/generation/configuration_utils.py:653: UserWarning: `do_sample` is set to `False`. However, `top_k` is set to `20` -- this flag is only used in sample-based generation modes. You should set `do_sample=True` or unset `top_k`.\n",
      "  warnings.warn(\n"
     ]
    }
   ],
   "source": [
    "generation_rows = []\n",
    "case_rows = []\n",
    "first_and_warm = []\n",
    "load_ms = None\n",
    "\n",
    "if not COURSE_SMOKE:\n",
    "    import torch\n",
    "\n",
    "    started = perf_counter()\n",
    "    tokenizer, text_model = load_text()\n",
    "    sync()\n",
    "    load_ms = (perf_counter() - started) * 1000\n",
    "\n",
    "\n",
    "def generate_pairs(order, samples):\n",
    "    sync()\n",
    "    on_cuda = text_model.device.type == \"cuda\"\n",
    "    idle_bytes = None\n",
    "    if on_cuda:\n",
    "        idle_bytes = torch.cuda.memory_allocated()\n",
    "        torch.cuda.reset_peak_memory_stats()\n",
    "\n",
    "    started = perf_counter()\n",
    "    torch.manual_seed(order[\"seed\"])\n",
    "    prompt = tokenizer.apply_chat_template(\n",
    "        [{\"role\": \"user\", \"content\": build_prompt(order)}], tokenize=False, add_generation_prompt=True,\n",
    "    )\n",
    "    encoded = tokenizer(prompt, return_tensors=\"pt\", add_special_tokens=False).to(text_model.device)\n",
    "    sampling = {\"do_sample\": False} if samples == 1 else {\n",
    "        \"do_sample\": True, \"temperature\": SAMPLING_TEMPERATURE, \"top_p\": TOP_P,\n",
    "    }\n",
    "    with torch.inference_mode():\n",
    "        output = text_model.generate(\n",
    "            **encoded, max_new_tokens=TOKEN_LIMIT, num_return_sequences=samples,\n",
    "            pad_token_id=tokenizer.pad_token_id, **sampling,\n",
    "        )\n",
    "    prompt_tokens = int(encoded.input_ids.shape[1])\n",
    "    output = output[:, prompt_tokens:].cpu().tolist()\n",
    "    end_ids = text_model.generation_config.eos_token_id\n",
    "    stops = set(end_ids if isinstance(end_ids, list) else [end_ids])\n",
    "    generated_lengths = [\n",
    "        next((index + 1 for index, token in enumerate(sequence) if token in stops), len(sequence))\n",
    "        for sequence in output\n",
    "    ]\n",
    "    raw = tokenizer.batch_decode(output, skip_special_tokens=True)\n",
    "    sync()\n",
    "    generation_ms = (perf_counter() - started) * 1000\n",
    "    peak_bytes = torch.cuda.max_memory_allocated() if on_cuda else None\n",
    "    return {\n",
    "        \"raw_candidates\": raw,\n",
    "        \"prompt_tokens_per_sample\": prompt_tokens,\n",
    "        \"sampled_output_tokens\": generated_lengths,\n",
    "        \"compute_proxy_tokens\": samples * prompt_tokens + sum(generated_lengths),\n",
    "        \"generation_wall_ms\": generation_ms,\n",
    "        \"peak_allocated_bytes\": peak_bytes,\n",
    "        \"peak_above_idle_bytes\": peak_bytes - idle_bytes if on_cuda else None,\n",
    "    }\n",
    "\n",
    "\n",
    "def record_generation(order, optimum, samples, measured):\n",
    "    raw = measured[\"raw_candidates\"]\n",
    "    assert len(raw) == samples\n",
    "    candidates = [parse_pair(answer) for answer in raw]\n",
    "    grades = [grade_pair(order, pair, optimum) for pair in candidates]\n",
    "    generation_rows.append({\n",
    "        \"case_id\": order[\"case_id\"], \"family\": order[\"family\"], \"slice\": order[\"slice\"],\n",
    "        \"samples\": samples, \"prompt\": build_prompt(order), **measured,\n",
    "        \"candidates\": [dict(pair=pair, **grade) for pair, grade in zip(candidates, grades)],\n",
    "        \"distinct_parsed_pairs\": len({pair for pair in candidates if pair}),\n",
    "        \"has_feasible\": any(row[\"feasible\"] for row in grades),\n",
    "        \"has_optimal\": any(row[\"strict_pass\"] for row in grades),\n",
    "    })\n",
    "\n",
    "    policies = (\"greedy\",) if samples == 1 else (\"plurality\", \"verified\")\n",
    "    for policy in policies:\n",
    "        started = perf_counter()\n",
    "        selected = choose_pair(order, [parse_pair(answer) for answer in raw], policy)\n",
    "        selection_ms = (perf_counter() - started) * 1000 if not COURSE_SMOKE else None\n",
    "        verdict = grade_pair(order, selected, optimum)\n",
    "        if policy == \"verified\":\n",
    "            assert verdict[\"strict_pass\"] == any(row[\"strict_pass\"] for row in grades)\n",
    "        case_rows.append({\n",
    "            \"case_id\": order[\"case_id\"], \"family\": order[\"family\"], \"slice\": order[\"slice\"],\n",
    "            \"arm\": f\"{policy}_{samples}\", \"samples\": samples, \"selected\": selected,\n",
    "            \"selected_raw_candidates\": [answer for answer, pair in zip(raw, candidates)\n",
    "                                        if pair == selected and (selected or policy != \"verified\")],\n",
    "            **verdict, \"optimal_priority\": optimum,\n",
    "            \"compute_proxy_tokens\": measured[\"compute_proxy_tokens\"], \"selection_wall_ms\": selection_ms,\n",
    "            \"comparison_wall_ms\": measured[\"generation_wall_ms\"] + selection_ms if not COURSE_SMOKE else None,\n",
    "        })\n",
    "\n",
    "\n",
    "if COURSE_SMOKE:\n",
    "    print(\"Constructed candidate lists exercise the reporting path. No model measurements are recorded.\")\n",
    "else:\n",
    "    for repeat in range(3):\n",
    "        timing = generate_pairs(work_orders[0], 1)\n",
    "        first_and_warm.append({\n",
    "            \"phase\": \"first_generation\" if repeat == 0 else \"warm_repeat\", \"repeat\": repeat,\n",
    "            \"case_id\": work_orders[0][\"case_id\"], **timing,\n",
    "        })\n",
    "\n",
    "for order in work_orders:\n",
    "    started = perf_counter()\n",
    "    optimum, reference = exact_pair(order)\n",
    "    solve_ms = (perf_counter() - started) * 1000\n",
    "    case_rows.append({\n",
    "        \"case_id\": order[\"case_id\"], \"family\": order[\"family\"], \"slice\": order[\"slice\"],\n",
    "        \"arm\": \"exact_reference\", \"samples\": 0, \"selected\": reference,\n",
    "        **grade_pair(order, reference, optimum), \"optimal_priority\": optimum,\n",
    "        \"compute_proxy_tokens\": 0, \"comparison_wall_ms\": solve_ms if not COURSE_SMOKE else None,\n",
    "    })\n",
    "\n",
    "    for samples in SAMPLE_COUNTS:\n",
    "        if COURSE_SMOKE:\n",
    "            fixture_candidates = [\"not JSON\", '[\"unknown-a\", \"unknown-b\"]', json.dumps(reference)]\n",
    "            measured = dict(raw_candidates=(fixture_candidates * samples)[:samples],\n",
    "                            prompt_tokens_per_sample=None, sampled_output_tokens=None,\n",
    "                            compute_proxy_tokens=None, generation_wall_ms=None,\n",
    "                            peak_allocated_bytes=None, peak_above_idle_bytes=None)\n",
    "        else:\n",
    "            measured = generate_pairs(order, samples)\n",
    "        record_generation(order, optimum, samples, measured)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "lab-03-17",
   "metadata": {},
   "source": [
    "## Choose a development budget\n",
    "\n",
    "Divide additional proxy tokens by additional strictly correct outcomes.\n",
    "A policy with no extra wins has no finite positive cost per added win,\n",
    "so that field stays empty. Among model arms that clear the predeclared\n",
    "quality target, propose the one with the lowest total token work.\n",
    "An exact solver remains the practical comparator for these tiny lists."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "lab-03-18",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-11-27T06:21:59.917837Z",
     "iopub.status.busy": "2026-11-27T06:21:59.917101Z",
     "iopub.status.idle": "2026-11-27T06:22:00.647577Z",
     "shell.execute_reply": "2026-11-27T06:22:00.645676Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Development evidence: {\"mode\": \"development_model_comparison\", \"split\": \"dev\", \"model_load_ms\": 20373.123109000004, \"lab_elapsed_ms\": 127820.13778699997, \"workload\": {\"cases\": 24, \"families\": 12, \"slices\": [\"manual\", \"numeric\", \"multi_source\", \"ambiguity\", \"boundary\", \"follow_up\"], \"sample_counts\": [1, 2, 4], \"max_new_tokens\": 32, \"temperature\": 0.65, \"top_p\": 0.9, \"bootstrap_draws\": 1500, \"model\": \"Qwen/Qwen2.5-1.5B-Instruct\", \"model_revision\": \"989aa7980e4cf806f80c7fef2b1adb7bc71aa306\", \"development_split\": {\"sha256\": \"51dbc208b6b20a620237dd76ce0a2db4f10aa75f4f8fc404121e301b8d79a0cf\", \"n\": 120, \"families\": 12}}, \"model_quality_target\": 0.9, \"budget_candidate\": null, \"scorecard\": [{\"arm\": \"exact_reference\", \"cases\": 24, \"correct\": 24, \"strict_pass_rate\": 1.0, \"outcomes\": {\"optimal\": 24}, \"total_compute_proxy_tokens\": 0, \"mean_compute_proxy_tokens\": 0.0, \"median_wall_ms\": 0.03904999999804204, \"gained_vs_greedy\": 24, \"lost_vs_greedy\": 0, \"extra_tokens_vs_greedy\": null, \"tokens_per_added_win_vs_greedy\": null}, {\"arm\": \"greedy_1\", \"cases\": 24, \"correct\": 0, \"strict_pass_rate\": 0.0, \"outcomes\": {\"no_pair\": 24}, \"total_compute_proxy_tokens\": 4288, \"mean_compute_proxy_tokens\": 178.66666666666666, \"median_wall_ms\": 1194.2058264999673, \"gained_vs_greedy\": 0, \"lost_vs_greedy\": 0, \"extra_tokens_vs_greedy\": 0, \"tokens_per_added_win_vs_greedy\": null}, {\"arm\": \"plurality_2\", \"cases\": 24, \"correct\": 0, \"strict_pass_rate\": 0.0, \"outcomes\": {\"no_pair\": 24}, \"total_compute_proxy_tokens\": 8576, \"mean_compute_proxy_tokens\": 357.3333333333333, \"median_wall_ms\": 1259.2928944999926, \"gained_vs_greedy\": 0, \"lost_vs_greedy\": 0, \"extra_tokens_vs_greedy\": 4288, \"tokens_per_added_win_vs_greedy\": null}, {\"arm\": \"verified_2\", \"cases\": 24, \"correct\": 0, \"strict_pass_rate\": 0.0, \"outcomes\": {\"no_pair\": 24}, \"total_compute_proxy_tokens\": 8576, \"mean_compute_proxy_tokens\": 357.3333333333333, \"median_wall_ms\": 1259.271726999998, \"gained_vs_greedy\": 0, \"lost_vs_greedy\": 0, \"extra_tokens_vs_greedy\": 4288, \"tokens_per_added_win_vs_greedy\": null}, {\"arm\": \"plurality_4\", \"cases\": 24, \"correct\": 0, \"strict_pass_rate\": 0.0, \"outcomes\": {\"no_pair\": 24}, \"total_compute_proxy_tokens\": 17152, \"mean_compute_proxy_tokens\": 714.6666666666666, \"median_wall_ms\": 1369.3873925000162, \"gained_vs_greedy\": 0, \"lost_vs_greedy\": 0, \"extra_tokens_vs_greedy\": 12864, \"tokens_per_added_win_vs_greedy\": null}, {\"arm\": \"verified_4\", \"cases\": 24, \"correct\": 0, \"strict_pass_rate\": 0.0, \"outcomes\": {\"no_pair\": 24}, \"total_compute_proxy_tokens\": 17152, \"mean_compute_proxy_tokens\": 714.6666666666666, \"median_wall_ms\": 1369.3664634999436, \"gained_vs_greedy\": 0, \"lost_vs_greedy\": 0, \"extra_tokens_vs_greedy\": 12864, \"tokens_per_added_win_vs_greedy\": null}], \"by_slice\": [{\"slice\": \"manual\", \"arm\": \"exact_reference\", \"n\": 4, \"correct\": 4}, {\"slice\": \"manual\", \"arm\": \"greedy_1\", \"n\": 4, \"correct\": 0}, {\"slice\": \"manual\", \"arm\": \"plurality_2\", \"n\": 4, \"correct\": 0}, {\"slice\": \"manual\", \"arm\": \"verified_2\", \"n\": 4, \"correct\": 0}, {\"slice\": \"manual\", \"arm\": \"plurality_4\", \"n\": 4, \"correct\": 0}, {\"slice\": \"manual\", \"arm\": \"verified_4\", \"n\": 4, \"correct\": 0}, {\"slice\": \"numeric\", \"arm\": \"exact_reference\", \"n\": 4, \"correct\": 4}, {\"slice\": \"numeric\", \"arm\": \"greedy_1\", \"n\": 4, \"correct\": 0}, {\"slice\": \"numeric\", \"arm\": \"plurality_2\", \"n\": 4, \"correct\": 0}, {\"slice\": \"numeric\", \"arm\": \"verified_2\", \"n\": 4, \"correct\": 0}, {\"slice\": \"numeric\", \"arm\": \"plurality_4\", \"n\": 4, \"correct\": 0}, {\"slice\": \"numeric\", \"arm\": \"verified_4\", \"n\": 4, \"correct\": 0}, {\"slice\": \"multi_source\", \"arm\": \"exact_reference\", \"n\": 4, \"correct\": 4}, {\"slice\": \"multi_source\", \"arm\": \"greedy_1\", \"n\": 4, \"correct\": 0}, {\"slice\": \"multi_source\", \"arm\": \"plurality_2\", \"n\": 4, \"correct\": 0}, {\"slice\": \"multi_source\", \"arm\": \"verified_2\", \"n\": 4, \"correct\": 0}, {\"slice\": \"multi_source\", \"arm\": \"plurality_4\", \"n\": 4, \"correct\": 0}, {\"slice\": \"multi_source\", \"arm\": \"verified_4\", \"n\": 4, \"correct\": 0}, {\"slice\": \"ambiguity\", \"arm\": \"exact_reference\", \"n\": 4, \"correct\": 4}, {\"slice\": \"ambiguity\", \"arm\": \"greedy_1\", \"n\": 4, \"correct\": 0}, {\"slice\": \"ambiguity\", \"arm\": \"plurality_2\", \"n\": 4, \"correct\": 0}, {\"slice\": \"ambiguity\", \"arm\": \"verified_2\", \"n\": 4, \"correct\": 0}, {\"slice\": \"ambiguity\", \"arm\": \"plurality_4\", \"n\": 4, \"correct\": 0}, {\"slice\": \"ambiguity\", \"arm\": \"verified_4\", \"n\": 4, \"correct\": 0}, {\"slice\": \"boundary\", \"arm\": \"exact_reference\", \"n\": 4, \"correct\": 4}, {\"slice\": \"boundary\", \"arm\": \"greedy_1\", \"n\": 4, \"correct\": 0}, {\"slice\": \"boundary\", \"arm\": \"plurality_2\", \"n\": 4, \"correct\": 0}, {\"slice\": \"boundary\", \"arm\": \"verified_2\", \"n\": 4, \"correct\": 0}, {\"slice\": \"boundary\", \"arm\": \"plurality_4\", \"n\": 4, \"correct\": 0}, {\"slice\": \"boundary\", \"arm\": \"verified_4\", \"n\": 4, \"correct\": 0}, {\"slice\": \"follow_up\", \"arm\": \"exact_reference\", \"n\": 4, \"correct\": 4}, {\"slice\": \"follow_up\", \"arm\": \"greedy_1\", \"n\": 4, \"correct\": 0}, {\"slice\": \"follow_up\", \"arm\": \"plurality_2\", \"n\": 4, \"correct\": 0}, {\"slice\": \"follow_up\", \"arm\": \"verified_2\", \"n\": 4, \"correct\": 0}, {\"slice\": \"follow_up\", \"arm\": \"plurality_4\", \"n\": 4, \"correct\": 0}, {\"slice\": \"follow_up\", \"arm\": \"verified_4\", \"n\": 4, \"correct\": 0}], \"candidate_batches\": [{\"samples\": 1, \"cases\": 24, \"with_feasible\": 0, \"with_optimal\": 0, \"median_distinct_parsed_pairs\": 0.0, \"median_generation_ms\": 1194.1893129999812, \"peak_allocated_bytes\": [3111100928, 3111195648.0, 3111195648], \"peak_above_idle_bytes\": [15152128, 15246848.0, 15246848]}, {\"samples\": 2, \"cases\": 24, \"with_feasible\": 0, \"with_optimal\": 0, \"median_distinct_parsed_pairs\": 0.0, \"median_generation_ms\": 1259.2431780000197, \"peak_allocated_bytes\": [3126249472, 3126439936.0, 3126439936], \"peak_above_idle_bytes\": [30300672, 30491136.0, 30491136]}, {\"samples\": 4, \"cases\": 24, \"with_feasible\": 0, \"with_optimal\": 0, \"median_distinct_parsed_pairs\": 0.0, \"median_generation_ms\": 1369.3302914999776, \"peak_allocated_bytes\": [3157391360, 3157710848.0, 3157710848], \"peak_above_idle_bytes\": [61442560, 61762048.0, 61762048]}], \"paired_intervals\": [{\"candidate\": \"exact_reference\", \"incumbent\": \"greedy_1\", \"delta\": 1.0, \"low\": 1.0, \"high\": 1.0, \"n\": 24, \"families\": 12, \"gained\": 24, \"lost\": 0}, {\"candidate\": \"plurality_2\", \"incumbent\": \"greedy_1\", \"delta\": 0.0, \"low\": 0.0, \"high\": 0.0, \"n\": 24, \"families\": 12, \"gained\": 0, \"lost\": 0}, {\"candidate\": \"verified_2\", \"incumbent\": \"greedy_1\", \"delta\": 0.0, \"low\": 0.0, \"high\": 0.0, \"n\": 24, \"families\": 12, \"gained\": 0, \"lost\": 0}, {\"candidate\": \"plurality_4\", \"incumbent\": \"greedy_1\", \"delta\": 0.0, \"low\": 0.0, \"high\": 0.0, \"n\": 24, \"families\": 12, \"gained\": 0, \"lost\": 0}, {\"candidate\": \"verified_4\", \"incumbent\": \"greedy_1\", \"delta\": 0.0, \"low\": 0.0, \"high\": 0.0, \"n\": 24, \"families\": 12, \"gained\": 0, \"lost\": 0}, {\"candidate\": \"verified_2\", \"incumbent\": \"plurality_2\", \"delta\": 0.0, \"low\": 0.0, \"high\": 0.0, \"n\": 24, \"families\": 12, \"gained\": 0, \"lost\": 0}, {\"candidate\": \"verified_4\", \"incumbent\": \"plurality_4\", \"delta\": 0.0, \"low\": 0.0, \"high\": 0.0, \"n\": 24, \"families\": 12, \"gained\": 0, \"lost\": 0}]}\n",
      "First and warm generation receipt: [{'phase': 'first_generation', 'repeat': 0, 'case_id': 'F250-tight', 'raw_candidates': ['```json\\n[\"F-250\", \"V-230\"]\\n```'], 'prompt_tokens_per_sample': 160, 'sampled_output_tokens': [19], 'compute_proxy_tokens': 179, 'generation_wall_ms': 4403.148666999982, 'peak_allocated_bytes': 3111195648, 'peak_above_idle_bytes': 23766528}, {'phase': 'warm_repeat', 'repeat': 1, 'case_id': 'F250-tight', 'raw_candidates': ['```json\\n[\"F-250\", \"V-230\"]\\n```'], 'prompt_tokens_per_sample': 160, 'sampled_output_tokens': [19], 'compute_proxy_tokens': 179, 'generation_wall_ms': 1180.8639289999974, 'peak_allocated_bytes': 3111195648, 'peak_above_idle_bytes': 15246848}, {'phase': 'warm_repeat', 'repeat': 2, 'case_id': 'F250-tight', 'raw_candidates': ['```json\\n[\"F-250\", \"V-230\"]\\n```'], 'prompt_tokens_per_sample': 160, 'sampled_output_tokens': [19], 'compute_proxy_tokens': 179, 'generation_wall_ms': 1668.749101000003, 'peak_allocated_bytes': 3111195648, 'peak_above_idle_bytes': 15246848}]\n",
      "Opening decisions: [{'case_id': 'F250-tight', 'family': 'F250', 'slice': 'follow_up', 'arm': 'exact_reference', 'samples': 0, 'selected': ('F-250', 'P-210'), 'feasible': True, 'priority': 20, 'minutes': 26, 'check': 'feasible', 'outcome': 'optimal', 'strict_pass': True, 'optimal_priority': 20, 'compute_proxy_tokens': 0, 'comparison_wall_ms': 0.04579599999487982}, {'case_id': 'F250-tight', 'family': 'F250', 'slice': 'follow_up', 'arm': 'greedy_1', 'samples': 1, 'selected': (), 'selected_raw_candidates': ['```json\\n[\"F-250\", \"V-230\"]\\n```'], 'feasible': False, 'priority': None, 'minutes': None, 'check': 'no_pair', 'outcome': 'no_pair', 'strict_pass': False, 'optimal_priority': 20, 'compute_proxy_tokens': 179, 'selection_wall_ms': 0.017077000052267977, 'comparison_wall_ms': 1544.990017000032}, {'case_id': 'F250-tight', 'family': 'F250', 'slice': 'follow_up', 'arm': 'plurality_2', 'samples': 2, 'selected': (), 'selected_raw_candidates': ['```json\\n[\"F-250\", \"P-210\"]\\n```', '```json\\n[\"F-250\", \"P-210\"]\\n```'], 'feasible': False, 'priority': None, 'minutes': None, 'check': 'no_pair', 'outcome': 'no_pair', 'strict_pass': False, 'optimal_priority': 20, 'compute_proxy_tokens': 358, 'selection_wall_ms': 0.4110329999775786, 'comparison_wall_ms': 1945.2458409999736}, {'case_id': 'F250-tight', 'family': 'F250', 'slice': 'follow_up', 'arm': 'verified_2', 'samples': 2, 'selected': (), 'selected_raw_candidates': [], 'feasible': False, 'priority': None, 'minutes': None, 'check': 'no_pair', 'outcome': 'no_pair', 'strict_pass': False, 'optimal_priority': 20, 'compute_proxy_tokens': 358, 'selection_wall_ms': 0.05064200001925201, 'comparison_wall_ms': 1944.8854500000152}, {'case_id': 'F250-tight', 'family': 'F250', 'slice': 'follow_up', 'arm': 'plurality_4', 'samples': 4, 'selected': (), 'selected_raw_candidates': ['```json\\n[\"F-250\", \"V-230\"]\\n```', '```json\\n[\"F-250\", \"V-200\"]\\n```', '```json\\n[\"F-250\", \"V-200\"]\\n```', '```json\\n[\"F-250\", \"V-230\"]\\n```'], 'feasible': False, 'priority': None, 'minutes': None, 'check': 'no_pair', 'outcome': 'no_pair', 'strict_pass': False, 'optimal_priority': 20, 'compute_proxy_tokens': 716, 'selection_wall_ms': 0.059286999999130785, 'comparison_wall_ms': 1577.2509690000334}, {'case_id': 'F250-tight', 'family': 'F250', 'slice': 'follow_up', 'arm': 'verified_4', 'samples': 4, 'selected': (), 'selected_raw_candidates': [], 'feasible': False, 'priority': None, 'minutes': None, 'check': 'no_pair', 'outcome': 'no_pair', 'strict_pass': False, 'optimal_priority': 20, 'compute_proxy_tokens': 716, 'selection_wall_ms': 0.04271199998129305, 'comparison_wall_ms': 1577.2343940000155}, {'case_id': 'F250-loose', 'family': 'F250', 'slice': 'follow_up', 'arm': 'exact_reference', 'samples': 0, 'selected': ('F-250', 'V-200'), 'feasible': True, 'priority': 24, 'minutes': 29, 'check': 'feasible', 'outcome': 'optimal', 'strict_pass': True, 'optimal_priority': 24, 'compute_proxy_tokens': 0, 'comparison_wall_ms': 0.06680700005290419}, {'case_id': 'F250-loose', 'family': 'F250', 'slice': 'follow_up', 'arm': 'greedy_1', 'samples': 1, 'selected': (), 'selected_raw_candidates': ['```json\\n[\"F-250\", \"V-230\"]\\n```'], 'feasible': False, 'priority': None, 'minutes': None, 'check': 'no_pair', 'outcome': 'no_pair', 'strict_pass': False, 'optimal_priority': 24, 'compute_proxy_tokens': 179, 'selection_wall_ms': 0.01796100002593448, 'comparison_wall_ms': 1229.555448000042}, {'case_id': 'F250-loose', 'family': 'F250', 'slice': 'follow_up', 'arm': 'plurality_2', 'samples': 2, 'selected': (), 'selected_raw_candidates': ['```json\\n[\"F-250\", \"P-210\"]\\n```', '```json\\n[\"F-250\", \"P-210\"]\\n```'], 'feasible': False, 'priority': None, 'minutes': None, 'check': 'no_pair', 'outcome': 'no_pair', 'strict_pass': False, 'optimal_priority': 24, 'compute_proxy_tokens': 358, 'selection_wall_ms': 0.07454599995071476, 'comparison_wall_ms': 1277.6264999999967}, {'case_id': 'F250-loose', 'family': 'F250', 'slice': 'follow_up', 'arm': 'verified_2', 'samples': 2, 'selected': (), 'selected_raw_candidates': [], 'feasible': False, 'priority': None, 'minutes': None, 'check': 'no_pair', 'outcome': 'no_pair', 'strict_pass': False, 'optimal_priority': 24, 'compute_proxy_tokens': 358, 'selection_wall_ms': 0.04322400002365612, 'comparison_wall_ms': 1277.5951780000696}, {'case_id': 'F250-loose', 'family': 'F250', 'slice': 'follow_up', 'arm': 'plurality_4', 'samples': 4, 'selected': (), 'selected_raw_candidates': ['```json\\n[\"F-250\", \"V-230\"]\\n```', '```json\\n[\"F-250\", \"V-200\"]\\n```', '```json\\n[\"F-250\", \"V-200\"]\\n```', '```json\\n[\"F-250\", \"V-230\"]\\n```'], 'feasible': False, 'priority': None, 'minutes': None, 'check': 'no_pair', 'outcome': 'no_pair', 'strict_pass': False, 'optimal_priority': 24, 'compute_proxy_tokens': 716, 'selection_wall_ms': 0.05021700008001062, 'comparison_wall_ms': 1321.4329500000304}, {'case_id': 'F250-loose', 'family': 'F250', 'slice': 'follow_up', 'arm': 'verified_4', 'samples': 4, 'selected': (), 'selected_raw_candidates': [], 'feasible': False, 'priority': None, 'minutes': None, 'check': 'no_pair', 'outcome': 'no_pair', 'strict_pass': False, 'optimal_priority': 24, 'compute_proxy_tokens': 716, 'selection_wall_ms': 0.05320800005392812, 'comparison_wall_ms': 1321.4359410000043}]\n",
      "Opening proposals: [{'case_id': 'F250-tight', 'family': 'F250', 'slice': 'follow_up', 'samples': 1, 'prompt': 'Choose exactly two different assets to inspect. Their total duration must be at or below the available minutes. Maximise the sum of their priorities. Reply only with a JSON array of two asset identifier strings, for example [\"A-1\",\"B-2\"].\\nAvailable minutes: 28\\nAsset | Duration in minutes | Priority\\nF-250 | 15 | 14\\nV-200 | 14 | 10\\nP-210 | 11 | 6\\nF-220 | 7 | 4\\nV-230 | 7 | 2', 'raw_candidates': ['```json\\n[\"F-250\", \"V-230\"]\\n```'], 'prompt_tokens_per_sample': 160, 'sampled_output_tokens': [19], 'compute_proxy_tokens': 179, 'generation_wall_ms': 1544.9729399999796, 'peak_allocated_bytes': 3111195648, 'peak_above_idle_bytes': 15246848, 'candidates': [{'pair': (), 'feasible': False, 'priority': None, 'minutes': None, 'check': 'no_pair', 'outcome': 'no_pair', 'strict_pass': False}], 'distinct_parsed_pairs': 0, 'has_feasible': False, 'has_optimal': False}, {'case_id': 'F250-tight', 'family': 'F250', 'slice': 'follow_up', 'samples': 2, 'prompt': 'Choose exactly two different assets to inspect. Their total duration must be at or below the available minutes. Maximise the sum of their priorities. Reply only with a JSON array of two asset identifier strings, for example [\"A-1\",\"B-2\"].\\nAvailable minutes: 28\\nAsset | Duration in minutes | Priority\\nF-250 | 15 | 14\\nV-200 | 14 | 10\\nP-210 | 11 | 6\\nF-220 | 7 | 4\\nV-230 | 7 | 2', 'raw_candidates': ['```json\\n[\"F-250\", \"P-210\"]\\n```', '```json\\n[\"F-250\", \"P-210\"]\\n```'], 'prompt_tokens_per_sample': 160, 'sampled_output_tokens': [19, 19], 'compute_proxy_tokens': 358, 'generation_wall_ms': 1944.834807999996, 'peak_allocated_bytes': 3126439936, 'peak_above_idle_bytes': 30491136, 'candidates': [{'pair': (), 'feasible': False, 'priority': None, 'minutes': None, 'check': 'no_pair', 'outcome': 'no_pair', 'strict_pass': False}, {'pair': (), 'feasible': False, 'priority': None, 'minutes': None, 'check': 'no_pair', 'outcome': 'no_pair', 'strict_pass': False}], 'distinct_parsed_pairs': 0, 'has_feasible': False, 'has_optimal': False}, {'case_id': 'F250-tight', 'family': 'F250', 'slice': 'follow_up', 'samples': 4, 'prompt': 'Choose exactly two different assets to inspect. Their total duration must be at or below the available minutes. Maximise the sum of their priorities. Reply only with a JSON array of two asset identifier strings, for example [\"A-1\",\"B-2\"].\\nAvailable minutes: 28\\nAsset | Duration in minutes | Priority\\nF-250 | 15 | 14\\nV-200 | 14 | 10\\nP-210 | 11 | 6\\nF-220 | 7 | 4\\nV-230 | 7 | 2', 'raw_candidates': ['```json\\n[\"F-250\", \"V-230\"]\\n```', '```json\\n[\"F-250\", \"V-200\"]\\n```', '```json\\n[\"F-250\", \"V-200\"]\\n```', '```json\\n[\"F-250\", \"V-230\"]\\n```'], 'prompt_tokens_per_sample': 160, 'sampled_output_tokens': [19, 19, 19, 19], 'compute_proxy_tokens': 716, 'generation_wall_ms': 1577.1916820000342, 'peak_allocated_bytes': 3157710848, 'peak_above_idle_bytes': 61762048, 'candidates': [{'pair': (), 'feasible': False, 'priority': None, 'minutes': None, 'check': 'no_pair', 'outcome': 'no_pair', 'strict_pass': False}, {'pair': (), 'feasible': False, 'priority': None, 'minutes': None, 'check': 'no_pair', 'outcome': 'no_pair', 'strict_pass': False}, {'pair': (), 'feasible': False, 'priority': None, 'minutes': None, 'check': 'no_pair', 'outcome': 'no_pair', 'strict_pass': False}, {'pair': (), 'feasible': False, 'priority': None, 'minutes': None, 'check': 'no_pair', 'outcome': 'no_pair', 'strict_pass': False}], 'distinct_parsed_pairs': 0, 'has_feasible': False, 'has_optimal': False}, {'case_id': 'F250-loose', 'family': 'F250', 'slice': 'follow_up', 'samples': 1, 'prompt': 'Choose exactly two different assets to inspect. Their total duration must be at or below the available minutes. Maximise the sum of their priorities. Reply only with a JSON array of two asset identifier strings, for example [\"A-1\",\"B-2\"].\\nAvailable minutes: 29\\nAsset | Duration in minutes | Priority\\nF-250 | 15 | 14\\nV-200 | 14 | 10\\nP-210 | 11 | 6\\nF-220 | 7 | 4\\nV-230 | 7 | 2', 'raw_candidates': ['```json\\n[\"F-250\", \"V-230\"]\\n```'], 'prompt_tokens_per_sample': 160, 'sampled_output_tokens': [19], 'compute_proxy_tokens': 179, 'generation_wall_ms': 1229.537487000016, 'peak_allocated_bytes': 3111195648, 'peak_above_idle_bytes': 15246848, 'candidates': [{'pair': (), 'feasible': False, 'priority': None, 'minutes': None, 'check': 'no_pair', 'outcome': 'no_pair', 'strict_pass': False}], 'distinct_parsed_pairs': 0, 'has_feasible': False, 'has_optimal': False}, {'case_id': 'F250-loose', 'family': 'F250', 'slice': 'follow_up', 'samples': 2, 'prompt': 'Choose exactly two different assets to inspect. Their total duration must be at or below the available minutes. Maximise the sum of their priorities. Reply only with a JSON array of two asset identifier strings, for example [\"A-1\",\"B-2\"].\\nAvailable minutes: 29\\nAsset | Duration in minutes | Priority\\nF-250 | 15 | 14\\nV-200 | 14 | 10\\nP-210 | 11 | 6\\nF-220 | 7 | 4\\nV-230 | 7 | 2', 'raw_candidates': ['```json\\n[\"F-250\", \"P-210\"]\\n```', '```json\\n[\"F-250\", \"P-210\"]\\n```'], 'prompt_tokens_per_sample': 160, 'sampled_output_tokens': [19, 19], 'compute_proxy_tokens': 358, 'generation_wall_ms': 1277.551954000046, 'peak_allocated_bytes': 3126439936, 'peak_above_idle_bytes': 30491136, 'candidates': [{'pair': (), 'feasible': False, 'priority': None, 'minutes': None, 'check': 'no_pair', 'outcome': 'no_pair', 'strict_pass': False}, {'pair': (), 'feasible': False, 'priority': None, 'minutes': None, 'check': 'no_pair', 'outcome': 'no_pair', 'strict_pass': False}], 'distinct_parsed_pairs': 0, 'has_feasible': False, 'has_optimal': False}, {'case_id': 'F250-loose', 'family': 'F250', 'slice': 'follow_up', 'samples': 4, 'prompt': 'Choose exactly two different assets to inspect. Their total duration must be at or below the available minutes. Maximise the sum of their priorities. Reply only with a JSON array of two asset identifier strings, for example [\"A-1\",\"B-2\"].\\nAvailable minutes: 29\\nAsset | Duration in minutes | Priority\\nF-250 | 15 | 14\\nV-200 | 14 | 10\\nP-210 | 11 | 6\\nF-220 | 7 | 4\\nV-230 | 7 | 2', 'raw_candidates': ['```json\\n[\"F-250\", \"V-230\"]\\n```', '```json\\n[\"F-250\", \"V-200\"]\\n```', '```json\\n[\"F-250\", \"V-200\"]\\n```', '```json\\n[\"F-250\", \"V-230\"]\\n```'], 'prompt_tokens_per_sample': 160, 'sampled_output_tokens': [19, 19, 19, 19], 'compute_proxy_tokens': 716, 'generation_wall_ms': 1321.3827329999503, 'peak_allocated_bytes': 3157710848, 'peak_above_idle_bytes': 61762048, 'candidates': [{'pair': (), 'feasible': False, 'priority': None, 'minutes': None, 'check': 'no_pair', 'outcome': 'no_pair', 'strict_pass': False}, {'pair': (), 'feasible': False, 'priority': None, 'minutes': None, 'check': 'no_pair', 'outcome': 'no_pair', 'strict_pass': False}, {'pair': (), 'feasible': False, 'priority': None, 'minutes': None, 'check': 'no_pair', 'outcome': 'no_pair', 'strict_pass': False}, {'pair': (), 'feasible': False, 'priority': None, 'minutes': None, 'check': 'no_pair', 'outcome': 'no_pair', 'strict_pass': False}], 'distinct_parsed_pairs': 0, 'has_feasible': False, 'has_optimal': False}]\n",
      "Evidence saved to evidence/summary.json\n",
      "Evidence saved to evidence/records.json\n"
     ]
    },
    {
     "data": {
      "image/svg+xml": [
       "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"no\"?>\n",
       "<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\"\n",
       "  \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n",
       "<svg xmlns:xlink=\"http://www.w3.org/1999/xlink\" width=\"548.39952pt\" height=\"325.19952pt\" viewBox=\"0 0 548.39952 325.19952\" xmlns=\"http://www.w3.org/2000/svg\" version=\"1.1\">\n",
       " <metadata>\n",
       "  <rdf:RDF xmlns:dc=\"http://purl.org/dc/elements/1.1/\" xmlns:cc=\"http://creativecommons.org/ns#\" xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\">\n",
       "   <cc:Work>\n",
       "    <dc:type rdf:resource=\"http://purl.org/dc/dcmitype/StillImage\"/>\n",
       "    <dc:date>2026-11-27T06:22:00.537133</dc:date>\n",
       "    <dc:format>image/svg+xml</dc:format>\n",
       "    <dc:creator>\n",
       "     <cc:Agent>\n",
       "      <dc:title>Matplotlib v3.10.0, https://matplotlib.org/</dc:title>\n",
       "     </cc:Agent>\n",
       "    </dc:creator>\n",
       "   </cc:Work>\n",
       "  </rdf:RDF>\n",
       " </metadata>\n",
       " <defs>\n",
       "  <style type=\"text/css\">*{stroke-linejoin: round; stroke-linecap: butt}</style>\n",
       " </defs>\n",
       " <g id=\"figure_1\">\n",
       "  <g id=\"patch_1\">\n",
       "   <path d=\"M 0 325.19952 \n",
       "L 548.39952 325.19952 \n",
       "L 548.39952 0 \n",
       "L 0 0 \n",
       "z\n",
       "\" style=\"fill: #ffffff\"/>\n",
       "  </g>\n",
       "  <g id=\"axes_1\">\n",
       "   <g id=\"patch_2\">\n",
       "    <path d=\"M 46.965625 287.64327 \n",
       "L 541.19952 287.64327 \n",
       "L 541.19952 22.318125 \n",
       "L 46.965625 22.318125 \n",
       "z\n",
       "\" style=\"fill: #ffffff\"/>\n",
       "   </g>\n",
       "   <g id=\"PathCollection_1\">\n",
       "    <defs>\n",
       "     <path id=\"mbb570b4417\" d=\"M -3 3 \n",
       "L 3 3 \n",
       "L 3 -3 \n",
       "L -3 -3 \n",
       "z\n",
       "\" style=\"stroke: #334d68\"/>\n",
       "    </defs>\n",
       "    <g clip-path=\"url(#p307071d5be)\">\n",
       "     <use xlink:href=\"#mbb570b4417\" x=\"69.430802\" y=\"32.144982\" style=\"fill: #334d68; stroke: #334d68\"/>\n",
       "    </g>\n",
       "   </g>\n",
       "   <g id=\"matplotlib.axis_1\">\n",
       "    <g id=\"xtick_1\">\n",
       "     <g id=\"line2d_1\">\n",
       "      <path d=\"M 69.430802 287.64327 \n",
       "L 69.430802 22.318125 \n",
       "\" clip-path=\"url(#p307071d5be)\" style=\"fill: none; stroke: #b0b0b0; stroke-opacity: 0.22; stroke-width: 0.8; stroke-linecap: square\"/>\n",
       "     </g>\n",
       "     <g id=\"line2d_2\">\n",
       "      <defs>\n",
       "       <path id=\"mc6f5a670d4\" d=\"M 0 0 \n",
       "L 0 3.5 \n",
       "\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n",
       "      </defs>\n",
       "      <g>\n",
       "       <use xlink:href=\"#mc6f5a670d4\" x=\"69.430802\" y=\"287.64327\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_1\">\n",
       "      <!-- 0 -->\n",
       "      <g transform=\"translate(66.249552 302.241707) scale(0.1 -0.1)\">\n",
       "       <defs>\n",
       "        <path id=\"DejaVuSans-30\" d=\"M 2034 4250 \n",
       "Q 1547 4250 1301 3770 \n",
       "Q 1056 3291 1056 2328 \n",
       "Q 1056 1369 1301 889 \n",
       "Q 1547 409 2034 409 \n",
       "Q 2525 409 2770 889 \n",
       "Q 3016 1369 3016 2328 \n",
       "Q 3016 3291 2770 3770 \n",
       "Q 2525 4250 2034 4250 \n",
       "z\n",
       "M 2034 4750 \n",
       "Q 2819 4750 3233 4129 \n",
       "Q 3647 3509 3647 2328 \n",
       "Q 3647 1150 3233 529 \n",
       "Q 2819 -91 2034 -91 \n",
       "Q 1250 -91 836 529 \n",
       "Q 422 1150 422 2328 \n",
       "Q 422 3509 836 4129 \n",
       "Q 1250 4750 2034 4750 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "       </defs>\n",
       "       <use xlink:href=\"#DejaVuSans-30\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"xtick_2\">\n",
       "     <g id=\"line2d_3\">\n",
       "      <path d=\"M 132.299768 287.64327 \n",
       "L 132.299768 22.318125 \n",
       "\" clip-path=\"url(#p307071d5be)\" style=\"fill: none; stroke: #b0b0b0; stroke-opacity: 0.22; stroke-width: 0.8; stroke-linecap: square\"/>\n",
       "     </g>\n",
       "     <g id=\"line2d_4\">\n",
       "      <g>\n",
       "       <use xlink:href=\"#mc6f5a670d4\" x=\"132.299768\" y=\"287.64327\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_2\">\n",
       "      <!-- 100 -->\n",
       "      <g transform=\"translate(122.756018 302.241707) scale(0.1 -0.1)\">\n",
       "       <defs>\n",
       "        <path id=\"DejaVuSans-31\" d=\"M 794 531 \n",
       "L 1825 531 \n",
       "L 1825 4091 \n",
       "L 703 3866 \n",
       "L 703 4441 \n",
       "L 1819 4666 \n",
       "L 2450 4666 \n",
       "L 2450 531 \n",
       "L 3481 531 \n",
       "L 3481 0 \n",
       "L 794 0 \n",
       "L 794 531 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "       </defs>\n",
       "       <use xlink:href=\"#DejaVuSans-31\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-30\" transform=\"translate(63.623047 0)\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-30\" transform=\"translate(127.246094 0)\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"xtick_3\">\n",
       "     <g id=\"line2d_5\">\n",
       "      <path d=\"M 195.168733 287.64327 \n",
       "L 195.168733 22.318125 \n",
       "\" clip-path=\"url(#p307071d5be)\" style=\"fill: none; stroke: #b0b0b0; stroke-opacity: 0.22; stroke-width: 0.8; stroke-linecap: square\"/>\n",
       "     </g>\n",
       "     <g id=\"line2d_6\">\n",
       "      <g>\n",
       "       <use xlink:href=\"#mc6f5a670d4\" x=\"195.168733\" y=\"287.64327\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_3\">\n",
       "      <!-- 200 -->\n",
       "      <g transform=\"translate(185.624983 302.241707) scale(0.1 -0.1)\">\n",
       "       <defs>\n",
       "        <path id=\"DejaVuSans-32\" d=\"M 1228 531 \n",
       "L 3431 531 \n",
       "L 3431 0 \n",
       "L 469 0 \n",
       "L 469 531 \n",
       "Q 828 903 1448 1529 \n",
       "Q 2069 2156 2228 2338 \n",
       "Q 2531 2678 2651 2914 \n",
       "Q 2772 3150 2772 3378 \n",
       "Q 2772 3750 2511 3984 \n",
       "Q 2250 4219 1831 4219 \n",
       "Q 1534 4219 1204 4116 \n",
       "Q 875 4013 500 3803 \n",
       "L 500 4441 \n",
       "Q 881 4594 1212 4672 \n",
       "Q 1544 4750 1819 4750 \n",
       "Q 2544 4750 2975 4387 \n",
       "Q 3406 4025 3406 3419 \n",
       "Q 3406 3131 3298 2873 \n",
       "Q 3191 2616 2906 2266 \n",
       "Q 2828 2175 2409 1742 \n",
       "Q 1991 1309 1228 531 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "       </defs>\n",
       "       <use xlink:href=\"#DejaVuSans-32\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-30\" transform=\"translate(63.623047 0)\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-30\" transform=\"translate(127.246094 0)\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"xtick_4\">\n",
       "     <g id=\"line2d_7\">\n",
       "      <path d=\"M 258.037699 287.64327 \n",
       "L 258.037699 22.318125 \n",
       "\" clip-path=\"url(#p307071d5be)\" style=\"fill: none; stroke: #b0b0b0; stroke-opacity: 0.22; stroke-width: 0.8; stroke-linecap: square\"/>\n",
       "     </g>\n",
       "     <g id=\"line2d_8\">\n",
       "      <g>\n",
       "       <use xlink:href=\"#mc6f5a670d4\" x=\"258.037699\" y=\"287.64327\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_4\">\n",
       "      <!-- 300 -->\n",
       "      <g transform=\"translate(248.493949 302.241707) scale(0.1 -0.1)\">\n",
       "       <defs>\n",
       "        <path id=\"DejaVuSans-33\" d=\"M 2597 2516 \n",
       "Q 3050 2419 3304 2112 \n",
       "Q 3559 1806 3559 1356 \n",
       "Q 3559 666 3084 287 \n",
       "Q 2609 -91 1734 -91 \n",
       "Q 1441 -91 1130 -33 \n",
       "Q 819 25 488 141 \n",
       "L 488 750 \n",
       "Q 750 597 1062 519 \n",
       "Q 1375 441 1716 441 \n",
       "Q 2309 441 2620 675 \n",
       "Q 2931 909 2931 1356 \n",
       "Q 2931 1769 2642 2001 \n",
       "Q 2353 2234 1838 2234 \n",
       "L 1294 2234 \n",
       "L 1294 2753 \n",
       "L 1863 2753 \n",
       "Q 2328 2753 2575 2939 \n",
       "Q 2822 3125 2822 3475 \n",
       "Q 2822 3834 2567 4026 \n",
       "Q 2313 4219 1838 4219 \n",
       "Q 1578 4219 1281 4162 \n",
       "Q 984 4106 628 3988 \n",
       "L 628 4550 \n",
       "Q 988 4650 1302 4700 \n",
       "Q 1616 4750 1894 4750 \n",
       "Q 2613 4750 3031 4423 \n",
       "Q 3450 4097 3450 3541 \n",
       "Q 3450 3153 3228 2886 \n",
       "Q 3006 2619 2597 2516 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "       </defs>\n",
       "       <use xlink:href=\"#DejaVuSans-33\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-30\" transform=\"translate(63.623047 0)\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-30\" transform=\"translate(127.246094 0)\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"xtick_5\">\n",
       "     <g id=\"line2d_9\">\n",
       "      <path d=\"M 320.906664 287.64327 \n",
       "L 320.906664 22.318125 \n",
       "\" clip-path=\"url(#p307071d5be)\" style=\"fill: none; stroke: #b0b0b0; stroke-opacity: 0.22; stroke-width: 0.8; stroke-linecap: square\"/>\n",
       "     </g>\n",
       "     <g id=\"line2d_10\">\n",
       "      <g>\n",
       "       <use xlink:href=\"#mc6f5a670d4\" x=\"320.906664\" y=\"287.64327\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_5\">\n",
       "      <!-- 400 -->\n",
       "      <g transform=\"translate(311.362914 302.241707) scale(0.1 -0.1)\">\n",
       "       <defs>\n",
       "        <path id=\"DejaVuSans-34\" d=\"M 2419 4116 \n",
       "L 825 1625 \n",
       "L 2419 1625 \n",
       "L 2419 4116 \n",
       "z\n",
       "M 2253 4666 \n",
       "L 3047 4666 \n",
       "L 3047 1625 \n",
       "L 3713 1625 \n",
       "L 3713 1100 \n",
       "L 3047 1100 \n",
       "L 3047 0 \n",
       "L 2419 0 \n",
       "L 2419 1100 \n",
       "L 313 1100 \n",
       "L 313 1709 \n",
       "L 2253 4666 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "       </defs>\n",
       "       <use xlink:href=\"#DejaVuSans-34\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-30\" transform=\"translate(63.623047 0)\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-30\" transform=\"translate(127.246094 0)\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"xtick_6\">\n",
       "     <g id=\"line2d_11\">\n",
       "      <path d=\"M 383.77563 287.64327 \n",
       "L 383.77563 22.318125 \n",
       "\" clip-path=\"url(#p307071d5be)\" style=\"fill: none; stroke: #b0b0b0; stroke-opacity: 0.22; stroke-width: 0.8; stroke-linecap: square\"/>\n",
       "     </g>\n",
       "     <g id=\"line2d_12\">\n",
       "      <g>\n",
       "       <use xlink:href=\"#mc6f5a670d4\" x=\"383.77563\" y=\"287.64327\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_6\">\n",
       "      <!-- 500 -->\n",
       "      <g transform=\"translate(374.23188 302.241707) scale(0.1 -0.1)\">\n",
       "       <defs>\n",
       "        <path id=\"DejaVuSans-35\" d=\"M 691 4666 \n",
       "L 3169 4666 \n",
       "L 3169 4134 \n",
       "L 1269 4134 \n",
       "L 1269 2991 \n",
       "Q 1406 3038 1543 3061 \n",
       "Q 1681 3084 1819 3084 \n",
       "Q 2600 3084 3056 2656 \n",
       "Q 3513 2228 3513 1497 \n",
       "Q 3513 744 3044 326 \n",
       "Q 2575 -91 1722 -91 \n",
       "Q 1428 -91 1123 -41 \n",
       "Q 819 9 494 109 \n",
       "L 494 744 \n",
       "Q 775 591 1075 516 \n",
       "Q 1375 441 1709 441 \n",
       "Q 2250 441 2565 725 \n",
       "Q 2881 1009 2881 1497 \n",
       "Q 2881 1984 2565 2268 \n",
       "Q 2250 2553 1709 2553 \n",
       "Q 1456 2553 1204 2497 \n",
       "Q 953 2441 691 2322 \n",
       "L 691 4666 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "       </defs>\n",
       "       <use xlink:href=\"#DejaVuSans-35\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-30\" transform=\"translate(63.623047 0)\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-30\" transform=\"translate(127.246094 0)\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"xtick_7\">\n",
       "     <g id=\"line2d_13\">\n",
       "      <path d=\"M 446.644596 287.64327 \n",
       "L 446.644596 22.318125 \n",
       "\" clip-path=\"url(#p307071d5be)\" style=\"fill: none; stroke: #b0b0b0; stroke-opacity: 0.22; stroke-width: 0.8; stroke-linecap: square\"/>\n",
       "     </g>\n",
       "     <g id=\"line2d_14\">\n",
       "      <g>\n",
       "       <use xlink:href=\"#mc6f5a670d4\" x=\"446.644596\" y=\"287.64327\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_7\">\n",
       "      <!-- 600 -->\n",
       "      <g transform=\"translate(437.100846 302.241707) scale(0.1 -0.1)\">\n",
       "       <defs>\n",
       "        <path id=\"DejaVuSans-36\" d=\"M 2113 2584 \n",
       "Q 1688 2584 1439 2293 \n",
       "Q 1191 2003 1191 1497 \n",
       "Q 1191 994 1439 701 \n",
       "Q 1688 409 2113 409 \n",
       "Q 2538 409 2786 701 \n",
       "Q 3034 994 3034 1497 \n",
       "Q 3034 2003 2786 2293 \n",
       "Q 2538 2584 2113 2584 \n",
       "z\n",
       "M 3366 4563 \n",
       "L 3366 3988 \n",
       "Q 3128 4100 2886 4159 \n",
       "Q 2644 4219 2406 4219 \n",
       "Q 1781 4219 1451 3797 \n",
       "Q 1122 3375 1075 2522 \n",
       "Q 1259 2794 1537 2939 \n",
       "Q 1816 3084 2150 3084 \n",
       "Q 2853 3084 3261 2657 \n",
       "Q 3669 2231 3669 1497 \n",
       "Q 3669 778 3244 343 \n",
       "Q 2819 -91 2113 -91 \n",
       "Q 1303 -91 875 529 \n",
       "Q 447 1150 447 2328 \n",
       "Q 447 3434 972 4092 \n",
       "Q 1497 4750 2381 4750 \n",
       "Q 2619 4750 2861 4703 \n",
       "Q 3103 4656 3366 4563 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "       </defs>\n",
       "       <use xlink:href=\"#DejaVuSans-36\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-30\" transform=\"translate(63.623047 0)\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-30\" transform=\"translate(127.246094 0)\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"xtick_8\">\n",
       "     <g id=\"line2d_15\">\n",
       "      <path d=\"M 509.513561 287.64327 \n",
       "L 509.513561 22.318125 \n",
       "\" clip-path=\"url(#p307071d5be)\" style=\"fill: none; stroke: #b0b0b0; stroke-opacity: 0.22; stroke-width: 0.8; stroke-linecap: square\"/>\n",
       "     </g>\n",
       "     <g id=\"line2d_16\">\n",
       "      <g>\n",
       "       <use xlink:href=\"#mc6f5a670d4\" x=\"509.513561\" y=\"287.64327\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_8\">\n",
       "      <!-- 700 -->\n",
       "      <g transform=\"translate(499.969811 302.241707) scale(0.1 -0.1)\">\n",
       "       <defs>\n",
       "        <path id=\"DejaVuSans-37\" d=\"M 525 4666 \n",
       "L 3525 4666 \n",
       "L 3525 4397 \n",
       "L 1831 0 \n",
       "L 1172 0 \n",
       "L 2766 4134 \n",
       "L 525 4134 \n",
       "L 525 4666 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "       </defs>\n",
       "       <use xlink:href=\"#DejaVuSans-37\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-30\" transform=\"translate(63.623047 0)\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-30\" transform=\"translate(127.246094 0)\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"text_9\">\n",
       "     <!-- Mean prompt and generated tokens per work order -->\n",
       "     <g transform=\"translate(165.598197 315.919832) scale(0.1 -0.1)\">\n",
       "      <defs>\n",
       "       <path id=\"DejaVuSans-4d\" d=\"M 628 4666 \n",
       "L 1569 4666 \n",
       "L 2759 1491 \n",
       "L 3956 4666 \n",
       "L 4897 4666 \n",
       "L 4897 0 \n",
       "L 4281 0 \n",
       "L 4281 4097 \n",
       "L 3078 897 \n",
       "L 2444 897 \n",
       "L 1241 4097 \n",
       "L 1241 0 \n",
       "L 628 0 \n",
       "L 628 4666 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "       <path id=\"DejaVuSans-65\" d=\"M 3597 1894 \n",
       "L 3597 1613 \n",
       "L 953 1613 \n",
       "Q 991 1019 1311 708 \n",
       "Q 1631 397 2203 397 \n",
       "Q 2534 397 2845 478 \n",
       "Q 3156 559 3463 722 \n",
       "L 3463 178 \n",
       "Q 3153 47 2828 -22 \n",
       "Q 2503 -91 2169 -91 \n",
       "Q 1331 -91 842 396 \n",
       "Q 353 884 353 1716 \n",
       "Q 353 2575 817 3079 \n",
       "Q 1281 3584 2069 3584 \n",
       "Q 2775 3584 3186 3129 \n",
       "Q 3597 2675 3597 1894 \n",
       "z\n",
       "M 3022 2063 \n",
       "Q 3016 2534 2758 2815 \n",
       "Q 2500 3097 2075 3097 \n",
       "Q 1594 3097 1305 2825 \n",
       "Q 1016 2553 972 2059 \n",
       "L 3022 2063 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "       <path id=\"DejaVuSans-61\" d=\"M 2194 1759 \n",
       "Q 1497 1759 1228 1600 \n",
       "Q 959 1441 959 1056 \n",
       "Q 959 750 1161 570 \n",
       "Q 1363 391 1709 391 \n",
       "Q 2188 391 2477 730 \n",
       "Q 2766 1069 2766 1631 \n",
       "L 2766 1759 \n",
       "L 2194 1759 \n",
       "z\n",
       "M 3341 1997 \n",
       "L 3341 0 \n",
       "L 2766 0 \n",
       "L 2766 531 \n",
       "Q 2569 213 2275 61 \n",
       "Q 1981 -91 1556 -91 \n",
       "Q 1019 -91 701 211 \n",
       "Q 384 513 384 1019 \n",
       "Q 384 1609 779 1909 \n",
       "Q 1175 2209 1959 2209 \n",
       "L 2766 2209 \n",
       "L 2766 2266 \n",
       "Q 2766 2663 2505 2880 \n",
       "Q 2244 3097 1772 3097 \n",
       "Q 1472 3097 1187 3025 \n",
       "Q 903 2953 641 2809 \n",
       "L 641 3341 \n",
       "Q 956 3463 1253 3523 \n",
       "Q 1550 3584 1831 3584 \n",
       "Q 2591 3584 2966 3190 \n",
       "Q 3341 2797 3341 1997 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "       <path id=\"DejaVuSans-6e\" d=\"M 3513 2113 \n",
       "L 3513 0 \n",
       "L 2938 0 \n",
       "L 2938 2094 \n",
       "Q 2938 2591 2744 2837 \n",
       "Q 2550 3084 2163 3084 \n",
       "Q 1697 3084 1428 2787 \n",
       "Q 1159 2491 1159 1978 \n",
       "L 1159 0 \n",
       "L 581 0 \n",
       "L 581 3500 \n",
       "L 1159 3500 \n",
       "L 1159 2956 \n",
       "Q 1366 3272 1645 3428 \n",
       "Q 1925 3584 2291 3584 \n",
       "Q 2894 3584 3203 3211 \n",
       "Q 3513 2838 3513 2113 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "       <path id=\"DejaVuSans-20\" transform=\"scale(0.015625)\"/>\n",
       "       <path id=\"DejaVuSans-70\" d=\"M 1159 525 \n",
       "L 1159 -1331 \n",
       "L 581 -1331 \n",
       "L 581 3500 \n",
       "L 1159 3500 \n",
       "L 1159 2969 \n",
       "Q 1341 3281 1617 3432 \n",
       "Q 1894 3584 2278 3584 \n",
       "Q 2916 3584 3314 3078 \n",
       "Q 3713 2572 3713 1747 \n",
       "Q 3713 922 3314 415 \n",
       "Q 2916 -91 2278 -91 \n",
       "Q 1894 -91 1617 61 \n",
       "Q 1341 213 1159 525 \n",
       "z\n",
       "M 3116 1747 \n",
       "Q 3116 2381 2855 2742 \n",
       "Q 2594 3103 2138 3103 \n",
       "Q 1681 3103 1420 2742 \n",
       "Q 1159 2381 1159 1747 \n",
       "Q 1159 1113 1420 752 \n",
       "Q 1681 391 2138 391 \n",
       "Q 2594 391 2855 752 \n",
       "Q 3116 1113 3116 1747 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "       <path id=\"DejaVuSans-72\" d=\"M 2631 2963 \n",
       "Q 2534 3019 2420 3045 \n",
       "Q 2306 3072 2169 3072 \n",
       "Q 1681 3072 1420 2755 \n",
       "Q 1159 2438 1159 1844 \n",
       "L 1159 0 \n",
       "L 581 0 \n",
       "L 581 3500 \n",
       "L 1159 3500 \n",
       "L 1159 2956 \n",
       "Q 1341 3275 1631 3429 \n",
       "Q 1922 3584 2338 3584 \n",
       "Q 2397 3584 2469 3576 \n",
       "Q 2541 3569 2628 3553 \n",
       "L 2631 2963 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "       <path id=\"DejaVuSans-6f\" d=\"M 1959 3097 \n",
       "Q 1497 3097 1228 2736 \n",
       "Q 959 2375 959 1747 \n",
       "Q 959 1119 1226 758 \n",
       "Q 1494 397 1959 397 \n",
       "Q 2419 397 2687 759 \n",
       "Q 2956 1122 2956 1747 \n",
       "Q 2956 2369 2687 2733 \n",
       "Q 2419 3097 1959 3097 \n",
       "z\n",
       "M 1959 3584 \n",
       "Q 2709 3584 3137 3096 \n",
       "Q 3566 2609 3566 1747 \n",
       "Q 3566 888 3137 398 \n",
       "Q 2709 -91 1959 -91 \n",
       "Q 1206 -91 779 398 \n",
       "Q 353 888 353 1747 \n",
       "Q 353 2609 779 3096 \n",
       "Q 1206 3584 1959 3584 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "       <path id=\"DejaVuSans-6d\" d=\"M 3328 2828 \n",
       "Q 3544 3216 3844 3400 \n",
       "Q 4144 3584 4550 3584 \n",
       "Q 5097 3584 5394 3201 \n",
       "Q 5691 2819 5691 2113 \n",
       "L 5691 0 \n",
       "L 5113 0 \n",
       "L 5113 2094 \n",
       "Q 5113 2597 4934 2840 \n",
       "Q 4756 3084 4391 3084 \n",
       "Q 3944 3084 3684 2787 \n",
       "Q 3425 2491 3425 1978 \n",
       "L 3425 0 \n",
       "L 2847 0 \n",
       "L 2847 2094 \n",
       "Q 2847 2600 2669 2842 \n",
       "Q 2491 3084 2119 3084 \n",
       "Q 1678 3084 1418 2786 \n",
       "Q 1159 2488 1159 1978 \n",
       "L 1159 0 \n",
       "L 581 0 \n",
       "L 581 3500 \n",
       "L 1159 3500 \n",
       "L 1159 2956 \n",
       "Q 1356 3278 1631 3431 \n",
       "Q 1906 3584 2284 3584 \n",
       "Q 2666 3584 2933 3390 \n",
       "Q 3200 3197 3328 2828 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "       <path id=\"DejaVuSans-74\" d=\"M 1172 4494 \n",
       "L 1172 3500 \n",
       "L 2356 3500 \n",
       "L 2356 3053 \n",
       "L 1172 3053 \n",
       "L 1172 1153 \n",
       "Q 1172 725 1289 603 \n",
       "Q 1406 481 1766 481 \n",
       "L 2356 481 \n",
       "L 2356 0 \n",
       "L 1766 0 \n",
       "Q 1100 0 847 248 \n",
       "Q 594 497 594 1153 \n",
       "L 594 3053 \n",
       "L 172 3053 \n",
       "L 172 3500 \n",
       "L 594 3500 \n",
       "L 594 4494 \n",
       "L 1172 4494 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "       <path id=\"DejaVuSans-64\" d=\"M 2906 2969 \n",
       "L 2906 4863 \n",
       "L 3481 4863 \n",
       "L 3481 0 \n",
       "L 2906 0 \n",
       "L 2906 525 \n",
       "Q 2725 213 2448 61 \n",
       "Q 2172 -91 1784 -91 \n",
       "Q 1150 -91 751 415 \n",
       "Q 353 922 353 1747 \n",
       "Q 353 2572 751 3078 \n",
       "Q 1150 3584 1784 3584 \n",
       "Q 2172 3584 2448 3432 \n",
       "Q 2725 3281 2906 2969 \n",
       "z\n",
       "M 947 1747 \n",
       "Q 947 1113 1208 752 \n",
       "Q 1469 391 1925 391 \n",
       "Q 2381 391 2643 752 \n",
       "Q 2906 1113 2906 1747 \n",
       "Q 2906 2381 2643 2742 \n",
       "Q 2381 3103 1925 3103 \n",
       "Q 1469 3103 1208 2742 \n",
       "Q 947 2381 947 1747 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "       <path id=\"DejaVuSans-67\" d=\"M 2906 1791 \n",
       "Q 2906 2416 2648 2759 \n",
       "Q 2391 3103 1925 3103 \n",
       "Q 1463 3103 1205 2759 \n",
       "Q 947 2416 947 1791 \n",
       "Q 947 1169 1205 825 \n",
       "Q 1463 481 1925 481 \n",
       "Q 2391 481 2648 825 \n",
       "Q 2906 1169 2906 1791 \n",
       "z\n",
       "M 3481 434 \n",
       "Q 3481 -459 3084 -895 \n",
       "Q 2688 -1331 1869 -1331 \n",
       "Q 1566 -1331 1297 -1286 \n",
       "Q 1028 -1241 775 -1147 \n",
       "L 775 -588 \n",
       "Q 1028 -725 1275 -790 \n",
       "Q 1522 -856 1778 -856 \n",
       "Q 2344 -856 2625 -561 \n",
       "Q 2906 -266 2906 331 \n",
       "L 2906 616 \n",
       "Q 2728 306 2450 153 \n",
       "Q 2172 0 1784 0 \n",
       "Q 1141 0 747 490 \n",
       "Q 353 981 353 1791 \n",
       "Q 353 2603 747 3093 \n",
       "Q 1141 3584 1784 3584 \n",
       "Q 2172 3584 2450 3431 \n",
       "Q 2728 3278 2906 2969 \n",
       "L 2906 3500 \n",
       "L 3481 3500 \n",
       "L 3481 434 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "       <path id=\"DejaVuSans-6b\" d=\"M 581 4863 \n",
       "L 1159 4863 \n",
       "L 1159 1991 \n",
       "L 2875 3500 \n",
       "L 3609 3500 \n",
       "L 1753 1863 \n",
       "L 3688 0 \n",
       "L 2938 0 \n",
       "L 1159 1709 \n",
       "L 1159 0 \n",
       "L 581 0 \n",
       "L 581 4863 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "       <path id=\"DejaVuSans-73\" d=\"M 2834 3397 \n",
       "L 2834 2853 \n",
       "Q 2591 2978 2328 3040 \n",
       "Q 2066 3103 1784 3103 \n",
       "Q 1356 3103 1142 2972 \n",
       "Q 928 2841 928 2578 \n",
       "Q 928 2378 1081 2264 \n",
       "Q 1234 2150 1697 2047 \n",
       "L 1894 2003 \n",
       "Q 2506 1872 2764 1633 \n",
       "Q 3022 1394 3022 966 \n",
       "Q 3022 478 2636 193 \n",
       "Q 2250 -91 1575 -91 \n",
       "Q 1294 -91 989 -36 \n",
       "Q 684 19 347 128 \n",
       "L 347 722 \n",
       "Q 666 556 975 473 \n",
       "Q 1284 391 1588 391 \n",
       "Q 1994 391 2212 530 \n",
       "Q 2431 669 2431 922 \n",
       "Q 2431 1156 2273 1281 \n",
       "Q 2116 1406 1581 1522 \n",
       "L 1381 1569 \n",
       "Q 847 1681 609 1914 \n",
       "Q 372 2147 372 2553 \n",
       "Q 372 3047 722 3315 \n",
       "Q 1072 3584 1716 3584 \n",
       "Q 2034 3584 2315 3537 \n",
       "Q 2597 3491 2834 3397 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "       <path id=\"DejaVuSans-77\" d=\"M 269 3500 \n",
       "L 844 3500 \n",
       "L 1563 769 \n",
       "L 2278 3500 \n",
       "L 2956 3500 \n",
       "L 3675 769 \n",
       "L 4391 3500 \n",
       "L 4966 3500 \n",
       "L 4050 0 \n",
       "L 3372 0 \n",
       "L 2619 2869 \n",
       "L 1863 0 \n",
       "L 1184 0 \n",
       "L 269 3500 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "      </defs>\n",
       "      <use xlink:href=\"#DejaVuSans-4d\"/>\n",
       "      <use xlink:href=\"#DejaVuSans-65\" transform=\"translate(86.279297 0)\"/>\n",
       "      <use xlink:href=\"#DejaVuSans-61\" transform=\"translate(147.802734 0)\"/>\n",
       "      <use xlink:href=\"#DejaVuSans-6e\" transform=\"translate(209.082031 0)\"/>\n",
       "      <use xlink:href=\"#DejaVuSans-20\" transform=\"translate(272.460938 0)\"/>\n",
       "      <use xlink:href=\"#DejaVuSans-70\" transform=\"translate(304.248047 0)\"/>\n",
       "      <use xlink:href=\"#DejaVuSans-72\" transform=\"translate(367.724609 0)\"/>\n",
       "      <use xlink:href=\"#DejaVuSans-6f\" transform=\"translate(406.587891 0)\"/>\n",
       "      <use xlink:href=\"#DejaVuSans-6d\" transform=\"translate(467.769531 0)\"/>\n",
       "      <use xlink:href=\"#DejaVuSans-70\" transform=\"translate(565.181641 0)\"/>\n",
       "      <use xlink:href=\"#DejaVuSans-74\" transform=\"translate(628.658203 0)\"/>\n",
       "      <use xlink:href=\"#DejaVuSans-20\" transform=\"translate(667.867188 0)\"/>\n",
       "      <use xlink:href=\"#DejaVuSans-61\" transform=\"translate(699.654297 0)\"/>\n",
       "      <use xlink:href=\"#DejaVuSans-6e\" transform=\"translate(760.933594 0)\"/>\n",
       "      <use xlink:href=\"#DejaVuSans-64\" transform=\"translate(824.3125 0)\"/>\n",
       "      <use xlink:href=\"#DejaVuSans-20\" transform=\"translate(887.789062 0)\"/>\n",
       "      <use xlink:href=\"#DejaVuSans-67\" transform=\"translate(919.576172 0)\"/>\n",
       "      <use xlink:href=\"#DejaVuSans-65\" transform=\"translate(983.052734 0)\"/>\n",
       "      <use xlink:href=\"#DejaVuSans-6e\" transform=\"translate(1044.576172 0)\"/>\n",
       "      <use xlink:href=\"#DejaVuSans-65\" transform=\"translate(1107.955078 0)\"/>\n",
       "      <use xlink:href=\"#DejaVuSans-72\" transform=\"translate(1169.478516 0)\"/>\n",
       "      <use xlink:href=\"#DejaVuSans-61\" transform=\"translate(1210.591797 0)\"/>\n",
       "      <use xlink:href=\"#DejaVuSans-74\" transform=\"translate(1271.871094 0)\"/>\n",
       "      <use xlink:href=\"#DejaVuSans-65\" transform=\"translate(1311.080078 0)\"/>\n",
       "      <use xlink:href=\"#DejaVuSans-64\" transform=\"translate(1372.603516 0)\"/>\n",
       "      <use xlink:href=\"#DejaVuSans-20\" transform=\"translate(1436.080078 0)\"/>\n",
       "      <use xlink:href=\"#DejaVuSans-74\" transform=\"translate(1467.867188 0)\"/>\n",
       "      <use xlink:href=\"#DejaVuSans-6f\" transform=\"translate(1507.076172 0)\"/>\n",
       "      <use xlink:href=\"#DejaVuSans-6b\" transform=\"translate(1568.257812 0)\"/>\n",
       "      <use xlink:href=\"#DejaVuSans-65\" transform=\"translate(1622.542969 0)\"/>\n",
       "      <use xlink:href=\"#DejaVuSans-6e\" transform=\"translate(1684.066406 0)\"/>\n",
       "      <use xlink:href=\"#DejaVuSans-73\" transform=\"translate(1747.445312 0)\"/>\n",
       "      <use xlink:href=\"#DejaVuSans-20\" transform=\"translate(1799.544922 0)\"/>\n",
       "      <use xlink:href=\"#DejaVuSans-70\" transform=\"translate(1831.332031 0)\"/>\n",
       "      <use xlink:href=\"#DejaVuSans-65\" transform=\"translate(1894.808594 0)\"/>\n",
       "      <use xlink:href=\"#DejaVuSans-72\" transform=\"translate(1956.332031 0)\"/>\n",
       "      <use xlink:href=\"#DejaVuSans-20\" transform=\"translate(1997.445312 0)\"/>\n",
       "      <use xlink:href=\"#DejaVuSans-77\" transform=\"translate(2029.232422 0)\"/>\n",
       "      <use xlink:href=\"#DejaVuSans-6f\" transform=\"translate(2111.019531 0)\"/>\n",
       "      <use xlink:href=\"#DejaVuSans-72\" transform=\"translate(2172.201172 0)\"/>\n",
       "      <use xlink:href=\"#DejaVuSans-6b\" transform=\"translate(2213.314453 0)\"/>\n",
       "      <use xlink:href=\"#DejaVuSans-20\" transform=\"translate(2271.224609 0)\"/>\n",
       "      <use xlink:href=\"#DejaVuSans-6f\" transform=\"translate(2303.011719 0)\"/>\n",
       "      <use xlink:href=\"#DejaVuSans-72\" transform=\"translate(2364.193359 0)\"/>\n",
       "      <use xlink:href=\"#DejaVuSans-64\" transform=\"translate(2403.556641 0)\"/>\n",
       "      <use xlink:href=\"#DejaVuSans-65\" transform=\"translate(2467.033203 0)\"/>\n",
       "      <use xlink:href=\"#DejaVuSans-72\" transform=\"translate(2528.556641 0)\"/>\n",
       "     </g>\n",
       "    </g>\n",
       "   </g>\n",
       "   <g id=\"matplotlib.axis_2\">\n",
       "    <g id=\"ytick_1\">\n",
       "     <g id=\"line2d_17\">\n",
       "      <path d=\"M 46.965625 277.816413 \n",
       "L 541.19952 277.816413 \n",
       "\" clip-path=\"url(#p307071d5be)\" style=\"fill: none; stroke: #b0b0b0; stroke-opacity: 0.22; stroke-width: 0.8; stroke-linecap: square\"/>\n",
       "     </g>\n",
       "     <g id=\"line2d_18\">\n",
       "      <defs>\n",
       "       <path id=\"mbf4aa20b6a\" d=\"M 0 0 \n",
       "L -3.5 0 \n",
       "\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n",
       "      </defs>\n",
       "      <g>\n",
       "       <use xlink:href=\"#mbf4aa20b6a\" x=\"46.965625\" y=\"277.816413\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_10\">\n",
       "      <!-- 0 -->\n",
       "      <g transform=\"translate(33.603125 281.615632) scale(0.1 -0.1)\">\n",
       "       <use xlink:href=\"#DejaVuSans-30\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"ytick_2\">\n",
       "     <g id=\"line2d_19\">\n",
       "      <path d=\"M 46.965625 228.682127 \n",
       "L 541.19952 228.682127 \n",
       "\" clip-path=\"url(#p307071d5be)\" style=\"fill: none; stroke: #b0b0b0; stroke-opacity: 0.22; stroke-width: 0.8; stroke-linecap: square\"/>\n",
       "     </g>\n",
       "     <g id=\"line2d_20\">\n",
       "      <g>\n",
       "       <use xlink:href=\"#mbf4aa20b6a\" x=\"46.965625\" y=\"228.682127\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_11\">\n",
       "      <!-- 20 -->\n",
       "      <g transform=\"translate(27.240625 232.481345) scale(0.1 -0.1)\">\n",
       "       <use xlink:href=\"#DejaVuSans-32\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-30\" transform=\"translate(63.623047 0)\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"ytick_3\">\n",
       "     <g id=\"line2d_21\">\n",
       "      <path d=\"M 46.965625 179.547841 \n",
       "L 541.19952 179.547841 \n",
       "\" clip-path=\"url(#p307071d5be)\" style=\"fill: none; stroke: #b0b0b0; stroke-opacity: 0.22; stroke-width: 0.8; stroke-linecap: square\"/>\n",
       "     </g>\n",
       "     <g id=\"line2d_22\">\n",
       "      <g>\n",
       "       <use xlink:href=\"#mbf4aa20b6a\" x=\"46.965625\" y=\"179.547841\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_12\">\n",
       "      <!-- 40 -->\n",
       "      <g transform=\"translate(27.240625 183.347059) scale(0.1 -0.1)\">\n",
       "       <use xlink:href=\"#DejaVuSans-34\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-30\" transform=\"translate(63.623047 0)\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"ytick_4\">\n",
       "     <g id=\"line2d_23\">\n",
       "      <path d=\"M 46.965625 130.413554 \n",
       "L 541.19952 130.413554 \n",
       "\" clip-path=\"url(#p307071d5be)\" style=\"fill: none; stroke: #b0b0b0; stroke-opacity: 0.22; stroke-width: 0.8; stroke-linecap: square\"/>\n",
       "     </g>\n",
       "     <g id=\"line2d_24\">\n",
       "      <g>\n",
       "       <use xlink:href=\"#mbf4aa20b6a\" x=\"46.965625\" y=\"130.413554\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_13\">\n",
       "      <!-- 60 -->\n",
       "      <g transform=\"translate(27.240625 134.212773) scale(0.1 -0.1)\">\n",
       "       <use xlink:href=\"#DejaVuSans-36\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-30\" transform=\"translate(63.623047 0)\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"ytick_5\">\n",
       "     <g id=\"line2d_25\">\n",
       "      <path d=\"M 46.965625 81.279268 \n",
       "L 541.19952 81.279268 \n",
       "\" clip-path=\"url(#p307071d5be)\" style=\"fill: none; stroke: #b0b0b0; stroke-opacity: 0.22; stroke-width: 0.8; stroke-linecap: square\"/>\n",
       "     </g>\n",
       "     <g id=\"line2d_26\">\n",
       "      <g>\n",
       "       <use xlink:href=\"#mbf4aa20b6a\" x=\"46.965625\" y=\"81.279268\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_14\">\n",
       "      <!-- 80 -->\n",
       "      <g transform=\"translate(27.240625 85.078487) scale(0.1 -0.1)\">\n",
       "       <defs>\n",
       "        <path id=\"DejaVuSans-38\" d=\"M 2034 2216 \n",
       "Q 1584 2216 1326 1975 \n",
       "Q 1069 1734 1069 1313 \n",
       "Q 1069 891 1326 650 \n",
       "Q 1584 409 2034 409 \n",
       "Q 2484 409 2743 651 \n",
       "Q 3003 894 3003 1313 \n",
       "Q 3003 1734 2745 1975 \n",
       "Q 2488 2216 2034 2216 \n",
       "z\n",
       "M 1403 2484 \n",
       "Q 997 2584 770 2862 \n",
       "Q 544 3141 544 3541 \n",
       "Q 544 4100 942 4425 \n",
       "Q 1341 4750 2034 4750 \n",
       "Q 2731 4750 3128 4425 \n",
       "Q 3525 4100 3525 3541 \n",
       "Q 3525 3141 3298 2862 \n",
       "Q 3072 2584 2669 2484 \n",
       "Q 3125 2378 3379 2068 \n",
       "Q 3634 1759 3634 1313 \n",
       "Q 3634 634 3220 271 \n",
       "Q 2806 -91 2034 -91 \n",
       "Q 1263 -91 848 271 \n",
       "Q 434 634 434 1313 \n",
       "Q 434 1759 690 2068 \n",
       "Q 947 2378 1403 2484 \n",
       "z\n",
       "M 1172 3481 \n",
       "Q 1172 3119 1398 2916 \n",
       "Q 1625 2713 2034 2713 \n",
       "Q 2441 2713 2670 2916 \n",
       "Q 2900 3119 2900 3481 \n",
       "Q 2900 3844 2670 4047 \n",
       "Q 2441 4250 2034 4250 \n",
       "Q 1625 4250 1398 4047 \n",
       "Q 1172 3844 1172 3481 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "       </defs>\n",
       "       <use xlink:href=\"#DejaVuSans-38\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-30\" transform=\"translate(63.623047 0)\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"ytick_6\">\n",
       "     <g id=\"line2d_27\">\n",
       "      <path d=\"M 46.965625 32.144982 \n",
       "L 541.19952 32.144982 \n",
       "\" clip-path=\"url(#p307071d5be)\" style=\"fill: none; stroke: #b0b0b0; stroke-opacity: 0.22; stroke-width: 0.8; stroke-linecap: square\"/>\n",
       "     </g>\n",
       "     <g id=\"line2d_28\">\n",
       "      <g>\n",
       "       <use xlink:href=\"#mbf4aa20b6a\" x=\"46.965625\" y=\"32.144982\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_15\">\n",
       "      <!-- 100 -->\n",
       "      <g transform=\"translate(20.878125 35.944201) scale(0.1 -0.1)\">\n",
       "       <use xlink:href=\"#DejaVuSans-31\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-30\" transform=\"translate(63.623047 0)\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-30\" transform=\"translate(127.246094 0)\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"text_16\">\n",
       "     <!-- Strict pass rate (%) -->\n",
       "     <g transform=\"translate(14.798438 203.292416) rotate(-90) scale(0.1 -0.1)\">\n",
       "      <defs>\n",
       "       <path id=\"DejaVuSans-53\" d=\"M 3425 4513 \n",
       "L 3425 3897 \n",
       "Q 3066 4069 2747 4153 \n",
       "Q 2428 4238 2131 4238 \n",
       "Q 1616 4238 1336 4038 \n",
       "Q 1056 3838 1056 3469 \n",
       "Q 1056 3159 1242 3001 \n",
       "Q 1428 2844 1947 2747 \n",
       "L 2328 2669 \n",
       "Q 3034 2534 3370 2195 \n",
       "Q 3706 1856 3706 1288 \n",
       "Q 3706 609 3251 259 \n",
       "Q 2797 -91 1919 -91 \n",
       "Q 1588 -91 1214 -16 \n",
       "Q 841 59 441 206 \n",
       "L 441 856 \n",
       "Q 825 641 1194 531 \n",
       "Q 1563 422 1919 422 \n",
       "Q 2459 422 2753 634 \n",
       "Q 3047 847 3047 1241 \n",
       "Q 3047 1584 2836 1778 \n",
       "Q 2625 1972 2144 2069 \n",
       "L 1759 2144 \n",
       "Q 1053 2284 737 2584 \n",
       "Q 422 2884 422 3419 \n",
       "Q 422 4038 858 4394 \n",
       "Q 1294 4750 2059 4750 \n",
       "Q 2388 4750 2728 4690 \n",
       "Q 3069 4631 3425 4513 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "       <path id=\"DejaVuSans-69\" d=\"M 603 3500 \n",
       "L 1178 3500 \n",
       "L 1178 0 \n",
       "L 603 0 \n",
       "L 603 3500 \n",
       "z\n",
       "M 603 4863 \n",
       "L 1178 4863 \n",
       "L 1178 4134 \n",
       "L 603 4134 \n",
       "L 603 4863 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "       <path id=\"DejaVuSans-63\" d=\"M 3122 3366 \n",
       "L 3122 2828 \n",
       "Q 2878 2963 2633 3030 \n",
       "Q 2388 3097 2138 3097 \n",
       "Q 1578 3097 1268 2742 \n",
       "Q 959 2388 959 1747 \n",
       "Q 959 1106 1268 751 \n",
       "Q 1578 397 2138 397 \n",
       "Q 2388 397 2633 464 \n",
       "Q 2878 531 3122 666 \n",
       "L 3122 134 \n",
       "Q 2881 22 2623 -34 \n",
       "Q 2366 -91 2075 -91 \n",
       "Q 1284 -91 818 406 \n",
       "Q 353 903 353 1747 \n",
       "Q 353 2603 823 3093 \n",
       "Q 1294 3584 2113 3584 \n",
       "Q 2378 3584 2631 3529 \n",
       "Q 2884 3475 3122 3366 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "       <path id=\"DejaVuSans-28\" d=\"M 1984 4856 \n",
       "Q 1566 4138 1362 3434 \n",
       "Q 1159 2731 1159 2009 \n",
       "Q 1159 1288 1364 580 \n",
       "Q 1569 -128 1984 -844 \n",
       "L 1484 -844 \n",
       "Q 1016 -109 783 600 \n",
       "Q 550 1309 550 2009 \n",
       "Q 550 2706 781 3412 \n",
       "Q 1013 4119 1484 4856 \n",
       "L 1984 4856 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "       <path id=\"DejaVuSans-25\" d=\"M 4653 2053 \n",
       "Q 4381 2053 4226 1822 \n",
       "Q 4072 1591 4072 1178 \n",
       "Q 4072 772 4226 539 \n",
       "Q 4381 306 4653 306 \n",
       "Q 4919 306 5073 539 \n",
       "Q 5228 772 5228 1178 \n",
       "Q 5228 1588 5073 1820 \n",
       "Q 4919 2053 4653 2053 \n",
       "z\n",
       "M 4653 2450 \n",
       "Q 5147 2450 5437 2106 \n",
       "Q 5728 1763 5728 1178 \n",
       "Q 5728 594 5436 251 \n",
       "Q 5144 -91 4653 -91 \n",
       "Q 4153 -91 3862 251 \n",
       "Q 3572 594 3572 1178 \n",
       "Q 3572 1766 3864 2108 \n",
       "Q 4156 2450 4653 2450 \n",
       "z\n",
       "M 1428 4353 \n",
       "Q 1159 4353 1004 4120 \n",
       "Q 850 3888 850 3481 \n",
       "Q 850 3069 1003 2837 \n",
       "Q 1156 2606 1428 2606 \n",
       "Q 1700 2606 1854 2837 \n",
       "Q 2009 3069 2009 3481 \n",
       "Q 2009 3884 1853 4118 \n",
       "Q 1697 4353 1428 4353 \n",
       "z\n",
       "M 4250 4750 \n",
       "L 4750 4750 \n",
       "L 1831 -91 \n",
       "L 1331 -91 \n",
       "L 4250 4750 \n",
       "z\n",
       "M 1428 4750 \n",
       "Q 1922 4750 2215 4408 \n",
       "Q 2509 4066 2509 3481 \n",
       "Q 2509 2891 2217 2550 \n",
       "Q 1925 2209 1428 2209 \n",
       "Q 931 2209 642 2551 \n",
       "Q 353 2894 353 3481 \n",
       "Q 353 4063 643 4406 \n",
       "Q 934 4750 1428 4750 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "       <path id=\"DejaVuSans-29\" d=\"M 513 4856 \n",
       "L 1013 4856 \n",
       "Q 1481 4119 1714 3412 \n",
       "Q 1947 2706 1947 2009 \n",
       "Q 1947 1309 1714 600 \n",
       "Q 1481 -109 1013 -844 \n",
       "L 513 -844 \n",
       "Q 928 -128 1133 580 \n",
       "Q 1338 1288 1338 2009 \n",
       "Q 1338 2731 1133 3434 \n",
       "Q 928 4138 513 4856 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "      </defs>\n",
       "      <use xlink:href=\"#DejaVuSans-53\"/>\n",
       "      <use xlink:href=\"#DejaVuSans-74\" transform=\"translate(63.476562 0)\"/>\n",
       "      <use xlink:href=\"#DejaVuSans-72\" transform=\"translate(102.685547 0)\"/>\n",
       "      <use xlink:href=\"#DejaVuSans-69\" transform=\"translate(143.798828 0)\"/>\n",
       "      <use xlink:href=\"#DejaVuSans-63\" transform=\"translate(171.582031 0)\"/>\n",
       "      <use xlink:href=\"#DejaVuSans-74\" transform=\"translate(226.5625 0)\"/>\n",
       "      <use xlink:href=\"#DejaVuSans-20\" transform=\"translate(265.771484 0)\"/>\n",
       "      <use xlink:href=\"#DejaVuSans-70\" transform=\"translate(297.558594 0)\"/>\n",
       "      <use xlink:href=\"#DejaVuSans-61\" transform=\"translate(361.035156 0)\"/>\n",
       "      <use xlink:href=\"#DejaVuSans-73\" transform=\"translate(422.314453 0)\"/>\n",
       "      <use xlink:href=\"#DejaVuSans-73\" transform=\"translate(474.414062 0)\"/>\n",
       "      <use xlink:href=\"#DejaVuSans-20\" transform=\"translate(526.513672 0)\"/>\n",
       "      <use xlink:href=\"#DejaVuSans-72\" transform=\"translate(558.300781 0)\"/>\n",
       "      <use xlink:href=\"#DejaVuSans-61\" transform=\"translate(599.414062 0)\"/>\n",
       "      <use xlink:href=\"#DejaVuSans-74\" transform=\"translate(660.693359 0)\"/>\n",
       "      <use xlink:href=\"#DejaVuSans-65\" transform=\"translate(699.902344 0)\"/>\n",
       "      <use xlink:href=\"#DejaVuSans-20\" transform=\"translate(761.425781 0)\"/>\n",
       "      <use xlink:href=\"#DejaVuSans-28\" transform=\"translate(793.212891 0)\"/>\n",
       "      <use xlink:href=\"#DejaVuSans-25\" transform=\"translate(832.226562 0)\"/>\n",
       "      <use xlink:href=\"#DejaVuSans-29\" transform=\"translate(927.246094 0)\"/>\n",
       "     </g>\n",
       "    </g>\n",
       "   </g>\n",
       "   <g id=\"line2d_29\">\n",
       "    <path d=\"M 181.756687 277.816413 \n",
       "L 294.082572 277.816413 \n",
       "L 518.734343 277.816413 \n",
       "\" clip-path=\"url(#p307071d5be)\" style=\"fill: none; stroke: #8c5831; stroke-width: 1.5; stroke-linecap: square\"/>\n",
       "    <defs>\n",
       "     <path id=\"m542ee7c8bc\" d=\"M 0 3 \n",
       "C 0.795609 3 1.55874 2.683901 2.12132 2.12132 \n",
       "C 2.683901 1.55874 3 0.795609 3 0 \n",
       "C 3 -0.795609 2.683901 -1.55874 2.12132 -2.12132 \n",
       "C 1.55874 -2.683901 0.795609 -3 0 -3 \n",
       "C -0.795609 -3 -1.55874 -2.683901 -2.12132 -2.12132 \n",
       "C -2.683901 -1.55874 -3 -0.795609 -3 0 \n",
       "C -3 0.795609 -2.683901 1.55874 -2.12132 2.12132 \n",
       "C -1.55874 2.683901 -0.795609 3 0 3 \n",
       "z\n",
       "\" style=\"stroke: #8c5831\"/>\n",
       "    </defs>\n",
       "    <g clip-path=\"url(#p307071d5be)\">\n",
       "     <use xlink:href=\"#m542ee7c8bc\" x=\"181.756687\" y=\"277.816413\" style=\"fill: #8c5831; stroke: #8c5831\"/>\n",
       "     <use xlink:href=\"#m542ee7c8bc\" x=\"294.082572\" y=\"277.816413\" style=\"fill: #8c5831; stroke: #8c5831\"/>\n",
       "     <use xlink:href=\"#m542ee7c8bc\" x=\"518.734343\" y=\"277.816413\" style=\"fill: #8c5831; stroke: #8c5831\"/>\n",
       "    </g>\n",
       "   </g>\n",
       "   <g id=\"line2d_30\">\n",
       "    <path d=\"M 181.756687 277.816413 \n",
       "L 294.082572 277.816413 \n",
       "L 518.734343 277.816413 \n",
       "\" clip-path=\"url(#p307071d5be)\" style=\"fill: none; stroke: #286556; stroke-width: 1.5; stroke-linecap: square\"/>\n",
       "    <defs>\n",
       "     <path id=\"mb8d0a1108b\" d=\"M 0 3 \n",
       "C 0.795609 3 1.55874 2.683901 2.12132 2.12132 \n",
       "C 2.683901 1.55874 3 0.795609 3 0 \n",
       "C 3 -0.795609 2.683901 -1.55874 2.12132 -2.12132 \n",
       "C 1.55874 -2.683901 0.795609 -3 0 -3 \n",
       "C -0.795609 -3 -1.55874 -2.683901 -2.12132 -2.12132 \n",
       "C -2.683901 -1.55874 -3 -0.795609 -3 0 \n",
       "C -3 0.795609 -2.683901 1.55874 -2.12132 2.12132 \n",
       "C -1.55874 2.683901 -0.795609 3 0 3 \n",
       "z\n",
       "\" style=\"stroke: #286556\"/>\n",
       "    </defs>\n",
       "    <g clip-path=\"url(#p307071d5be)\">\n",
       "     <use xlink:href=\"#mb8d0a1108b\" x=\"181.756687\" y=\"277.816413\" style=\"fill: #286556; stroke: #286556\"/>\n",
       "     <use xlink:href=\"#mb8d0a1108b\" x=\"294.082572\" y=\"277.816413\" style=\"fill: #286556; stroke: #286556\"/>\n",
       "     <use xlink:href=\"#mb8d0a1108b\" x=\"518.734343\" y=\"277.816413\" style=\"fill: #286556; stroke: #286556\"/>\n",
       "    </g>\n",
       "   </g>\n",
       "   <g id=\"patch_3\">\n",
       "    <path d=\"M 46.965625 287.64327 \n",
       "L 46.965625 22.318125 \n",
       "\" style=\"fill: none; stroke: #000000; stroke-width: 0.8; stroke-linejoin: miter; stroke-linecap: square\"/>\n",
       "   </g>\n",
       "   <g id=\"patch_4\">\n",
       "    <path d=\"M 541.19952 287.64327 \n",
       "L 541.19952 22.318125 \n",
       "\" style=\"fill: none; stroke: #000000; stroke-width: 0.8; stroke-linejoin: miter; stroke-linecap: square\"/>\n",
       "   </g>\n",
       "   <g id=\"patch_5\">\n",
       "    <path d=\"M 46.965625 287.64327 \n",
       "L 541.19952 287.64327 \n",
       "\" style=\"fill: none; stroke: #000000; stroke-width: 0.8; stroke-linejoin: miter; stroke-linecap: square\"/>\n",
       "   </g>\n",
       "   <g id=\"patch_6\">\n",
       "    <path d=\"M 46.965625 22.318125 \n",
       "L 541.19952 22.318125 \n",
       "\" style=\"fill: none; stroke: #000000; stroke-width: 0.8; stroke-linejoin: miter; stroke-linecap: square\"/>\n",
       "   </g>\n",
       "   <g id=\"text_17\">\n",
       "    <!-- Optimal outcomes versus token work -->\n",
       "    <g transform=\"translate(182.200385 16.318125) scale(0.12 -0.12)\">\n",
       "     <defs>\n",
       "      <path id=\"DejaVuSans-4f\" d=\"M 2522 4238 \n",
       "Q 1834 4238 1429 3725 \n",
       "Q 1025 3213 1025 2328 \n",
       "Q 1025 1447 1429 934 \n",
       "Q 1834 422 2522 422 \n",
       "Q 3209 422 3611 934 \n",
       "Q 4013 1447 4013 2328 \n",
       "Q 4013 3213 3611 3725 \n",
       "Q 3209 4238 2522 4238 \n",
       "z\n",
       "M 2522 4750 \n",
       "Q 3503 4750 4090 4092 \n",
       "Q 4678 3434 4678 2328 \n",
       "Q 4678 1225 4090 567 \n",
       "Q 3503 -91 2522 -91 \n",
       "Q 1538 -91 948 565 \n",
       "Q 359 1222 359 2328 \n",
       "Q 359 3434 948 4092 \n",
       "Q 1538 4750 2522 4750 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "      <path id=\"DejaVuSans-6c\" d=\"M 603 4863 \n",
       "L 1178 4863 \n",
       "L 1178 0 \n",
       "L 603 0 \n",
       "L 603 4863 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "      <path id=\"DejaVuSans-75\" d=\"M 544 1381 \n",
       "L 544 3500 \n",
       "L 1119 3500 \n",
       "L 1119 1403 \n",
       "Q 1119 906 1312 657 \n",
       "Q 1506 409 1894 409 \n",
       "Q 2359 409 2629 706 \n",
       "Q 2900 1003 2900 1516 \n",
       "L 2900 3500 \n",
       "L 3475 3500 \n",
       "L 3475 0 \n",
       "L 2900 0 \n",
       "L 2900 538 \n",
       "Q 2691 219 2414 64 \n",
       "Q 2138 -91 1772 -91 \n",
       "Q 1169 -91 856 284 \n",
       "Q 544 659 544 1381 \n",
       "z\n",
       "M 1991 3584 \n",
       "L 1991 3584 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "      <path id=\"DejaVuSans-76\" d=\"M 191 3500 \n",
       "L 800 3500 \n",
       "L 1894 563 \n",
       "L 2988 3500 \n",
       "L 3597 3500 \n",
       "L 2284 0 \n",
       "L 1503 0 \n",
       "L 191 3500 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "     </defs>\n",
       "     <use xlink:href=\"#DejaVuSans-4f\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-70\" transform=\"translate(78.710938 0)\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-74\" transform=\"translate(142.1875 0)\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-69\" transform=\"translate(181.396484 0)\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-6d\" transform=\"translate(209.179688 0)\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-61\" transform=\"translate(306.591797 0)\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-6c\" transform=\"translate(367.871094 0)\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-20\" transform=\"translate(395.654297 0)\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-6f\" transform=\"translate(427.441406 0)\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-75\" transform=\"translate(488.623047 0)\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-74\" transform=\"translate(552.001953 0)\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-63\" transform=\"translate(591.210938 0)\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-6f\" transform=\"translate(646.191406 0)\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-6d\" transform=\"translate(707.373047 0)\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-65\" transform=\"translate(804.785156 0)\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-73\" transform=\"translate(866.308594 0)\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-20\" transform=\"translate(918.408203 0)\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-76\" transform=\"translate(950.195312 0)\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-65\" transform=\"translate(1009.375 0)\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-72\" transform=\"translate(1070.898438 0)\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-73\" transform=\"translate(1112.011719 0)\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-75\" transform=\"translate(1164.111328 0)\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-73\" transform=\"translate(1227.490234 0)\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-20\" transform=\"translate(1279.589844 0)\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-74\" transform=\"translate(1311.376953 0)\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-6f\" transform=\"translate(1350.585938 0)\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-6b\" transform=\"translate(1411.767578 0)\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-65\" transform=\"translate(1466.052734 0)\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-6e\" transform=\"translate(1527.576172 0)\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-20\" transform=\"translate(1590.955078 0)\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-77\" transform=\"translate(1622.742188 0)\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-6f\" transform=\"translate(1704.529297 0)\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-72\" transform=\"translate(1765.710938 0)\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-6b\" transform=\"translate(1806.824219 0)\"/>\n",
       "    </g>\n",
       "   </g>\n",
       "   <g id=\"legend_1\">\n",
       "    <g id=\"patch_7\">\n",
       "     <path d=\"M 413.013582 74.3525 \n",
       "L 534.19952 74.3525 \n",
       "Q 536.19952 74.3525 536.19952 72.3525 \n",
       "L 536.19952 29.318125 \n",
       "Q 536.19952 27.318125 534.19952 27.318125 \n",
       "L 413.013582 27.318125 \n",
       "Q 411.013582 27.318125 411.013582 29.318125 \n",
       "L 411.013582 72.3525 \n",
       "Q 411.013582 74.3525 413.013582 74.3525 \n",
       "z\n",
       "\" style=\"fill: #ffffff; opacity: 0.8; stroke: #cccccc; stroke-linejoin: miter\"/>\n",
       "    </g>\n",
       "    <g id=\"line2d_31\">\n",
       "     <path d=\"M 415.013582 35.416562 \n",
       "L 425.013582 35.416562 \n",
       "L 435.013582 35.416562 \n",
       "\" style=\"fill: none; stroke: #8c5831; stroke-width: 1.5; stroke-linecap: square\"/>\n",
       "     <g>\n",
       "      <use xlink:href=\"#m542ee7c8bc\" x=\"425.013582\" y=\"35.416562\" style=\"fill: #8c5831; stroke: #8c5831\"/>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"text_18\">\n",
       "     <!-- Plurality -->\n",
       "     <g transform=\"translate(443.013582 38.916562) scale(0.1 -0.1)\">\n",
       "      <defs>\n",
       "       <path id=\"DejaVuSans-50\" d=\"M 1259 4147 \n",
       "L 1259 2394 \n",
       "L 2053 2394 \n",
       "Q 2494 2394 2734 2622 \n",
       "Q 2975 2850 2975 3272 \n",
       "Q 2975 3691 2734 3919 \n",
       "Q 2494 4147 2053 4147 \n",
       "L 1259 4147 \n",
       "z\n",
       "M 628 4666 \n",
       "L 2053 4666 \n",
       "Q 2838 4666 3239 4311 \n",
       "Q 3641 3956 3641 3272 \n",
       "Q 3641 2581 3239 2228 \n",
       "Q 2838 1875 2053 1875 \n",
       "L 1259 1875 \n",
       "L 1259 0 \n",
       "L 628 0 \n",
       "L 628 4666 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "       <path id=\"DejaVuSans-79\" d=\"M 2059 -325 \n",
       "Q 1816 -950 1584 -1140 \n",
       "Q 1353 -1331 966 -1331 \n",
       "L 506 -1331 \n",
       "L 506 -850 \n",
       "L 844 -850 \n",
       "Q 1081 -850 1212 -737 \n",
       "Q 1344 -625 1503 -206 \n",
       "L 1606 56 \n",
       "L 191 3500 \n",
       "L 800 3500 \n",
       "L 1894 763 \n",
       "L 2988 3500 \n",
       "L 3597 3500 \n",
       "L 2059 -325 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "      </defs>\n",
       "      <use xlink:href=\"#DejaVuSans-50\"/>\n",
       "      <use xlink:href=\"#DejaVuSans-6c\" transform=\"translate(60.302734 0)\"/>\n",
       "      <use xlink:href=\"#DejaVuSans-75\" transform=\"translate(88.085938 0)\"/>\n",
       "      <use xlink:href=\"#DejaVuSans-72\" transform=\"translate(151.464844 0)\"/>\n",
       "      <use xlink:href=\"#DejaVuSans-61\" transform=\"translate(192.578125 0)\"/>\n",
       "      <use xlink:href=\"#DejaVuSans-6c\" transform=\"translate(253.857422 0)\"/>\n",
       "      <use xlink:href=\"#DejaVuSans-69\" transform=\"translate(281.640625 0)\"/>\n",
       "      <use xlink:href=\"#DejaVuSans-74\" transform=\"translate(309.423828 0)\"/>\n",
       "      <use xlink:href=\"#DejaVuSans-79\" transform=\"translate(348.632812 0)\"/>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"line2d_32\">\n",
       "     <path d=\"M 415.013582 50.094687 \n",
       "L 425.013582 50.094687 \n",
       "L 435.013582 50.094687 \n",
       "\" style=\"fill: none; stroke: #286556; stroke-width: 1.5; stroke-linecap: square\"/>\n",
       "     <g>\n",
       "      <use xlink:href=\"#mb8d0a1108b\" x=\"425.013582\" y=\"50.094687\" style=\"fill: #286556; stroke: #286556\"/>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"text_19\">\n",
       "     <!-- Verified -->\n",
       "     <g transform=\"translate(443.013582 53.594687) scale(0.1 -0.1)\">\n",
       "      <defs>\n",
       "       <path id=\"DejaVuSans-56\" d=\"M 1831 0 \n",
       "L 50 4666 \n",
       "L 709 4666 \n",
       "L 2188 738 \n",
       "L 3669 4666 \n",
       "L 4325 4666 \n",
       "L 2547 0 \n",
       "L 1831 0 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "       <path id=\"DejaVuSans-66\" d=\"M 2375 4863 \n",
       "L 2375 4384 \n",
       "L 1825 4384 \n",
       "Q 1516 4384 1395 4259 \n",
       "Q 1275 4134 1275 3809 \n",
       "L 1275 3500 \n",
       "L 2222 3500 \n",
       "L 2222 3053 \n",
       "L 1275 3053 \n",
       "L 1275 0 \n",
       "L 697 0 \n",
       "L 697 3053 \n",
       "L 147 3053 \n",
       "L 147 3500 \n",
       "L 697 3500 \n",
       "L 697 3744 \n",
       "Q 697 4328 969 4595 \n",
       "Q 1241 4863 1831 4863 \n",
       "L 2375 4863 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "      </defs>\n",
       "      <use xlink:href=\"#DejaVuSans-56\"/>\n",
       "      <use xlink:href=\"#DejaVuSans-65\" transform=\"translate(60.658203 0)\"/>\n",
       "      <use xlink:href=\"#DejaVuSans-72\" transform=\"translate(122.181641 0)\"/>\n",
       "      <use xlink:href=\"#DejaVuSans-69\" transform=\"translate(163.294922 0)\"/>\n",
       "      <use xlink:href=\"#DejaVuSans-66\" transform=\"translate(191.078125 0)\"/>\n",
       "      <use xlink:href=\"#DejaVuSans-69\" transform=\"translate(226.283203 0)\"/>\n",
       "      <use xlink:href=\"#DejaVuSans-65\" transform=\"translate(254.066406 0)\"/>\n",
       "      <use xlink:href=\"#DejaVuSans-64\" transform=\"translate(315.589844 0)\"/>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"PathCollection_2\">\n",
       "     <g>\n",
       "      <use xlink:href=\"#mbb570b4417\" x=\"425.013582\" y=\"65.647812\" style=\"fill: #334d68; stroke: #334d68\"/>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"text_20\">\n",
       "     <!-- Exact comparator -->\n",
       "     <g transform=\"translate(443.013582 68.272812) scale(0.1 -0.1)\">\n",
       "      <defs>\n",
       "       <path id=\"DejaVuSans-45\" d=\"M 628 4666 \n",
       "L 3578 4666 \n",
       "L 3578 4134 \n",
       "L 1259 4134 \n",
       "L 1259 2753 \n",
       "L 3481 2753 \n",
       "L 3481 2222 \n",
       "L 1259 2222 \n",
       "L 1259 531 \n",
       "L 3634 531 \n",
       "L 3634 0 \n",
       "L 628 0 \n",
       "L 628 4666 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "       <path id=\"DejaVuSans-78\" d=\"M 3513 3500 \n",
       "L 2247 1797 \n",
       "L 3578 0 \n",
       "L 2900 0 \n",
       "L 1881 1375 \n",
       "L 863 0 \n",
       "L 184 0 \n",
       "L 1544 1831 \n",
       "L 300 3500 \n",
       "L 978 3500 \n",
       "L 1906 2253 \n",
       "L 2834 3500 \n",
       "L 3513 3500 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "      </defs>\n",
       "      <use xlink:href=\"#DejaVuSans-45\"/>\n",
       "      <use xlink:href=\"#DejaVuSans-78\" transform=\"translate(63.183594 0)\"/>\n",
       "      <use xlink:href=\"#DejaVuSans-61\" transform=\"translate(122.363281 0)\"/>\n",
       "      <use xlink:href=\"#DejaVuSans-63\" transform=\"translate(183.642578 0)\"/>\n",
       "      <use xlink:href=\"#DejaVuSans-74\" transform=\"translate(238.623047 0)\"/>\n",
       "      <use xlink:href=\"#DejaVuSans-20\" transform=\"translate(277.832031 0)\"/>\n",
       "      <use xlink:href=\"#DejaVuSans-63\" transform=\"translate(309.619141 0)\"/>\n",
       "      <use xlink:href=\"#DejaVuSans-6f\" transform=\"translate(364.599609 0)\"/>\n",
       "      <use xlink:href=\"#DejaVuSans-6d\" transform=\"translate(425.78125 0)\"/>\n",
       "      <use xlink:href=\"#DejaVuSans-70\" transform=\"translate(523.193359 0)\"/>\n",
       "      <use xlink:href=\"#DejaVuSans-61\" transform=\"translate(586.669922 0)\"/>\n",
       "      <use xlink:href=\"#DejaVuSans-72\" transform=\"translate(647.949219 0)\"/>\n",
       "      <use xlink:href=\"#DejaVuSans-61\" transform=\"translate(689.0625 0)\"/>\n",
       "      <use xlink:href=\"#DejaVuSans-74\" transform=\"translate(750.341797 0)\"/>\n",
       "      <use xlink:href=\"#DejaVuSans-6f\" transform=\"translate(789.550781 0)\"/>\n",
       "      <use xlink:href=\"#DejaVuSans-72\" transform=\"translate(850.732422 0)\"/>\n",
       "     </g>\n",
       "    </g>\n",
       "   </g>\n",
       "  </g>\n",
       " </g>\n",
       " <defs>\n",
       "  <clipPath id=\"p307071d5be\">\n",
       "   <rect x=\"46.965625\" y=\"22.318125\" width=\"494.233895\" height=\"265.325145\"/>\n",
       "  </clipPath>\n",
       " </defs>\n",
       "</svg>\n"
      ],
      "text/plain": [
       "<Figure size 750x440 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "def row_scores(rows):\n",
    "    return [int(row[\"strict_pass\"]) for row in rows]\n",
    "\n",
    "\n",
    "by_arm = {arm: [row for row in case_rows if row[\"arm\"] == arm]\n",
    "          for arm in dict.fromkeys(row[\"arm\"] for row in case_rows)}\n",
    "expected_ids = [order[\"case_id\"] for order in work_orders]\n",
    "for rows in by_arm.values():\n",
    "    assert [row[\"case_id\"] for row in rows] == expected_ids\n",
    "greedy_rows = by_arm[\"greedy_1\"]\n",
    "greedy_correct = sum(row_scores(greedy_rows))\n",
    "greedy_tokens = None if COURSE_SMOKE else sum(row[\"compute_proxy_tokens\"] for row in greedy_rows)\n",
    "scorecard = []\n",
    "for arm, rows in by_arm.items():\n",
    "    scores = row_scores(rows)\n",
    "    correct = sum(scores)\n",
    "    tokens = None if COURSE_SMOKE else sum(row[\"compute_proxy_tokens\"] for row in rows)\n",
    "    gained = sum(new > old for new, old in zip(scores, row_scores(greedy_rows)))\n",
    "    lost = sum(new < old for new, old in zip(scores, row_scores(greedy_rows)))\n",
    "    extra_tokens = tokens - greedy_tokens if tokens is not None and arm != \"exact_reference\" else None\n",
    "    scorecard.append({\n",
    "        \"arm\": arm,\n",
    "        \"cases\": len(rows),\n",
    "        \"correct\": correct,\n",
    "        \"strict_pass_rate\": correct / len(rows),\n",
    "        \"outcomes\": dict(Counter(row[\"outcome\"] for row in rows)),\n",
    "        \"total_compute_proxy_tokens\": tokens,\n",
    "        \"mean_compute_proxy_tokens\": tokens / len(rows) if tokens is not None else None,\n",
    "        \"median_wall_ms\": None if COURSE_SMOKE else median(row[\"comparison_wall_ms\"] for row in rows),\n",
    "        \"gained_vs_greedy\": gained,\n",
    "        \"lost_vs_greedy\": lost,\n",
    "        \"extra_tokens_vs_greedy\": extra_tokens,\n",
    "        \"tokens_per_added_win_vs_greedy\": extra_tokens / (gained - lost)\n",
    "        if extra_tokens is not None and gained > lost else None,\n",
    "    })\n",
    "by_slice = []\n",
    "for category in SLICES:\n",
    "    for arm, rows in by_arm.items():\n",
    "        slice_rows = [row for row in rows if row[\"slice\"] == category]\n",
    "        by_slice.append({\"slice\": category, \"arm\": arm, \"n\": len(slice_rows),\n",
    "                         \"correct\": sum(row_scores(slice_rows))})\n",
    "\n",
    "generation_card = []\n",
    "for samples in SAMPLE_COUNTS:\n",
    "    rows = [row for row in generation_rows if row[\"samples\"] == samples]\n",
    "    assert [row[\"case_id\"] for row in rows] == expected_ids\n",
    "    peak_bytes = [row[\"peak_allocated_bytes\"] for row in rows if row[\"peak_allocated_bytes\"] is not None]\n",
    "    extra_bytes = [row[\"peak_above_idle_bytes\"] for row in rows if row[\"peak_above_idle_bytes\"] is not None]\n",
    "    generation_card.append({\n",
    "        \"samples\": samples, \"cases\": len(rows),\n",
    "        \"with_feasible\": sum(row[\"has_feasible\"] for row in rows),\n",
    "        \"with_optimal\": sum(row[\"has_optimal\"] for row in rows),\n",
    "        \"median_distinct_parsed_pairs\": median(row[\"distinct_parsed_pairs\"] for row in rows),\n",
    "        \"median_generation_ms\": None if COURSE_SMOKE else median(row[\"generation_wall_ms\"] for row in rows),\n",
    "        \"peak_allocated_bytes\": [min(peak_bytes), median(peak_bytes), max(peak_bytes)] if peak_bytes else None,\n",
    "        \"peak_above_idle_bytes\": [min(extra_bytes), median(extra_bytes), max(extra_bytes)] if extra_bytes else None,\n",
    "    })\n",
    "\n",
    "comparisons = [(arm, \"greedy_1\") for arm in by_arm if arm != \"greedy_1\"]\n",
    "comparisons += [(f\"verified_{samples}\", f\"plurality_{samples}\") for samples in SAMPLE_COUNTS if samples > 1]\n",
    "intervals = []\n",
    "for candidate_arm, incumbent_arm in comparisons:\n",
    "    candidate_scores = row_scores(by_arm[candidate_arm])\n",
    "    incumbent_scores = row_scores(by_arm[incumbent_arm])\n",
    "    intervals.append({\n",
    "        \"candidate\": candidate_arm, \"incumbent\": incumbent_arm,\n",
    "        **paired_interval(work_orders, candidate_scores, incumbent_scores, draws=BOOTSTRAP_DRAWS),\n",
    "        \"gained\": sum(new > old for new, old in zip(candidate_scores, incumbent_scores)),\n",
    "        \"lost\": sum(new < old for new, old in zip(candidate_scores, incumbent_scores)),\n",
    "    })\n",
    "qualifying_arms = [\n",
    "    row for row in scorecard if not COURSE_SMOKE and row[\"arm\"] != \"exact_reference\"\n",
    "    and row[\"strict_pass_rate\"] >= MINIMUM_MODEL_PASS_RATE\n",
    "]\n",
    "candidate = min(qualifying_arms, key=lambda row: row[\"total_compute_proxy_tokens\"], default=None)\n",
    "configured_workload = {\n",
    "    \"cases\": len(work_orders), \"families\": len(dev_assets), \"slices\": list(SLICES),\n",
    "    \"sample_counts\": SAMPLE_COUNTS, \"max_new_tokens\": TOKEN_LIMIT,\n",
    "    \"temperature\": SAMPLING_TEMPERATURE, \"top_p\": TOP_P, \"bootstrap_draws\": BOOTSTRAP_DRAWS,\n",
    "    \"model\": MODEL_IDS[\"text\"][0], \"model_revision\": MODEL_IDS[\"text\"][1],\n",
    "    \"development_split\": SPLIT_MANIFEST[ACTIVE_SPLIT],\n",
    "}\n",
    "results = {\n",
    "    \"mode\": \"constructed_fixtures\" if COURSE_SMOKE else \"development_model_comparison\",\n",
    "    \"split\": ACTIVE_SPLIT,\n",
    "    \"model_load_ms\": load_ms,\n",
    "    \"lab_elapsed_ms\": None if COURSE_SMOKE else (perf_counter() - run_started) * 1000,\n",
    "    \"workload\": configured_workload,\n",
    "    \"model_quality_target\": MINIMUM_MODEL_PASS_RATE,\n",
    "    \"budget_candidate\": candidate,\n",
    "    \"scorecard\": scorecard,\n",
    "    \"by_slice\": by_slice,\n",
    "    \"candidate_batches\": generation_card,\n",
    "    \"paired_intervals\": intervals,\n",
    "}\n",
    "print(\"Development evidence:\", json.dumps(results, default=_convert))\n",
    "print(\"First and warm generation receipt:\", first_and_warm)\n",
    "opening_ids = set(expected_ids[:2])\n",
    "print(\"Opening decisions:\", [row for row in case_rows if row[\"case_id\"] in opening_ids])\n",
    "print(\"Opening proposals:\", [row for row in generation_rows if row[\"case_id\"] in opening_ids])\n",
    "save(\"summary\", results)\n",
    "save(\"records\", {\n",
    "    \"mode\": results[\"mode\"],\n",
    "    \"work_orders\": work_orders, \"policies\": case_rows,\n",
    "    \"generations\": generation_rows, \"first_and_warm\": first_and_warm,\n",
    "})\n",
    "if COURSE_SMOKE:\n",
    "    chart(\"Strictly optimal work orders by policy\", [row[\"arm\"] for row in scorecard],\n",
    "          [row[\"strict_pass_rate\"] * 100 for row in scorecard], \"Percent of work orders\")\n",
    "else:\n",
    "    import matplotlib.pyplot as plt\n",
    "\n",
    "    score_by_arm = {row[\"arm\"]: row for row in scorecard}\n",
    "    figure, axis = plt.subplots(figsize=(7.5, 4.4), layout=\"constrained\")\n",
    "    for policy, color in ((\"plurality\", \"#8c5831\"), (\"verified\", \"#286556\")):\n",
    "        series = [score_by_arm[\"greedy_1\"], score_by_arm[f\"{policy}_2\"], score_by_arm[f\"{policy}_4\"]]\n",
    "        axis.plot(\n",
    "            [row[\"mean_compute_proxy_tokens\"] for row in series],\n",
    "            [row[\"strict_pass_rate\"] * 100 for row in series],\n",
    "            marker=\"o\", color=color, label=policy.capitalize(),\n",
    "        )\n",
    "    axis.scatter([0], [score_by_arm[\"exact_reference\"][\"strict_pass_rate\"] * 100],\n",
    "                 color=\"#334d68\", marker=\"s\", label=\"Exact comparator\")\n",
    "    axis.set(\n",
    "        title=\"Optimal outcomes versus token work\",\n",
    "        xlabel=\"Mean prompt and generated tokens per work order\",\n",
    "        ylabel=\"Strict pass rate (%)\",\n",
    "        ylim=(-4, 104),\n",
    "    )\n",
    "    axis.grid(alpha=0.22)\n",
    "    axis.legend(loc=\"best\")\n",
    "    figure.savefig(Path(\"evidence\") / \"quality-versus-compute.svg\")\n",
    "    plt.show()\n",
    "    plt.close(figure)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "lab-03-19",
   "metadata": {},
   "source": [
    "Inspect cases where a larger sample set contains a good pair but voting\n",
    "does not choose it. Separate failure to produce a feasible candidate\n",
    "from failure to rank it. The exact comparator is tractable because the\n",
    "input contains five candidates and only two can be chosen. Increasing\n",
    "shortlist length, allowing several picks, or adding a harder constraint\n",
    "changes that comparison. Keep those workloads separate from this result.\n",
    "\n",
    "[Read the lesson and compare the measured results](https://docs.recohut.com/courses/advanced-ai-systems-engineering/1-measure-the-model/03-spend-inference-compute)."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "lab-03-20",
   "metadata": {},
   "source": [
    "## Read the result\n",
    "\n",
    "Inspect the per-case records in `evidence/` before drawing a conclusion from an aggregate. Use the printed sample size, split and hardware when comparing it with another run.\n",
    "\n",
    "- [Scaling LLM Test-Time Compute Optimally can be More Effective than Scaling Model Parameters](https://arxiv.org/abs/2408.03314)"
   ]
  }
 ],
 "metadata": {
  "course": {
   "lab": 3,
   "slug": "03-spend-inference-compute"
  },
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.13.16"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
