{
  "nbformat": 4,
  "nbformat_minor": 5,
  "metadata": {
    "kernelspec": {
      "display_name": "Python 3",
      "language": "python",
      "name": "python3"
    },
    "language_info": {
      "name": "python",
      "version": "3.12.14"
    },
    "execution_note": "Code cells executed with Python via an AST-based offline notebook runner; outputs are actual stdout and rich MIME return values. No Jupyter package dependency."
  },
  "cells": [
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "# The cost of asking a learned index for a key\n",
        "\n",
        "This notebook reruns the attached offline analysis. Place all bundle files in one directory and run from that directory. The default path uses Python’s standard library only. Published measurements, metadata and illustrative numerical probes are identified in the article and provenance. No model or API calls occur.\n"
      ],
      "id": "cell-1"
    },
    {
      "cell_type": "code",
      "metadata": {},
      "source": [
        "import sys, json, runpy\n",
        "from pathlib import Path\n",
        "if str(Path.cwd()) not in sys.path:\n",
        "    sys.path.insert(0, str(Path.cwd()))\n",
        "analysis = runpy.run_path('analyze.py', run_name='offline_analysis')\n",
        "result = analysis['analyze']()\n",
        "analysis['draw'](result)\n",
        "print('All analysis assertions passed; figures and results regenerated.')\n",
        "print(json.dumps(result, indent=2))\n"
      ],
      "execution_count": 1,
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "All analysis assertions passed; figures and results regenerated.\n",
            "{\n",
            "  \"evidence\": \"published batch timing means, not new model runs\",\n",
            "  \"rows\": [\n",
            "    {\n",
            "      \"dataset\": \"Quora\",\n",
            "      \"keys_approx\": \"513000\",\n",
            "      \"parameter_fraction\": 0.05,\n",
            "      \"size\": \"S\",\n",
            "      \"support_score_s\": 0.00134,\n",
            "      \"support_grad_s\": 0.0025,\n",
            "      \"key_score_s\": 0.00128,\n",
            "      \"key_grad_s\": 0.00129,\n",
            "      \"support_grad_over_score\": 1.8656716417910448,\n",
            "      \"key_grad_over_score\": 1.0078124999999998,\n",
            "      \"support_over_key_grad\": 1.9379844961240311,\n",
            "      \"key_grad_us_per_query_equivalent\": 0.31494140625,\n",
            "      \"support_grad_us_per_query_equivalent\": 0.6103515625,\n",
            "      \"grad_batch_saving_ms\": 1.2100000000000002,\n",
            "      \"combined_ratios\": {\n",
            "        \"0\": 1.9379844961240311,\n",
            "        \"5\": 1.1923688394276628,\n",
            "        \"20\": 1.0568341944574917,\n",
            "        \"100\": 1.0119458979168723\n",
            "      }\n",
            "    },\n",
            "    {\n",
            "      \"dataset\": \"Quora\",\n",
            "      \"keys_approx\": \"513000\",\n",
            "      \"parameter_fraction\": 0.1,\n",
            "      \"size\": \"M\",\n",
            "      \"support_score_s\": 0.00218,\n",
            "      \"support_grad_s\": 0.00408,\n",
            "      \"key_score_s\": 0.00213,\n",
            "      \"key_grad_s\": 0.00212,\n",
            "      \"support_grad_over_score\": 1.871559633027523,\n",
            "      \"key_grad_over_score\": 0.9953051643192488,\n",
            "      \"support_over_key_grad\": 1.9245283018867927,\n",
            "      \"key_grad_us_per_query_equivalent\": 0.517578125,\n",
            "      \"support_grad_us_per_query_equivalent\": 0.9960937500000001,\n",
            "      \"grad_batch_saving_ms\": 1.9600000000000004,\n",
            "      \"combined_ratios\": {\n",
            "        \"0\": 1.9245283018867927,\n",
            "        \"5\": 1.2752808988764048,\n",
            "        \"20\": 1.0886075949367089,\n",
            "        \"100\": 1.019193106149628\n",
            "      }\n",
            "    },\n",
            "    {\n",
            "      \"dataset\": \"Quora\",\n",
            "      \"keys_approx\": \"513000\",\n",
            "      \"parameter_fraction\": 0.2,\n",
            "      \"size\": \"L\",\n",
            "      \"support_score_s\": 0.00199,\n",
            "      \"support_grad_s\": 0.00312,\n",
            "      \"key_score_s\": 0.0019,\n",
            "      \"key_grad_s\": 0.0019,\n",
            "      \"support_grad_over_score\": 1.5678391959798994,\n",
            "      \"key_grad_over_score\": 1.0,\n",
            "      \"support_over_key_grad\": 1.6421052631578947,\n",
            "      \"key_grad_us_per_query_equivalent\": 0.4638671875,\n",
            "      \"support_grad_us_per_query_equivalent\": 0.76171875,\n",
            "      \"grad_batch_saving_ms\": 1.22,\n",
            "      \"combined_ratios\": {\n",
            "        \"0\": 1.6421052631578947,\n",
            "        \"5\": 1.1768115942028987,\n",
            "        \"20\": 1.0557077625570777,\n",
            "        \"100\": 1.011972522080471\n",
            "      }\n",
            "    },\n",
            "    {\n",
            "      \"dataset\": \"Natural Questions\",\n",
            "      \"keys_approx\": \"2600000\",\n",
            "      \"parameter_fraction\": 0.05,\n",
            "      \"size\": \"S\",\n",
            "      \"support_score_s\": 0.00456,\n",
            "      \"support_grad_s\": 0.00864,\n",
            "      \"key_score_s\": 0.00446,\n",
            "      \"key_grad_s\": 0.00446,\n",
            "      \"support_grad_over_score\": 1.8947368421052633,\n",
            "      \"key_grad_over_score\": 1.0,\n",
            "      \"support_over_key_grad\": 1.9372197309417039,\n",
            "      \"key_grad_us_per_query_equivalent\": 1.0888671875,\n",
            "      \"support_grad_us_per_query_equivalent\": 2.109375,\n",
            "      \"grad_batch_saving_ms\": 4.18,\n",
            "      \"combined_ratios\": {\n",
            "        \"0\": 1.9372197309417039,\n",
            "        \"5\": 1.441860465116279,\n",
            "        \"20\": 1.1708912510220766,\n",
            "        \"100\": 1.0400153168677004\n",
            "      }\n",
            "    },\n",
            "    {\n",
            "      \"dataset\": \"Natural Questions\",\n",
            "      \"keys_approx\": \"2600000\",\n",
            "      \"parameter_fraction\": 0.1,\n",
            "      \"size\": \"M\",\n",
            "      \"support_score_s\": 0.00855,\n",
            "      \"support_grad_s\": 0.0162,\n",
            "      \"key_score_s\": 0.00768,\n",
            "      \"key_grad_s\": 0.00769,\n",
            "      \"support_grad_over_score\": 1.894736842105263,\n",
            "      \"key_grad_over_score\": 1.0013020833333333,\n",
            "      \"support_over_key_grad\": 2.106631989596879,\n",
            "      \"key_grad_us_per_query_equivalent\": 1.87744140625,\n",
            "      \"support_grad_us_per_query_equivalent\": 3.955078125,\n",
            "      \"grad_batch_saving_ms\": 8.51,\n",
            "      \"combined_ratios\": {\n",
            "        \"0\": 2.106631989596879,\n",
            "        \"5\": 1.6706067769897557,\n",
            "        \"20\": 1.307331166486096,\n",
            "        \"100\": 1.0790231219240412\n",
            "      }\n",
            "    },\n",
            "    {\n",
            "      \"dataset\": \"Natural Questions\",\n",
            "      \"keys_approx\": \"2600000\",\n",
            "      \"parameter_fraction\": 0.2,\n",
            "      \"size\": \"L\",\n",
            "      \"support_score_s\": 0.00708,\n",
            "      \"support_grad_s\": 0.0123,\n",
            "      \"key_score_s\": 0.006,\n",
            "      \"key_grad_s\": 0.00599,\n",
            "      \"support_grad_over_score\": 1.7372881355932204,\n",
            "      \"key_grad_over_score\": 0.9983333333333333,\n",
            "      \"support_over_key_grad\": 2.0534223706176964,\n",
            "      \"key_grad_us_per_query_equivalent\": 1.46240234375,\n",
            "      \"support_grad_us_per_query_equivalent\": 3.0029296875,\n",
            "      \"grad_batch_saving_ms\": 6.3100000000000005,\n",
            "      \"combined_ratios\": {\n",
            "        \"0\": 2.0534223706176964,\n",
            "        \"5\": 1.5741583257506824,\n",
            "        \"20\": 1.2427856868026166,\n",
            "        \"100\": 1.0595339182941788\n",
            "      }\n",
            "    },\n",
            "    {\n",
            "      \"dataset\": \"HotpotQA\",\n",
            "      \"keys_approx\": \"5200000\",\n",
            "      \"parameter_fraction\": 0.05,\n",
            "      \"size\": \"S\",\n",
            "      \"support_score_s\": 0.00869,\n",
            "      \"support_grad_s\": 0.0168,\n",
            "      \"key_score_s\": 0.00815,\n",
            "      \"key_grad_s\": 0.00815,\n",
            "      \"support_grad_over_score\": 1.9332566168009204,\n",
            "      \"key_grad_over_score\": 1.0,\n",
            "      \"support_over_key_grad\": 2.061349693251534,\n",
            "      \"key_grad_us_per_query_equivalent\": 1.9897460937499998,\n",
            "      \"support_grad_us_per_query_equivalent\": 4.1015625,\n",
            "      \"grad_batch_saving_ms\": 8.65,\n",
            "      \"combined_ratios\": {\n",
            "        \"0\": 2.061349693251534,\n",
            "        \"5\": 1.6577946768060838,\n",
            "        \"20\": 1.3072824156305505,\n",
            "        \"100\": 1.079981507165973\n",
            "      }\n",
            "    },\n",
            "    {\n",
            "      \"dataset\": \"HotpotQA\",\n",
            "      \"keys_approx\": \"5200000\",\n",
            "      \"parameter_fraction\": 0.1,\n",
            "      \"size\": \"M\",\n",
            "      \"support_score_s\": 0.0159,\n",
            "      \"support_grad_s\": 0.0305,\n",
            "      \"key_score_s\": 0.0149,\n",
            "      \"key_grad_s\": 0.0149,\n",
            "      \"support_grad_over_score\": 1.9182389937106916,\n",
            "      \"key_grad_over_score\": 1.0,\n",
            "      \"support_over_key_grad\": 2.046979865771812,\n",
            "      \"key_grad_us_per_query_equivalent\": 3.6376953125,\n",
            "      \"support_grad_us_per_query_equivalent\": 7.4462890625,\n",
            "      \"grad_batch_saving_ms\": 15.6,\n",
            "      \"combined_ratios\": {\n",
            "        \"0\": 2.046979865771812,\n",
            "        \"5\": 1.7839195979899496,\n",
            "        \"20\": 1.4469914040114613,\n",
            "        \"100\": 1.1357702349869452\n",
            "      }\n",
            "    },\n",
            "    {\n",
            "      \"dataset\": \"HotpotQA\",\n",
            "      \"keys_approx\": \"5200000\",\n",
            "      \"parameter_fraction\": 0.2,\n",
            "      \"size\": \"L\",\n",
            "      \"support_score_s\": 0.0314,\n",
            "      \"support_grad_s\": 0.0596,\n",
            "      \"key_score_s\": 0.0285,\n",
            "      \"key_grad_s\": 0.0286,\n",
            "      \"support_grad_over_score\": 1.8980891719745225,\n",
            "      \"key_grad_over_score\": 1.0035087719298246,\n",
            "      \"support_over_key_grad\": 2.0839160839160837,\n",
            "      \"key_grad_us_per_query_equivalent\": 6.982421875,\n",
            "      \"support_grad_us_per_query_equivalent\": 14.55078125,\n",
            "      \"grad_batch_saving_ms\": 31.0,\n",
            "      \"combined_ratios\": {\n",
            "        \"0\": 2.0839160839160837,\n",
            "        \"5\": 1.922619047619048,\n",
            "        \"20\": 1.6378600823045266,\n",
            "        \"100\": 1.241057542768274\n",
            "      }\n",
            "    }\n",
            "  ],\n",
            "  \"support_grad_over_score_range\": [\n",
            "    1.5678391959798994,\n",
            "    1.9332566168009204\n",
            "  ],\n",
            "  \"key_grad_over_score_range\": [\n",
            "    0.9953051643192488,\n",
            "    1.0078124999999998\n",
            "  ],\n",
            "  \"support_over_key_grad_range\": [\n",
            "    1.6421052631578947,\n",
            "    2.106631989596879\n",
            "  ],\n",
            "  \"median_support_over_key_grad\": 2.046979865771812,\n",
            "  \"nonmonotonic_pairs\": [\n",
            "    {\n",
            "      \"dataset\": \"Quora\",\n",
            "      \"column\": \"support_score_s\",\n",
            "      \"M_to_L_ratio\": 0.9128440366972477\n",
            "    },\n",
            "    {\n",
            "      \"dataset\": \"Quora\",\n",
            "      \"column\": \"support_grad_s\",\n",
            "      \"M_to_L_ratio\": 0.7647058823529411\n",
            "    },\n",
            "    {\n",
            "      \"dataset\": \"Quora\",\n",
            "      \"column\": \"key_score_s\",\n",
            "      \"M_to_L_ratio\": 0.892018779342723\n",
            "    },\n",
            "    {\n",
            "      \"dataset\": \"Quora\",\n",
            "      \"column\": \"key_grad_s\",\n",
            "      \"M_to_L_ratio\": 0.8962264150943396\n",
            "    },\n",
            "    {\n",
            "      \"dataset\": \"Natural Questions\",\n",
            "      \"column\": \"support_score_s\",\n",
            "      \"M_to_L_ratio\": 0.8280701754385965\n",
            "    },\n",
            "    {\n",
            "      \"dataset\": \"Natural Questions\",\n",
            "      \"column\": \"support_grad_s\",\n",
            "      \"M_to_L_ratio\": 0.7592592592592593\n",
            "    },\n",
            "    {\n",
            "      \"dataset\": \"Natural Questions\",\n",
            "      \"column\": \"key_score_s\",\n",
            "      \"M_to_L_ratio\": 0.78125\n",
            "    },\n",
            "    {\n",
            "      \"dataset\": \"Natural Questions\",\n",
            "      \"column\": \"key_grad_s\",\n",
            "      \"M_to_L_ratio\": 0.7789336801040312\n",
            "    }\n",
            "  ]\n",
            "}\n"
          ]
        }
      ],
      "id": "cell-2"
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "## Regenerated figures\n",
        "\n",
        "The following rich SVG outputs come from files regenerated by the preceding code, not screenshots of an external result.\n"
      ],
      "id": "cell-3"
    },
    {
      "cell_type": "code",
      "metadata": {},
      "source": [
        "class LocalSVG:\n",
        "    def __init__(self, filename):\n",
        "        self.filename = filename\n",
        "    def _repr_mimebundle_(self, include=None, exclude=None):\n",
        "        return {'image/svg+xml': Path(self.filename).read_text(), 'text/plain': self.filename}\n"
      ],
      "execution_count": 2,
      "outputs": [],
      "id": "cell-4"
    },
    {
      "cell_type": "code",
      "metadata": {},
      "source": [
        "LocalSVG('downstream-sensitivity.svg')\n"
      ],
      "execution_count": 3,
      "outputs": [
        {
          "output_type": "execute_result",
          "data": {
            "image/svg+xml": "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 920 530\" role=\"img\" aria-labelledby=\"t d\"><title id=\"t\">A twofold component ratio is not a twofold pipeline gain</title><desc id=\"d\">Calculated sensitivity using M-size published means; downstream time is an assumption, not a measurement.</desc><rect width=\"100%\" height=\"100%\" fill=\"#faf9f5\"/><style>text{font-family:Arial,sans-serif;fill:#292d29;font-size:14px} .title{font-family:Georgia,serif;font-size:25px} .sub{fill:#646961;font-size:13px} .axis{stroke:#d6dbd3;stroke-width:1} .value{font-weight:600} </style><text class=\"title\" x=\"36\" y=\"41\">A twofold component ratio is not a twofold pipeline gain</text><text class=\"sub\" x=\"36\" y=\"67\">Calculated sensitivity using M-size published means; downstream time is an assumption, not a measurement.</text><line x1=\"100\" y1=\"400.0\" x2=\"840\" y2=\"400.0\" stroke=\"#d6dbd3\" stroke-width=\"1\"/><text x=\"84\" y=\"404.0\" class=\"\" text-anchor=\"end\">1×</text><line x1=\"100\" y1=\"344.0\" x2=\"840\" y2=\"344.0\" stroke=\"#d6dbd3\" stroke-width=\"1\"/><text x=\"84\" y=\"348.0\" class=\"\" text-anchor=\"end\">1.25×</text><line x1=\"100\" y1=\"288.0\" x2=\"840\" y2=\"288.0\" stroke=\"#d6dbd3\" stroke-width=\"1\"/><text x=\"84\" y=\"292.0\" class=\"\" text-anchor=\"end\">1.5×</text><line x1=\"100\" y1=\"232.0\" x2=\"840\" y2=\"232.0\" stroke=\"#d6dbd3\" stroke-width=\"1\"/><text x=\"84\" y=\"236.0\" class=\"\" text-anchor=\"end\">1.75×</text><line x1=\"100\" y1=\"176.0\" x2=\"840\" y2=\"176.0\" stroke=\"#d6dbd3\" stroke-width=\"1\"/><text x=\"84\" y=\"180.0\" class=\"\" text-anchor=\"end\">2×</text><line x1=\"100\" y1=\"120.0\" x2=\"840\" y2=\"120.0\" stroke=\"#d6dbd3\" stroke-width=\"1\"/><text x=\"84\" y=\"124.0\" class=\"\" text-anchor=\"end\">2.25×</text><polyline fill=\"none\" stroke=\"#6f836f\" stroke-width=\"2\" points=\"120.0,192.90566037735843 126.9,259.2820512820512 133.8,293.43689320388347 140.7,314.24999999999994 147.6,328.26143790849676 154.5,338.3370786516853 161.4,345.9310344827586 168.3,351.859649122807 175.2,356.6166007905138 182.1,360.51798561151077 189.0,363.77557755775575 195.9,366.5365853658536 202.8,368.9065155807366 209.7,370.962962962963 216.60000000000002,372.7642679900745 223.5,374.3551401869159 230.4,375.7704194260486 237.3,377.0376569037657 244.2,378.1789264413519 251.1,379.21212121212125 258.0,380.1518987341772 264.9,381.0103806228374 271.8,381.7976782752902 278.70000000000005,382.5222929936306 285.6,383.1914241960184 292.5,383.811209439528 299.4,384.3869132290185 306.3,384.9230769230769 313.20000000000005,385.4236387782205 320.1,385.89203084832906 327.0,386.3312577833126 333.9,386.743961352657 340.8,387.13247362250877 347.70000000000005,387.498861047836 354.6,387.84496124031006 361.5,388.17241379310343 368.4,388.4826862539349 375.29999999999995,388.7770961145194 382.2,389.0568295114656 389.1,389.3229571984436 396.0,389.5764482431149 402.9,389.81818181818176 409.8,390.04895738893924 416.7,390.26950354609926 423.6,390.4804856895056 430.5,390.6825127334465 437.40000000000003,390.8761429758936 444.29999999999995,391.0618892508143 451.2,391.24022346368713 458.09999999999997,391.4115805946792 465.0,391.5763622409823 471.90000000000003,391.73493975903614 478.8,391.88765705838875 485.70000000000005,392.03483309143684 492.6,392.17676407697786 499.50000000000006,392.3137254901961 506.40000000000003,392.44597384721266 513.3,392.573748308525 520.2,392.69727212242185 527.0999999999999,392.81675392670155 534.0,392.93238892466195 540.9,393.04435994930293 547.8,393.1528384279476 554.7,393.25798525798524 561.6,393.3599516031458 568.5,393.4588796185935 575.4000000000001,393.554903112155 582.3,393.6481481481481 589.2,393.73873359954365 596.0999999999999,393.82677165354335 603.0,393.91236827509704 609.9,393.9956236323851 616.8,394.0766324878575 623.7,394.1554845580405 630.5999999999999,394.2322648449816 637.5,394.3070539419087 644.4,394.37992831541214 651.3000000000001,394.4509605662285 658.2,394.52021967049427 665.1,394.5877712031558 672.0,394.653677545056 678.9000000000001,394.71799807507216 685.8,394.78078934854966 692.6999999999999,394.8421052631579 699.6,394.9019972131909 706.5,394.9605142332415 713.4,395.0177031320926 720.3,395.07360861759423 727.2,395.1282734132268 734.1,395.1817383669886 741.0,395.23404255319144 747.9,395.28522336769754 754.8000000000001,395.3353166170846 761.7,395.3843566021867 768.5999999999999,395.43237619642116 775.5,395.4794069192751 782.4,395.52547900529964 789.3,395.57062146892656 796.1999999999999,395.6148621654015 803.1,395.65822784810126 810.0,395.7007442224833\"/><circle cx=\"120.0\" cy=\"192.90566037735843\" r=\"5\" fill=\"#6f836f\"/><circle cx=\"154.5\" cy=\"338.3370786516853\" r=\"5\" fill=\"#6f836f\"/><circle cx=\"258.0\" cy=\"380.1518987341772\" r=\"5\" fill=\"#6f836f\"/><circle cx=\"810.0\" cy=\"395.7007442224833\" r=\"5\" fill=\"#6f836f\"/><text x=\"80\" y=\"465\" class=\"\" text-anchor=\"start\" style=\"fill:#6f836f\">Quora · M</text><polyline fill=\"none\" stroke=\"#b37951\" stroke-width=\"2\" points=\"120.0,152.11443433029916 126.9,180.63981588032217 133.8,203.27760577915376 140.7,221.6800748362956 147.6,236.93413173652692 154.5,249.78408195429472 161.4,260.75675675675683 168.3,270.23553437712735 175.2,278.50605481198215 182.1,285.7855002995806 189.0,292.24194460146975 195.9,298.0074906367041 202.8,303.18740477399695 209.7,307.8666022232963 216.60000000000002,312.11433840479486 223.5,315.9876597620097 230.4,319.53398058252424 237.3,322.7930336168489 244.2,325.7983651226158 251.1,328.57849381790936 258.0,331.1578187071145 264.9,333.55733705123737 271.8,335.7952172448636 278.70000000000005,337.88725969371126 285.6,339.84727043231305 292.5,341.6873661670236 299.4,343.4182249925794 306.3,345.049293744595 313.20000000000005,346.58896049313535 320.1,348.0446988280185 327.0,349.42318917484744 333.9,350.7304212974929 340.8,351.97178130511463 347.70000000000005,353.1521258294422 354.6,354.2758455265052 361.5,355.3469196533146 368.4,356.3689631494621 375.29999999999995,357.3452673976281 382.2,358.2788356314292 389.1,359.1724137931035 396.0,360.02851750891176 402.9,360.84945574039847 409.8,361.6373515797947 416.7,362.39416058394164 423.6,363.12168698007355 430.5,363.82159802619094 437.40000000000003,364.4954367666232 444.29999999999995,365.14463338818797 451.2,365.7705153528461 458.09999999999997,366.37431645792907 465.0,366.9571849540648 471.90000000000003,367.52019083319135 478.8,368.0643323839839 485.70000000000005,368.59054209919265 492.6,369.09969200842926 499.50000000000006,369.59259850055827 506.40000000000003,370.0700266917883 513.3,370.53269438862264 520.2,370.9812756888415 527.0999999999999,371.41640425850954 534.0,371.8386763185109 540.9,372.248653370214 547.8,372.6468646864687 554.7,373.03380959117277 561.6,373.4099595480542 568.5,373.7757600770395 575.4000000000001,374.1316325145882 582.3,374.4779756326148 589.2,374.81516712907916 596.0999999999999,375.14356500195595 603.0,375.4635088170936 609.9,375.77532087940017 616.8,376.0793073158489 623.7,376.3757590779527 630.5999999999999,376.66495287060843 637.5,376.94715201354455 644.4,377.2226072410085 651.3000000000001,377.4915574447987 658.2,377.75423036527013 665.1,378.0108432345138 672.0,378.2616033755274 678.9000000000001,378.5067087608524 685.8,378.7463485338388 692.6999999999999,378.98070349542394 699.6,379.20994655905764 706.5,379.43424317617865 713.4,379.6537517344434 720.3,379.8686239307213 727.2,380.0790051207023 734.1,380.28503464680944 741.0,380.486846145972 747.9,380.6845678386868 754.8000000000001,380.87832280068216 761.7,381.0682292183931 768.5999999999999,381.2544006293638 775.5,381.4369461486026 782.4,381.61597068184017 789.3,381.79157512656417 796.1999999999999,381.96385656164256 803.1,382.13290842628174 810.0,382.2988206890148\"/><circle cx=\"120.0\" cy=\"152.11443433029916\" r=\"5\" fill=\"#b37951\"/><circle cx=\"154.5\" cy=\"249.78408195429472\" r=\"5\" fill=\"#b37951\"/><circle cx=\"258.0\" cy=\"331.1578187071145\" r=\"5\" fill=\"#b37951\"/><circle cx=\"810.0\" cy=\"382.2988206890148\" r=\"5\" fill=\"#b37951\"/><text x=\"360\" y=\"465\" class=\"\" text-anchor=\"start\" style=\"fill:#b37951\">Natural Questions · M</text><polyline fill=\"none\" stroke=\"#374f52\" stroke-width=\"2\" points=\"120.0,165.47651006711413 126.9,180.22641509433961 133.8,193.23076923076917 140.7,204.7821229050279 147.6,215.1111111111111 154.5,224.40201005025128 161.4,232.80382775119625 168.3,240.43835616438358 175.2,247.4061135371179 182.1,253.79079497907946 189.0,259.6626506024096 195.9,265.0810810810811 202.8,270.096654275093 209.7,274.75268817204307 216.60000000000002,279.08650519031147 223.5,283.13043478260875 230.4,286.9126213592233 237.3,290.4576802507837 244.2,293.78723404255317 251.1,296.92035398230087 258.0,299.87392550143267 264.9,302.66295264623955 271.8,305.30081300813015 278.70000000000005,307.79947229551453 285.6,310.1696658097687 292.5,312.421052631579 299.4,314.5623471882641 306.3,316.6014319809069 313.20000000000005,318.54545454545456 320.1,320.40091116173124 327.0,322.173719376392 333.9,323.8692810457516 340.8,325.4925373134328 347.70000000000005,327.0480167014614 354.6,328.53987730061345 361.5,329.9719438877755 368.4,331.34774066797644 375.29999999999995,332.67052023121386 382.2,333.94328922495276 389.1,335.16883116883116 396.0,336.34972677595624 402.9,337.48837209302326 409.8,338.58699472759224 416.7,339.6476683937824 423.6,340.67232597623087 430.5,341.6627712854758 437.40000000000003,342.6206896551724 444.29999999999995,343.5476575121163 451.2,344.4451510333863 458.09999999999997,345.3145539906103 465.0,346.15716486902926 471.90000000000003,346.9742033383916 478.8,347.7668161434978 485.70000000000005,348.5360824742268 492.6,349.28301886792457 499.50000000000006,350.00858369098717 506.40000000000003,350.7136812411848 513.3,351.3991655076495 520.2,352.0658436213992 527.0999999999999,352.7144790257104 534.0,353.3457943925234 540.9,353.9604743083004 547.8,354.55916775032506 554.7,355.14249037227216 561.6,355.71102661596956 568.5,356.2653316645807 575.4000000000001,356.80593325092707 582.3,357.3333333333333 589.2,357.848009650181 596.0999999999999,358.3504171632896 603.0,358.8409893992933 609.9,359.3201396973224 616.8,359.78826237054085 623.7,360.2457337883959 630.5999999999999,360.6929133858267 637.5,361.1301446051168 644.4,361.55775577557756 651.3000000000001,361.97606093579975 658.2,362.3853606027987 665.1,362.7859424920128 672.0,363.17808219178085 678.9000000000001,363.5620437956204 685.8,363.938080495356 692.6999999999999,364.3064351378958 699.6,364.6673407482305 706.5,365.021021021021 713.4,365.3676907829534 720.3,365.70755642787043 727.2,366.0408163265306 734.1,366.3676612127045 741.0,366.6882745471878 747.9,367.0028328611898 754.8000000000001,367.311506080449 761.7,367.6144578313253 768.5999999999999,367.9118457300275 775.5,368.20382165605093 782.4,368.4905320108206 789.3,368.7721179624665 796.1999999999999,369.0487156775908 803.1,369.32045654082526 810.0,369.58746736292426\"/><circle cx=\"120.0\" cy=\"165.47651006711413\" r=\"5\" fill=\"#374f52\"/><circle cx=\"154.5\" cy=\"224.40201005025128\" r=\"5\" fill=\"#374f52\"/><circle cx=\"258.0\" cy=\"299.87392550143267\" r=\"5\" fill=\"#374f52\"/><circle cx=\"810.0\" cy=\"369.58746736292426\" r=\"5\" fill=\"#374f52\"/><text x=\"640\" y=\"465\" class=\"\" text-anchor=\"start\" style=\"fill:#374f52\">HotpotQA · M</text><text x=\"120.0\" y=\"428\" class=\"\" text-anchor=\"middle\">0 ms</text><text x=\"258.0\" y=\"428\" class=\"\" text-anchor=\"middle\">20 ms</text><text x=\"396.0\" y=\"428\" class=\"\" text-anchor=\"middle\">40 ms</text><text x=\"534.0\" y=\"428\" class=\"\" text-anchor=\"middle\">60 ms</text><text x=\"672.0\" y=\"428\" class=\"\" text-anchor=\"middle\">80 ms</text><text x=\"810.0\" y=\"428\" class=\"\" text-anchor=\"middle\">100 ms</text><text x=\"470\" y=\"502\" class=\"sub\" text-anchor=\"middle\">Assumed equal downstream time per batch</text></svg>",
            "text/plain": "downstream-sensitivity.svg"
          },
          "metadata": {},
          "execution_count": 3
        }
      ],
      "id": "cell-5"
    },
    {
      "cell_type": "code",
      "metadata": {},
      "source": [
        "LocalSVG('gradient-overhead.svg')\n",
        "\n",
        "import base64\n",
        "from pathlib import Path\n",
        "print('__NOTEBOOK_IMAGE__svg+xml:' + base64.b64encode(Path('downstream-sensitivity.svg').read_bytes()).decode())\n",
        "print('__NOTEBOOK_IMAGE__svg+xml:' + base64.b64encode(Path('gradient-overhead.svg').read_bytes()).decode())\n"
      ],
      "execution_count": 4,
      "outputs": [
        {
          "output_type": "execute_result",
          "data": {
            "image/svg+xml": "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 920 550\" role=\"img\" aria-labelledby=\"t d\"><title id=\"t\">A predicted key changes the cost of the interface</title><desc id=\"d\">Gradient time / score time within each published configuration. Batch = 4096; 100-run means.</desc><rect width=\"100%\" height=\"100%\" fill=\"#faf9f5\"/><style>text{font-family:Arial,sans-serif;fill:#292d29;font-size:14px} .title{font-family:Georgia,serif;font-size:25px} .sub{fill:#646961;font-size:13px} .axis{stroke:#d6dbd3;stroke-width:1} .value{font-weight:600} </style><text class=\"title\" x=\"36\" y=\"41\">A predicted key changes the cost of the interface</text><text class=\"sub\" x=\"36\" y=\"67\">Gradient time / score time within each published configuration. Batch = 4096; 100-run means.</text><line x1=\"245.0\" y1=\"107\" x2=\"245.0\" y2=\"455\" stroke=\"#d6dbd3\" stroke-width=\"1\"/><text x=\"245.0\" y=\"482\" class=\"\" text-anchor=\"middle\">1×</text><line x1=\"358.0\" y1=\"107\" x2=\"358.0\" y2=\"455\" stroke=\"#d6dbd3\" stroke-width=\"1\"/><text x=\"358.0\" y=\"482\" class=\"\" text-anchor=\"middle\">1.25×</text><line x1=\"471.0\" y1=\"107\" x2=\"471.0\" y2=\"455\" stroke=\"#d6dbd3\" stroke-width=\"1\"/><text x=\"471.0\" y=\"482\" class=\"\" text-anchor=\"middle\">1.5×</text><line x1=\"584.0\" y1=\"107\" x2=\"584.0\" y2=\"455\" stroke=\"#d6dbd3\" stroke-width=\"1\"/><text x=\"584.0\" y=\"482\" class=\"\" text-anchor=\"middle\">1.75×</text><line x1=\"697.0\" y1=\"107\" x2=\"697.0\" y2=\"455\" stroke=\"#d6dbd3\" stroke-width=\"1\"/><text x=\"697.0\" y=\"482\" class=\"\" text-anchor=\"middle\">2×</text><line x1=\"810.0\" y1=\"107\" x2=\"810.0\" y2=\"455\" stroke=\"#d6dbd3\" stroke-width=\"1\"/><text x=\"810.0\" y=\"482\" class=\"\" text-anchor=\"middle\">2.25×</text><text x=\"36\" y=\"126\" class=\"\" text-anchor=\"start\">Quora · S</text><line x1=\"248.5312499999999\" y1=\"121\" x2=\"636.2835820895523\" y2=\"121\" stroke=\"#929d90\" stroke-width=\"3\"/><circle cx=\"248.5312499999999\" cy=\"121\" r=\"5\" fill=\"#394d3c\"/><circle cx=\"636.2835820895523\" cy=\"121\" r=\"5\" fill=\"#b37951\"/><text x=\"646.2835820895523\" y=\"126\" class=\"\" text-anchor=\"start\">1.87×</text><text x=\"36\" y=\"163\" class=\"\" text-anchor=\"start\">Quora · M</text><line x1=\"242.87793427230045\" y1=\"158\" x2=\"638.9449541284404\" y2=\"158\" stroke=\"#929d90\" stroke-width=\"3\"/><circle cx=\"242.87793427230045\" cy=\"158\" r=\"5\" fill=\"#394d3c\"/><circle cx=\"638.9449541284404\" cy=\"158\" r=\"5\" fill=\"#b37951\"/><text x=\"648.9449541284404\" y=\"163\" class=\"\" text-anchor=\"start\">1.87×</text><text x=\"36\" y=\"200\" class=\"\" text-anchor=\"start\">Quora · L</text><line x1=\"245.0\" y1=\"195\" x2=\"501.6633165829145\" y2=\"195\" stroke=\"#929d90\" stroke-width=\"3\"/><circle cx=\"245.0\" cy=\"195\" r=\"5\" fill=\"#394d3c\"/><circle cx=\"501.6633165829145\" cy=\"195\" r=\"5\" fill=\"#b37951\"/><text x=\"511.6633165829145\" y=\"200\" class=\"\" text-anchor=\"start\">1.57×</text><text x=\"36\" y=\"237\" class=\"\" text-anchor=\"start\">Natural Questions · S</text><line x1=\"245.0\" y1=\"232\" x2=\"649.421052631579\" y2=\"232\" stroke=\"#929d90\" stroke-width=\"3\"/><circle cx=\"245.0\" cy=\"232\" r=\"5\" fill=\"#394d3c\"/><circle cx=\"649.421052631579\" cy=\"232\" r=\"5\" fill=\"#b37951\"/><text x=\"659.421052631579\" y=\"237\" class=\"\" text-anchor=\"start\">1.89×</text><text x=\"36\" y=\"274\" class=\"\" text-anchor=\"start\">Natural Questions · M</text><line x1=\"245.58854166666663\" y1=\"269\" x2=\"649.421052631579\" y2=\"269\" stroke=\"#929d90\" stroke-width=\"3\"/><circle cx=\"245.58854166666663\" cy=\"269\" r=\"5\" fill=\"#394d3c\"/><circle cx=\"649.421052631579\" cy=\"269\" r=\"5\" fill=\"#b37951\"/><text x=\"659.421052631579\" y=\"274\" class=\"\" text-anchor=\"start\">1.89×</text><text x=\"36\" y=\"311\" class=\"\" text-anchor=\"start\">Natural Questions · L</text><line x1=\"244.24666666666664\" y1=\"306\" x2=\"578.2542372881355\" y2=\"306\" stroke=\"#929d90\" stroke-width=\"3\"/><circle cx=\"244.24666666666664\" cy=\"306\" r=\"5\" fill=\"#394d3c\"/><circle cx=\"578.2542372881355\" cy=\"306\" r=\"5\" fill=\"#b37951\"/><text x=\"588.2542372881355\" y=\"311\" class=\"\" text-anchor=\"start\">1.74×</text><text x=\"36\" y=\"348\" class=\"\" text-anchor=\"start\">HotpotQA · S</text><line x1=\"245.0\" y1=\"343\" x2=\"666.8319907940161\" y2=\"343\" stroke=\"#929d90\" stroke-width=\"3\"/><circle cx=\"245.0\" cy=\"343\" r=\"5\" fill=\"#394d3c\"/><circle cx=\"666.8319907940161\" cy=\"343\" r=\"5\" fill=\"#b37951\"/><text x=\"676.8319907940161\" y=\"348\" class=\"\" text-anchor=\"start\">1.93×</text><text x=\"36\" y=\"385\" class=\"\" text-anchor=\"start\">HotpotQA · M</text><line x1=\"245.0\" y1=\"380\" x2=\"660.0440251572327\" y2=\"380\" stroke=\"#929d90\" stroke-width=\"3\"/><circle cx=\"245.0\" cy=\"380\" r=\"5\" fill=\"#394d3c\"/><circle cx=\"660.0440251572327\" cy=\"380\" r=\"5\" fill=\"#b37951\"/><text x=\"670.0440251572327\" y=\"385\" class=\"\" text-anchor=\"start\">1.92×</text><text x=\"36\" y=\"422\" class=\"\" text-anchor=\"start\">HotpotQA · L</text><line x1=\"246.5859649122807\" y1=\"417\" x2=\"650.9363057324842\" y2=\"417\" stroke=\"#929d90\" stroke-width=\"3\"/><circle cx=\"246.5859649122807\" cy=\"417\" r=\"5\" fill=\"#394d3c\"/><circle cx=\"650.9363057324842\" cy=\"417\" r=\"5\" fill=\"#b37951\"/><text x=\"660.9363057324842\" y=\"422\" class=\"\" text-anchor=\"start\">1.90×</text><circle cx=\"290\" cy=\"512\" r=\"5\" fill=\"#394d3c\"/><text x=\"301\" y=\"517\" class=\"\" text-anchor=\"start\">KeyNet</text><circle cx=\"440\" cy=\"512\" r=\"5\" fill=\"#b37951\"/><text x=\"451\" y=\"517\" class=\"\" text-anchor=\"start\">SupportNet</text></svg>",
            "text/plain": "gradient-overhead.svg"
          },
          "metadata": {},
          "execution_count": 4
        }
      ],
      "id": "cell-6"
    }
  ]
}
