|
@@ -2,53 +2,29 @@
|
|
|
"cells": [
|
|
|
{
|
|
|
"cell_type": "code",
|
|
|
- "execution_count": 32,
|
|
|
+ "execution_count": 6,
|
|
|
"metadata": {},
|
|
|
"outputs": [],
|
|
|
"source": [
|
|
|
- "%load_ext line_profiler\n",
|
|
|
- "%matplotlib inline\n",
|
|
|
- "\n",
|
|
|
- "import matplotlib.pyplot as plt\n",
|
|
|
- "from IPython.display import set_matplotlib_formats\n",
|
|
|
+ "import sys\n",
|
|
|
+ "import time\n",
|
|
|
+ "import pandas as pd\n",
|
|
|
"import numpy as np\n",
|
|
|
+ "\n",
|
|
|
+ "# QCGPU Imports\n",
|
|
|
"import qcgpu\n",
|
|
|
+ "\n",
|
|
|
+ "# ProjectQ Imports\n",
|
|
|
"from projectq import MainEngine\n",
|
|
|
"import projectq.ops as ops\n",
|
|
|
"from projectq.backends import Simulator\n",
|
|
|
- "import sys\n",
|
|
|
- "import time\n",
|
|
|
- "\n",
|
|
|
- "set_matplotlib_formats('png', 'pdf')\n",
|
|
|
- "plt.style.use('ggplot')"
|
|
|
- ]
|
|
|
- },
|
|
|
- {
|
|
|
- "cell_type": "code",
|
|
|
- "execution_count": 27,
|
|
|
- "metadata": {},
|
|
|
- "outputs": [],
|
|
|
- "source": [
|
|
|
- "def plot_qcgpu_state(state):\n",
|
|
|
- " labels = map(\n",
|
|
|
- " lambda i: np.binary_repr(i, state.num_qubits), \n",
|
|
|
- " range(0, 2**state.num_qubits)\n",
|
|
|
- " )\n",
|
|
|
- "\n",
|
|
|
- " y_pos = np.arange(len(labels))\n",
|
|
|
- " performance = list(state.probabilities())\n",
|
|
|
- " \n",
|
|
|
- " plt.bar(y_pos, performance, align='center')\n",
|
|
|
- " plt.xticks(y_pos, labels)\n",
|
|
|
- " plt.ylabel('Amplitude')\n",
|
|
|
- " plt.title('Probability Amplitudes')\n",
|
|
|
- "\n",
|
|
|
- " plt.show()"
|
|
|
+ "from projectq.types import Qureg\n",
|
|
|
+ "\n"
|
|
|
]
|
|
|
},
|
|
|
{
|
|
|
"cell_type": "code",
|
|
|
- "execution_count": 28,
|
|
|
+ "execution_count": 7,
|
|
|
"metadata": {},
|
|
|
"outputs": [],
|
|
|
"source": [
|
|
@@ -100,32 +76,35 @@
|
|
|
},
|
|
|
{
|
|
|
"cell_type": "code",
|
|
|
- "execution_count": 29,
|
|
|
+ "execution_count": 8,
|
|
|
"metadata": {},
|
|
|
- "outputs": [],
|
|
|
+ "outputs": [
|
|
|
+ {
|
|
|
+ "name": "stdout",
|
|
|
+ "output_type": "stream",
|
|
|
+ "text": [
|
|
|
+ "started\n",
|
|
|
+ "('ended: ', 0.2940499782562256)\n"
|
|
|
+ ]
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "data": {
|
|
|
+ "text/plain": [
|
|
|
+ "0.2940499782562256"
|
|
|
+ ]
|
|
|
+ },
|
|
|
+ "execution_count": 8,
|
|
|
+ "metadata": {},
|
|
|
+ "output_type": "execute_result"
|
|
|
+ }
|
|
|
+ ],
|
|
|
"source": [
|
|
|
- "# h = qcgpu.gate.h()\n",
|
|
|
- "# x = qcgpu.gate.x()\n",
|
|
|
- "# s = qcgpu.gate.s()\n",
|
|
|
- "# t = qcgpu.gate.t()\n",
|
|
|
- "# y = qcgpu.gate.y()\n",
|
|
|
- "# z = qcgpu.gate.z()\n",
|
|
|
- "\n",
|
|
|
- "# # Random Circuit\n",
|
|
|
- "# state = qcgpu.State(5)\n",
|
|
|
- "\n",
|
|
|
- "# state.apply_gate(h, 0)\n",
|
|
|
- "# state.apply_gate(t, 0)\n",
|
|
|
- "# state.apply_gate(y, 0)\n",
|
|
|
- "# state.apply_gate(z, 0)\n",
|
|
|
- "# state.apply_gate(h, 0)\n",
|
|
|
- "\n",
|
|
|
- "# state.num_qubits"
|
|
|
+ "bench_qcgpu(26,5)"
|
|
|
]
|
|
|
},
|
|
|
{
|
|
|
"cell_type": "code",
|
|
|
- "execution_count": 35,
|
|
|
+ "execution_count": 9,
|
|
|
"metadata": {},
|
|
|
"outputs": [
|
|
|
{
|
|
@@ -133,21 +112,41 @@
|
|
|
"output_type": "stream",
|
|
|
"text": [
|
|
|
"started\n",
|
|
|
- "('ended: ', 0.2988259792327881)\n"
|
|
|
+ "('ended: ', 12.032409906387329)\n"
|
|
|
]
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "data": {
|
|
|
+ "text/plain": [
|
|
|
+ "12.032409906387329"
|
|
|
+ ]
|
|
|
+ },
|
|
|
+ "execution_count": 9,
|
|
|
+ "metadata": {},
|
|
|
+ "output_type": "execute_result"
|
|
|
}
|
|
|
],
|
|
|
"source": [
|
|
|
- "%lprun -f bench_qcgpu bench_qcgpu(26,5)"
|
|
|
+ "bench_projectq(26,5)"
|
|
|
]
|
|
|
},
|
|
|
{
|
|
|
"cell_type": "code",
|
|
|
- "execution_count": 31,
|
|
|
+ "execution_count": 13,
|
|
|
"metadata": {},
|
|
|
"outputs": [],
|
|
|
"source": [
|
|
|
- "# bench_projectq(26,5)"
|
|
|
+ "raw_data = {\n",
|
|
|
+ " 'num_qubits': [2,2,2,3,3,3,4,4,4,5,5,5,6,6,6], \n",
|
|
|
+ " 'depth': [10,20,30,10,20,30,10,20,30,10,20,30,10,20,30], \n",
|
|
|
+ " 'time': [0.2940499782562256, 0.2940499782562256, 0.2940499782562256, 0.2940499782562256, 0.2940499782562256, 0.2940499782562256, 0.2940499782562256, 0.2940499782562256, 0.2940499782562256, 0.2940499782562256, 0.2940499782562256, 0.2940499782562256, 0.2940499782562256, 0.2940499782562256, 0.2940499782562256]\n",
|
|
|
+ "}\n",
|
|
|
+ "\n",
|
|
|
+ "df = pd.DataFrame(raw_data, columns = ['num_qubits', 'depth', 'time'])\n",
|
|
|
+ "\n",
|
|
|
+ "df\n",
|
|
|
+ "\n",
|
|
|
+ "df.to_csv('out.csv')"
|
|
|
]
|
|
|
},
|
|
|
{
|