Skip to content

Commit

Permalink
Resource estimation
Browse files Browse the repository at this point in the history
  • Loading branch information
fedimser committed Jan 19, 2025
1 parent 6dec883 commit d0cc3ca
Show file tree
Hide file tree
Showing 19 changed files with 12,228 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"id": "077b48c6",
"metadata": {},
"outputs": [],
"source": [
"import qsharp\n",
"import json\n",
"from diskcache import Cache\n",
"from matplotlib import pyplot as plt\n",
"\n",
"ws_range = list(range(1,11))\n",
"\n",
"cache2 = Cache(\"~/quant-arith-cache/re-multiply-window\")\n",
"\n",
"@cache2.memoize()\n",
"def estimate_resources_multiply_window(op, n, window_size):\n",
" est = qsharp.estimate(f\"{op}({n},{n},0L,0L,0L,{window_size})\")\n",
" return json.dumps(est) \n",
"\n",
"for n in [32, 64, 128, 256, 512]:\n",
" runtime = []\n",
" for window_size in ws_range:\n",
" op = \"QuantumArithmetic.CG20192.MultiplyWindow\"\n",
" est = json.loads(estimate_resources_multiply_window(op, n, window_size))\n",
" runtime.append(est['physicalCounts']['runtime']/10**9)\n",
" plt.plot(ws_range, runtime, label=f\"MulWindow, n={n}\", marker='.')\n",
" \n",
"plt.legend()\n",
"plt.xlabel('Window size')\n",
"plt.ylabel('Estimated runtime, sec')\n",
"plt.title('Estimated runtime of multiplication')\n",
"plt.xlim([0,20])\n",
"plt.yscale('log')"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"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.12.3"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
Loading

0 comments on commit d0cc3ca

Please sign in to comment.