Commit db5a885c authored by Abhishek's avatar Abhishek

.

parent 5995e619
......@@ -471,26 +471,6 @@
"\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"editable": false,
"nbgrader": {
"grade": true,
"grade_id": "exercise1",
"locked": true,
"points": "2",
"solution": false
}
},
"outputs": [],
"source": [
"###\n",
"### AUTOGRADER TEST - DO NOT REMOVE\n",
"###\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
......@@ -548,26 +528,6 @@
"print(gap)\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"editable": false,
"nbgrader": {
"grade": true,
"grade_id": "exercise2",
"locked": true,
"points": "2",
"solution": false
}
},
"outputs": [],
"source": [
"###\n",
"### AUTOGRADER TEST - DO NOT REMOVE\n",
"###\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
......@@ -628,26 +588,6 @@
"print(gap)\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"editable": false,
"nbgrader": {
"grade": true,
"grade_id": "exercise3",
"locked": true,
"points": "1",
"solution": false
}
},
"outputs": [],
"source": [
"###\n",
"### AUTOGRADER TEST - DO NOT REMOVE\n",
"###\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
......
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# **Quantum Computing: Lab 10**"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"In this lab we are going to work on creating Error Correction Codes on Quantum Circuits."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Before you begin, execute this cell to import numpy and packages from the D-Wave Ocean suite, and all necessary functions for the gate-model framework you are going to use, whether that is the Forest SDK or Qiskit. In the case of Forest SDK, it also starts the qvm and quilc servers."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"%run -i \"assignment_helper_QML.py\"\n",
"%matplotlib inline"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# **Classical Hamming Code** #"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import numpy as np\n",
"import math\n",
"\n",
"G = np.array([[1, 0, 0, 0, 1, 1, 1],\n",
" [0, 1, 0, 0, 1, 1, 0],\n",
" [0, 0, 1, 0, 1, 0, 1],\n",
" [0, 0, 0, 1, 0, 1, 1]])\n",
"# G corrects one error\n",
"\n",
"\n",
"# Codewords are row space(mod 2)\n",
"# Encode: mG\n",
"\n",
"# Suppose is m = [1, 1, 0, 1]\n",
"m = np.array([[0, 1, 1, 1]])\n",
"\n",
"\n",
"print(np.matmul(m,G) % 2)\n",
"\n",
"e = np.array([[0, 0, 0, 0, 0, 0, 0]])\n",
"e[0,3] = 1\n",
"\n",
"H = np.array([[1, 1, 1],\n",
" [1, 1, 0],\n",
" [1, 0, 1],\n",
" [0, 1, 1],\n",
" [1, 0, 0],\n",
" [0, 1, 0],\n",
" [0, 0, 1]])\n",
"\n",
"print(np.matmul((np.matmul(m,G) + e),H)%2)\n",
"print(np.matmul(e,H)%2)\n",
"# and hence we know that the error is at ith position of e\n",
"\n",
"#print(np.matmul(e,H))"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# **Shor's Bit Error Correction Code** #\n",
"\n",
"\n",
"<img src=\"images/qubit.png\" style=\"width: 600px;\"/>\n",
"\n",
"_*try placing a qubit error between the barriers_"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## *Create some arbitrary quantum State* ##"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from qiskit import ClassicalRegister, QuantumRegister, QuantumCircuit\n",
"from qiskit.tools.visualization import circuit_drawer, plot_histogram\n",
"from qiskit import execute\n",
"from qiskit import BasicAer\n",
"import numpy as np\n",
"%matplotlib inline\n",
"backend = BasicAer.get_backend('qasm_simulator')\n",
"\n",
"q = QuantumRegister(1,'q')\n",
"c = ClassicalRegister(1,'c')\n",
"circuit = QuantumCircuit(q, c)\n",
"\n",
"\n",
"circuit.u3(np.pi/3, 2*np.pi/7, np.pi/5, q[0])\n",
"\n",
"amp = get_amplitudes(circuit)\n",
"print(amp)\n",
"circuit.measure(q[0],c[0])\n",
"\n",
"num_shots = 1000\n",
"job = execute(circuit, backend=backend, shots=num_shots)\n",
"\n",
"result = job.result()\n",
"res = result.get_counts()\n",
"plot_histogram(res)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## *Encoder* ##"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from qiskit import ClassicalRegister, QuantumRegister, QuantumCircuit\n",
"from qiskit.tools.visualization import circuit_drawer, plot_histogram\n",
"from qiskit import execute\n",
"from qiskit import BasicAer\n",
"import numpy as np\n",
"%matplotlib inline\n",
"backend = BasicAer.get_backend('qasm_simulator')\n",
"\n",
"q = QuantumRegister(3,'q')\n",
"c = ClassicalRegister(1,'c')\n",
"circuit = QuantumCircuit(q, c)\n",
"\n",
"\n",
"circuit.u3(np.pi/3, 2*np.pi/7, np.pi/5, q[0])\n",
"circuit.cx(q[0], q[1])\n",
"circuit.cx(q[0], q[2])\n",
"circuit.barrier()\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## *Error* ##"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"circuit.x(q[0])\n",
"circuit.barrier()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## *Decoder* ##"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"\n",
"circuit.cx(q[0], q[1])\n",
"circuit.cx(q[0], q[2])\n",
"circuit.ccx(q[1], q[2], q[0])\n",
"\n",
"amp = get_amplitudes(circuit)\n",
"\n",
"\n",
"circuit.measure(q[0],c[0])\n",
"# circuit.measure(q[1],c[1])\n",
"# circuit.measure(q[2],c[2])\n",
"\n",
"\n",
"circuit_drawer(circuit, output='mpl')"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"num_shots = 20000\n",
"job = execute(circuit, backend=backend, shots=num_shots)\n",
"\n",
"result = job.result()\n",
"res = result.get_counts()\n",
"plot_histogram(res)\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"print(amp)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# **Shor's Phase Error Correction Code** #\n",
"\n",
"\n",
"<img src=\"images/phase.png\" style=\"width: 700px;\"/>\n",
"\n",
"_*try placing a qubit error between the barriers_"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## *Encoder* ##"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from qiskit import ClassicalRegister, QuantumRegister, QuantumCircuit\n",
"from qiskit.tools.visualization import circuit_drawer, plot_histogram\n",
"from qiskit import execute\n",
"from qiskit import BasicAer\n",
"import numpy as np\n",
"%matplotlib inline\n",
"backend = BasicAer.get_backend('qasm_simulator')\n",
"#backend = BasicAer.get_backend('statevector_simulator')\n",
"\n",
"q = QuantumRegister(3,'q')\n",
"c = ClassicalRegister(3,'c')\n",
"circuit = QuantumCircuit(q, c)\n",
"\n",
"\n",
"circuit.u3(np.pi/3, 2*np.pi/7, np.pi/5, q[0])\n",
"circuit.cx(q[0], q[1])\n",
"circuit.cx(q[0], q[2])\n",
"circuit.h(q[0])\n",
"circuit.h(q[1])\n",
"circuit.h(q[2])\n",
"\n",
"circuit.barrier()\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## *Error* ##"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"circuit.z(q[0])\n",
"circuit.barrier()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## *Decoder* ##"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"circuit.h(q[0])\n",
"circuit.h(q[1])\n",
"circuit.h(q[2])\n",
"circuit.cx(q[0], q[1])\n",
"circuit.cx(q[0], q[2])\n",
"circuit.ccx(q[1], q[2], q[0])\n",
"\n",
"#circuit.x(q[0])\n",
"amp = get_amplitudes(circuit)\n",
"\n",
"circuit.measure(q[0],c[0])\n",
"circuit.measure(q[1],c[1])\n",
"circuit.measure(q[2],c[2])\n",
"\n",
"\n",
"circuit_drawer(circuit, output='mpl')"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"num_shots = 20000\n",
"job = execute(circuit, backend=backend, shots=num_shots)\n",
"\n",
"result = job.result()\n",
"res = result.get_counts()\n",
"plot_histogram(res)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"print(amp)\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# **EXERCISE: Build Shor's 9-Qubit Bit-Phase Error Correction Code** #"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<img src=\"images/shors9.png\" style=\"width: 800px;\"/>\n",
"\n",
"_*try placing a qubit error between the barriers_"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"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.6.7"
}
},
"nbformat": 4,
"nbformat_minor": 4
}
......@@ -4,7 +4,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# **Quantum Computing: Lab 10** #"
"# **Quantum Computing: Lab 11** #"
]
},
{
......@@ -335,7 +335,7 @@
{
"data": {
"text/plain": [
"[<matplotlib.lines.Line2D at 0x7f30e89d1860>]"
"[<matplotlib.lines.Line2D at 0x7fe4a2443668>]"
]
},
"execution_count": 9,
......@@ -425,9 +425,9 @@
"name": "stdout",
"output_type": "stream",
"text": [
"Ancilla post-selection probability was found to be 0.732421875\n",
"Probability for class 0 is 0.6306666666666667\n",
"Probability for class 1 is 0.36933333333333335\n"
"Ancilla post-selection probability was found to be 0.72265625\n",
"Probability for class 0 is 0.6162162162162163\n",
"Probability for class 1 is 0.3837837837837838\n"
]
}
],
......@@ -459,9 +459,9 @@
"name": "stdout",
"output_type": "stream",
"text": [
"Ancilla post-selection probability was found to be 0.912109375\n",
"Probability for class 0 is 0.5524625267665952\n",
"Probability for class 1 is 0.4475374732334047\n"
"Ancilla post-selection probability was found to be 0.908203125\n",
"Probability for class 0 is 0.535483870967742\n",
"Probability for class 1 is 0.4645161290322581\n"
]
}
],
......
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# **Quantum Computing: Lab 11**"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"In this lab we are going to work on creating Error Correction Codes on Quantum Circuits."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Before you begin, execute this cell to import numpy and packages from the D-Wave Ocean suite, and all necessary functions for the gate-model framework you are going to use, whether that is the Forest SDK or Qiskit. In the case of Forest SDK, it also starts the qvm and quilc servers."
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Available frameworks:\n",
"Qiskit\n",
"D-Wave Ocean\n"
]
}
],
"source": [
"%run -i \"assignment_helper_QML.py\"\n",
"%matplotlib inline"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# **Hamming Code** #"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import numpy as np\n",
"import math\n",
"\n",
"G = np.array([[1, 0, 0, 0, 1, 1, 1],\n",
" [0, 1, 0, 0, 1, 1, 0],\n",
" [0, 0, 1, 0, 1, 0, 1],\n",
" [0, 0, 0, 1, 0, 1, 1]])\n",
"# G corrects one error\n",
"\n",
"\n",
"# Codewords are row space(mod 2)\n",
"# Encode: mG\n",
"\n",
"# Suppose is m = [1, 1, 0, 1]\n",
"m = np.array([[0, 1, 1, 1]])\n",
"\n",
"\n",
"print(np.matmul(m,G) % 2)\n",
"\n",
"e = np.array([[0, 0, 0, 0, 0, 0, 0]])\n",
"e[0,3] = 1\n",
"\n",
"H = np.array([[1, 1, 1],\n",
" [1, 1, 0],\n",
" [1, 0, 1],\n",
" [0, 1, 1],\n",
" [1, 0, 0],\n",
" [0, 1, 0],\n",
" [0, 0, 1]])\n",
"\n",
"print(np.matmul((np.matmul(m,G) + e),H)%2)\n",
"print(np.matmul(e,H)%2)\n",
"# and hence we know that the error is at ith position of e\n",
"\n",
"#print(np.matmul(e,H))"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# **Shor's Bit Error Correction Code** #\n",
"\n",
"\n",
"<img src=\"images/qubit.png\" style=\"width: 600px;\"/>"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## *Create some arbitrary quantum State* ##"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"[0.8660254+0.j 0.3117449+0.39091574j]\n"
]
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAccAAAE1CAYAAACSpiugAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMi40LCBodHRwOi8vbWF0cGxvdGxpYi5vcmcv7US4rQAAHklJREFUeJzt3X+UXWV97/H3l5CJSUxiJkzHGcIkhMRx8oMwQHuR8kshXsErCyNL2lJErXIRpdfGXihURey9aS+CwlK8lJQKiFR+BVvBVKRTjShVm0yGhAzTpJMfJBnjkOQmMb8mTp77xzmJk81MZg6ZOSeZeb/WOitnP/vZ53wPh5NP9t7PfnaklJAkSb91QqkLkCTpWGM4SpKUYThKkpRhOEqSlGE4SpKUYThKkpRhOEqSlGE4SpKUYThKkpRxYqkLGCgTJkxINTU1pS5DknQMWbZs2WsppYre+g3acKypqaGhoaHUZUiSjiHl5eXr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wh08dJkjToGY6SJGUYjpJ0DHj++ef5vd/7Pc466yzuvvvu162/9957OeecczjvvPO44oorePXVVw9bv2PHDmbMmMFNN90EwM6dO7ngggsOPaZOncott9xSlM8yGBiOklRinZ2d3HTTTTz++OO8+OKLPPXUU7zyyiuH9Tn99NNpaGjghRde4PLLL+e22247bP38+fM599xzDy2PGTOGxYsXH3qccsopvO997yvK5xkMDEdJKrElS5Zw6qmnMnnyZMrKypg7dy6LFi06rM/555/PqFGjADj77LPZtGnToXXLli2jvb2dd76z+3tDrF69mvb2dt7xjncM3IcYZAxHSSqxtrY2Tj755EPL1dXVtLW19dj/kUce4ZJLLgHgwIEDfO5zn+OLX/xij/0XLlzI+9//fiKi/4oe5JzhRpKOI48//jiNjY0888wzADzwwAPMmTPnsHDNWrhwIffdd1+xShwUDEdJKrGqqio2btx4aHnTpk1UVVW9rt8Pf/hD7rrrLp555hlGjBgBwC9+8QtefPFFHnjgAXbt2kVHRwejR48+dE5yxYoVdHZ2csYZZxTnwwwShqMkldiZZ55Ja2sr69ato6qqioULF3L//fcf1uell15i3rx5PPHEE1RUVBxq79rv0UcfZdmyZYcN1nnqqaeYO3fuwH+IQcZwlKQSO/HEE7njjju48sor6ezs5Oqrr6auro758+dTX1/PpZdeym233cauXbv4yEdyE5ZNnDiRRx99tNfX/s53vsNjjz020B9h0ImUUqlrGBD19fWpoaHhqF/npofG90M1Otbcce22UpcgqQTKy8uXpJTO7q2fo1UlScowHCVJyjAcJUnKMBwlScpwtKqkQcVBdINTsQfRuecoSVKG4ShJUobhKElShuEoSVKG4ShJUobhKElShuEoSVKG4ShJUobhKElShuEoSVJG0cMxIm6IiDURsTcilkTE+UfoOzcinouI9ojYGRE/i4jLi1mvJGnoKWo4RsRVwD3AfKAe+CmwKCJqetjkQqABeG++//eAp48UqJIkHa1iTzw+D3gwpbQgv3xjRLwH+ARwS7ZzSul/ZJpuj4j3AlcAPx7QSiVJQ1bR9hwjogw4C3gus+o54NwCXmoMUNzp2SVJQ0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5vckrgTcBbwEeSin9SUkKHWQMxyEuf1nHe4ErgL3k5rt9IqX0SkkLk3RIRIwHKlNKr0REGbC/68CciLgK+AfgTAfS9Q/DUYdExAkppQOlrkNS7/LjBSKl1BkRHyd3SHVUqesaLE4sdQE6dhiM0vEj83sdA9xWqloGI/ccJek4FxHDgU7/gdt/DEdJkjK8zlGSpAzDUZKkDMNRkqQMw1GSpAzDUZKkjP8P6JQ/gKGm2cYAAAAASUVORK5CYII=\n",
"text/plain": [
"<Figure size 504x360 with 1 Axes>"
]
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"from qiskit import ClassicalRegister, QuantumRegister, QuantumCircuit\n",
"from qiskit.tools.visualization import circuit_drawer, plot_histogram\n",
"from qiskit import execute\n",
"from qiskit import BasicAer\n",
"import numpy as np\n",
"%matplotlib inline\n",
"backend = BasicAer.get_backend('qasm_simulator')\n",
"\n",
"q = QuantumRegister(1,'q')\n",