-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
19 changed files
with
12,228 additions
and
0 deletions.
There are no files selected for viewing
62 changes: 62 additions & 0 deletions
62
resource_estimate/Resource estimation for windowed multiplication by constant.ipynb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} |
Oops, something went wrong.