{
  "cells": [
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "\n# Batch size vs achieved HP-AXI bandwidth\n\nSynthetic illustration of the measured HP-AXI read bandwidth the pccx GEMV\ncore achieves as a function of autoregressive batch size. Numbers are\nplausibility-scaled for an LPDDR4-3200 KV260 setup (peak ~12.8 GB/s\naggregate across HP0-HP3) and are *not* measurement results \u2014 they're here\nto exercise the plotting pipeline.\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "import numpy as np\nimport matplotlib.pyplot as plt\n\nimport scienceplots  # noqa: F401  (registers 'science' / 'ieee' styles)\n\nplt.style.use([\"science\", \"ieee\", \"no-latex\"])\n\nrng = np.random.default_rng(seed=42)\n\n# -- Synthetic data ---------------------------------------------------------\nbatch = np.array([1, 2, 4, 8, 16, 32, 64, 128, 256])\n\n# A simple saturation model: GEMV is weight-bandwidth bound at small batch,\n# asymptotically approaching the HP-AXI peak at large batch because weights\n# amortize across activations.\npeak = 12.8                                     # GB/s aggregate\nk = 0.22\nbw_nominal = peak * (1 - np.exp(-k * batch))\nbw = bw_nominal + rng.normal(0, 0.12, size=batch.shape)\n\n# -- Figure -----------------------------------------------------------------\nfig, ax = plt.subplots(figsize=(3.4, 2.1))\n\nax.plot(batch, bw, marker=\"o\", label=\"HP-AXI (GEMV)\")\nax.axhline(peak, linestyle=\"--\", linewidth=0.8, label=\"LPDDR4 peak (12.8 GB/s)\")\n\nax.set_xscale(\"log\", base=2)\nax.set_xticks(batch)\nax.get_xaxis().set_major_formatter(plt.ScalarFormatter())\n\nax.set_xlabel(\"Decode batch size\")\nax.set_ylabel(\"Achieved bandwidth (GB/s)\")\nax.set_ylim(0, peak * 1.08)\nax.set_title(\"GEMV bandwidth vs. batch (synthetic)\")\nax.legend(loc=\"lower right\", frameon=False)\n\nfig.tight_layout()\nplt.show()"
      ]
    }
  ],
  "metadata": {
    "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.11.14"
    }
  },
  "nbformat": 4,
  "nbformat_minor": 0
}