EntanglementDistillation_DEJMPS_EN.ipynb 15.2 KB
Newer Older
Q
Quleaf 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Entanglement Distillation -- DEJMPS Protocol\n",
    "\n",
    "\n",
    "<em> Copyright (c) 2021 Institute for Quantum Computing, Baidu Inc. All Rights Reserved. </em>"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Overview\n",
    "\n",
    "Before reading this tutorial, we highly recommend you to read the [BBPSSW protocol](./EntanglementDistillation_BBPSSW_EN.ipynb) first if you are not familiar with entanglement distillation. The DEJMPS protocol, introduced by Deutsch et al. [1], is similar to the BBPSSW protocol. The main difference between these two protocols is the state for distillation: the DEJMPS protocol can distill Bell-diagonal states, while the BBPSSW protocol could distill isotropic states. In entanglement distillation, the main purpose is to generate a **maximally entangled state** $|\\Phi^+\\rangle$ from many copies of imperfect entangled states, using only LOCC operations. Recall the four Bell states,\n",
    "\n",
    "$$ \n",
    "\\begin{align*}\n",
    "|\\Phi^{\\pm}\\rangle_{AB} &= \\frac{1}{\\sqrt{2}}(|0\\rangle_A\\otimes|0\\rangle_B \\pm |1\\rangle_A\\otimes|1\\rangle_B), \\\\\n",
Q
Quleaf 已提交
24
    "|\\Psi^{\\pm}\\rangle_{AB} &= \\frac{1}{\\sqrt{2}}(|0\\rangle_A\\otimes|1\\rangle_B \\pm |1\\rangle_A\\otimes|0\\rangle_B),\n",
Q
Quleaf 已提交
25 26 27 28 29 30 31 32
    "\\tag{1}\n",
    "\\end{align*}\n",
    "$$\n",
    "\n",
    "where $A$ and $B$ represent the bi-party Alice and Bob. The Bell-diagonal state, by definition, is diagonal in the Bell basis that can be expressed as\n",
    "\n",
    "$$\n",
    "\\rho_{\\text{diag}} = p_1 | \\Phi^+\\rangle \\langle \\Phi^+ | + p_2 | \\Psi^+\\rangle \\langle \\Psi^+ | + \n",
Q
Quleaf 已提交
33
    "p_3 | \\Phi^-\\rangle \\langle \\Phi^- |  + p_4 | \\Psi^-\\rangle \\langle \\Psi^- |,\n",
Q
Quleaf 已提交
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
    "\\tag{2}\n",
    "$$\n",
    "\n",
    "with $p_1 > p_2 \\geq p_3 \\geq p_4$ and $p_1 + p_2+ p_3+ p_4 = 1$. Then the entanglement quantification of a Bell-diagonal state can be described as:\n",
    "\n",
    "* State fidelity $F = \\langle \\Phi^+|\\rho_{\\text{diag}}|\\Phi^+\\rangle = p_1$\n",
    "* Negativity $\\mathcal{N}(\\rho_{\\text{diag}}) = p_1 - 1/2$\n",
    "\n",
    "**Note:** The Bell-diagonal state is distillable when $p_1 > 1/2$."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## DEJMPS protocol\n",
    "\n",
Q
Quleaf 已提交
51
    "Suppose that two parties, namely Alice($A$) and Bob($B$), possess two copies of entangled qubit: $\\{ A_0, B_0 \\}, \\{ A_1, B_1 \\}$. If these two pairs are all in the same Bell-diagonal state $\\rho_{\\text{diag}}$, with $p_1 > 0.5$. We can apply the following workflow to purify the input states and obtain an output state that has a fidelity closer to $|\\Phi^+\\rangle$:\n",
Q
Quleaf 已提交
52 53 54 55 56 57 58 59 60
    "1. Alice and Bob firstly choose the qubit pair **they want to keep as the memory qubit pair after distillation**. Here, they choose $A_0$ and $B_0$. \n",
    "2. Alice performs $R_x(\\pi/2)$ gates on both qubits, and Bob performs $R_x(-\\pi/2)$ gates on both qubits.\n",
    "3. Then, Alice and Bob both apply a CNOT gate on their qubits. Here, they choose $A_0,B_0$ as the control qubits and $A_1,B_1$ as the target qubits.\n",
    "4. Two remote parties measure the target qubits and use a classical communication channel to exchange their measurement results $m_{A_1}, m_{B_1}$.\n",
    "5. If the measurement results of Alice and Bob are the same (00 or 11), the distillation is successful, and the qubit pair $A_0, B_0$ is stored as state $\\rho_{out}$; If the measurement results are different (01 or 10), they claim the distillation failed and the qubit pair $A_0, B_0$ will be discarded.\n",
    "\n",
    "<center><img src=\"figures/distillation-fig-DEJMPS.jpg\" height=\"250\" width=\"300\"></center>\n",
    "<div style=\"text-align:center\">Figure 1: Schematic diagram of the DEJMPS protocol </div>\n",
    "\n",
Q
Quleaf 已提交
61
    "After the distillation, the final state $\\rho_{out}$ of entangled pair $A_0, B_0$ will have a higher fidelity than the initial state $\\rho$. The fidelity of the final state $F_{out}$ is\n",
Q
Quleaf 已提交
62 63
    "\n",
    "$$\n",
Q
Quleaf 已提交
64
    "F_{out} = \\frac{p_1^2 + p_4^2}{(p_1 + p_4)^2 + (p_2 + p_3)^2}.\n",
Q
Quleaf 已提交
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80
    "\\tag{3}\n",
    "$$\n",
    "\n",
    "Similar to the BBPSSW protocol, the DEJMPS protocol is probabilistic, with the probability of a successful distillation being \n",
    "\n",
    "$$ \n",
    "p_{succ} = (p_1 + p_4)^2 + (p_2 + p_3)^2.\n",
    "\\tag{4}\n",
    "$$"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Simulation with Paddle Quantum\n",
Q
Quleaf 已提交
81
    "First, we need to import relevant packages:"
Q
Quleaf 已提交
82 83 84 85
   ]
  },
  {
   "cell_type": "code",
Q
Quleaf 已提交
86
   "execution_count": 2,
Q
Quleaf 已提交
87 88
   "metadata": {
    "ExecuteTime": {
Q
Quleaf 已提交
89 90
     "end_time": "2021-02-23T09:13:33.570407Z",
     "start_time": "2021-02-23T09:13:30.832819Z"
Q
Quleaf 已提交
91 92 93 94 95
    }
   },
   "outputs": [],
   "source": [
    "import numpy as np\n",
Q
Quleaf 已提交
96
    "import paddle\n",
Q
Quleaf 已提交
97 98 99
    "from paddle import matmul, trace\n",
    "import paddle_quantum\n",
    "from paddle_quantum.locc import LoccNet\n",
Q
Quleaf 已提交
100
    "from paddle_quantum.state import bell_state, isotropic_state, bell_diagonal_state\n",
Q
Quleaf 已提交
101 102 103
    "from paddle_quantum.qinfo import negativity, logarithmic_negativity, is_ppt\n",
    "# Change to density matrix mode\n",
    "paddle_quantum.set_backend('density_matrix')"
Q
Quleaf 已提交
104 105 106 107 108 109
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
Q
Quleaf 已提交
110
    "Let us see the theoretical result of applying the **DEJMPS protocol** to the state\n",
Q
Quleaf 已提交
111 112 113 114 115 116 117 118 119 120 121 122
    "\n",
    "$$\n",
    "\\rho = p_1 | \\Phi^+\\rangle \\langle \\Phi^+ | + \\frac{1-p_1}{2} | \\Psi^+\\rangle \\langle \\Psi^+ |+ \n",
    "\\frac{1-p_1}{3}| \\Phi^-\\rangle \\langle \\Phi^- |  + \\frac{1-p_1}{6} | \\Psi^-\\rangle \\langle \\Psi^- |.\n",
    "\\tag{5}\n",
    "$$\n",
    "\n",
    "Suppose we take $p_1 = 0.7$, then the theoretical improvement of fidelity can be calculated by the following block:"
   ]
  },
  {
   "cell_type": "code",
Q
Quleaf 已提交
123
   "execution_count": 3,
Q
Quleaf 已提交
124 125
   "metadata": {
    "ExecuteTime": {
Q
Quleaf 已提交
126 127
     "end_time": "2021-02-23T09:13:33.689788Z",
     "start_time": "2021-02-23T09:13:33.669677Z"
Q
Quleaf 已提交
128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The input fidelity is: 0.7\n",
      "The output fidelity is: 0.7879999999999999\n",
      "With a probability of success: 0.625\n",
      "The input state satisfies the PPT condition and hence not distillable? False\n"
     ]
    }
   ],
   "source": [
    "def DEJMPS_metrics(*p):\n",
    "    \"\"\"\n",
    "    Returns output fidelity and probability of success of the DEJMPS protocol.\n",
    "    \"\"\"\n",
    "    F_in = p[0]\n",
    "    p_succ = (p[0] + p[3]) ** 2 + (p[1] + p[2]) ** 2\n",
    "    F_out = (p[0] ** 2 + p[3] ** 2)/p_succ\n",
Q
Quleaf 已提交
150
    "\n",
Q
Quleaf 已提交
151 152 153 154 155 156 157 158
    "    return F_in, F_out, p_succ\n",
    "\n",
    "p = 0.7\n",
    "F_in, F_out, p_succ = DEJMPS_metrics(p, (1-p)/2, (1-p)/3, (1-p)/6)\n",
    "print(\"The input fidelity is:\", F_in)\n",
    "print(\"The output fidelity is:\", F_out)\n",
    "print(\"With a probability of success:\", p_succ)\n",
    "print(\"The input state satisfies the PPT condition and hence not distillable?\", \n",
Q
Quleaf 已提交
159
    "      is_ppt(bell_diagonal_state([p, (1-p)/2, (1-p)/3, (1-p)/6])))"
Q
Quleaf 已提交
160 161 162 163 164 165 166 167 168 169 170
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Then we can simulate the DEJMPS protocol and check if the results match with the theory."
   ]
  },
  {
   "cell_type": "code",
Q
Quleaf 已提交
171
   "execution_count": 4,
Q
Quleaf 已提交
172 173
   "metadata": {
    "ExecuteTime": {
Q
Quleaf 已提交
174 175
     "end_time": "2021-02-23T09:13:35.397596Z",
     "start_time": "2021-02-23T09:13:35.383842Z"
Q
Quleaf 已提交
176 177
    }
   },
Q
Quleaf 已提交
178
   "outputs": [],
Q
Quleaf 已提交
179 180 181 182 183 184
   "source": [
    "class LOCC(LoccNet):\n",
    "    def __init__(self):\n",
    "        super(LOCC, self).__init__()\n",
    "        # Add the first party Alice \n",
    "        # The first parameter 2 stands for how many qubits A holds\n",
Q
Quleaf 已提交
185
    "        # The second parameter records the name of this party\n",
Q
Quleaf 已提交
186 187 188
    "        self.add_new_party(2, party_name='Alice')\n",
    "        # Add the second party Bob\n",
    "        # The first parameter 2 stands for how many qubits A holds\n",
Q
Quleaf 已提交
189
    "        # The second parameter records the name of this party\n",
Q
Quleaf 已提交
190
    "        self.add_new_party(2, party_name='Bob')\n",
Q
Quleaf 已提交
191
    "\n",
Q
Quleaf 已提交
192
    "        # Define the input quantum states rho_in\n",
Q
Quleaf 已提交
193
    "        _state = bell_diagonal_state([p, (1-p)/2, (1-p)/3, (1-p)/6])\n",
Q
Quleaf 已提交
194 195
    "        # ('Alice', 0) means Alice's first qubit A0\n",
    "        # ('Bob', 0) means Bob's first qubit B0\n",
Q
Quleaf 已提交
196
    "        self.set_init_state(_state, [('Alice', 0), ('Bob', 0)])\n",
Q
Quleaf 已提交
197 198
    "        # ('Alice', 1) means Alice's second qubit A1\n",
    "        # ('Bob', 1) means Bob's second qubit B1\n",
Q
Quleaf 已提交
199 200
    "        self.set_init_state(_state, [('Alice', 1), ('Bob', 1)])\n",
    "\n",
Q
Quleaf 已提交
201
    "        # Set the angles of the Rx gates\n",
Q
Quleaf 已提交
202 203
    "        self.theta1 = paddle.to_tensor([np.pi/2, np.pi/2])\n",
    "        self.theta2 = paddle.to_tensor([-np.pi/2, -np.pi/2])\n",
Q
Quleaf 已提交
204
    "\n",
Q
Quleaf 已提交
205 206 207 208 209
    "        # Create Alice's local operations \n",
    "        self.cir1 = self.create_ansatz('Alice')\n",
    "        self.cir1.rx(qubits_idx=0, param=self.theta1[0])\n",
    "        self.cir1.rx(qubits_idx=1, param=self.theta1[1])\n",
    "        self.cir1.cnot([0, 1])\n",
Q
Quleaf 已提交
210
    "        # Create Bob's local operations \n",
Q
Quleaf 已提交
211 212 213 214 215 216 217
    "        self.cir2 = self.create_ansatz('Bob')\n",
    "        self.cir2.rx(qubits_idx=0, param=self.theta2[0])\n",
    "        self.cir2.rx(qubits_idx=1, param=self.theta2[1])\n",
    "        self.cir2.cnot([0, 1])\n",
    "\n",
    "    def DEJMPS(self):\n",
    "        status = self.init_status\n",
Q
Quleaf 已提交
218
    "        # Run circuit\n",
Q
Quleaf 已提交
219 220 221
    "        status = self.cir1(status)\n",
    "        status_mid = self.cir2(status)\n",
    "\n",
Q
Quleaf 已提交
222 223 224 225 226
    "        # ('Alice', 1) means measuring Alice's second qubit A1\n",
    "        # ('Bob', 1) means measuring Bob's second qubit B1\n",
    "        # ['00','11'] specifies the success condition for distillation\n",
    "        # Means Alice and Bob both measure '00' or '11'\n",
    "        status_mid = self.measure(status_mid, [('Alice', 1), ('Bob', 1)], [\"00\", \"11\"])\n",
Q
Quleaf 已提交
227
    "\n",
Q
Quleaf 已提交
228 229 230
    "        # Trace out the measured qubits A1&B1\n",
    "        # Leaving only Alice’s first qubit and Bob’s first qubit A0&B0 as the memory register\n",
    "        status_fin = self.partial_state(status_mid, [('Alice', 0), ('Bob', 0)])\n",
Q
Quleaf 已提交
231
    "\n",
Q
Quleaf 已提交
232 233 234 235 236
    "        return status_fin"
   ]
  },
  {
   "cell_type": "code",
Q
Quleaf 已提交
237
   "execution_count": 6,
Q
Quleaf 已提交
238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253
   "metadata": {
    "ExecuteTime": {
     "end_time": "2021-02-23T09:13:43.070659Z",
     "start_time": "2021-02-23T09:13:42.826239Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The fidelity of the input quantum state is: 0.70000\n",
      "The fidelity of the purified quantum state is: 0.78800\n",
      "The probability of successful purification is: 62.500%\n",
      "========================================================\n",
      "The output state is:\n",
Q
Quleaf 已提交
254 255 256 257 258 259
      " [[0.45 +0.j 0.   +0.j 0.   +0.j 0.338+0.j]\n",
      " [0.   +0.j 0.05 +0.j 0.002+0.j 0.   +0.j]\n",
      " [0.   +0.j 0.002+0.j 0.05 +0.j 0.   +0.j]\n",
      " [0.338+0.j 0.   +0.j 0.   +0.j 0.45 +0.j]]\n",
      "The initial negativity is: 0.19999995827674866\n",
      "The final negativity is: 0.28800004720687866\n"
Q
Quleaf 已提交
260 261 262 263 264 265
     ]
    }
   ],
   "source": [
    "# Run DEJMPS protocol\n",
    "status_fin = LOCC().DEJMPS()\n",
Q
Quleaf 已提交
266
    "\n",
Q
Quleaf 已提交
267
    "# Calculate fidelity\n",
Q
Quleaf 已提交
268
    "target_state = bell_state(2)\n",
Q
Quleaf 已提交
269 270
    "fidelity = 0\n",
    "for status in status_fin:\n",
Q
Quleaf 已提交
271
    "    fidelity += paddle.real(trace(matmul(target_state.data, status.data)))\n",
Q
Quleaf 已提交
272 273 274 275 276 277 278 279 280 281 282
    "fidelity /= len(status_fin)\n",
    "\n",
    "# Calculate success rate\n",
    "suc_rate = sum([status.prob for status in status_fin])\n",
    "\n",
    "# Output simulation results\n",
    "print(f\"The fidelity of the input quantum state is: {p:.5f}\")\n",
    "print(f\"The fidelity of the purified quantum state is: {fidelity.numpy()[0]:.5f}\")\n",
    "print(f\"The probability of successful purification is: {suc_rate.numpy()[0]:#.3%}\")\n",
    "\n",
    "# Print the output state\n",
Q
Quleaf 已提交
283
    "rho_out = status_fin[0]\n",
Q
Quleaf 已提交
284
    "print(\"========================================================\")\n",
Q
Quleaf 已提交
285 286 287
    "print(f\"The output state is:\\n {np.around(rho_out.data.numpy(), 4)}\")\n",
    "print(f\"The initial negativity is: {negativity(bell_diagonal_state([p, (1-p)/2, (1-p)/3, (1-p)/6])).numpy()[0]}\")\n",
    "print(f\"The final negativity is: {negativity(rho_out).numpy()[0]}\")"
Q
Quleaf 已提交
288 289 290 291 292 293 294 295 296 297 298 299 300 301 302
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "One can observe that the simulation result is in exact accordance with the theoretical values."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Conclusion\n",
    "\n",
Q
Quleaf 已提交
303
    "The DEJMPS protocol can effectively extract one entangled pair with a higher fidelity from two noisy pairs. And compared to the BBPSSW protocol [2], it can be applied to Bell-diagonal states instead of isotropic states. Note that isotropic state is a special case of Bell-diagonal state. So in this sense, the DEJMPS protocol is more general than the BBPSSW protocol. However, it also shares the same disadvantages of the BBPSSW protocol including the limited type of input states and poor scalability. \n",
Q
Quleaf 已提交
304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323
    "\n",
    "Next, We suggest interested readers to check the tutorial on [how to design a new distillation protocol with LOCCNet](./EntanglementDistillation_LOCCNet_EN.ipynb)."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "---\n",
    "\n",
    "## References\n",
    "\n",
    "[1] Deutsch, David, et al. \"Quantum privacy amplification and the security of quantum cryptography over noisy channels.\" [Physical Review Letters 77.13 (1996): 2818.](https://journals.aps.org/prl/abstract/10.1103/PhysRevLett.77.2818)\n",
    "\n",
    "[2] Bennett, Charles H., et al. \"Purification of noisy entanglement and faithful teleportation via noisy channels.\" [Physical Review Letters 76.5 (1996): 722.](https://journals.aps.org/prl/abstract/10.1103/PhysRevLett.76.722)\n"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
Q
Quleaf 已提交
324
   "display_name": "Python 3 (ipykernel)",
Q
Quleaf 已提交
325 326 327 328 329 330 331 332 333 334 335 336 337
   "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",
Q
Quleaf 已提交
338
   "version": "3.8.13"
Q
Quleaf 已提交
339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385
  },
  "toc": {
   "base_numbering": 1,
   "nav_menu": {},
   "number_sections": true,
   "sideBar": true,
   "skip_h1_title": false,
   "title_cell": "Table of Contents",
   "title_sidebar": "Contents",
   "toc_cell": false,
   "toc_position": {},
   "toc_section_display": true,
   "toc_window_display": true
  },
  "varInspector": {
   "cols": {
    "lenName": 16,
    "lenType": 16,
    "lenVar": 40
   },
   "kernels_config": {
    "python": {
     "delete_cmd_postfix": "",
     "delete_cmd_prefix": "del ",
     "library": "var_list.py",
     "varRefreshCmd": "print(var_dic_list())"
    },
    "r": {
     "delete_cmd_postfix": ") ",
     "delete_cmd_prefix": "rm(",
     "library": "var_list.r",
     "varRefreshCmd": "cat(var_dic_list()) "
    }
   },
   "types_to_exclude": [
    "module",
    "function",
    "builtin_function_or_method",
    "instance",
    "_Feature"
   ],
   "window_display": false
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}