{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "lab-11-00",
   "metadata": {},
   "source": [
    "# 11 · Benchmark inference serving\n",
    "\n",
    "Which changes improve throughput without hurting the slowest requests?\n",
    "\n",
    "Replay a fixed short and long request mix. Sweep batch and concurrency first. Compare the frozen model in a supported quantised format only after a correctness check. Profile each serving configuration before making runtime claims.\n",
    "\n",
    "**Measures** — Time to first token, p95 total latency, requests per second, peak memory and quality drift.\n",
    "\n",
    "**Evidence** — Load-test trace, comparable configuration records and a capacity envelope.\n",
    "\n",
    "**Runtime** — One T4, serving compatibility profile. The course bench uses invented facilities, equipment and records."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "lab-11-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-11-02",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-11-27T07:32:10.859987Z",
     "iopub.status.busy": "2026-11-27T07:32:10.859683Z",
     "iopub.status.idle": "2026-11-27T07:32:10.876023Z",
     "shell.execute_reply": "2026-11-27T07:32:10.875169Z"
    }
   },
   "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-11-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-11-04",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-11-27T07:32:10.879427Z",
     "iopub.status.busy": "2026-11-27T07:32:10.878873Z",
     "iopub.status.idle": "2026-11-27T07:32:10.896358Z",
     "shell.execute_reply": "2026-11-27T07:32:10.895630Z"
    }
   },
   "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 = 11\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-11-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-11-06",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-11-27T07:32:10.899379Z",
     "iopub.status.busy": "2026-11-27T07:32:10.899033Z",
     "iopub.status.idle": "2026-11-27T07:32:10.906939Z",
     "shell.execute_reply": "2026-11-27T07:32:10.906140Z"
    }
   },
   "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-11-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-11-08",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-11-27T07:32:10.909996Z",
     "iopub.status.busy": "2026-11-27T07:32:10.909712Z",
     "iopub.status.idle": "2026-11-27T07:32:10.919817Z",
     "shell.execute_reply": "2026-11-27T07:32:10.919091Z"
    }
   },
   "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-11-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-11-10",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-11-27T07:32:10.923252Z",
     "iopub.status.busy": "2026-11-27T07:32:10.922904Z",
     "iopub.status.idle": "2026-11-27T07:32:18.131228Z",
     "shell.execute_reply": "2026-11-27T07:32:18.130330Z"
    }
   },
   "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-11-11",
   "metadata": {},
   "source": [
    "### Which dispatch should the Facilities Helpdesk use?\n",
    "\n",
    "Open [Benchmark inference serving](https://docs.recohut.com/courses/advanced-ai-systems-engineering/4-operate-and-release/11-benchmark-inference-serving)\n",
    "alongside the notebook. A request to classify the priority of fan F-250 arrives\n",
    "with three others. Keep all four tickets, their order and the answer contract\n",
    "fixed. Predict what changes when the dispatcher groups requests instead of\n",
    "starting each alone.\n",
    "\n",
    "The priority board and its answers are synthetic. It isolates serving\n",
    "performance with known short and long inputs and a fixed token budget. This\n",
    "workload does not use the registered release split or grade manual reading.\n",
    "\n",
    "[NVIDIA benchmarking walkthrough](https://nvidia.github.io/TensorRT-LLM/developer-guide/perf-benchmarking.html)\n",
    "· [MLPerf closed- and open-arrival scenarios](https://github.com/mlcommons/inference_policies/blob/master/inference_rules.adoc)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "lab-11-12",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-11-27T07:32:18.135079Z",
     "iopub.status.busy": "2026-11-27T07:32:18.134602Z",
     "iopub.status.idle": "2026-11-27T07:32:18.143813Z",
     "shell.execute_reply": "2026-11-27T07:32:18.142852Z"
    }
   },
   "outputs": [],
   "source": [
    "from dataclasses import asdict, dataclass\n",
    "import gc\n",
    "from time import perf_counter\n",
    "\n",
    "import numpy as np\n",
    "\n",
    "\n",
    "@dataclass(frozen=True)\n",
    "class ServingRequest:\n",
    "    request_id: str\n",
    "    asset: str\n",
    "    kind: str\n",
    "    prompt: str\n",
    "    expected: str\n",
    "\n",
    "\n",
    "def serving_inputs(count):\n",
    "    \"\"\"Make a deterministic priority queue with a fixed short and long mix.\"\"\"\n",
    "    queue = []\n",
    "    for i in range(count):\n",
    "        long = i % 4 in (1, 2)\n",
    "        asset = \"F-250\" if i == 1 else f\"P-{i:03}\"\n",
    "        label = str(2 + i % 7)\n",
    "        distractors = \"\\n\".join(\n",
    "            f\"Asset F-{j:02} has priority 1; maintenance note archived.\"\n",
    "            for j in range(22 if long else 1)\n",
    "        )\n",
    "        prompt = (\n",
    "            f\"{distractors}\\nAsset {asset} has priority {label}. \"\n",
    "            f\"What is the priority of {asset}? Reply only with the digit.\"\n",
    "        )\n",
    "        queue.append(ServingRequest(f\"load-{i:03}\", asset, \"long\" if long else \"short\", prompt, label))\n",
    "    return queue\n",
    "\n",
    "\n",
    "def waves(items, concurrency, batch_size):\n",
    "    \"\"\"Yield simultaneous arrivals, grouped into FIFO dispatches.\"\"\"\n",
    "    for offset in range(0, len(items), concurrency):\n",
    "        wave = items[offset : offset + concurrency]\n",
    "        yield [wave[i : i + batch_size] for i in range(0, len(wave), batch_size)]"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "lab-11-13",
   "metadata": {},
   "source": [
    "### What does changing batch size leave fixed?\n",
    "\n",
    "Four outstanding tickets can enter four dispatches of one or one dispatch\n",
    "of four. The next group waits until the earlier group has finished. This\n",
    "generates a closed-loop load with no HTTP traffic, streaming or continuous\n",
    "batching. Its throughput depends on that arrival pattern."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "lab-11-14",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-11-27T07:32:18.147218Z",
     "iopub.status.busy": "2026-11-27T07:32:18.146856Z",
     "iopub.status.idle": "2026-11-27T07:32:18.154507Z",
     "shell.execute_reply": "2026-11-27T07:32:18.153845Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Outstanding 1 batch cap 1\n",
      "Outstanding 2 batch cap 1\n",
      "Outstanding 2 batch cap 2\n",
      "Outstanding 4 batch cap 1\n",
      "Outstanding 4 batch cap 4\n"
     ]
    }
   ],
   "source": [
    "CONFIGURATIONS = [(1, 1), (2, 1), (2, 2), (4, 1), (4, 4)]\n",
    "REQUEST_COUNT = 100\n",
    "DECODE_STEPS = 6\n",
    "WARMUP_REQUESTS = 8\n",
    "PROBE_COUNT = 12\n",
    "TAIL_RESAMPLES = 1_500\n",
    "TAIL_SEED = 11\n",
    "\n",
    "serving_queue = serving_inputs(REQUEST_COUNT)\n",
    "assert len({request.request_id for request in serving_queue}) == REQUEST_COUNT\n",
    "assert sum(request.kind == \"long\" for request in serving_queue) == REQUEST_COUNT // 2\n",
    "for concurrency, batch_size in CONFIGURATIONS:\n",
    "    replay_order = [\n",
    "        request\n",
    "        for wave in waves(serving_queue, concurrency, batch_size)\n",
    "        for group in wave\n",
    "        for request in group\n",
    "    ]\n",
    "    assert replay_order == serving_queue\n",
    "    print(\"Outstanding\", concurrency, \"batch cap\", batch_size)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "lab-11-15",
   "metadata": {},
   "source": [
    "### Where does F-250 wait?\n",
    "\n",
    "Read the same four opening tickets in FIFO order. Until you see the measured\n",
    "times, only the order and group boundaries are known."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "lab-11-16",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-11-27T07:32:18.158008Z",
     "iopub.status.busy": "2026-11-27T07:32:18.157247Z",
     "iopub.status.idle": "2026-11-27T07:32:18.163711Z",
     "shell.execute_reply": "2026-11-27T07:32:18.162630Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Opening dispatch {'concurrency': 4, 'batch_size': 1, 'groups': [['load-000'], ['load-001'], ['load-002'], ['load-003']]}\n",
      "Opening dispatch {'concurrency': 4, 'batch_size': 4, 'groups': [['load-000', 'load-001', 'load-002', 'load-003']]}\n"
     ]
    }
   ],
   "source": [
    "opening = {\n",
    "    \"highlight_id\": \"load-001\",\n",
    "    \"requests\": [asdict(request) for request in serving_queue[:4]],\n",
    "    \"dispatches\": [\n",
    "        {\n",
    "            \"concurrency\": 4,\n",
    "            \"batch_size\": batch_size,\n",
    "            \"groups\": [\n",
    "                [request.request_id for request in batch]\n",
    "                for batch in next(waves(serving_queue, 4, batch_size))\n",
    "            ],\n",
    "        }\n",
    "        for batch_size in (1, 4)\n",
    "    ],\n",
    "}\n",
    "assert opening[\"requests\"][1][\"asset\"] == \"F-250\"\n",
    "for plan in opening[\"dispatches\"]:\n",
    "    print(\"Opening dispatch\", plan)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "lab-11-17",
   "metadata": {},
   "source": [
    "### Where are the timing boundaries?\n",
    "\n",
    "Time to first token begins at the wave's arrival and ends when the first\n",
    "token IDs reach the host. Tokenisation, dispatch wait and prefill are inside\n",
    "this interval. Total latency ends after the fixed continuation is decoded to\n",
    "text in Python. There is no network or user-visible streaming in the timer.\n",
    "\n",
    "Left padding puts the real final prompt token at the end of every row. Physical\n",
    "cache positions include the padding. Rotary positions for the real tokens\n",
    "count along each row's unpadded text."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "lab-11-18",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-11-27T07:32:18.167013Z",
     "iopub.status.busy": "2026-11-27T07:32:18.166641Z",
     "iopub.status.idle": "2026-11-27T07:32:18.176417Z",
     "shell.execute_reply": "2026-11-27T07:32:18.175735Z"
    }
   },
   "outputs": [],
   "source": [
    "def timed_decoder(model, tokenizer, requests, steps):\n",
    "    import torch\n",
    "    from transformers import DynamicCache\n",
    "\n",
    "    device = model.device\n",
    "    chats = [\n",
    "        tokenizer.apply_chat_template(\n",
    "            [{\"role\": \"user\", \"content\": request.prompt}],\n",
    "            tokenize=False,\n",
    "            add_generation_prompt=True,\n",
    "        )\n",
    "        for request in requests\n",
    "    ]\n",
    "    encoded = tokenizer(chats, return_tensors=\"pt\", padding=True, add_special_tokens=False).to(device)\n",
    "    input_ids = encoded.input_ids\n",
    "    mask = encoded.attention_mask\n",
    "    input_lengths = mask.sum(dim=1).tolist()\n",
    "    padded_input_tokens = input_ids.shape[1]\n",
    "    position_ids = (mask.cumsum(dim=1) - 1).clamp_min(0)\n",
    "    cache_positions = torch.arange(padded_input_tokens, device=device)\n",
    "    cache = DynamicCache()\n",
    "    generated = []\n",
    "    with torch.inference_mode():\n",
    "        for index in range(steps):\n",
    "            result = model(\n",
    "                input_ids=input_ids,\n",
    "                attention_mask=mask,\n",
    "                position_ids=position_ids,\n",
    "                cache_position=cache_positions,\n",
    "                past_key_values=cache,\n",
    "                use_cache=True,\n",
    "                logits_to_keep=1,\n",
    "            )\n",
    "            cache = result.past_key_values\n",
    "            token = result.logits[:, -1].argmax(dim=-1, keepdim=True)\n",
    "            generated.append(token)\n",
    "            if index == 0:\n",
    "                first_ids = token.cpu()\n",
    "                first_at = perf_counter()\n",
    "            input_ids = token\n",
    "            position_ids = mask.sum(dim=1, keepdim=True)\n",
    "            mask = torch.cat([mask, mask.new_ones((mask.shape[0], 1))], dim=1)\n",
    "            cache_positions = cache_positions[-1:] + 1\n",
    "        generated_ids = torch.cat(generated, dim=1).cpu()\n",
    "    outputs = tokenizer.batch_decode(generated_ids, skip_special_tokens=True)\n",
    "    first_outputs = tokenizer.batch_decode(first_ids, skip_special_tokens=True)\n",
    "    return {\n",
    "        \"first_at\": first_at,\n",
    "        \"finished_at\": perf_counter(),\n",
    "        \"inputs\": input_lengths,\n",
    "        \"padded_input_tokens\": padded_input_tokens,\n",
    "        \"first_outputs\": first_outputs,\n",
    "        \"outputs\": outputs,\n",
    "        \"token_ids\": generated_ids,\n",
    "        \"encoded\": encoded,\n",
    "    }"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "lab-11-19",
   "metadata": {},
   "source": [
    "### Does cached decoding preserve the first two tokens?\n",
    "\n",
    "Check the first token against the library generator and replay the full prefix\n",
    "to check the second. Then record the raw first token and expected digit. The\n",
    "token parity check compares decoding implementations within one format. The\n",
    "digit check asks a separate question about the response."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "lab-11-20",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-11-27T07:32:18.179392Z",
     "iopub.status.busy": "2026-11-27T07:32:18.178996Z",
     "iopub.status.idle": "2026-11-27T07:32:18.186297Z",
     "shell.execute_reply": "2026-11-27T07:32:18.185227Z"
    }
   },
   "outputs": [],
   "source": [
    "def correctness_probe(model, tokenizer, requests):\n",
    "    import torch\n",
    "\n",
    "    result = timed_decoder(model, tokenizer, requests, steps=2)\n",
    "    encoded = result[\"encoded\"]\n",
    "    with torch.inference_mode():\n",
    "        library_first = model.generate(\n",
    "            **encoded, max_new_tokens=1, do_sample=False,\n",
    "            temperature=None, top_p=None, top_k=None, pad_token_id=tokenizer.pad_token_id,\n",
    "        )[:, -1:]\n",
    "        assert torch.equal(library_first.cpu(), result[\"token_ids\"][:, :1]), \"First token diverged\"\n",
    "        ids = torch.cat([encoded.input_ids, library_first], dim=1)\n",
    "        mask = encoded.attention_mask\n",
    "        mask = torch.cat([mask, mask.new_ones((mask.shape[0], 1))], dim=1)\n",
    "        raw = model(\n",
    "            input_ids=ids, attention_mask=mask,\n",
    "            position_ids=(mask.cumsum(dim=1) - 1).clamp_min(0),\n",
    "            use_cache=False,\n",
    "            logits_to_keep=1,\n",
    "        ).logits[:, -1]\n",
    "        uncached_second = raw.argmax(dim=-1).cpu()\n",
    "    assert torch.equal(uncached_second, result[\"token_ids\"][:, 1]), \"Cached decode diverged\"\n",
    "    assert result[\"first_at\"] <= result[\"finished_at\"]\n",
    "    return [\n",
    "        {**asdict(request), \"raw_first_token\": text, \"exact_first_token\": text.strip() == request.expected}\n",
    "        for request, text in zip(requests, result[\"first_outputs\"])\n",
    "    ]"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "lab-11-21",
   "metadata": {},
   "source": [
    "### How do we count a failed request?\n",
    "\n",
    "Record each accepted request exactly once. A failed request has a terminal\n",
    "latency and no first-token observation. Keep it in total-latency percentiles\n",
    "and the failure count, and exclude it from the completed-request numerator."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "lab-11-22",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-11-27T07:32:18.189390Z",
     "iopub.status.busy": "2026-11-27T07:32:18.188846Z",
     "iopub.status.idle": "2026-11-27T07:32:18.205405Z",
     "shell.execute_reply": "2026-11-27T07:32:18.204547Z"
    }
   },
   "outputs": [],
   "source": [
    "def replay(items, concurrency, batch_size, phase, decode, steps):\n",
    "    records = []\n",
    "    overall_start = perf_counter()\n",
    "    for wave_index, wave in enumerate(waves(items, concurrency, batch_size)):\n",
    "        accepted_at = perf_counter()\n",
    "        for dispatch_index, batch in enumerate(wave):\n",
    "            dispatch_at = perf_counter()\n",
    "            queue_ms = 1e3 * (dispatch_at - accepted_at)\n",
    "            common = dict(phase=phase, wave=wave_index, dispatch=dispatch_index,\n",
    "                          actual_batch_size=len(batch), queue_ms=queue_ms)\n",
    "            try:\n",
    "                measured = decode(batch, steps)\n",
    "            except (RuntimeError, ValueError) as exc:\n",
    "                terminal_ms = 1e3 * (perf_counter() - accepted_at)\n",
    "                records.extend(\n",
    "                    dict(request_id=r.request_id, kind=r.kind, **common,\n",
    "                         status=type(exc).__name__, ttft_ms=None, total_ms=terminal_ms,\n",
    "                         input_tokens=None, padded_input_tokens=None, generated_tokens=0,\n",
    "                         raw_first_token=None, raw_continuation=None, exact_first_token=False)\n",
    "                    for r in batch\n",
    "                )\n",
    "                continue\n",
    "            assert len(batch) == len(measured[\"outputs\"]) == len(measured[\"inputs\"]) == len(measured[\"first_outputs\"])\n",
    "            for request, size, first, text in zip(\n",
    "                batch, measured[\"inputs\"], measured[\"first_outputs\"], measured[\"outputs\"]\n",
    "            ):\n",
    "                records.append(dict(\n",
    "                    request_id=request.request_id, kind=request.kind, **common, status=\"ok\",\n",
    "                    ttft_ms=1e3 * (measured[\"first_at\"] - accepted_at),\n",
    "                    total_ms=1e3 * (measured[\"finished_at\"] - accepted_at),\n",
    "                    input_tokens=size, padded_input_tokens=measured[\"padded_input_tokens\"],\n",
    "                    generated_tokens=steps, raw_first_token=first, raw_continuation=text,\n",
    "                    exact_first_token=first.strip() == request.expected,\n",
    "                ))\n",
    "    return records, perf_counter() - overall_start\n",
    "\n",
    "\n",
    "def percentile(rows, key, q):\n",
    "    values = [r[key] for r in rows if r[key] is not None]\n",
    "    return float(np.quantile(values, q)) if values else None\n",
    "\n",
    "\n",
    "def summarize_replay(rows, elapsed, peak_mib):\n",
    "    completed = sum(row[\"status\"] == \"ok\" for row in rows)\n",
    "    useful = sum(row[\"input_tokens\"] or 0 for row in rows)\n",
    "    allocated = sum(row[\"padded_input_tokens\"] or 0 for row in rows)\n",
    "    return dict(\n",
    "        n=len(rows), completed=completed, failures=len(rows) - completed, elapsed_seconds=elapsed,\n",
    "        p50_ttft_ms=percentile(rows, \"ttft_ms\", .50), p95_ttft_ms=percentile(rows, \"ttft_ms\", .95),\n",
    "        p95_queue_ms=percentile(rows, \"queue_ms\", .95),\n",
    "        p95_total_ms=percentile(rows, \"total_ms\", .95), throughput_rps=completed / elapsed,\n",
    "        peak_mib=peak_mib, logical_prompt_tokens=useful, dense_prompt_positions=allocated,\n",
    "        exact_first_tokens=sum(row[\"exact_first_token\"] for row in rows),\n",
    "    )\n",
    "\n",
    "\n",
    "def paired_digits(baseline, candidate):\n",
    "    assert [r[\"request_id\"] for r in baseline] == [r[\"request_id\"] for r in candidate]\n",
    "    return dict(\n",
    "        n=len(baseline),\n",
    "        baseline_only=sum(a[\"exact_first_token\"] and not b[\"exact_first_token\"] for a, b in zip(baseline, candidate)),\n",
    "        candidate_only=sum(b[\"exact_first_token\"] and not a[\"exact_first_token\"] for a, b in zip(baseline, candidate)),\n",
    "        text_changes=sum(a[\"raw_first_token\"] != b[\"raw_first_token\"] for a, b in zip(baseline, candidate)),\n",
    "    )\n",
    "\n",
    "\n",
    "def paired_tail(baseline, candidate):\n",
    "    \"\"\"Keep requests sharing a wave together when resampling the p95 contrast.\"\"\"\n",
    "    assert [(r[\"request_id\"], r[\"wave\"]) for r in baseline] == [\n",
    "        (r[\"request_id\"], r[\"wave\"]) for r in candidate\n",
    "    ]\n",
    "    groups = {}\n",
    "    for first, second in zip(baseline, candidate):\n",
    "        groups.setdefault(first[\"wave\"], []).append([first[\"total_ms\"], second[\"total_ms\"]])\n",
    "    waves_to_draw = [np.array(group) for group in groups.values()]\n",
    "\n",
    "    def contrast(paired):\n",
    "        base_p95, candidate_p95 = np.quantile(paired, .95, axis=0)\n",
    "        return float(candidate_p95 - base_p95)\n",
    "\n",
    "    rng = np.random.default_rng(TAIL_SEED)\n",
    "    draws = [\n",
    "        contrast(np.concatenate([waves_to_draw[index] for index in indices]))\n",
    "        for indices in rng.integers(len(waves_to_draw), size=(TAIL_RESAMPLES, len(waves_to_draw)))\n",
    "    ]\n",
    "    low, high = np.quantile(draws, [.025, .975]).tolist()\n",
    "    return dict(p95_total_delta_ms=contrast(np.concatenate(waves_to_draw)),\n",
    "                p95_total_low_ms=low, p95_total_high_ms=high, paired_waves=len(waves_to_draw))"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "lab-11-23",
   "metadata": {},
   "source": [
    "### How should we compare precision formats?\n",
    "\n",
    "Replay the same queue in FP16 and in NF4 if the latter loads and passes the\n",
    "parity probe on this runtime. NF4 changes weight storage; the matrix\n",
    "computation uses FP16. Separate a load or parity failure from quality drift\n",
    "on successful runs. The initial short replay follows the correctness probe\n",
    "and may reuse kernels, so it is not a cold-start measurement.\n",
    "\n",
    "[Transformers cache documentation](https://huggingface.co/docs/transformers/v4.51.3/cache_explanation)\n",
    "· [bitsandbytes quantisation](https://huggingface.co/docs/transformers/v4.51.3/quantization/bitsandbytes)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "lab-11-24",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-11-27T07:32:18.208922Z",
     "iopub.status.busy": "2026-11-27T07:32:18.208290Z",
     "iopub.status.idle": "2026-11-27T07:32:18.224345Z",
     "shell.execute_reply": "2026-11-27T07:32:18.223613Z"
    }
   },
   "outputs": [],
   "source": [
    "def run_serving():\n",
    "    import torch\n",
    "\n",
    "    assert \"T4\" in device_name(), \"Run the capacity experiment on a Colab T4\"\n",
    "    probe_queue = [\n",
    "        *serving_queue[:4],\n",
    "        *[\n",
    "            ServingRequest(\n",
    "                f\"probe-{i:02}\", f\"PT-{i}\", \"short\",\n",
    "                f\"Equipment PT-{i} is in zone {i % 7 + 2}. Reply with only its zone digit.\",\n",
    "                str(i % 7 + 2),\n",
    "            )\n",
    "            for i in range(PROBE_COUNT - 4)\n",
    "        ],\n",
    "    ]\n",
    "    formats = {}\n",
    "    summaries = []\n",
    "    traces = []\n",
    "    slices = []\n",
    "    probes = []\n",
    "    schedule_pairs = []\n",
    "    for format_name in (\"fp16\", \"nf4\"):\n",
    "        start_load = perf_counter()\n",
    "        try:\n",
    "            tokenizer, model = load_text(quant=(format_name == \"nf4\"))\n",
    "            tokenizer.padding_side = \"left\"\n",
    "            sync()\n",
    "            load_ms = 1e3 * (perf_counter() - start_load)\n",
    "        except (ImportError, RuntimeError, ValueError) as exc:\n",
    "            if format_name == \"fp16\":\n",
    "                raise\n",
    "            formats[format_name] = dict(status=\"load_failed\", error_type=type(exc).__name__)\n",
    "            print(\"NF4_LOAD_FAILED\", type(exc).__name__, str(exc))\n",
    "            break\n",
    "        try:\n",
    "            quality = [\n",
    "                outcome for group in waves(probe_queue, 4, 4)\n",
    "                for outcome in correctness_probe(model, tokenizer, group[0])\n",
    "            ]\n",
    "        except (RuntimeError, ValueError, AssertionError) as exc:\n",
    "            if format_name == \"fp16\":\n",
    "                raise\n",
    "            formats[format_name] = dict(status=\"parity_failed\", load_ms=load_ms, error_type=type(exc).__name__)\n",
    "            print(\"NF4_PARITY_FAILED\", type(exc).__name__, str(exc))\n",
    "            del model, tokenizer\n",
    "            gc.collect()\n",
    "            torch.cuda.empty_cache()\n",
    "            break\n",
    "        formats[format_name] = dict(status=\"ok\", load_ms=load_ms, probe_n=len(quality),\n",
    "                                    probe_exact=sum(row[\"exact_first_token\"] for row in quality))\n",
    "        probes.extend({**row, \"format\": format_name} for row in quality)\n",
    "\n",
    "        def decode(batch, steps):\n",
    "            return timed_decoder(model, tokenizer, batch, steps)\n",
    "\n",
    "        warm_results = {}\n",
    "        for concurrency, batch_size in CONFIGURATIONS:\n",
    "            labels = dict(format=format_name, concurrency=concurrency, batch_size=batch_size)\n",
    "            for phase, items in (\n",
    "                (\"prewarm\", serving_queue[:concurrency]),\n",
    "                (\"warmup\", serving_queue[:WARMUP_REQUESTS]),\n",
    "                (\"warm\", serving_queue),\n",
    "            ):\n",
    "                torch.cuda.reset_peak_memory_stats(model.device)\n",
    "                rows, duration = replay(items, concurrency, batch_size, phase, decode, DECODE_STEPS)\n",
    "                peak_mib = torch.cuda.max_memory_allocated(model.device) / 2**20\n",
    "                if phase == \"warmup\":\n",
    "                    continue\n",
    "                assert [row[\"request_id\"] for row in rows] == [request.request_id for request in items]\n",
    "                traces.extend({**row, **labels} for row in rows)\n",
    "                summaries.append({**labels, \"phase\": phase, **summarize_replay(rows, duration, peak_mib)})\n",
    "                if phase == \"warm\":\n",
    "                    warm_results[(concurrency, batch_size)] = rows\n",
    "                    for kind in (\"short\", \"long\"):\n",
    "                        group = [row for row in rows if row[\"kind\"] == kind]\n",
    "                        slices.append({**labels, \"kind\": kind, \"n\": len(group),\n",
    "                                       \"p95_total_ms\": percentile(group, \"total_ms\", .95),\n",
    "                                       \"p95_ttft_ms\": percentile(group, \"ttft_ms\", .95)})\n",
    "        schedule_pairs.extend(\n",
    "            dict(format=format_name, concurrency=concurrency, baseline_batch=1, candidate_batch=concurrency,\n",
    "                 **paired_digits(warm_results[(concurrency, 1)], warm_results[(concurrency, concurrency)]),\n",
    "                 **paired_tail(warm_results[(concurrency, 1)], warm_results[(concurrency, concurrency)]))\n",
    "            for concurrency in (2, 4)\n",
    "        )\n",
    "        del model, tokenizer\n",
    "        gc.collect()\n",
    "        torch.cuda.empty_cache()\n",
    "    format_pair = None\n",
    "    if formats[\"nf4\"][\"status\"] == \"ok\":\n",
    "        format_pair = paired_digits(\n",
    "            [r for r in probes if r[\"format\"] == \"fp16\"], [r for r in probes if r[\"format\"] == \"nf4\"]\n",
    "        )\n",
    "    return formats, summaries, traces, slices, probes, schedule_pairs, format_pair"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "lab-11-25",
   "metadata": {},
   "source": [
    "### What should we repeat before capacity planning?\n",
    "\n",
    "Compare throughput and tail latency on the same request mix, then inspect\n",
    "short and long requests separately. Peak allocated memory includes the weights\n",
    "and live tensors that PyTorch tracks. It excludes CUDA memory outside the\n",
    "allocator. A single replay gives a conditional profile of this queue.\n",
    "The separate probe checks exact digits under greedy decoding and does not\n",
    "estimate Facilities Helpdesk quality on the release split.\n",
    "\n",
    "[PagedAttention](https://arxiv.org/html/2309.06180v1)\n",
    "· [DistServe](https://www.usenix.org/system/files/osdi24-zhong-yinmin.pdf)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "lab-11-26",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-11-27T07:32:18.227716Z",
     "iopub.status.busy": "2026-11-27T07:32:18.227150Z",
     "iopub.status.idle": "2026-11-27T07:37:38.205610Z",
     "shell.execute_reply": "2026-11-27T07:37:38.202999Z"
    }
   },
   "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/bitsandbytes/backends/cuda/ops.py:464: FutureWarning: _check_is_size will be removed in a future PyTorch release along with guard_size_oblivious.     Use _check(i >= 0) instead.\n",
      "  torch._check_is_size(blocksize)\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Format readiness: {'fp16': {'status': 'ok', 'load_ms': 17338.68321799946, 'probe_n': 12, 'probe_exact': 12}, 'nf4': {'status': 'ok', 'load_ms': 12318.11757200012, 'probe_n': 12, 'probe_exact': 12}}\n",
      "Measured lab body, seconds: 319.479\n",
      "Profile: {'format': 'fp16', 'concurrency': 1, 'batch_size': 1, 'phase': 'prewarm', 'n': 1, 'completed': 1, 'failures': 0, 'elapsed_seconds': 0.3501357019995339, 'p50_ttft_ms': 56.329650999941805, 'p95_ttft_ms': 56.329650999941805, 'p95_queue_ms': 0.0004889998308499344, 'p95_total_ms': 350.0084199995399, 'throughput_rps': 2.8560355150567625, 'peak_mib': 2959.748046875, 'logical_prompt_tokens': 71, 'dense_prompt_positions': 71, 'exact_first_tokens': 1}\n",
      "Profile: {'format': 'fp16', 'concurrency': 1, 'batch_size': 1, 'phase': 'warm', 'n': 100, 'completed': 100, 'failures': 0, 'elapsed_seconds': 22.764974201999394, 'p50_ttft_ms': 47.78450599997086, 'p95_ttft_ms': 58.29298694961835, 'p95_queue_ms': 0.0013691000731341774, 'p95_total_ms': 321.2909792496248, 'throughput_rps': 4.392713082504493, 'peak_mib': 2986.7509765625, 'logical_prompt_tokens': 21800, 'dense_prompt_positions': 21800, 'exact_first_tokens': 100}\n",
      "Profile: {'format': 'fp16', 'concurrency': 2, 'batch_size': 1, 'phase': 'prewarm', 'n': 2, 'completed': 2, 'failures': 0, 'elapsed_seconds': 0.43916753200028324, 'p50_ttft_ms': 148.2912184997076, 'p95_ttft_ms': 246.5220546499495, 'p95_queue_ms': 198.59502305002934, 'p95_total_ms': 427.5091810999129, 'throughput_rps': 4.55407072305771, 'peak_mib': 2986.7470703125, 'logical_prompt_tokens': 436, 'dense_prompt_positions': 436, 'exact_first_tokens': 2}\n",
      "Profile: {'format': 'fp16', 'concurrency': 2, 'batch_size': 1, 'phase': 'warm', 'n': 100, 'completed': 100, 'failures': 0, 'elapsed_seconds': 23.509473928999796, 'p50_ttft_ms': 151.10620199993718, 'p95_ttft_ms': 373.91570070030866, 'p95_queue_ms': 318.150708400708, 'p95_total_ms': 590.9578430497731, 'throughput_rps': 4.253604325728716, 'peak_mib': 2986.7509765625, 'logical_prompt_tokens': 21800, 'dense_prompt_positions': 21800, 'exact_first_tokens': 100}\n",
      "Profile: {'format': 'fp16', 'concurrency': 2, 'batch_size': 2, 'phase': 'prewarm', 'n': 2, 'completed': 2, 'failures': 0, 'elapsed_seconds': 0.2834822669992718, 'p50_ttft_ms': 107.94540299957589, 'p95_ttft_ms': 107.94540299957589, 'p95_queue_ms': 0.00046500008465955034, 'p95_total_ms': 283.35134699955233, 'throughput_rps': 7.055115020669485, 'peak_mib': 3020.4111328125, 'logical_prompt_tokens': 436, 'dense_prompt_positions': 730, 'exact_first_tokens': 2}\n",
      "Profile: {'format': 'fp16', 'concurrency': 2, 'batch_size': 2, 'phase': 'warm', 'n': 100, 'completed': 100, 'failures': 0, 'elapsed_seconds': 15.308803998999792, 'p50_ttft_ms': 110.62319700022272, 'p95_ttft_ms': 113.91310999988491, 'p95_queue_ms': 0.001377000444335863, 'p95_total_ms': 398.07405900046433, 'throughput_rps': 6.5321889290981545, 'peak_mib': 3020.4228515625, 'logical_prompt_tokens': 21800, 'dense_prompt_positions': 36500, 'exact_first_tokens': 100}\n",
      "Profile: {'format': 'fp16', 'concurrency': 4, 'batch_size': 1, 'phase': 'prewarm', 'n': 4, 'completed': 4, 'failures': 0, 'elapsed_seconds': 0.8662383800001408, 'p50_ttft_ms': 371.3284649998059, 'p95_ttft_ms': 655.9853212498637, 'p95_queue_ms': 617.9218964998653, 'p95_total_ms': 833.8237955003932, 'throughput_rps': 4.617666559636102, 'peak_mib': 2986.7509765625, 'logical_prompt_tokens': 872, 'dense_prompt_positions': 872, 'exact_first_tokens': 4}\n",
      "Profile: {'format': 'fp16', 'concurrency': 4, 'batch_size': 1, 'phase': 'warm', 'n': 100, 'completed': 100, 'failures': 0, 'elapsed_seconds': 23.45929785499993, 'p50_ttft_ms': 426.252367500183, 'p95_ttft_ms': 850.4313346500112, 'p95_queue_ms': 806.7774509500396, 'p95_total_ms': 1065.0157492496874, 'throughput_rps': 4.262702175405765, 'peak_mib': 2986.7509765625, 'logical_prompt_tokens': 21800, 'dense_prompt_positions': 21800, 'exact_first_tokens': 100}\n",
      "Profile: {'format': 'fp16', 'concurrency': 4, 'batch_size': 4, 'phase': 'prewarm', 'n': 4, 'completed': 4, 'failures': 0, 'elapsed_seconds': 0.41686708199995337, 'p50_ttft_ms': 231.1540930004412, 'p95_ttft_ms': 231.1540930004412, 'p95_queue_ms': 0.00048000038077589124, 'p95_total_ms': 416.7475320000449, 'throughput_rps': 9.595384650689324, 'peak_mib': 3087.5625, 'logical_prompt_tokens': 872, 'dense_prompt_positions': 1460, 'exact_first_tokens': 4}\n",
      "Profile: {'format': 'fp16', 'concurrency': 4, 'batch_size': 4, 'phase': 'warm', 'n': 100, 'completed': 100, 'failures': 0, 'elapsed_seconds': 10.835083295000004, 'p50_ttft_ms': 229.4623749994571, 'p95_ttft_ms': 237.04225500023313, 'p95_queue_ms': 0.0013400003808783367, 'p95_total_ms': 518.8831069999651, 'throughput_rps': 9.229278379996058, 'peak_mib': 3087.5849609375, 'logical_prompt_tokens': 21800, 'dense_prompt_positions': 36500, 'exact_first_tokens': 100}\n",
      "Profile: {'format': 'nf4', 'concurrency': 1, 'batch_size': 1, 'phase': 'prewarm', 'n': 1, 'completed': 1, 'failures': 0, 'elapsed_seconds': 0.337988597999356, 'p50_ttft_ms': 67.59904400041705, 'p95_ttft_ms': 67.59904400041705, 'p95_queue_ms': 0.0003579998519853689, 'p95_total_ms': 337.80702800049767, 'throughput_rps': 2.9586796889577482, 'peak_mib': 1198.83837890625, 'logical_prompt_tokens': 71, 'dense_prompt_positions': 71, 'exact_first_tokens': 1}\n",
      "Profile: {'format': 'nf4', 'concurrency': 1, 'batch_size': 1, 'phase': 'warm', 'n': 100, 'completed': 100, 'failures': 0, 'elapsed_seconds': 38.690140799999426, 'p50_ttft_ms': 78.19298600043112, 'p95_ttft_ms': 111.22650734982925, 'p95_queue_ms': 0.0014995000583439833, 'p95_total_ms': 561.4072622503954, 'throughput_rps': 2.584637789687276, 'peak_mib': 1220.97412109375, 'logical_prompt_tokens': 21800, 'dense_prompt_positions': 21800, 'exact_first_tokens': 100}\n",
      "Profile: {'format': 'nf4', 'concurrency': 2, 'batch_size': 1, 'phase': 'prewarm', 'n': 2, 'completed': 2, 'failures': 0, 'elapsed_seconds': 0.6748969959999158, 'p50_ttft_ms': 238.40017199972863, 'p95_ttft_ms': 385.92200609941756, 'p95_queue_ms': 309.0026183000191, 'p95_total_ms': 657.2481435493046, 'throughput_rps': 2.9634151757289042, 'peak_mib': 1220.97021484375, 'logical_prompt_tokens': 436, 'dense_prompt_positions': 436, 'exact_first_tokens': 2}\n",
      "Profile: {'format': 'nf4', 'concurrency': 2, 'batch_size': 1, 'phase': 'warm', 'n': 100, 'completed': 100, 'failures': 0, 'elapsed_seconds': 36.95783713199944, 'p50_ttft_ms': 252.27331099995354, 'p95_ttft_ms': 575.9291508499246, 'p95_queue_ms': 483.97918270052287, 'p95_total_ms': 912.8998924001733, 'throughput_rps': 2.70578604594305, 'peak_mib': 1220.97412109375, 'logical_prompt_tokens': 21800, 'dense_prompt_positions': 21800, 'exact_first_tokens': 100}\n",
      "Profile: {'format': 'nf4', 'concurrency': 2, 'batch_size': 2, 'phase': 'prewarm', 'n': 2, 'completed': 2, 'failures': 0, 'elapsed_seconds': 0.6720772799999395, 'p50_ttft_ms': 142.33017700007622, 'p95_ttft_ms': 142.33017700007622, 'p95_queue_ms': 0.0007259995982167311, 'p95_total_ms': 671.8748690000211, 'throughput_rps': 2.9758482536415753, 'peak_mib': 1248.396484375, 'logical_prompt_tokens': 436, 'dense_prompt_positions': 730, 'exact_first_tokens': 2}\n",
      "Profile: {'format': 'nf4', 'concurrency': 2, 'batch_size': 2, 'phase': 'warm', 'n': 100, 'completed': 100, 'failures': 0, 'elapsed_seconds': 26.22139245299968, 'p50_ttft_ms': 141.00066850051007, 'p95_ttft_ms': 143.98218900078064, 'p95_queue_ms': 0.0015010000424808823, 'p95_total_ms': 659.4861080002374, 'throughput_rps': 3.8136800011381613, 'peak_mib': 1248.408203125, 'logical_prompt_tokens': 21800, 'dense_prompt_positions': 36500, 'exact_first_tokens': 100}\n",
      "Profile: {'format': 'nf4', 'concurrency': 4, 'batch_size': 1, 'phase': 'prewarm', 'n': 4, 'completed': 4, 'failures': 0, 'elapsed_seconds': 1.5576346330008164, 'p50_ttft_ms': 794.5032615002674, 'p95_ttft_ms': 1235.3798323998944, 'p95_queue_ms': 1165.9475970998299, 'p95_total_ms': 1506.0326296500532, 'throughput_rps': 2.5679963165006896, 'peak_mib': 1220.97412109375, 'logical_prompt_tokens': 872, 'dense_prompt_positions': 872, 'exact_first_tokens': 4}\n",
      "Profile: {'format': 'nf4', 'concurrency': 4, 'batch_size': 1, 'phase': 'warm', 'n': 100, 'completed': 100, 'failures': 0, 'elapsed_seconds': 36.835623838000174, 'p50_ttft_ms': 692.9794904999653, 'p95_ttft_ms': 1373.854080699948, 'p95_queue_ms': 1294.9778135994165, 'p95_total_ms': 1697.9322885493275, 'throughput_rps': 2.7147633073839383, 'peak_mib': 1220.97412109375, 'logical_prompt_tokens': 21800, 'dense_prompt_positions': 21800, 'exact_first_tokens': 100}\n",
      "Profile: {'format': 'nf4', 'concurrency': 4, 'batch_size': 4, 'phase': 'prewarm', 'n': 4, 'completed': 4, 'failures': 0, 'elapsed_seconds': 0.5908172429999468, 'p50_ttft_ms': 252.3859100001573, 'p95_ttft_ms': 252.3859100001573, 'p95_queue_ms': 0.00037199970392975956, 'p95_total_ms': 590.6172280001556, 'throughput_rps': 6.770283107665429, 'peak_mib': 1302.298828125, 'logical_prompt_tokens': 872, 'dense_prompt_positions': 1460, 'exact_first_tokens': 4}\n",
      "Profile: {'format': 'nf4', 'concurrency': 4, 'batch_size': 4, 'phase': 'warm', 'n': 100, 'completed': 100, 'failures': 0, 'elapsed_seconds': 20.232849127999543, 'p50_ttft_ms': 260.16137700025865, 'p95_ttft_ms': 288.01396200015006, 'p95_queue_ms': 0.0016680005501257256, 'p95_total_ms': 1450.7736650002698, 'throughput_rps': 4.942457652274658, 'peak_mib': 1302.3212890625, 'logical_prompt_tokens': 21800, 'dense_prompt_positions': 36500, 'exact_first_tokens': 100}\n",
      "Queue schedule digit pairs: [{'format': 'fp16', 'concurrency': 2, 'baseline_batch': 1, 'candidate_batch': 2, 'n': 100, 'baseline_only': 0, 'candidate_only': 0, 'text_changes': 0, 'p95_total_delta_ms': -192.88378404930882, 'p95_total_low_ms': -277.9429929996695, 'p95_total_high_ms': -114.63229204277582, 'paired_waves': 50}, {'format': 'fp16', 'concurrency': 4, 'baseline_batch': 1, 'candidate_batch': 4, 'n': 100, 'baseline_only': 0, 'candidate_only': 0, 'text_changes': 0, 'p95_total_delta_ms': -546.1326422497223, 'p95_total_low_ms': -701.911898335045, 'p95_total_high_ms': -389.28183000756786, 'paired_waves': 25}, {'format': 'nf4', 'concurrency': 2, 'baseline_batch': 1, 'candidate_batch': 2, 'n': 100, 'baseline_only': 0, 'candidate_only': 0, 'text_changes': 0, 'p95_total_delta_ms': -253.41378439993582, 'p95_total_low_ms': -407.7310031142156, 'p95_total_high_ms': -125.46816692369019, 'paired_waves': 50}, {'format': 'nf4', 'concurrency': 4, 'baseline_batch': 1, 'candidate_batch': 4, 'n': 100, 'baseline_only': 0, 'candidate_only': 0, 'text_changes': 0, 'p95_total_delta_ms': -247.15862354905767, 'p95_total_low_ms': -644.3012979998457, 'p95_total_high_ms': 174.01370640000187, 'paired_waves': 25}] Format probe pair: {'n': 12, 'baseline_only': 0, 'candidate_only': 0, 'text_changes': 0}\n",
      "F-250 measured examples: [{'request_id': 'load-001', 'kind': 'long', 'phase': 'warm', 'wave': 0, 'dispatch': 1, 'actual_batch_size': 1, 'queue_ms': 202.85106000028463, 'status': 'ok', 'ttft_ms': 254.85235300038767, 'total_ms': 443.12433899995085, 'input_tokens': 365, 'padded_input_tokens': 365, 'generated_tokens': 6, 'raw_first_token': '3', 'raw_continuation': '3\\nHuman:', 'exact_first_token': True, 'format': 'fp16', 'concurrency': 4, 'batch_size': 1}, {'request_id': 'load-001', 'kind': 'long', 'phase': 'warm', 'wave': 0, 'dispatch': 0, 'actual_batch_size': 4, 'queue_ms': 0.0004700004865298979, 'status': 'ok', 'ttft_ms': 234.9968610005817, 'total_ms': 410.12976900037756, 'input_tokens': 365, 'padded_input_tokens': 365, 'generated_tokens': 6, 'raw_first_token': '3', 'raw_continuation': '3\\nHuman:', 'exact_first_token': True, 'format': 'fp16', 'concurrency': 4, 'batch_size': 4}, {'request_id': 'load-001', 'kind': 'long', 'phase': 'warm', 'wave': 0, 'dispatch': 1, 'actual_batch_size': 1, 'queue_ms': 314.2932680002559, 'status': 'ok', 'ttft_ms': 395.6545740002184, 'total_ms': 690.1493249997657, 'input_tokens': 365, 'padded_input_tokens': 365, 'generated_tokens': 6, 'raw_first_token': '3', 'raw_continuation': '3\\nHuman:', 'exact_first_token': True, 'format': 'nf4', 'concurrency': 4, 'batch_size': 1}, {'request_id': 'load-001', 'kind': 'long', 'phase': 'warm', 'wave': 0, 'dispatch': 0, 'actual_batch_size': 4, 'queue_ms': 0.0003679997462313622, 'status': 'ok', 'ttft_ms': 252.9758889995719, 'total_ms': 587.1990470004675, 'input_tokens': 365, 'padded_input_tokens': 365, 'generated_tokens': 6, 'raw_first_token': '3', 'raw_continuation': '3\\nHuman:', 'exact_first_token': True, 'format': 'nf4', 'concurrency': 4, 'batch_size': 4}]\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=\"591.59952pt\" height=\"476.39952pt\" viewBox=\"0 0 591.59952 476.39952\" 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-27T07:37:38.131754</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 476.39952 \n",
       "L 591.59952 476.39952 \n",
       "L 591.59952 0 \n",
       "L 0 0 \n",
       "z\n",
       "\" style=\"fill: #f5f7f2\"/>\n",
       "  </g>\n",
       "  <g id=\"axes_1\">\n",
       "   <g id=\"patch_2\">\n",
       "    <path d=\"M 65.9125 436.84327 \n",
       "L 584.39952 436.84327 \n",
       "L 584.39952 34.3575 \n",
       "L 65.9125 34.3575 \n",
       "z\n",
       "\" style=\"fill: #f5f7f2\"/>\n",
       "   </g>\n",
       "   <g id=\"matplotlib.axis_1\">\n",
       "    <g id=\"xtick_1\">\n",
       "     <g id=\"line2d_1\">\n",
       "      <path d=\"M 65.9125 436.84327 \n",
       "L 65.9125 34.3575 \n",
       "\" clip-path=\"url(#p3d7954f8e0)\" style=\"fill: none; stroke: #d3ded6; stroke-width: 0.75; stroke-linecap: square\"/>\n",
       "     </g>\n",
       "     <g id=\"line2d_2\"/>\n",
       "     <g id=\"text_1\">\n",
       "      <!-- 0 -->\n",
       "      <g style=\"fill: #20382f\" transform=\"translate(62.73125 449.441707) 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 161.130297 436.84327 \n",
       "L 161.130297 34.3575 \n",
       "\" clip-path=\"url(#p3d7954f8e0)\" style=\"fill: none; stroke: #d3ded6; stroke-width: 0.75; stroke-linecap: square\"/>\n",
       "     </g>\n",
       "     <g id=\"line2d_4\"/>\n",
       "     <g id=\"text_2\">\n",
       "      <!-- 2 -->\n",
       "      <g style=\"fill: #20382f\" transform=\"translate(157.949047 449.441707) 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",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"xtick_3\">\n",
       "     <g id=\"line2d_5\">\n",
       "      <path d=\"M 256.348095 436.84327 \n",
       "L 256.348095 34.3575 \n",
       "\" clip-path=\"url(#p3d7954f8e0)\" style=\"fill: none; stroke: #d3ded6; stroke-width: 0.75; stroke-linecap: square\"/>\n",
       "     </g>\n",
       "     <g id=\"line2d_6\"/>\n",
       "     <g id=\"text_3\">\n",
       "      <!-- 4 -->\n",
       "      <g style=\"fill: #20382f\" transform=\"translate(253.166845 449.441707) 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",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"xtick_4\">\n",
       "     <g id=\"line2d_7\">\n",
       "      <path d=\"M 351.565892 436.84327 \n",
       "L 351.565892 34.3575 \n",
       "\" clip-path=\"url(#p3d7954f8e0)\" style=\"fill: none; stroke: #d3ded6; stroke-width: 0.75; stroke-linecap: square\"/>\n",
       "     </g>\n",
       "     <g id=\"line2d_8\"/>\n",
       "     <g id=\"text_4\">\n",
       "      <!-- 6 -->\n",
       "      <g style=\"fill: #20382f\" transform=\"translate(348.384642 449.441707) 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",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"xtick_5\">\n",
       "     <g id=\"line2d_9\">\n",
       "      <path d=\"M 446.78369 436.84327 \n",
       "L 446.78369 34.3575 \n",
       "\" clip-path=\"url(#p3d7954f8e0)\" style=\"fill: none; stroke: #d3ded6; stroke-width: 0.75; stroke-linecap: square\"/>\n",
       "     </g>\n",
       "     <g id=\"line2d_10\"/>\n",
       "     <g id=\"text_5\">\n",
       "      <!-- 8 -->\n",
       "      <g style=\"fill: #20382f\" transform=\"translate(443.60244 449.441707) 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",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"xtick_6\">\n",
       "     <g id=\"line2d_11\">\n",
       "      <path d=\"M 542.001487 436.84327 \n",
       "L 542.001487 34.3575 \n",
       "\" clip-path=\"url(#p3d7954f8e0)\" style=\"fill: none; stroke: #d3ded6; stroke-width: 0.75; stroke-linecap: square\"/>\n",
       "     </g>\n",
       "     <g id=\"line2d_12\"/>\n",
       "     <g id=\"text_6\">\n",
       "      <!-- 10 -->\n",
       "      <g style=\"fill: #20382f\" transform=\"translate(535.638987 449.441707) 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",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"text_7\">\n",
       "     <!-- requests/s -->\n",
       "     <g style=\"fill: #20382f\" transform=\"translate(65.9125 467.119832) scale(0.1 -0.1)\">\n",
       "      <defs>\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-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-71\" d=\"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",
       "M 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",
       "L 2906 3500 \n",
       "L 3481 3500 \n",
       "L 3481 -1331 \n",
       "L 2906 -1331 \n",
       "L 2906 525 \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-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-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-2f\" d=\"M 1625 4666 \n",
       "L 2156 4666 \n",
       "L 531 -594 \n",
       "L 0 -594 \n",
       "L 1625 4666 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "      </defs>\n",
       "      <use xlink:href=\"#DejaVuSans-72\"/>\n",
       "      <use xlink:href=\"#DejaVuSans-65\" transform=\"translate(38.863281 0)\"/>\n",
       "      <use xlink:href=\"#DejaVuSans-71\" transform=\"translate(100.386719 0)\"/>\n",
       "      <use xlink:href=\"#DejaVuSans-75\" transform=\"translate(163.863281 0)\"/>\n",
       "      <use xlink:href=\"#DejaVuSans-65\" transform=\"translate(227.242188 0)\"/>\n",
       "      <use xlink:href=\"#DejaVuSans-73\" transform=\"translate(288.765625 0)\"/>\n",
       "      <use xlink:href=\"#DejaVuSans-74\" transform=\"translate(340.865234 0)\"/>\n",
       "      <use xlink:href=\"#DejaVuSans-73\" transform=\"translate(380.074219 0)\"/>\n",
       "      <use xlink:href=\"#DejaVuSans-2f\" transform=\"translate(432.173828 0)\"/>\n",
       "      <use xlink:href=\"#DejaVuSans-73\" transform=\"translate(465.865234 0)\"/>\n",
       "     </g>\n",
       "    </g>\n",
       "   </g>\n",
       "   <g id=\"matplotlib.axis_2\">\n",
       "    <g id=\"ytick_1\">\n",
       "     <g id=\"line2d_13\"/>\n",
       "     <g id=\"text_8\">\n",
       "      <!-- fp16 c1/b1 -->\n",
       "      <g style=\"fill: #20382f\" transform=\"translate(7.2 66.987803) scale(0.1 -0.1)\">\n",
       "       <defs>\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",
       "        <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-20\" 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-62\" d=\"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",
       "M 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",
       "L 1159 0 \n",
       "L 581 0 \n",
       "L 581 4863 \n",
       "L 1159 4863 \n",
       "L 1159 2969 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "       </defs>\n",
       "       <use xlink:href=\"#DejaVuSans-66\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-70\" transform=\"translate(35.205078 0)\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-31\" transform=\"translate(98.681641 0)\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-36\" transform=\"translate(162.304688 0)\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-20\" transform=\"translate(225.927734 0)\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-63\" transform=\"translate(257.714844 0)\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-31\" transform=\"translate(312.695312 0)\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-2f\" transform=\"translate(376.318359 0)\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-62\" transform=\"translate(410.009766 0)\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-31\" transform=\"translate(473.486328 0)\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"ytick_2\">\n",
       "     <g id=\"line2d_14\"/>\n",
       "     <g id=\"text_9\">\n",
       "      <!-- fp16 c2/b1 -->\n",
       "      <g style=\"fill: #20382f\" transform=\"translate(7.2 105.301537) scale(0.1 -0.1)\">\n",
       "       <use xlink:href=\"#DejaVuSans-66\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-70\" transform=\"translate(35.205078 0)\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-31\" transform=\"translate(98.681641 0)\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-36\" transform=\"translate(162.304688 0)\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-20\" transform=\"translate(225.927734 0)\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-63\" transform=\"translate(257.714844 0)\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-32\" transform=\"translate(312.695312 0)\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-2f\" transform=\"translate(376.318359 0)\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-62\" transform=\"translate(410.009766 0)\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-31\" transform=\"translate(473.486328 0)\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"ytick_3\">\n",
       "     <g id=\"line2d_15\"/>\n",
       "     <g id=\"text_10\">\n",
       "      <!-- fp16 c2/b2 -->\n",
       "      <g style=\"fill: #20382f\" transform=\"translate(7.2 143.61527) scale(0.1 -0.1)\">\n",
       "       <use xlink:href=\"#DejaVuSans-66\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-70\" transform=\"translate(35.205078 0)\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-31\" transform=\"translate(98.681641 0)\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-36\" transform=\"translate(162.304688 0)\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-20\" transform=\"translate(225.927734 0)\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-63\" transform=\"translate(257.714844 0)\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-32\" transform=\"translate(312.695312 0)\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-2f\" transform=\"translate(376.318359 0)\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-62\" transform=\"translate(410.009766 0)\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-32\" transform=\"translate(473.486328 0)\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"ytick_4\">\n",
       "     <g id=\"line2d_16\"/>\n",
       "     <g id=\"text_11\">\n",
       "      <!-- fp16 c4/b1 -->\n",
       "      <g style=\"fill: #20382f\" transform=\"translate(7.2 181.929004) scale(0.1 -0.1)\">\n",
       "       <use xlink:href=\"#DejaVuSans-66\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-70\" transform=\"translate(35.205078 0)\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-31\" transform=\"translate(98.681641 0)\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-36\" transform=\"translate(162.304688 0)\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-20\" transform=\"translate(225.927734 0)\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-63\" transform=\"translate(257.714844 0)\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-34\" transform=\"translate(312.695312 0)\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-2f\" transform=\"translate(376.318359 0)\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-62\" transform=\"translate(410.009766 0)\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-31\" transform=\"translate(473.486328 0)\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"ytick_5\">\n",
       "     <g id=\"line2d_17\"/>\n",
       "     <g id=\"text_12\">\n",
       "      <!-- fp16 c4/b4 -->\n",
       "      <g style=\"fill: #20382f\" transform=\"translate(7.2 220.242737) scale(0.1 -0.1)\">\n",
       "       <use xlink:href=\"#DejaVuSans-66\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-70\" transform=\"translate(35.205078 0)\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-31\" transform=\"translate(98.681641 0)\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-36\" transform=\"translate(162.304688 0)\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-20\" transform=\"translate(225.927734 0)\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-63\" transform=\"translate(257.714844 0)\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-34\" transform=\"translate(312.695312 0)\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-2f\" transform=\"translate(376.318359 0)\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-62\" transform=\"translate(410.009766 0)\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-34\" transform=\"translate(473.486328 0)\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"ytick_6\">\n",
       "     <g id=\"line2d_18\"/>\n",
       "     <g id=\"text_13\">\n",
       "      <!-- nf4 c1/b1 -->\n",
       "      <g style=\"fill: #20382f\" transform=\"translate(13.573438 258.55647) scale(0.1 -0.1)\">\n",
       "       <defs>\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",
       "       </defs>\n",
       "       <use xlink:href=\"#DejaVuSans-6e\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-66\" transform=\"translate(63.378906 0)\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-34\" transform=\"translate(98.583984 0)\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-20\" transform=\"translate(162.207031 0)\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-63\" transform=\"translate(193.994141 0)\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-31\" transform=\"translate(248.974609 0)\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-2f\" transform=\"translate(312.597656 0)\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-62\" transform=\"translate(346.289062 0)\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-31\" transform=\"translate(409.765625 0)\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"ytick_7\">\n",
       "     <g id=\"line2d_19\"/>\n",
       "     <g id=\"text_14\">\n",
       "      <!-- nf4 c2/b1 -->\n",
       "      <g style=\"fill: #20382f\" transform=\"translate(13.573438 296.870204) scale(0.1 -0.1)\">\n",
       "       <use xlink:href=\"#DejaVuSans-6e\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-66\" transform=\"translate(63.378906 0)\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-34\" transform=\"translate(98.583984 0)\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-20\" transform=\"translate(162.207031 0)\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-63\" transform=\"translate(193.994141 0)\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-32\" transform=\"translate(248.974609 0)\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-2f\" transform=\"translate(312.597656 0)\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-62\" transform=\"translate(346.289062 0)\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-31\" transform=\"translate(409.765625 0)\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"ytick_8\">\n",
       "     <g id=\"line2d_20\"/>\n",
       "     <g id=\"text_15\">\n",
       "      <!-- nf4 c2/b2 -->\n",
       "      <g style=\"fill: #20382f\" transform=\"translate(13.573438 335.183937) scale(0.1 -0.1)\">\n",
       "       <use xlink:href=\"#DejaVuSans-6e\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-66\" transform=\"translate(63.378906 0)\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-34\" transform=\"translate(98.583984 0)\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-20\" transform=\"translate(162.207031 0)\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-63\" transform=\"translate(193.994141 0)\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-32\" transform=\"translate(248.974609 0)\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-2f\" transform=\"translate(312.597656 0)\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-62\" transform=\"translate(346.289062 0)\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-32\" transform=\"translate(409.765625 0)\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"ytick_9\">\n",
       "     <g id=\"line2d_21\"/>\n",
       "     <g id=\"text_16\">\n",
       "      <!-- nf4 c4/b1 -->\n",
       "      <g style=\"fill: #20382f\" transform=\"translate(13.573438 373.497671) scale(0.1 -0.1)\">\n",
       "       <use xlink:href=\"#DejaVuSans-6e\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-66\" transform=\"translate(63.378906 0)\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-34\" transform=\"translate(98.583984 0)\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-20\" transform=\"translate(162.207031 0)\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-63\" transform=\"translate(193.994141 0)\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-34\" transform=\"translate(248.974609 0)\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-2f\" transform=\"translate(312.597656 0)\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-62\" transform=\"translate(346.289062 0)\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-31\" transform=\"translate(409.765625 0)\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"ytick_10\">\n",
       "     <g id=\"line2d_22\"/>\n",
       "     <g id=\"text_17\">\n",
       "      <!-- nf4 c4/b4 -->\n",
       "      <g style=\"fill: #20382f\" transform=\"translate(13.573438 411.811404) scale(0.1 -0.1)\">\n",
       "       <use xlink:href=\"#DejaVuSans-6e\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-66\" transform=\"translate(63.378906 0)\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-34\" transform=\"translate(98.583984 0)\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-20\" transform=\"translate(162.207031 0)\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-63\" transform=\"translate(193.994141 0)\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-34\" transform=\"translate(248.974609 0)\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-2f\" transform=\"translate(312.597656 0)\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-62\" transform=\"translate(346.289062 0)\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-34\" transform=\"translate(409.765625 0)\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "   </g>\n",
       "   <g id=\"patch_3\">\n",
       "    <path d=\"M 65.9125 52.652308 \n",
       "L 275.044732 52.652308 \n",
       "L 275.044732 73.724861 \n",
       "L 65.9125 73.724861 \n",
       "z\n",
       "\" clip-path=\"url(#p3d7954f8e0)\" style=\"fill: #3d6b5b\"/>\n",
       "   </g>\n",
       "   <g id=\"patch_4\">\n",
       "    <path d=\"M 65.9125 90.966041 \n",
       "L 268.421918 90.966041 \n",
       "L 268.421918 112.038595 \n",
       "L 65.9125 112.038595 \n",
       "z\n",
       "\" clip-path=\"url(#p3d7954f8e0)\" style=\"fill: #298876\"/>\n",
       "   </g>\n",
       "   <g id=\"patch_5\">\n",
       "    <path d=\"M 65.9125 129.279775 \n",
       "L 376.902821 129.279775 \n",
       "L 376.902821 150.352328 \n",
       "L 65.9125 150.352328 \n",
       "z\n",
       "\" clip-path=\"url(#p3d7954f8e0)\" style=\"fill: #7b97a2\"/>\n",
       "   </g>\n",
       "   <g id=\"patch_6\">\n",
       "    <path d=\"M 65.9125 167.593508 \n",
       "L 268.855056 167.593508 \n",
       "L 268.855056 188.666062 \n",
       "L 65.9125 188.666062 \n",
       "z\n",
       "\" clip-path=\"url(#p3d7954f8e0)\" style=\"fill: #9c6951\"/>\n",
       "   </g>\n",
       "   <g id=\"patch_7\">\n",
       "    <path d=\"M 65.9125 205.907242 \n",
       "L 505.30828 205.907242 \n",
       "L 505.30828 226.979795 \n",
       "L 65.9125 226.979795 \n",
       "z\n",
       "\" clip-path=\"url(#p3d7954f8e0)\" style=\"fill: #3d6b5b\"/>\n",
       "   </g>\n",
       "   <g id=\"patch_8\">\n",
       "    <path d=\"M 65.9125 244.220975 \n",
       "L 188.964259 244.220975 \n",
       "L 188.964259 265.293528 \n",
       "L 65.9125 265.293528 \n",
       "z\n",
       "\" clip-path=\"url(#p3d7954f8e0)\" style=\"fill: #298876\"/>\n",
       "   </g>\n",
       "   <g id=\"patch_9\">\n",
       "    <path d=\"M 65.9125 282.534708 \n",
       "L 194.731994 282.534708 \n",
       "L 194.731994 303.607262 \n",
       "L 65.9125 303.607262 \n",
       "z\n",
       "\" clip-path=\"url(#p3d7954f8e0)\" style=\"fill: #7b97a2\"/>\n",
       "   </g>\n",
       "   <g id=\"patch_10\">\n",
       "    <path d=\"M 65.9125 320.848442 \n",
       "L 247.477605 320.848442 \n",
       "L 247.477605 341.920995 \n",
       "L 65.9125 341.920995 \n",
       "z\n",
       "\" clip-path=\"url(#p3d7954f8e0)\" style=\"fill: #9c6951\"/>\n",
       "   </g>\n",
       "   <g id=\"patch_11\">\n",
       "    <path d=\"M 65.9125 359.162175 \n",
       "L 195.159391 359.162175 \n",
       "L 195.159391 380.234729 \n",
       "L 65.9125 380.234729 \n",
       "z\n",
       "\" clip-path=\"url(#p3d7954f8e0)\" style=\"fill: #3d6b5b\"/>\n",
       "   </g>\n",
       "   <g id=\"patch_12\">\n",
       "    <path d=\"M 65.9125 397.475909 \n",
       "L 301.217466 397.475909 \n",
       "L 301.217466 418.548462 \n",
       "L 65.9125 418.548462 \n",
       "z\n",
       "\" clip-path=\"url(#p3d7954f8e0)\" style=\"fill: #298876\"/>\n",
       "   </g>\n",
       "   <g id=\"text_18\">\n",
       "    <!-- 4.39 -->\n",
       "    <g style=\"fill: #20382f\" transform=\"translate(281.044732 65.947959) scale(0.1 -0.1)\">\n",
       "     <defs>\n",
       "      <path id=\"DejaVuSans-2e\" d=\"M 684 794 \n",
       "L 1344 794 \n",
       "L 1344 0 \n",
       "L 684 0 \n",
       "L 684 794 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\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",
       "      <path id=\"DejaVuSans-39\" d=\"M 703 97 \n",
       "L 703 672 \n",
       "Q 941 559 1184 500 \n",
       "Q 1428 441 1663 441 \n",
       "Q 2288 441 2617 861 \n",
       "Q 2947 1281 2994 2138 \n",
       "Q 2813 1869 2534 1725 \n",
       "Q 2256 1581 1919 1581 \n",
       "Q 1219 1581 811 2004 \n",
       "Q 403 2428 403 3163 \n",
       "Q 403 3881 828 4315 \n",
       "Q 1253 4750 1959 4750 \n",
       "Q 2769 4750 3195 4129 \n",
       "Q 3622 3509 3622 2328 \n",
       "Q 3622 1225 3098 567 \n",
       "Q 2575 -91 1691 -91 \n",
       "Q 1453 -91 1209 -44 \n",
       "Q 966 3 703 97 \n",
       "z\n",
       "M 1959 2075 \n",
       "Q 2384 2075 2632 2365 \n",
       "Q 2881 2656 2881 3163 \n",
       "Q 2881 3666 2632 3958 \n",
       "Q 2384 4250 1959 4250 \n",
       "Q 1534 4250 1286 3958 \n",
       "Q 1038 3666 1038 3163 \n",
       "Q 1038 2656 1286 2365 \n",
       "Q 1534 2075 1959 2075 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "     </defs>\n",
       "     <use xlink:href=\"#DejaVuSans-34\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-2e\" transform=\"translate(63.623047 0)\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-33\" transform=\"translate(95.410156 0)\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-39\" transform=\"translate(159.033203 0)\"/>\n",
       "    </g>\n",
       "   </g>\n",
       "   <g id=\"text_19\">\n",
       "    <!-- 4.25 -->\n",
       "    <g style=\"fill: #20382f\" transform=\"translate(274.421918 104.261693) 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-34\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-2e\" transform=\"translate(63.623047 0)\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-32\" transform=\"translate(95.410156 0)\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-35\" transform=\"translate(159.033203 0)\"/>\n",
       "    </g>\n",
       "   </g>\n",
       "   <g id=\"text_20\">\n",
       "    <!-- 6.53 -->\n",
       "    <g style=\"fill: #20382f\" transform=\"translate(382.902821 142.575426) scale(0.1 -0.1)\">\n",
       "     <use xlink:href=\"#DejaVuSans-36\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-2e\" transform=\"translate(63.623047 0)\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-35\" transform=\"translate(95.410156 0)\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-33\" transform=\"translate(159.033203 0)\"/>\n",
       "    </g>\n",
       "   </g>\n",
       "   <g id=\"text_21\">\n",
       "    <!-- 4.26 -->\n",
       "    <g style=\"fill: #20382f\" transform=\"translate(274.855056 180.88916) scale(0.1 -0.1)\">\n",
       "     <use xlink:href=\"#DejaVuSans-34\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-2e\" transform=\"translate(63.623047 0)\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-32\" transform=\"translate(95.410156 0)\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-36\" transform=\"translate(159.033203 0)\"/>\n",
       "    </g>\n",
       "   </g>\n",
       "   <g id=\"text_22\">\n",
       "    <!-- 9.23 -->\n",
       "    <g style=\"fill: #20382f\" transform=\"translate(511.30828 219.202893) scale(0.1 -0.1)\">\n",
       "     <use xlink:href=\"#DejaVuSans-39\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-2e\" transform=\"translate(63.623047 0)\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-32\" transform=\"translate(95.410156 0)\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-33\" transform=\"translate(159.033203 0)\"/>\n",
       "    </g>\n",
       "   </g>\n",
       "   <g id=\"text_23\">\n",
       "    <!-- 2.58 -->\n",
       "    <g style=\"fill: #20382f\" transform=\"translate(194.964259 257.516627) scale(0.1 -0.1)\">\n",
       "     <use xlink:href=\"#DejaVuSans-32\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-2e\" transform=\"translate(63.623047 0)\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-35\" transform=\"translate(95.410156 0)\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-38\" transform=\"translate(159.033203 0)\"/>\n",
       "    </g>\n",
       "   </g>\n",
       "   <g id=\"text_24\">\n",
       "    <!-- 2.71 -->\n",
       "    <g style=\"fill: #20382f\" transform=\"translate(200.731994 295.83036) 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-32\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-2e\" transform=\"translate(63.623047 0)\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-37\" transform=\"translate(95.410156 0)\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-31\" transform=\"translate(159.033203 0)\"/>\n",
       "    </g>\n",
       "   </g>\n",
       "   <g id=\"text_25\">\n",
       "    <!-- 3.81 -->\n",
       "    <g style=\"fill: #20382f\" transform=\"translate(253.477605 334.144094) scale(0.1 -0.1)\">\n",
       "     <use xlink:href=\"#DejaVuSans-33\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-2e\" transform=\"translate(63.623047 0)\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-38\" transform=\"translate(95.410156 0)\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-31\" transform=\"translate(159.033203 0)\"/>\n",
       "    </g>\n",
       "   </g>\n",
       "   <g id=\"text_26\">\n",
       "    <!-- 2.71 -->\n",
       "    <g style=\"fill: #20382f\" transform=\"translate(201.159391 372.457827) scale(0.1 -0.1)\">\n",
       "     <use xlink:href=\"#DejaVuSans-32\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-2e\" transform=\"translate(63.623047 0)\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-37\" transform=\"translate(95.410156 0)\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-31\" transform=\"translate(159.033203 0)\"/>\n",
       "    </g>\n",
       "   </g>\n",
       "   <g id=\"text_27\">\n",
       "    <!-- 4.94 -->\n",
       "    <g style=\"fill: #20382f\" transform=\"translate(307.217466 410.771561) scale(0.1 -0.1)\">\n",
       "     <use xlink:href=\"#DejaVuSans-34\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-2e\" transform=\"translate(63.623047 0)\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-39\" transform=\"translate(95.410156 0)\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-34\" transform=\"translate(159.033203 0)\"/>\n",
       "    </g>\n",
       "   </g>\n",
       "   <g id=\"text_28\">\n",
       "    <!-- Warm throughput by load and format -->\n",
       "    <g style=\"fill: #20382f\" transform=\"translate(65.9125 19.3575) scale(0.16 -0.16)\">\n",
       "     <defs>\n",
       "      <path id=\"DejaVuSans-Bold-57\" d=\"M 191 4666 \n",
       "L 1344 4666 \n",
       "L 2150 1275 \n",
       "L 2950 4666 \n",
       "L 4109 4666 \n",
       "L 4909 1275 \n",
       "L 5716 4666 \n",
       "L 6859 4666 \n",
       "L 5759 0 \n",
       "L 4372 0 \n",
       "L 3525 3547 \n",
       "L 2688 0 \n",
       "L 1300 0 \n",
       "L 191 4666 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "      <path id=\"DejaVuSans-Bold-61\" d=\"M 2106 1575 \n",
       "Q 1756 1575 1579 1456 \n",
       "Q 1403 1338 1403 1106 \n",
       "Q 1403 894 1545 773 \n",
       "Q 1688 653 1941 653 \n",
       "Q 2256 653 2472 879 \n",
       "Q 2688 1106 2688 1447 \n",
       "L 2688 1575 \n",
       "L 2106 1575 \n",
       "z\n",
       "M 3816 1997 \n",
       "L 3816 0 \n",
       "L 2688 0 \n",
       "L 2688 519 \n",
       "Q 2463 200 2181 54 \n",
       "Q 1900 -91 1497 -91 \n",
       "Q 953 -91 614 226 \n",
       "Q 275 544 275 1050 \n",
       "Q 275 1666 698 1953 \n",
       "Q 1122 2241 2028 2241 \n",
       "L 2688 2241 \n",
       "L 2688 2328 \n",
       "Q 2688 2594 2478 2717 \n",
       "Q 2269 2841 1825 2841 \n",
       "Q 1466 2841 1156 2769 \n",
       "Q 847 2697 581 2553 \n",
       "L 581 3406 \n",
       "Q 941 3494 1303 3539 \n",
       "Q 1666 3584 2028 3584 \n",
       "Q 2975 3584 3395 3211 \n",
       "Q 3816 2838 3816 1997 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "      <path id=\"DejaVuSans-Bold-72\" d=\"M 3138 2547 \n",
       "Q 2991 2616 2845 2648 \n",
       "Q 2700 2681 2553 2681 \n",
       "Q 2122 2681 1889 2404 \n",
       "Q 1656 2128 1656 1613 \n",
       "L 1656 0 \n",
       "L 538 0 \n",
       "L 538 3500 \n",
       "L 1656 3500 \n",
       "L 1656 2925 \n",
       "Q 1872 3269 2151 3426 \n",
       "Q 2431 3584 2822 3584 \n",
       "Q 2878 3584 2943 3579 \n",
       "Q 3009 3575 3134 3559 \n",
       "L 3138 2547 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "      <path id=\"DejaVuSans-Bold-6d\" d=\"M 3781 2919 \n",
       "Q 3994 3244 4286 3414 \n",
       "Q 4578 3584 4928 3584 \n",
       "Q 5531 3584 5847 3212 \n",
       "Q 6163 2841 6163 2131 \n",
       "L 6163 0 \n",
       "L 5038 0 \n",
       "L 5038 1825 \n",
       "Q 5041 1866 5042 1909 \n",
       "Q 5044 1953 5044 2034 \n",
       "Q 5044 2406 4934 2573 \n",
       "Q 4825 2741 4581 2741 \n",
       "Q 4263 2741 4089 2478 \n",
       "Q 3916 2216 3909 1719 \n",
       "L 3909 0 \n",
       "L 2784 0 \n",
       "L 2784 1825 \n",
       "Q 2784 2406 2684 2573 \n",
       "Q 2584 2741 2328 2741 \n",
       "Q 2006 2741 1831 2477 \n",
       "Q 1656 2213 1656 1722 \n",
       "L 1656 0 \n",
       "L 531 0 \n",
       "L 531 3500 \n",
       "L 1656 3500 \n",
       "L 1656 2988 \n",
       "Q 1863 3284 2130 3434 \n",
       "Q 2397 3584 2719 3584 \n",
       "Q 3081 3584 3359 3409 \n",
       "Q 3638 3234 3781 2919 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "      <path id=\"DejaVuSans-Bold-20\" transform=\"scale(0.015625)\"/>\n",
       "      <path id=\"DejaVuSans-Bold-74\" d=\"M 1759 4494 \n",
       "L 1759 3500 \n",
       "L 2913 3500 \n",
       "L 2913 2700 \n",
       "L 1759 2700 \n",
       "L 1759 1216 \n",
       "Q 1759 972 1856 886 \n",
       "Q 1953 800 2241 800 \n",
       "L 2816 800 \n",
       "L 2816 0 \n",
       "L 1856 0 \n",
       "Q 1194 0 917 276 \n",
       "Q 641 553 641 1216 \n",
       "L 641 2700 \n",
       "L 84 2700 \n",
       "L 84 3500 \n",
       "L 641 3500 \n",
       "L 641 4494 \n",
       "L 1759 4494 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "      <path id=\"DejaVuSans-Bold-68\" d=\"M 4056 2131 \n",
       "L 4056 0 \n",
       "L 2931 0 \n",
       "L 2931 347 \n",
       "L 2931 1625 \n",
       "Q 2931 2084 2911 2256 \n",
       "Q 2891 2428 2841 2509 \n",
       "Q 2775 2619 2662 2680 \n",
       "Q 2550 2741 2406 2741 \n",
       "Q 2056 2741 1856 2470 \n",
       "Q 1656 2200 1656 1722 \n",
       "L 1656 0 \n",
       "L 538 0 \n",
       "L 538 4863 \n",
       "L 1656 4863 \n",
       "L 1656 2988 \n",
       "Q 1909 3294 2193 3439 \n",
       "Q 2478 3584 2822 3584 \n",
       "Q 3428 3584 3742 3212 \n",
       "Q 4056 2841 4056 2131 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "      <path id=\"DejaVuSans-Bold-6f\" d=\"M 2203 2784 \n",
       "Q 1831 2784 1636 2517 \n",
       "Q 1441 2250 1441 1747 \n",
       "Q 1441 1244 1636 976 \n",
       "Q 1831 709 2203 709 \n",
       "Q 2569 709 2762 976 \n",
       "Q 2956 1244 2956 1747 \n",
       "Q 2956 2250 2762 2517 \n",
       "Q 2569 2784 2203 2784 \n",
       "z\n",
       "M 2203 3584 \n",
       "Q 3106 3584 3614 3096 \n",
       "Q 4122 2609 4122 1747 \n",
       "Q 4122 884 3614 396 \n",
       "Q 3106 -91 2203 -91 \n",
       "Q 1297 -91 786 396 \n",
       "Q 275 884 275 1747 \n",
       "Q 275 2609 786 3096 \n",
       "Q 1297 3584 2203 3584 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "      <path id=\"DejaVuSans-Bold-75\" d=\"M 500 1363 \n",
       "L 500 3500 \n",
       "L 1625 3500 \n",
       "L 1625 3150 \n",
       "Q 1625 2866 1622 2436 \n",
       "Q 1619 2006 1619 1863 \n",
       "Q 1619 1441 1641 1255 \n",
       "Q 1663 1069 1716 984 \n",
       "Q 1784 875 1895 815 \n",
       "Q 2006 756 2150 756 \n",
       "Q 2500 756 2700 1025 \n",
       "Q 2900 1294 2900 1772 \n",
       "L 2900 3500 \n",
       "L 4019 3500 \n",
       "L 4019 0 \n",
       "L 2900 0 \n",
       "L 2900 506 \n",
       "Q 2647 200 2364 54 \n",
       "Q 2081 -91 1741 -91 \n",
       "Q 1134 -91 817 281 \n",
       "Q 500 653 500 1363 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "      <path id=\"DejaVuSans-Bold-67\" d=\"M 2919 594 \n",
       "Q 2688 288 2409 144 \n",
       "Q 2131 0 1766 0 \n",
       "Q 1125 0 706 504 \n",
       "Q 288 1009 288 1791 \n",
       "Q 288 2575 706 3076 \n",
       "Q 1125 3578 1766 3578 \n",
       "Q 2131 3578 2409 3434 \n",
       "Q 2688 3291 2919 2981 \n",
       "L 2919 3500 \n",
       "L 4044 3500 \n",
       "L 4044 353 \n",
       "Q 4044 -491 3511 -936 \n",
       "Q 2978 -1381 1966 -1381 \n",
       "Q 1638 -1381 1331 -1331 \n",
       "Q 1025 -1281 716 -1178 \n",
       "L 716 -306 \n",
       "Q 1009 -475 1290 -558 \n",
       "Q 1572 -641 1856 -641 \n",
       "Q 2406 -641 2662 -400 \n",
       "Q 2919 -159 2919 353 \n",
       "L 2919 594 \n",
       "z\n",
       "M 2181 2772 \n",
       "Q 1834 2772 1640 2515 \n",
       "Q 1447 2259 1447 1791 \n",
       "Q 1447 1309 1634 1061 \n",
       "Q 1822 813 2181 813 \n",
       "Q 2531 813 2725 1069 \n",
       "Q 2919 1325 2919 1791 \n",
       "Q 2919 2259 2725 2515 \n",
       "Q 2531 2772 2181 2772 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "      <path id=\"DejaVuSans-Bold-70\" d=\"M 1656 506 \n",
       "L 1656 -1331 \n",
       "L 538 -1331 \n",
       "L 538 3500 \n",
       "L 1656 3500 \n",
       "L 1656 2988 \n",
       "Q 1888 3294 2169 3439 \n",
       "Q 2450 3584 2816 3584 \n",
       "Q 3463 3584 3878 3070 \n",
       "Q 4294 2556 4294 1747 \n",
       "Q 4294 938 3878 423 \n",
       "Q 3463 -91 2816 -91 \n",
       "Q 2450 -91 2169 54 \n",
       "Q 1888 200 1656 506 \n",
       "z\n",
       "M 2400 2772 \n",
       "Q 2041 2772 1848 2508 \n",
       "Q 1656 2244 1656 1747 \n",
       "Q 1656 1250 1848 986 \n",
       "Q 2041 722 2400 722 \n",
       "Q 2759 722 2948 984 \n",
       "Q 3138 1247 3138 1747 \n",
       "Q 3138 2247 2948 2509 \n",
       "Q 2759 2772 2400 2772 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "      <path id=\"DejaVuSans-Bold-62\" d=\"M 2400 722 \n",
       "Q 2759 722 2948 984 \n",
       "Q 3138 1247 3138 1747 \n",
       "Q 3138 2247 2948 2509 \n",
       "Q 2759 2772 2400 2772 \n",
       "Q 2041 2772 1848 2508 \n",
       "Q 1656 2244 1656 1747 \n",
       "Q 1656 1250 1848 986 \n",
       "Q 2041 722 2400 722 \n",
       "z\n",
       "M 1656 2988 \n",
       "Q 1888 3294 2169 3439 \n",
       "Q 2450 3584 2816 3584 \n",
       "Q 3463 3584 3878 3070 \n",
       "Q 4294 2556 4294 1747 \n",
       "Q 4294 938 3878 423 \n",
       "Q 3463 -91 2816 -91 \n",
       "Q 2450 -91 2169 54 \n",
       "Q 1888 200 1656 506 \n",
       "L 1656 0 \n",
       "L 538 0 \n",
       "L 538 4863 \n",
       "L 1656 4863 \n",
       "L 1656 2988 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "      <path id=\"DejaVuSans-Bold-79\" d=\"M 78 3500 \n",
       "L 1197 3500 \n",
       "L 2138 1125 \n",
       "L 2938 3500 \n",
       "L 4056 3500 \n",
       "L 2584 -331 \n",
       "Q 2363 -916 2067 -1148 \n",
       "Q 1772 -1381 1288 -1381 \n",
       "L 641 -1381 \n",
       "L 641 -647 \n",
       "L 991 -647 \n",
       "Q 1275 -647 1404 -556 \n",
       "Q 1534 -466 1606 -231 \n",
       "L 1638 -134 \n",
       "L 78 3500 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "      <path id=\"DejaVuSans-Bold-6c\" d=\"M 538 4863 \n",
       "L 1656 4863 \n",
       "L 1656 0 \n",
       "L 538 0 \n",
       "L 538 4863 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "      <path id=\"DejaVuSans-Bold-64\" d=\"M 2919 2988 \n",
       "L 2919 4863 \n",
       "L 4044 4863 \n",
       "L 4044 0 \n",
       "L 2919 0 \n",
       "L 2919 506 \n",
       "Q 2688 197 2409 53 \n",
       "Q 2131 -91 1766 -91 \n",
       "Q 1119 -91 703 423 \n",
       "Q 288 938 288 1747 \n",
       "Q 288 2556 703 3070 \n",
       "Q 1119 3584 1766 3584 \n",
       "Q 2128 3584 2408 3439 \n",
       "Q 2688 3294 2919 2988 \n",
       "z\n",
       "M 2181 722 \n",
       "Q 2541 722 2730 984 \n",
       "Q 2919 1247 2919 1747 \n",
       "Q 2919 2247 2730 2509 \n",
       "Q 2541 2772 2181 2772 \n",
       "Q 1825 2772 1636 2509 \n",
       "Q 1447 2247 1447 1747 \n",
       "Q 1447 1247 1636 984 \n",
       "Q 1825 722 2181 722 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "      <path id=\"DejaVuSans-Bold-6e\" d=\"M 4056 2131 \n",
       "L 4056 0 \n",
       "L 2931 0 \n",
       "L 2931 347 \n",
       "L 2931 1631 \n",
       "Q 2931 2084 2911 2256 \n",
       "Q 2891 2428 2841 2509 \n",
       "Q 2775 2619 2662 2680 \n",
       "Q 2550 2741 2406 2741 \n",
       "Q 2056 2741 1856 2470 \n",
       "Q 1656 2200 1656 1722 \n",
       "L 1656 0 \n",
       "L 538 0 \n",
       "L 538 3500 \n",
       "L 1656 3500 \n",
       "L 1656 2988 \n",
       "Q 1909 3294 2193 3439 \n",
       "Q 2478 3584 2822 3584 \n",
       "Q 3428 3584 3742 3212 \n",
       "Q 4056 2841 4056 2131 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "      <path id=\"DejaVuSans-Bold-66\" d=\"M 2841 4863 \n",
       "L 2841 4128 \n",
       "L 2222 4128 \n",
       "Q 1984 4128 1890 4042 \n",
       "Q 1797 3956 1797 3744 \n",
       "L 1797 3500 \n",
       "L 2753 3500 \n",
       "L 2753 2700 \n",
       "L 1797 2700 \n",
       "L 1797 0 \n",
       "L 678 0 \n",
       "L 678 2700 \n",
       "L 122 2700 \n",
       "L 122 3500 \n",
       "L 678 3500 \n",
       "L 678 3744 \n",
       "Q 678 4316 997 4589 \n",
       "Q 1316 4863 1984 4863 \n",
       "L 2841 4863 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "     </defs>\n",
       "     <use xlink:href=\"#DejaVuSans-Bold-57\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-Bold-61\" transform=\"translate(106.677734 0)\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-Bold-72\" transform=\"translate(174.158203 0)\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-Bold-6d\" transform=\"translate(223.474609 0)\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-Bold-20\" transform=\"translate(327.673828 0)\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-Bold-74\" transform=\"translate(362.488281 0)\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-Bold-68\" transform=\"translate(410.291016 0)\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-Bold-72\" transform=\"translate(481.482422 0)\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-Bold-6f\" transform=\"translate(530.798828 0)\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-Bold-75\" transform=\"translate(599.5 0)\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-Bold-67\" transform=\"translate(670.691406 0)\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-Bold-68\" transform=\"translate(742.273438 0)\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-Bold-70\" transform=\"translate(813.464844 0)\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-Bold-75\" transform=\"translate(885.046875 0)\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-Bold-74\" transform=\"translate(956.238281 0)\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-Bold-20\" transform=\"translate(1004.041016 0)\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-Bold-62\" transform=\"translate(1038.855469 0)\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-Bold-79\" transform=\"translate(1110.4375 0)\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-Bold-20\" transform=\"translate(1175.623047 0)\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-Bold-6c\" transform=\"translate(1210.4375 0)\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-Bold-6f\" transform=\"translate(1244.714844 0)\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-Bold-61\" transform=\"translate(1313.416016 0)\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-Bold-64\" transform=\"translate(1380.896484 0)\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-Bold-20\" transform=\"translate(1452.478516 0)\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-Bold-61\" transform=\"translate(1487.292969 0)\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-Bold-6e\" transform=\"translate(1554.773438 0)\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-Bold-64\" transform=\"translate(1625.964844 0)\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-Bold-20\" transform=\"translate(1697.546875 0)\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-Bold-66\" transform=\"translate(1732.361328 0)\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-Bold-6f\" transform=\"translate(1775.867188 0)\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-Bold-72\" transform=\"translate(1844.568359 0)\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-Bold-6d\" transform=\"translate(1893.884766 0)\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-Bold-61\" transform=\"translate(1998.083984 0)\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-Bold-74\" transform=\"translate(2065.564453 0)\"/>\n",
       "    </g>\n",
       "   </g>\n",
       "  </g>\n",
       " </g>\n",
       " <defs>\n",
       "  <clipPath id=\"p3d7954f8e0\">\n",
       "   <rect x=\"65.9125\" y=\"34.3575\" width=\"518.48702\" height=\"402.48577\"/>\n",
       "  </clipPath>\n",
       " </defs>\n",
       "</svg>\n"
      ],
      "text/plain": [
       "<Figure size 810x650 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "if COURSE_SMOKE:\n",
    "    def fixture_decode(batch, steps):\n",
    "        if len(batch) == 1 and batch[0].request_id == \"load-002\":\n",
    "            raise RuntimeError(\"fixture terminal failure\")\n",
    "        now = perf_counter()\n",
    "        sizes = [4 if request.kind == \"short\" else 12 for request in batch]\n",
    "        outputs = [request.expected for request in batch]\n",
    "        return dict(first_at=now, finished_at=now, inputs=sizes, padded_input_tokens=max(sizes),\n",
    "                    first_outputs=outputs, outputs=outputs)\n",
    "\n",
    "    serial, duration = replay(serving_queue[:4], 4, 1, \"fixture\", fixture_decode, DECODE_STEPS)\n",
    "    grouped, _ = replay(serving_queue[:4], 4, 4, \"fixture\", fixture_decode, DECODE_STEPS)\n",
    "    assert summarize_replay(serial, duration, 0)[\"failures\"] == 1\n",
    "    assert serial[2][\"ttft_ms\"] is None and serial[2][\"total_ms\"] >= serial[2][\"queue_ms\"]\n",
    "    assert [row[\"dispatch\"] for row in serial] == [0, 1, 2, 3]\n",
    "    assert {row[\"dispatch\"] for row in grouped} == {0}\n",
    "    assert paired_digits(serial, grouped)[\"candidate_only\"] == 1\n",
    "    same = paired_tail(serial, serial)\n",
    "    assert same == dict(p95_total_delta_ms=0.0, p95_total_low_ms=0.0, p95_total_high_ms=0.0, paired_waves=1)\n",
    "    save(\"summary\", {\"mode\": \"fixture\", \"measured_gpu\": False})\n",
    "    save(\"records\", {\"mode\": \"fixture\", \"opening\": opening})\n",
    "    print(\"SMOKE OK\")\n",
    "else:\n",
    "    started = perf_counter()\n",
    "    formats, profiles, trace, slices, probes, schedule_pairs, format_pair = run_serving()\n",
    "    elapsed = perf_counter() - started\n",
    "    print(\"Format readiness:\", formats)\n",
    "    print(\"Measured lab body, seconds:\", round(elapsed, 3))\n",
    "    for row in profiles:\n",
    "        print(\"Profile:\", row)\n",
    "    print(\"Queue schedule digit pairs:\", schedule_pairs, \"Format probe pair:\", format_pair)\n",
    "    opening_trace = [r for r in trace if r[\"request_id\"] == opening[\"highlight_id\"]\n",
    "                     and r[\"phase\"] == \"warm\" and r[\"concurrency\"] == 4]\n",
    "    print(\"F-250 measured examples:\", opening_trace)\n",
    "    save(\"summary\", {\n",
    "        \"mode\": \"measured\", \"request_count\": REQUEST_COUNT, \"decode_steps\": DECODE_STEPS,\n",
    "        \"warmup_requests\": WARMUP_REQUESTS, \"measurement_wall_seconds\": elapsed,\n",
    "        \"tail_resamples\": TAIL_RESAMPLES, \"tail_seed\": TAIL_SEED,\n",
    "        \"formats\": formats, \"profiles\": profiles, \"length_slices\": slices,\n",
    "        \"schedule_pairs\": schedule_pairs, \"format_pair\": format_pair,\n",
    "    })\n",
    "    save(\"records\", {\n",
    "        \"opening\": opening, \"requests\": [asdict(r) for r in serving_queue],\n",
    "        \"traces\": trace, \"format_probe\": probes,\n",
    "    })\n",
    "    warm_profiles = [row for row in profiles if row[\"phase\"] == \"warm\"]\n",
    "    labels = [f'{r[\"format\"]} c{r[\"concurrency\"]}/b{r[\"batch_size\"]}' for r in warm_profiles]\n",
    "    chart(\"Warm throughput by load and format\", labels,\n",
    "          [r[\"throughput_rps\"] for r in warm_profiles], \"requests/s\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "lab-11-27",
   "metadata": {},
   "source": [
    "### Read the result\n",
    "\n",
    "Pick a precision and batch cap for a latency target. Find the F-250 trace\n",
    "under both dispatch schedules. Explain whether waiting behind other work or\n",
    "forming a longer padded batch explains its first-token time. Carry any\n",
    "disagreement between formats to release evaluation before changing precision.\n",
    "\n",
    "Return to [Benchmark inference serving](https://docs.recohut.com/courses/advanced-ai-systems-engineering/4-operate-and-release/11-benchmark-inference-serving)."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "lab-11-28",
   "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",
    "- [AWQ: Activation-aware Weight Quantization for LLM Compression and Acceleration](https://arxiv.org/abs/2306.00978)\n",
    "- [Efficient Memory Management for Large Language Model Serving with PagedAttention](https://arxiv.org/abs/2309.06180)"
   ]
  }
 ],
 "metadata": {
  "course": {
   "lab": 11,
   "slug": "11-benchmark-inference-serving"
  },
  "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
}
