├── .DS_Store ├── Captain_Badge ├── 2022 │ ├── .DS_Store │ ├── QE_Badge1_Lab1.ipynb │ ├── QE_Badge1_Lab2_Grover_IQC2020Fall_1b.ipynb │ └── QE_Introductory_Demo.ipynb ├── 2023 │ ├── QE_Badge1_Lab1_2023.ipynb │ ├── QE_Badge1_Lab1_2023_solution.ipynb │ ├── QE_Badge1_Lab2_Grover_IQC2020Fall_1b_2023.ipynb │ ├── QE_Badge1_PracticeQuiz1.ipynb │ ├── QE_Badge1_PracticeQuiz2.ipynb │ ├── QE_Badge1_PracticeQuiz3.ipynb │ ├── QE_Badge1_PracticeQuiz4.ipynb │ ├── QE_Introductory_Demo_2023.ipynb │ └── QE_Teleportation_Lab_2023.ipynb ├── .DS_Store ├── .ipynb_checkpoints │ ├── QE_Badge1_Lab1-checkpoint.ipynb │ ├── QE_Badge1_Lab2_Grover_IQC2020Fall_1b-checkpoint.ipynb │ └── QE_Introductory_Demo-checkpoint.ipynb └── QiskitBlocks_Tips.pdf ├── Expert_Navigator_Badge ├── 2023 │ ├── .DS_Store │ ├── QE_Badge6_Lab1.ipynb │ ├── QE_Badge6_Lab1_solutions.ipynb │ └── QE_Optimization__Introductory_Demo_2023.ipynb ├── .DS_Store └── .ipynb_checkpoints │ └── QE_Optimization_Introductory_Demo-checkpoint.ipynb ├── LICENSE.txt ├── README.md ├── Space_Combatant_Badge ├── 2023 │ ├── .DS_Store │ ├── QE_Badge5_Lab1-ja.ipynb │ ├── QE_Badge5_Lab1.ipynb │ ├── QE_Badge5_Lab2-ja.ipynb │ ├── QE_Badge5_Lab2.ipynb │ ├── QE_QML_Glossary-ja.md │ ├── QE_QML_Glossary.md │ └── QE_QML_References.pdf └── .DS_Store ├── Time_Traveler_Badge ├── 2023 │ ├── .DS_Store │ ├── QE_Badge4_Lab1_2023-ja.ipynb │ ├── QE_Badge4_Lab1_2023.ipynb │ ├── QE_Badge4_Lab2_QEM_IQC2022Fall_1_2023.ipynb │ ├── QE_Badge4_Lab2_QEM_IQC2022Fall_1_2023_solution.ipynb │ ├── QE_Badge4_Lab3_QEM_Advanced-ja.ipynb │ ├── QE_Badge4_Lab3_QEM_Advanced.ipynb │ └── quantum-error-suppression-mitigation-correction-ja.ipynb └── .DS_Store ├── credly.md └── images ├── .DS_Store ├── QE Medium Banner.jpg ├── credly_badges.png ├── incoming message.jpg └── qe_banner.jpg /.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qiskit-community/quantum-explorers/597fec6917327884425c9121257bcbf027df5f16/.DS_Store -------------------------------------------------------------------------------- /Captain_Badge/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qiskit-community/quantum-explorers/597fec6917327884425c9121257bcbf027df5f16/Captain_Badge/.DS_Store -------------------------------------------------------------------------------- /Captain_Badge/2022/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qiskit-community/quantum-explorers/597fec6917327884425c9121257bcbf027df5f16/Captain_Badge/2022/.DS_Store -------------------------------------------------------------------------------- /Captain_Badge/2023/QE_Badge1_PracticeQuiz1.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "# Problem Set 1 - Introduction to Near-Term Quantum Computing" 8 | ] 9 | }, 10 | { 11 | "cell_type": "markdown", 12 | "metadata": { 13 | "tags": [] 14 | }, 15 | "source": [ 16 | "## Overview\n", 17 | "\n", 18 | "_Problem set adapted from:_
\n", 19 | "The University of Tokyo
\n", 20 | "Introduction to Near-Term Quantum Computing
\n", 21 | "\n", 22 | "
\n", 23 | "\n", 24 | "**Unit 1: Welcome to Introduction to Near-Term Quantum Computing!**\n", 25 | "\n", 26 | "\n", 27 | "This set of questions is based on the following contents:\n", 28 | "\n", 29 | "- [VIDEO: Understanding Quantum Information and Computation | Lesson 1 (John Watrous)](https://youtu.be/3-c4xJa7Flk)\n", 30 | "- [TEXTBOOK: Single systems of Basics of quantum information](https://learning.quantum-computing.ibm.com/course/basics-of-quantum-information/single-systems) \n" 31 | ] 32 | }, 33 | { 34 | "cell_type": "markdown", 35 | "metadata": {}, 36 | "source": [ 37 | "## Quiz 1-1" 38 | ] 39 | }, 40 | { 41 | "cell_type": "markdown", 42 | "metadata": {}, 43 | "source": [ 44 | "### Quiz 1-1\n", 45 | "\n", 46 | "\n", 47 | "Which of the following is a probability vector?\n", 48 | "\n", 49 | "a)\n", 50 | "\n", 51 | "$\\begin{pmatrix} \\sqrt{2}\\\\\\\\ 1 - \\sqrt{2} \\end{pmatrix}$\n", 52 | "\n", 53 | "b)\n", 54 | "\n", 55 | "$\\begin{pmatrix} 0.4 \\\\\\\\ 0.4 \\end{pmatrix}$\n", 56 | "\n", 57 | "c)\n", 58 | "\n", 59 | "$\\begin{pmatrix} 1 \\\\\\\\ 0 \\\\\\\\ 0 \\end{pmatrix}$\n", 60 | "\n" 61 | ] 62 | }, 63 | { 64 | "cell_type": "markdown", 65 | "metadata": {}, 66 | "source": [ 67 | "## Quiz 1-2" 68 | ] 69 | }, 70 | { 71 | "cell_type": "markdown", 72 | "metadata": {}, 73 | "source": [ 74 | "### Quiz 1-2\n", 75 | "\n", 76 | "\n", 77 | "Which of the following is a quantum state vector? \n", 78 | "\n", 79 | "a)\n", 80 | "\n", 81 | "$\\begin{pmatrix} \\sqrt{2}\\\\\\\\ 1 - \\sqrt{2} \\end{pmatrix}$\n", 82 | "\n", 83 | "b)\n", 84 | "\n", 85 | "$\\begin{pmatrix} -\\frac{1+2i}{3} \\\\\\\\ -\\frac{2}{3} \\end{pmatrix}$\n", 86 | "\n", 87 | "c)\n", 88 | "\n", 89 | "$\\begin{pmatrix} 1 \\\\\\\\ 0 \\\\\\\\ 1 \\end{pmatrix}$\n" 90 | ] 91 | }, 92 | { 93 | "cell_type": "markdown", 94 | "metadata": {}, 95 | "source": [ 96 | "## Quiz 1-3" 97 | ] 98 | }, 99 | { 100 | "cell_type": "markdown", 101 | "metadata": {}, 102 | "source": [ 103 | "### Quiz 1-3\n", 104 | "\n", 105 | "\n", 106 | "Which of the following is a deterministic operator?\n", 107 | "\n", 108 | "a)\n", 109 | "\n", 110 | "$\\begin{pmatrix} 1 & 0 \\\\\\\\ 1 & 0 \\end{pmatrix}$\n", 111 | "\n", 112 | "b)\n", 113 | "\n", 114 | "$\\begin{pmatrix} 0 & \\frac{1}{2} \\\\\\\\ \\frac{-i}{2} & 0 \\end{pmatrix}$\n", 115 | "\n", 116 | "c)\n", 117 | "\n", 118 | "$\\begin{pmatrix} 1 & 0 \\\\\\\\ 0 & i \\end{pmatrix}$\n", 119 | "\n", 120 | "d)\n", 121 | "\n", 122 | "$\\begin{pmatrix} 0 & 0 \\\\\\\\ 1 & 1 \\end{pmatrix}$\n", 123 | "\n" 124 | ] 125 | }, 126 | { 127 | "cell_type": "markdown", 128 | "metadata": {}, 129 | "source": [ 130 | "## Quiz 1-4" 131 | ] 132 | }, 133 | { 134 | "cell_type": "markdown", 135 | "metadata": {}, 136 | "source": [ 137 | "### Quiz 1-4\n", 138 | "\n", 139 | "\n", 140 | "Which of the following is a probabilistic operator? \n", 141 | "\n", 142 | "a)\n", 143 | "\n", 144 | "$\\begin{pmatrix} 1 & 0 \\\\\\\\ 1 & 0 \\end{pmatrix}$\n", 145 | "\n", 146 | "b)\n", 147 | "\n", 148 | "$\\begin{pmatrix} \\frac{1}{2} & 0 \\\\\\\\ \\frac{1}{2} & 1 \\end{pmatrix}$\n", 149 | "\n", 150 | "c)\n", 151 | "\n", 152 | "$\\begin{pmatrix} 1 & 0 \\\\\\\\ 0 & i \\end{pmatrix}$\n", 153 | "\n", 154 | "d)\n", 155 | "\n", 156 | "$\\begin{pmatrix} 0 & \\frac{1}{2} \\\\\\\\ \\frac{-i}{2} & 0 \\end{pmatrix}$\n" 157 | ] 158 | }, 159 | { 160 | "cell_type": "markdown", 161 | "metadata": {}, 162 | "source": [ 163 | "## Quiz 1-5" 164 | ] 165 | }, 166 | { 167 | "cell_type": "markdown", 168 | "metadata": {}, 169 | "source": [ 170 | "### Quiz 1-5\n", 171 | "\n", 172 | "\n", 173 | "Which of the following is unitary?\n", 174 | "\n", 175 | "a)\n", 176 | "\n", 177 | "$\\begin{pmatrix} 1 & 0 \\\\\\\\ 1 & 0 \\end{pmatrix}$\n", 178 | "\n", 179 | "b)\n", 180 | "\n", 181 | "$\\begin{pmatrix} 0 & \\frac{1}{2} \\\\\\\\ \\frac{-i}{2} & 0 \\end{pmatrix}$\n", 182 | "\n", 183 | "c)\n", 184 | "\n", 185 | "$\\begin{pmatrix} 1 & 0 \\\\\\\\ 0 & i \\end{pmatrix}$\n" 186 | ] 187 | }, 188 | { 189 | "cell_type": "markdown", 190 | "metadata": {}, 191 | "source": [ 192 | "## Quiz 1-6" 193 | ] 194 | }, 195 | { 196 | "cell_type": "markdown", 197 | "metadata": {}, 198 | "source": [ 199 | "### Quiz 1-6\n", 200 | "\n", 201 | "\n", 202 | "\n", 203 | "The probabilities of result in 0 and 1 by measuring the plus state or the minus state is same as far as standard basis measurements.\n", 204 | "\n", 205 | "\n", 206 | "\n", 207 | "Yes\n", 208 | "\n", 209 | "\n", 210 | "\n", 211 | "No\n", 212 | "\n" 213 | ] 214 | }, 215 | { 216 | "cell_type": "markdown", 217 | "metadata": {}, 218 | "source": [ 219 | "## Quiz 1-7" 220 | ] 221 | }, 222 | { 223 | "cell_type": "markdown", 224 | "metadata": {}, 225 | "source": [ 226 | "### Quiz 1-7\n", 227 | "\n", 228 | "\n", 229 | "\n", 230 | "Which operation is equal to $ HZH $ ?\n", 231 | "\n", 232 | "\n", 233 | "\n", 234 | "$X$\n", 235 | "\n", 236 | "\n", 237 | "\n", 238 | "$Y$\n", 239 | "\n", 240 | "\n", 241 | "\n", 242 | "$Z$\n", 243 | "\n", 244 | "\n", 245 | "\n", 246 | "$H$\n", 247 | "\n" 248 | ] 249 | }, 250 | { 251 | "cell_type": "markdown", 252 | "metadata": {}, 253 | "source": [ 254 | "## Quiz 1-8" 255 | ] 256 | }, 257 | { 258 | "cell_type": "markdown", 259 | "metadata": {}, 260 | "source": [ 261 | "### Quiz 1-8\n", 262 | "\n", 263 | "\n", 264 | "\n", 265 | "Which operation is equal to $ HXH $ ?\n", 266 | "\n", 267 | "\n", 268 | "\n", 269 | "$X$\n", 270 | "\n", 271 | "\n", 272 | "$Y$\n", 273 | "\n", 274 | "\n", 275 | "$Z$\n", 276 | "\n", 277 | "\n", 278 | "\n", 279 | "$H$\n", 280 | "\n" 281 | ] 282 | }, 283 | { 284 | "cell_type": "markdown", 285 | "metadata": {}, 286 | "source": [ 287 | "## Quiz 1-9" 288 | ] 289 | }, 290 | { 291 | "cell_type": "markdown", 292 | "metadata": {}, 293 | "source": [ 294 | "### Quiz 1-9\n", 295 | "\n", 296 | "\n", 297 | "What is $ S|-\\rangle$ ?\n", 298 | "\n", 299 | "a)\n", 300 | "\n", 301 | "$\\frac{1}{\\sqrt{2}}|0\\rangle + \\frac{1}{\\sqrt{2}}|1\\rangle$\n", 302 | "\n", 303 | "b)\n", 304 | "\n", 305 | "$\\frac{1}{\\sqrt{2}}|0\\rangle -\\frac{1}{\\sqrt{2}}|1\\rangle$\n", 306 | "\n", 307 | "c)\n", 308 | "\n", 309 | "$\\frac{1}{\\sqrt{2}}|0\\rangle +\\frac{i}{\\sqrt{2}}|1\\rangle$\n", 310 | "\n", 311 | "d)\n", 312 | "\n", 313 | "$\\frac{1}{\\sqrt{2}}|0\\rangle -\\frac{i}{\\sqrt{2}}|1\\rangle$\n", 314 | "\n" 315 | ] 316 | }, 317 | { 318 | "cell_type": "markdown", 319 | "metadata": {}, 320 | "source": [ 321 | "## Quiz 1-10" 322 | ] 323 | }, 324 | { 325 | "cell_type": "markdown", 326 | "metadata": {}, 327 | "source": [ 328 | "### Quiz 1-10\n", 329 | "\n", 330 | "\n", 331 | "\n", 332 | "Permutation matrices are the only matrices that can represent both classical and quantum operations.\n", 333 | "\n", 334 | "\n", 335 | "\n", 336 | "Yes\n", 337 | "\n", 338 | "\n", 339 | "No\n", 340 | "\n" 341 | ] 342 | }, 343 | { 344 | "cell_type": "markdown", 345 | "metadata": {}, 346 | "source": [ 347 | "## Answers\n", 348 | "1) c
\n", 349 | "2) b
\n", 350 | "3) d
\n", 351 | "4) b
\n", 352 | "5) c
\n", 353 | "6) Yes
\n", 354 | "7) X
\n", 355 | "8) Z
\n", 356 | "9) d
\n", 357 | "10) Yes
" 358 | ] 359 | }, 360 | { 361 | "cell_type": "code", 362 | "execution_count": null, 363 | "metadata": {}, 364 | "outputs": [], 365 | "source": [] 366 | } 367 | ], 368 | "metadata": { 369 | "kernelspec": { 370 | "display_name": "Python 3 (ipykernel)", 371 | "language": "python", 372 | "name": "python3" 373 | }, 374 | "language_info": { 375 | "codemirror_mode": { 376 | "name": "ipython", 377 | "version": 3 378 | }, 379 | "file_extension": ".py", 380 | "mimetype": "text/x-python", 381 | "name": "python", 382 | "nbconvert_exporter": "python", 383 | "pygments_lexer": "ipython3", 384 | "version": "3.10.8" 385 | }, 386 | "widgets": { 387 | "application/vnd.jupyter.widget-state+json": { 388 | "state": {}, 389 | "version_major": 2, 390 | "version_minor": 0 391 | } 392 | } 393 | }, 394 | "nbformat": 4, 395 | "nbformat_minor": 4 396 | } 397 | -------------------------------------------------------------------------------- /Captain_Badge/2023/QE_Badge1_PracticeQuiz2.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "# Problem Set 2 - Introduction to Near-Term Quantum Computing" 8 | ] 9 | }, 10 | { 11 | "cell_type": "markdown", 12 | "metadata": {}, 13 | "source": [ 14 | "## Overview\n", 15 | "\n", 16 | "_Problem set adapted from:_
\n", 17 | "The University of Tokyo
\n", 18 | "Introduction to Near-Term Quantum Computing
\n", 19 | "\n", 20 | "
\n", 21 | "\n", 22 | "**Unit 2: Multiple Systems**\n", 23 | "\n", 24 | "\n", 25 | "This set of questions is based on the following contents:\n", 26 | "\n", 27 | "- [VIDEO: Understanding Quantum Information & Computation | Lesson 2 (John Watrous)](https://youtu.be/DfZZS8Spe7U)\n", 28 | "- [TEXTBOOK: Multiple Systems of Basics of quantum information](https://learning.quantum-computing.ibm.com/course/basics-of-quantum-information/multiple-systems#introduction) \n" 29 | ] 30 | }, 31 | { 32 | "cell_type": "markdown", 33 | "metadata": {}, 34 | "source": [ 35 | "## Quiz 2-1\n", 36 | "\n", 37 | "In which of the following probabilistic states of a pair of compound system $(\\mathsf{X},\\mathsf{Y})$ of systems where $\\mathsf{X}$ and $\\mathsf{Y}$ are both bits, the systems $\\mathsf{X}$ and $\\mathsf{Y}$ are independent?" 38 | ] 39 | }, 40 | { 41 | "cell_type": "markdown", 42 | "metadata": {}, 43 | "source": [ 44 | "### Quiz 2-1\n", 45 | "\n", 46 | "a)\n", 47 | "\n", 48 | "$\\frac{1}{3} \\vert 00 \\rangle + \\frac{1}{6} \\vert 01 \\rangle + \\frac{1}{3} \\vert 10 \\rangle + \\frac{1}{6} \\vert 11 \\rangle$\n", 49 | "\n", 50 | "b)\n", 51 | "\n", 52 | "$\\frac{1}{2} \\vert 00 \\rangle - \\frac{1}{2} \\vert 11 \\rangle $\n", 53 | "\n", 54 | "c)\n", 55 | "\n", 56 | "$\\frac{1}{2} \\vert 00 \\rangle + \\frac{1}{2} \\vert 11 \\rangle $\n" 57 | ] 58 | }, 59 | { 60 | "cell_type": "markdown", 61 | "metadata": {}, 62 | "source": [ 63 | "## Quiz 2-2\n", 64 | "\n", 65 | "Suppose that the classical state set of $\\mathsf{X}$ is $\\Sigma = \\{0,1\\}$, the classical state set of $\\mathsf{Y}$ is $\\Gamma = \\{1,2,3\\}$, and the probablistic state of $(\\mathsf{X},\\mathsf{Y})$ is\n", 66 | "\n", 67 | "$$\n", 68 | " \\vert \\psi \\rangle\n", 69 | " = \\frac{1}{2} \\vert 0,1 \\rangle\n", 70 | " + \\frac{1}{12} \\vert 0,3 \\rangle\n", 71 | " + \\frac{1}{12} \\vert 1,1 \\rangle\n", 72 | " + \\frac{1}{6} \\vert 1,2 \\rangle \n", 73 | " + \\frac{1}{6} \\vert 1,3 \\rangle.\n", 74 | "$$\n", 75 | "\n", 76 | "If only $\\mathsf{Y}$ is measured and the result is 3, which of the following is the probabilistic state of $\\mathsf{X}$?" 77 | ] 78 | }, 79 | { 80 | "cell_type": "markdown", 81 | "metadata": {}, 82 | "source": [ 83 | "### Quiz 2-2\n", 84 | "\n", 85 | "a)\n", 86 | "\n", 87 | "$\\frac{1}{2} \\vert 0 \\rangle + \\frac{1}{12} \\vert 1 \\rangle$\n", 88 | "\n", 89 | "b)\n", 90 | "\n", 91 | "$\\frac{1}{12} \\vert 0 \\rangle + \\frac{1}{6} \\vert 1 \\rangle$\n", 92 | "\n", 93 | "c)\n", 94 | "\n", 95 | "$\\frac{6}{7} \\vert 0 \\rangle + \\frac{1}{7} \\vert 1 \\rangle$\n", 96 | "\n", 97 | "d)\n", 98 | "\n", 99 | "$\\frac{1}{3} \\vert 0 \\rangle + \\frac{2}{3} \\vert 1 \\rangle$\n", 100 | "\n" 101 | ] 102 | }, 103 | { 104 | "cell_type": "markdown", 105 | "metadata": {}, 106 | "source": [ 107 | "## Quiz 2-3\n", 108 | "\n", 109 | "Which of the following is NOT a probablistic operator? " 110 | ] 111 | }, 112 | { 113 | "cell_type": "markdown", 114 | "metadata": {}, 115 | "source": [ 116 | "### Quiz 2-3\n", 117 | "\n", 118 | "a)\n", 119 | "\n", 120 | "$\n", 121 | "\\begin{pmatrix}\n", 122 | "1 & \\frac{1}{2} & \\frac{1}{2} & 0\\\\\\\\\n", 123 | "0 & 0 & 0 & 0\\\\\\\\\n", 124 | "0 & 0 & 0 & 0\\\\\\\\\n", 125 | "0 & \\frac{1}{2} & \\frac{1}{2} & 1\n", 126 | "\\end{pmatrix}$\n", 127 | "\n", 128 | "b)\n", 129 | "\n", 130 | "$\n", 131 | "\\begin{pmatrix}\n", 132 | "1 & 0 & 0 & 0\\\\\\\\\n", 133 | "0 & 0 & 0 & 1\\\\\\\\\n", 134 | "0 & 0 & 1 & 0\\\\\\\\\n", 135 | "0 & 1 & 0 & 0\n", 136 | "\\end{pmatrix}\n", 137 | "$\n", 138 | "\n", 139 | "c)\n", 140 | "\n", 141 | "$\n", 142 | "\\begin{pmatrix}\n", 143 | "1 & 0 & 0 & 0\\\\\\\\\n", 144 | "0 & 1 & 0 & 0\\\\\\\\\n", 145 | "0 & 0 & 0 & 1\\\\\\\\\n", 146 | "0 & 0 & 1 & 0\n", 147 | "\\end{pmatrix}\n", 148 | "$\n", 149 | "\n", 150 | "d)\n", 151 | "\n", 152 | "$\n", 153 | "\\begin{pmatrix}\n", 154 | "1 & 1 & 1 & 0\\\\\\\\\n", 155 | "0 & 0 & 0 & 0\\\\\\\\\n", 156 | "0 & 0 & 0 & 0\\\\\\\\\n", 157 | "0 & 1 & 1 & 1\n", 158 | "\\end{pmatrix}$\n", 159 | "\n" 160 | ] 161 | }, 162 | { 163 | "cell_type": "markdown", 164 | "metadata": {}, 165 | "source": [ 166 | "## Quiz 2-4\n", 167 | "\n", 168 | "Which of the following quantum states is incorrect?" 169 | ] 170 | }, 171 | { 172 | "cell_type": "markdown", 173 | "metadata": {}, 174 | "source": [ 175 | "### Quiz 2-4\n", 176 | "\n", 177 | "a)\n", 178 | "\n", 179 | "$\\frac{i}{\\sqrt{5}} \\vert 00 \\rangle + \\frac{1}{\\sqrt{5}} \\vert 01\\rangle - \\frac{i}{\\sqrt{5}} \\vert 10\\rangle - \\sqrt{\\frac{2}{5}} \\vert 11\\rangle$\n", 180 | "\n", 181 | "b)\n", 182 | "\n", 183 | "$\\frac{3}{5} \\vert 00\\rangle - \\frac{4}{5} \\vert 11\\rangle$\n", 184 | "\n", 185 | "c)\n", 186 | "\n", 187 | "$\\vert 01 \\rangle$\n", 188 | "\n", 189 | "d)\n", 190 | "\n", 191 | "$\\frac{1}{3} \\vert 00 \\rangle + \\frac{1}{6} \\vert 01 \\rangle + \\frac{2}{3} \\vert 10 \\rangle + \\frac{1}{3} \\vert 11 \\rangle$\n", 192 | "\n", 193 | "e)\n", 194 | "\n", 195 | "$\\frac{1}{\\sqrt{2}} \\vert 00\\rangle + \\frac{1}{\\sqrt{2}} \\vert 11\\rangle$\n", 196 | " \n" 197 | ] 198 | }, 199 | { 200 | "cell_type": "markdown", 201 | "metadata": {}, 202 | "source": [ 203 | "## Quiz 2-5\n", 204 | "\n", 205 | "Which quantum state is equal to \n", 206 | "\n", 207 | "$\\frac{1}{\\sqrt{2}} \\vert \\phi^+\\rangle - \\frac{1}{\\sqrt{2}} \\vert \\phi^-\\rangle$ ?" 208 | ] 209 | }, 210 | { 211 | "cell_type": "markdown", 212 | "metadata": {}, 213 | "source": [ 214 | "### Quiz 2-5\n", 215 | "\n", 216 | "a)\n", 217 | "\n", 218 | "$\\vert 0 0 \\rangle$\n", 219 | "\n", 220 | "b)\n", 221 | "\n", 222 | "$\\vert 0 1 \\rangle$\n", 223 | "\n", 224 | "c)\n", 225 | "\n", 226 | "$\\vert 1 1 \\rangle$\n", 227 | "\n", 228 | "d)\n", 229 | "\n", 230 | "$\\vert 1 0 \\rangle$\n" 231 | ] 232 | }, 233 | { 234 | "cell_type": "markdown", 235 | "metadata": {}, 236 | "source": [ 237 | "## Quiz 2-6\n", 238 | "\n", 239 | "Suppose the quantum state vector of the compound system of $(\\mathsf{X},\\mathsf{Y})$ of two systems $\\mathsf{X}$ and $\\mathsf{Y}$ is the following\n", 240 | "\n", 241 | "$$\n", 242 | " \\vert \\psi \\rangle \n", 243 | " = \\frac{1}{\\sqrt{6}} \\vert 00 \\rangle\n", 244 | " - \\frac{i}{\\sqrt{6}} \\vert 01\\rangle\n", 245 | " + \\frac{i}{\\sqrt{2}} \\vert 10\\rangle\n", 246 | " + \\frac{1}{\\sqrt{6}} \\vert 11\\rangle\n", 247 | "$$\n", 248 | "\n", 249 | "(where $\\vert a b \\rangle = \\vert a\\rangle_{\\mathsf{X}}\\vert b \\rangle_{\\mathsf{Y}}$).\n", 250 | "\n", 251 | "If the system $\\mathsf{Y}$ is measured, what is the probability that the measurement result is 1?" 252 | ] 253 | }, 254 | { 255 | "cell_type": "markdown", 256 | "metadata": {}, 257 | "source": [ 258 | "### Quiz 2-6\n", 259 | "\n", 260 | "a)\n", 261 | "\n", 262 | "$\\frac{1}{6}$\n", 263 | "\n", 264 | "b)\n", 265 | "\n", 266 | "$\\frac{1}{3}$\n", 267 | "\n", 268 | "c)\n", 269 | "\n", 270 | "$\\frac{1}{\\sqrt{3}}$\n", 271 | "\n", 272 | "d)\n", 273 | "\n", 274 | "$\\sqrt{\\frac{1}{2}}$\n" 275 | ] 276 | }, 277 | { 278 | "cell_type": "markdown", 279 | "metadata": {}, 280 | "source": [ 281 | "## Quiz 2-7\n", 282 | "\n", 283 | "Suppose the quantum state vector of the compound system of $(\\mathsf{X},\\mathsf{Y})$ of two systems $\\mathsf{X}$ and $\\mathsf{Y}$ is the following\n", 284 | "\n", 285 | "$$\n", 286 | " \\vert \\psi \\rangle \n", 287 | " = \\frac{1}{\\sqrt{6}} \\vert 00 \\rangle\n", 288 | " - \\frac{i}{\\sqrt{6}} \\vert 01\\rangle\n", 289 | " + \\frac{i}{\\sqrt{2}} \\vert 10\\rangle\n", 290 | " + \\frac{1}{\\sqrt{6}} \\vert 11\\rangle\n", 291 | "$$\n", 292 | "\n", 293 | "(where $\\vert a b \\rangle = \\vert a\\rangle_{\\mathsf{X}}\\vert b \\rangle_{\\mathsf{Y}}$).\n", 294 | "\n", 295 | "If the system $\\mathsf{Y}$ is measured and its result is 1, what would be the state of $(\\mathsf{X},\\mathsf{Y})$ ?\n" 296 | ] 297 | }, 298 | { 299 | "cell_type": "markdown", 300 | "metadata": {}, 301 | "source": [ 302 | "### Quiz 2-7\n", 303 | "\n", 304 | "a)\n", 305 | "\n", 306 | "$\\vert 1\\rangle \\otimes \\biggl(\\sqrt{\\frac{3}{4}} \\vert 0\\rangle +\\frac{i}{\\sqrt{2}} \\vert 1\\rangle\\biggr) $\n", 307 | "\n", 308 | "b)\n", 309 | "\n", 310 | "$\\vert 1\\rangle \\otimes \\biggl(\\sqrt{\\frac{3}{4}} \\vert 0\\rangle +\\frac{i}{2} \\vert 1\\rangle\\biggr) $\n", 311 | "\n", 312 | "c)\n", 313 | "\n", 314 | "$\\biggl(-\\frac{i}{\\sqrt{6}} \\vert 0\\rangle +\\frac{1}{\\sqrt{6}} \\vert 1\\rangle\\biggr) \\otimes \\vert 1\\rangle$\n", 315 | "\n", 316 | "d)\n", 317 | "\n", 318 | "$\\biggl(-\\frac{i}{\\sqrt{2}} \\vert 0\\rangle +\\frac{1}{\\sqrt{2}} \\vert 1\\rangle\\biggr) \\otimes \\vert 1\\rangle$\n" 319 | ] 320 | }, 321 | { 322 | "cell_type": "markdown", 323 | "metadata": {}, 324 | "source": [ 325 | "## Quiz 2-8\n", 326 | "\n", 327 | "Which quantum state will be the result of applying the controlled-X operation, $CX = \\vert 0\\rangle \\langle 0\\vert \\otimes \\mathbb{1}_{\\mathsf{Y}} + \\vert 1\\rangle \\langle 1\\vert \\otimes X$, to $|11 \\rangle$ of the compound system $(\\mathsf{X},\\mathsf{Y})$ ? " 328 | ] 329 | }, 330 | { 331 | "cell_type": "markdown", 332 | "metadata": {}, 333 | "source": [ 334 | "### Quiz 2-8\n", 335 | "\n", 336 | "a)\n", 337 | "\n", 338 | "$\\vert 0 0 \\rangle$\n", 339 | "\n", 340 | "b)\n", 341 | "\n", 342 | "$\\vert 0 1 \\rangle$\n", 343 | "\n", 344 | "c)\n", 345 | "\n", 346 | "$\\vert 1 0 \\rangle$\n", 347 | "\n", 348 | "d)\n", 349 | "\n", 350 | "$\\vert 1 1 \\rangle$\n" 351 | ] 352 | }, 353 | { 354 | "cell_type": "markdown", 355 | "metadata": {}, 356 | "source": [ 357 | "## Quiz 2-9\n", 358 | "\n", 359 | "Which quantum state will be the result of applying the controlled-Z operation, $CZ = \n", 360 | " \\vert 0\\rangle \\langle 0\\vert \\otimes \\mathbb{1}_{\\mathsf{Y}} + \\vert 1\\rangle \\langle 1\\vert \\otimes Z$, to $|11 \\rangle$ of the compound system $(\\mathsf{X},\\mathsf{Y})$ ? " 361 | ] 362 | }, 363 | { 364 | "cell_type": "markdown", 365 | "metadata": {}, 366 | "source": [ 367 | "### Quiz 2-9\n", 368 | "\n", 369 | "a)\n", 370 | "\n", 371 | "-$\\vert 1 1 \\rangle$\n", 372 | "\n", 373 | "b)\n", 374 | "\n", 375 | "$\\vert 10 \\rangle$\n", 376 | "\n", 377 | "c)\n", 378 | "\n", 379 | "$\\vert 1 1 \\rangle$\n", 380 | "\n", 381 | "d)\n", 382 | "$\\frac{1}{2} \\vert 00 \\rangle + \\frac{1}{2} \\vert 11 \\rangle$\n", 383 | "\n" 384 | ] 385 | }, 386 | { 387 | "cell_type": "markdown", 388 | "metadata": {}, 389 | "source": [ 390 | "## Quiz 2-10\n", 391 | "\n", 392 | "Which quantum state will be the result of applying a Toffoli operation, $CCX = \\bigl(\n", 393 | " \\vert 00 \\rangle \\langle 00 \\vert \n", 394 | " + \\vert 01 \\rangle \\langle 01 \\vert \n", 395 | " + \\vert 10 \\rangle \\langle 10 \\vert \\bigr) \\otimes \\mathbb{1}\n", 396 | " + \\vert 11 \\rangle \\langle 11 \\vert \\otimes X$, to $|111 \\rangle$?" 397 | ] 398 | }, 399 | { 400 | "cell_type": "markdown", 401 | "metadata": {}, 402 | "source": [ 403 | "### Quiz 2-10\n", 404 | "\n", 405 | "a)\n", 406 | "\n", 407 | "$\\vert 111 \\rangle$\n", 408 | "\n", 409 | "b)\n", 410 | "\n", 411 | "$\\vert 110 \\rangle$\n", 412 | "\n", 413 | "c)\n", 414 | "\n", 415 | "$\\vert 001 \\rangle$\n", 416 | "\n", 417 | "d)\n", 418 | "\n", 419 | "$\\frac{1}{\\sqrt{2}} \\vert 000\\rangle + \\frac{1}{\\sqrt{2}} \\vert 111\\rangle$\n" 420 | ] 421 | }, 422 | { 423 | "cell_type": "markdown", 424 | "metadata": {}, 425 | "source": [ 426 | "## Answers\n", 427 | "1) a
\n", 428 | "2) d
\n", 429 | "3) d
\n", 430 | "4) d
\n", 431 | "5) c
\n", 432 | "6) b
\n", 433 | "7) d
\n", 434 | "8) c
\n", 435 | "9) a
\n", 436 | "10) b
" 437 | ] 438 | } 439 | ], 440 | "metadata": { 441 | "kernelspec": { 442 | "display_name": "Python 3 (ipykernel)", 443 | "language": "python", 444 | "name": "python3" 445 | }, 446 | "language_info": { 447 | "codemirror_mode": { 448 | "name": "ipython", 449 | "version": 3 450 | }, 451 | "file_extension": ".py", 452 | "mimetype": "text/x-python", 453 | "name": "python", 454 | "nbconvert_exporter": "python", 455 | "pygments_lexer": "ipython3", 456 | "version": "3.10.8" 457 | }, 458 | "widgets": { 459 | "application/vnd.jupyter.widget-state+json": { 460 | "state": {}, 461 | "version_major": 2, 462 | "version_minor": 0 463 | } 464 | } 465 | }, 466 | "nbformat": 4, 467 | "nbformat_minor": 4 468 | } 469 | -------------------------------------------------------------------------------- /Captain_Badge/2023/QE_Badge1_PracticeQuiz4.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "# Problem Set 4 - Introduction to Near-Term Quantum Computing" 8 | ] 9 | }, 10 | { 11 | "cell_type": "markdown", 12 | "metadata": {}, 13 | "source": [ 14 | "## Overview\n", 15 | "\n", 16 | "_Problem set adapted from:_
\n", 17 | "The University of Tokyo
\n", 18 | "Introduction to Near-Term Quantum Computing
\n", 19 | "\n", 20 | "
\n", 21 | "\n", 22 | "**Unit 4: Quantum Teleportation and Superdense Coding**\n", 23 | "\n", 24 | "\n", 25 | "This set of questions is based on the following contents:\n", 26 | "\n", 27 | "- [VIDEO: Understanding Quantum Information & Computation | Lesson 4 (John Watrous)](https://youtu.be/GSsElSQgMbU)\n", 28 | "- [TEXTBOOK: Entanglement in action of Basics of quantum information](https://learning.quantum-computing.ibm.com/course/basics-of-quantum-information/entanglement-in-action#introduction) \n" 29 | ] 30 | }, 31 | { 32 | "cell_type": "markdown", 33 | "metadata": {}, 34 | "source": [ 35 | "## Quiz 4-1\n", 36 | "\n", 37 | "Order the steps below to create the quantum teleportation protocol.\n", 38 | "\n", 39 | "\n", 40 | "Suppose that Alice has a qubit $\\mathsf{A}$, Bob has a qubit $\\mathsf{B}$, $(\\mathsf{A},\\mathsf{B})$ is in the quantum state $\\vert\\phi^+\\rangle$, and Alice has a third qubit $\\mathsf{Q}$ that she wants to send to Bob. " 41 | ] 42 | }, 43 | { 44 | "cell_type": "markdown", 45 | "metadata": {}, 46 | "source": [ 47 | "### Quiz 4-1\n", 48 | "\n", 49 | "1. Alice performs CNOT operation on the pair (A, Q) with Q being the control and A being the target.\n", 50 | "2. Bob performs the operation based on Alice's information.\n", 51 | "3. Alice measures both A and Q, with respect to a standard basis measurement in both cases, and transmits the classical outcomes to Bob. \n", 52 | "4. Alice performs Hadamard operation to Q.\n" 53 | ] 54 | }, 55 | { 56 | "cell_type": "markdown", 57 | "metadata": {}, 58 | "source": [ 59 | "## Quiz 4-2\n", 60 | "\n", 61 | "In the following sentence describing the protocol of the superdense coding, choose the appropriate one for (2-1) and (2-2).\n", 62 | "\n", 63 | "Alice holds a qubit $\\mathsf{Y}$, Bob holds a qubit $\\mathsf{X}$, and together the pair $(\\mathsf{X},\\mathsf{Y})$ is in the state $\\vert \\phi^+\\rangle$.\n", 64 | "If Alice wants to send classical information $ab = 11$ to Bob, she performs (2-1) on her qubit $\\mathsf{Y}$ and sends it to Bob. Therefore, the state of Bob's two qubits $(\\mathsf{X},\\mathsf{Y})$ becomes (2-2). Bob performs a CNOT gate, with $\\mathsf{Y}$ being the control and $\\mathsf{X}$ being the target, and then a Hadamard gate to $\\mathsf{Y}$, then measures $\\mathsf{X}$ to obtain $a=1$ and $\\mathsf{Y}$ to obtain $b=1$." 65 | ] 66 | }, 67 | { 68 | "cell_type": "markdown", 69 | "metadata": {}, 70 | "source": [ 71 | "### Quiz 4-2\n", 72 | "\n", 73 | "\n", 74 | "Choose the appropriate one for (2-1) \n", 75 | "\n", 76 | "\n", 77 | "\n", 78 | "a $Z$ gate\n", 79 | "\n", 80 | "\n", 81 | "\n", 82 | "an $X$ gate\n", 83 | "\n", 84 | "\n", 85 | "\n", 86 | "a $Z$ gate and an $X$ gate\n", 87 | "\n", 88 | "\n", 89 | "\n", 90 | "***\n", 91 | "\n", 92 | "\n", 93 | "Choose the appropriate one for (2-2) \n", 94 | "\n", 95 | "\n", 96 | "\n", 97 | "$\\vert \\phi^+\\rangle$\n", 98 | "\n", 99 | "\n", 100 | "\n", 101 | "$\\vert \\phi^-\\rangle$\n", 102 | "\n", 103 | "\n", 104 | "\n", 105 | "$\\vert \\psi^+\\rangle$\n", 106 | "\n", 107 | "\n", 108 | "\n", 109 | "$\\vert \\psi^-\\rangle$\n" 110 | ] 111 | }, 112 | { 113 | "cell_type": "markdown", 114 | "metadata": {}, 115 | "source": [ 116 | "## Quiz 4-3\n", 117 | "\n", 118 | "In the following sentence describing the CHSH game, choose the appropriate one for (3-1), (3-2), and (3-3).\n", 119 | "\n", 120 | "Alice holds a qubit $\\mathsf{A}$, Bob holds a qubit $\\mathsf{B}$, and the two qubits are in the $\\vert\\phi^+\\rangle$ state. If Alice's question is $x=1$, she applies (3-1) to her qubit $\\mathsf{A}$ and measures it. If Bob's question is $y=1$, he applies (3-2) to his qubit $\\mathsf{B}$ and measures it. If the respective measurement results are $a$ and $b$, the probability of $\\operatorname{Pr}(a \\not= b)$ becomes (3-3), and therefore they win with probability of (3-3). That's significantly better than any classical strategy can do for this game." 121 | ] 122 | }, 123 | { 124 | "cell_type": "markdown", 125 | "metadata": {}, 126 | "source": [ 127 | "### Quiz 4-3\n", 128 | "\n", 129 | "\n", 130 | "Choose the appropriate one for (3-1) \n", 131 | "\n", 132 | "\n", 133 | "$U_{0}$\n", 134 | "\n", 135 | "\n", 136 | "\n", 137 | "$U_{\\pi/4}$\n", 138 | "\n", 139 | "\n", 140 | "\n", 141 | "$U_{\\pi/8}$\n", 142 | "\n", 143 | "\n", 144 | "\n", 145 | "$U_{-\\pi/8}$\n", 146 | "\n", 147 | "\n", 148 | "\n", 149 | "***\n", 150 | "\n", 151 | "Choose the appropriate one for (3-2) \n", 152 | "\n", 153 | "\n", 154 | "\n", 155 | "$U_{0}$\n", 156 | "\n", 157 | "\n", 158 | "\n", 159 | "$U_{\\pi/4}$\n", 160 | "\n", 161 | "\n", 162 | "\n", 163 | "$U_{\\pi/8}$\n", 164 | "\n", 165 | "\n", 166 | "$U_{-\\pi/8}$\n", 167 | "\n", 168 | "\n", 169 | "\n", 170 | "***\n", 171 | "\n", 172 | "\n", 173 | "Choose the appropriate one for (3-3) \n", 174 | "\n", 175 | "\n", 176 | "\n", 177 | "$3/4$\n", 178 | "\n", 179 | "\n", 180 | "\n", 181 | "$\\frac{2-\\sqrt{2}}{4}$\n", 182 | "\n", 183 | "\n", 184 | "\n", 185 | "$\\frac{2+\\sqrt{2}}{4}$\n", 186 | "\n" 187 | ] 188 | }, 189 | { 190 | "cell_type": "markdown", 191 | "metadata": {}, 192 | "source": [ 193 | "## Execution\n", 194 | "\n", 195 | "\n", 196 | "Execute Qiskit code of the lecture notebook.\n", 197 | "\n", 198 | "" 199 | ] 200 | }, 201 | { 202 | "cell_type": "markdown", 203 | "metadata": {}, 204 | "source": [ 205 | "## Answers\n", 206 | "1) 1, 4, 3, 2
\n", 207 | "2) Z then X, $\\vert \\psi^-\\rangle$
\n", 208 | "3) $U_{\\pi/4}$, $U_{-\\pi/8}$, $\\frac{2+\\sqrt{2}}{4}$" 209 | ] 210 | } 211 | ], 212 | "metadata": { 213 | "kernelspec": { 214 | "display_name": "Python 3 (ipykernel)", 215 | "language": "python", 216 | "name": "python3" 217 | }, 218 | "language_info": { 219 | "codemirror_mode": { 220 | "name": "ipython", 221 | "version": 3 222 | }, 223 | "file_extension": ".py", 224 | "mimetype": "text/x-python", 225 | "name": "python", 226 | "nbconvert_exporter": "python", 227 | "pygments_lexer": "ipython3", 228 | "version": "3.10.8" 229 | }, 230 | "widgets": { 231 | "application/vnd.jupyter.widget-state+json": { 232 | "state": {}, 233 | "version_major": 2, 234 | "version_minor": 0 235 | } 236 | } 237 | }, 238 | "nbformat": 4, 239 | "nbformat_minor": 4 240 | } 241 | -------------------------------------------------------------------------------- /Captain_Badge/QiskitBlocks_Tips.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qiskit-community/quantum-explorers/597fec6917327884425c9121257bcbf027df5f16/Captain_Badge/QiskitBlocks_Tips.pdf -------------------------------------------------------------------------------- /Expert_Navigator_Badge/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qiskit-community/quantum-explorers/597fec6917327884425c9121257bcbf027df5f16/Expert_Navigator_Badge/.DS_Store -------------------------------------------------------------------------------- /Expert_Navigator_Badge/2023/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qiskit-community/quantum-explorers/597fec6917327884425c9121257bcbf027df5f16/Expert_Navigator_Badge/2023/.DS_Store -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "{}" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright 2024 IBM Quantum 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ![Image](images/qe_banner.jpg) 2 | # Quantum Explorers 3 | 4 | Quantum Explorers is our self-paced, game-based quantum computing learning program for high school students and above. The theme of the learning journey is space exploration. You’ll embark on an interstellar journey as the captain of a starship and grow proficiency in quantum computing along the way. 5 | 6 | Anyone can join, from students to industry professionals to quantum enthusiasts! The program is beginner-friendly, though it increases in difficulty as achievements are unlocked. The program is comprised of engaging study materials, seminars, gamified achievements to unlock, community events, and career advice. 7 | 8 | Participants will gain a general understanding of quantum computing, learn some of its applications such as quantum machine learning and quantum optimization, and program real quantum computers. 9 | 10 | There are seven themed achievements to unlock with corresponding badges to collect. Each badge has a learning module, event, or set of tasks associated with it that must be completed in order to unlock its achievement. The program culminates in a certification based on how many badges you collect. 11 | 12 | **Location:** A substantial amount of this program takes place on a dedicated Discord server. If you don’t have a Discord account already, please create one in preparation for this program. (Having trouble? Here’s [How to Create a Discord Account](https://www.wikihow.com/Create-a-Discord-Account-on-a-PC-or-Mac).) 13 | 14 | **Timeline:** The program will be live from July 2023 to February 2024. Total materials cover approximately 50 to 85 hours spanning over these 7 months. Level of engagement depends on the participant. 15 | 16 | Promotional Flyers: 17 | 18 | - Quantum Explorers official event flyer: https://ibm.ent.box.com/v/qe-2023-flyer 19 | - Are you an educator interested in learning or teaching quantum? Check out this flyer for educators: https://ibm.ent.box.com/v/qe-educators-flyer 20 | 21 | Please feel free to download and circulate these flyers! 22 | 23 | If you want to participate in the next cohort of Quantum Explorers, and would like to be notified via email about updates, please [fill this form](https://airtable.com/shrRPWsAjAOZrRABF). Note: this does not count as registration. Registration information to come. 24 | 25 | Both new Explorers and those who participated in the 2022–23 cohort are all welcome! 26 | 27 | 28 | Event website: [qisk.it/quantum-explorers](http://qisk.it/quantum-explorers). 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /Space_Combatant_Badge/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qiskit-community/quantum-explorers/597fec6917327884425c9121257bcbf027df5f16/Space_Combatant_Badge/.DS_Store -------------------------------------------------------------------------------- /Space_Combatant_Badge/2023/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qiskit-community/quantum-explorers/597fec6917327884425c9121257bcbf027df5f16/Space_Combatant_Badge/2023/.DS_Store -------------------------------------------------------------------------------- /Space_Combatant_Badge/2023/QE_Badge5_Lab2-ja.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "# 量子ニューラル・ネットワーク技術入門 - チュートリアル\n", 8 | "\n", 9 | "このチュートリアルはQiskit Machine learning docsから作成しました。https://qiskit.org/ecosystem/machine-learning/locale/ja_JP/tutorials/01_neural_networks.html\n" 10 | ] 11 | }, 12 | { 13 | "cell_type": "markdown", 14 | "metadata": {}, 15 | "source": [ 16 | "# 量子ニューラル・ネットワーク\n", 17 | "\n", 18 | "## 概要\n", 19 | "\n", 20 | "このノートブックでは、 `qiskit-machine-learning` で提供されるさまざまな量子ニューラルネットワーク (QNN) の実装と、それらを基本的な量子機械学習 (QML) ワークフローに統合する方法について説明します。\n", 21 | "\n", 22 | "このチュートリアルの構造は以下のとおりです。\n", 23 | "\n", 24 | "1. [はじめに](#1.-Implementation-in-`qiskit-machine-learning`)\n", 25 | "2. [SamplerQNN](#2.`SamplerQNN`)\n", 26 | "3. [フォワード・パスの実行方法](#3.-How-to-Run-a-Forward-Pass)\n", 27 | "4. [バックワード・パスの実行方法](#4.-How-to-Run-a-Backward-Pass)\n", 28 | "5. [拡張機能](#5.-Advanced-Functionality)\n", 29 | "6. [結論](#6.-Conclusion)" 30 | ] 31 | }, 32 | { 33 | "cell_type": "markdown", 34 | "metadata": {}, 35 | "source": [ 36 | "## 1. `qiskit-machine-learning` での実装\n", 37 | "\n", 38 | "`qiskit-machine-learning` のQNNはアプリケーションに依存しない計算ユニットであり、様々なユースケースに使用できます。\n", 39 | "\n", 40 | "このモジュールには、QNNのインターフェースと 2 つの特定の実装が含まれています。\n", 41 | "\n", 42 | "1. [NeuralNetwork](https://qiskit.org/ecosystem/machine-learning/stubs/qiskit_machine_learning.neural_networks.NeuralNetwork.html): ニューラルネットワークのインターフェイス。これは全ての QNN が継承する抽象クラスです。。\n", 43 | "2. [EstimatorQNN](https://qiskit.org/ecosystem/machine-learning/stubs/qiskit_machine_learning.neural_networks.EstimatorQNN.html): 量子力学的観測可能量(オブザーバブル)の評価に基づくネットワーク。\n", 44 | "3. [SamplerQNN](https://qiskit.org/ecosystem/machine-learning/locale/fr_FR/stubs/qiskit_machine_learning.neural_networks.SamplerQNN.html): 量子回路の測定から得られたサンプルを基にしたネットワーク。\n", 45 | " \n", 46 | "これらの実装は [qiskit primitives](https://qiskit.org/documentation/apidoc/primitives.html) に基づいています。それぞれの実装である `EstimatorQNN` と `SamplerQNN` は、対応するprimitive (`BaseEstimator` と `BaseSampler` の任意のサブクラス) のオプション・インスタンスを取り込みます。" 47 | ] 48 | }, 49 | { 50 | "cell_type": "markdown", 51 | "metadata": {}, 52 | "source": [ 53 | "***\n", 54 | "\n", 55 | "それでは、2つの `NeuralNetwork` 実装の具体例を見てみましょう。しかしその前に、実行のたびに結果が変わらないように、アルゴリズムのseedを設定します。" 56 | ] 57 | }, 58 | { 59 | "cell_type": "code", 60 | "execution_count": 1, 61 | "metadata": {}, 62 | "outputs": [], 63 | "source": [ 64 | "from qiskit.utils import algorithm_globals\n", 65 | "\n", 66 | "algorithm_globals.random_seed = 42" 67 | ] 68 | }, 69 | { 70 | "cell_type": "markdown", 71 | "metadata": {}, 72 | "source": [ 73 | "## 2. `SamplerQNN`\n", 74 | "\n", 75 | "`SamplerQNN` は、 `EstimatorQNN` と同様にインスタンス化されます。 \n", 76 | "\n", 77 | " - しかし、量子回路の測定から直接サンプルを吸収するので、カスタムのオブザーバブルを必要としません。\n", 78 | "\n", 79 | "これらの出力サンプルは、デフォルトでは、ビット文字列に対応する整数インデックスを測定する確率として解釈されます。\n", 80 | "\n", 81 | "ただし、 `SamplerQNN` ではサンプルを後処理するための `interpret` 関数を指定することもできます。 この関数は (ビット文字列から) 測定された整数を取って、それを新しい値、すなわち非負の整数にマップするように定義する必要があります。" 82 | ] 83 | }, 84 | { 85 | "cell_type": "markdown", 86 | "metadata": {}, 87 | "source": [ 88 | "`SamplerQNN` 用に別の量子回路を作成しましょう。 この場合、2 つの入力パラメーターと 4 つの訓練可能な重みを持ち、Two-local 回路をパラメーター化します。" 89 | ] 90 | }, 91 | { 92 | "cell_type": "code", 93 | "execution_count": 5, 94 | "metadata": {}, 95 | "outputs": [ 96 | { 97 | "name": "stdout", 98 | "output_type": "stream", 99 | "text": [ 100 | "input parameters: ['input[0]', 'input[1]']\n", 101 | "weight parameters: ['weight[0]', 'weight[1]', 'weight[2]', 'weight[3]']\n" 102 | ] 103 | }, 104 | { 105 | "data": { 106 | "image/png": "iVBORw0KGgoAAAANSUhEUgAAAbIAAACuCAYAAABTEIhIAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjYuMywgaHR0cHM6Ly9tYXRwbG90bGliL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5, 112 | "metadata": {}, 113 | "output_type": "execute_result" 114 | } 115 | ], 116 | "source": [ 117 | "from qiskit.circuit import QuantumCircuit, ParameterVector\n", 118 | "\n", 119 | "inputs2 = ParameterVector(\"input\", 2)\n", 120 | "weights2 = ParameterVector(\"weight\", 4)\n", 121 | "print(f\"input parameters: {[str(item) for item in inputs2.params]}\")\n", 122 | "print(f\"weight parameters: {[str(item) for item in weights2.params]}\")\n", 123 | "\n", 124 | "qc2 = QuantumCircuit(2)\n", 125 | "qc2.ry(inputs2[0], 0)\n", 126 | "qc2.ry(inputs2[1], 1)\n", 127 | "qc2.cx(0, 1)\n", 128 | "qc2.ry(weights2[0], 0)\n", 129 | "qc2.ry(weights2[1], 1)\n", 130 | "qc2.cx(0, 1)\n", 131 | "qc2.ry(weights2[2], 0)\n", 132 | "qc2.ry(weights2[3], 1)\n", 133 | "\n", 134 | "qc2.draw(output=\"mpl\")" 135 | ] 136 | }, 137 | { 138 | "cell_type": "markdown", 139 | "metadata": {}, 140 | "source": [ 141 | "\n", 142 | "`EstimatorQNN` と同様に、 `SamplerQNN` をインスタンス化する際に入力と重みを指定する必要があります。 この場合、キーワード引数は以下のようになります: \n", 143 | "- `sampler`: オプションのprimitiveインスタンス \n", 144 | "- `input_params`: 「ネットワーク入力」として扱われるべき量子回路パラメーターのリスト \n", 145 | "- `weight_params`: 「ネットワーク重み」として扱われるべき量子回路パラメーターのリスト\n", 146 | "\n", 147 | "再び、 `Sampler` インスタンスを QNN に設定せず、デフォルトにしていることに注意してください。" 148 | ] 149 | }, 150 | { 151 | "cell_type": "code", 152 | "execution_count": 7, 153 | "metadata": {}, 154 | "outputs": [ 155 | { 156 | "data": { 157 | "text/plain": [ 158 | "" 159 | ] 160 | }, 161 | "execution_count": 7, 162 | "metadata": {}, 163 | "output_type": "execute_result" 164 | } 165 | ], 166 | "source": [ 167 | "from qiskit_machine_learning.neural_networks import SamplerQNN\n", 168 | "\n", 169 | "sampler_qnn = SamplerQNN(circuit=qc2, input_params=inputs2, weight_params=weights2)\n", 170 | "sampler_qnn" 171 | ] 172 | }, 173 | { 174 | "cell_type": "markdown", 175 | "metadata": {}, 176 | "source": [ 177 | "\n", 178 | "上記の基本的な引数に加えて、 `SamplerQNN` は `input_gradients` と `interpret` と `output_shape` の 3 つの設定を受け付けます。 これらはセクション4とセクション5で紹介されます。" 179 | ] 180 | }, 181 | { 182 | "cell_type": "markdown", 183 | "metadata": {}, 184 | "source": [ 185 | "## 3. フォワード・パスの実行方法" 186 | ] 187 | }, 188 | { 189 | "cell_type": "markdown", 190 | "metadata": {}, 191 | "source": [ 192 | "### 3.1. セットアップ\n", 193 | "\n", 194 | "実際の設定では、入力はデータセットによって定義され、重みは学習アルゴリズムや学習済みモデルの一部として定義されます。しかし、このチュートリアルのために、適切な次元の入力と重みのランダムなセットを指定します。" 195 | ] 196 | }, 197 | { 198 | "cell_type": "code", 199 | "execution_count": 8, 200 | "metadata": { 201 | "scrolled": true 202 | }, 203 | "outputs": [], 204 | "source": [ 205 | "sampler_qnn_input = algorithm_globals.random.random(sampler_qnn.num_inputs)\n", 206 | "sampler_qnn_weights = algorithm_globals.random.random(sampler_qnn.num_weights)" 207 | ] 208 | }, 209 | { 210 | "cell_type": "code", 211 | "execution_count": 9, 212 | "metadata": {}, 213 | "outputs": [ 214 | { 215 | "name": "stdout", 216 | "output_type": "stream", 217 | "text": [ 218 | "Number of input features for SamplerQNN: 2 \n", 219 | "Input: [0.77395605 0.43887844]\n", 220 | "Number of trainable weights for SamplerQNN: 4 \n", 221 | "Weights: [0.85859792 0.69736803 0.09417735 0.97562235]\n" 222 | ] 223 | } 224 | ], 225 | "source": [ 226 | "print(\n", 227 | " f\"Number of input features for SamplerQNN: {sampler_qnn.num_inputs} \\nInput: {sampler_qnn_input}\"\n", 228 | ")\n", 229 | "print(\n", 230 | " f\"Number of trainable weights for SamplerQNN: {sampler_qnn.num_weights} \\nWeights: {sampler_qnn_weights}\"\n", 231 | ")" 232 | ] 233 | }, 234 | { 235 | "cell_type": "markdown", 236 | "metadata": {}, 237 | "source": [ 238 | "入力と重みを設定したら、バッチパスと非バッチパスの結果を確認しましょう。" 239 | ] 240 | }, 241 | { 242 | "cell_type": "markdown", 243 | "metadata": {}, 244 | "source": [ 245 | "### 3.2. 非バッチ・フォワード・パス" 246 | ] 247 | }, 248 | { 249 | "cell_type": "markdown", 250 | "metadata": {}, 251 | "source": [ 252 | "\n", 253 | "\n", 254 | "`SamplerQNN` (カスタム interpret 関数なし) では、フォワード・パスの期待される出力形状は `(1, 2**num_qubits)` になります。 カスタム interpret 関数を使用すると、出力形状は `(1, output_shape)` になります。ここで、`1` はサンプル数です。" 255 | ] 256 | }, 257 | { 258 | "cell_type": "code", 259 | "execution_count": 10, 260 | "metadata": {}, 261 | "outputs": [ 262 | { 263 | "name": "stdout", 264 | "output_type": "stream", 265 | "text": [ 266 | "Forward pass result for SamplerQNN: [[0.23851185 0.1411135 0.3367757 0.28359895]]. \n", 267 | "Shape: (1, 4)\n" 268 | ] 269 | } 270 | ], 271 | "source": [ 272 | "sampler_qnn_forward = sampler_qnn.forward(sampler_qnn_input, sampler_qnn_weights)\n", 273 | "\n", 274 | "print(\n", 275 | " f\"Forward pass result for SamplerQNN: {sampler_qnn_forward}. \\nShape: {sampler_qnn_forward.shape}\"\n", 276 | ")" 277 | ] 278 | }, 279 | { 280 | "cell_type": "markdown", 281 | "metadata": {}, 282 | "source": [ 283 | "### 3.3. バッチ・フォワード・パス" 284 | ] 285 | }, 286 | { 287 | "cell_type": "markdown", 288 | "metadata": {}, 289 | "source": [ 290 | "\n", 291 | "`SamplerQNN` (カスタム interpret 関数なし) では、フォワード・パスの期待される出力形状は `(batch_size, 2**num_qubits)` になります。 カスタム interpret 関数を使用すると、出力形状は `(batch_size, output_shape)` になります。" 292 | ] 293 | }, 294 | { 295 | "cell_type": "code", 296 | "execution_count": 11, 297 | "metadata": {}, 298 | "outputs": [ 299 | { 300 | "name": "stdout", 301 | "output_type": "stream", 302 | "text": [ 303 | "Forward pass result for SamplerQNN: [[0.23851185 0.1411135 0.3367757 0.28359895]\n", 304 | " [0.23851185 0.1411135 0.3367757 0.28359895]]. \n", 305 | "Shape: (2, 4)\n" 306 | ] 307 | } 308 | ], 309 | "source": [ 310 | "sampler_qnn_forward_batched = sampler_qnn.forward(\n", 311 | " [sampler_qnn_input, sampler_qnn_input], sampler_qnn_weights\n", 312 | ")\n", 313 | "\n", 314 | "print(\n", 315 | " f\"Forward pass result for SamplerQNN: {sampler_qnn_forward_batched}. \\nShape: {sampler_qnn_forward_batched.shape}\"\n", 316 | ")" 317 | ] 318 | }, 319 | { 320 | "cell_type": "markdown", 321 | "metadata": {}, 322 | "source": [ 323 | "## 4. バックワード・パスの実行方法\n", 324 | "\n", 325 | "上記で定義した入力と重みを利用して、バックワード・パスの動作を示しましょう。このパスはタプル `(input_gradients, weight_gradients)` を返します。 デフォルトでは、バックワード・パスは重みパラメーターに対する勾配のみを計算します。\n", 326 | "\n", 327 | "入力パラメーターに対して勾配を有効にする場合は、QNN インスタンスを作成するときに次のフラグを設定する必要があります。\n", 328 | "\n", 329 | "```python\n", 330 | "qnn = ...QNN(..., input_gradients=True)\n", 331 | "```\n", 332 | "\n", 333 | "\n", 334 | "PyTorchとの統合に `TorchConnector` を使用するには、入力勾配が **必要** であることを忘れないでください。" 335 | ] 336 | }, 337 | { 338 | "cell_type": "markdown", 339 | "metadata": {}, 340 | "source": [ 341 | "### 4.1. 入力勾配のないバックワード・パス" 342 | ] 343 | }, 344 | { 345 | "cell_type": "markdown", 346 | "metadata": {}, 347 | "source": [ 348 | "\n", 349 | "`SamplerQNN` (カスタム interpret 関数なし) では、フォワード・パスの期待される出力形状は `(batch_size, 2**num_qubits, num_weights) `になります。 カスタム interpret 関数を使用すると、出力形状は `(batch_size, output_shape, num_weights)` になります。" 350 | ] 351 | }, 352 | { 353 | "cell_type": "code", 354 | "execution_count": 12, 355 | "metadata": {}, 356 | "outputs": [ 357 | { 358 | "name": "stdout", 359 | "output_type": "stream", 360 | "text": [ 361 | "Input gradients for SamplerQNN: None. \n", 362 | "Shape: None\n", 363 | "Weight gradients for SamplerQNN: [[[ 0.00609879 -0.30661818 -0.1834591 -0.28341665]\n", 364 | " [-0.02969169 0.17866236 0.1834591 -0.20004909]\n", 365 | " [-0.37812738 0.30266095 -0.30904568 0.28341665]\n", 366 | " [ 0.40172028 -0.17470512 0.30904568 0.20004909]]]. \n", 367 | "Shape: (1, 4, 4)\n" 368 | ] 369 | } 370 | ], 371 | "source": [ 372 | "sampler_qnn_input_grad, sampler_qnn_weight_grad = sampler_qnn.backward(\n", 373 | " sampler_qnn_input, sampler_qnn_weights\n", 374 | ")\n", 375 | "\n", 376 | "print(\n", 377 | " f\"Input gradients for SamplerQNN: {sampler_qnn_input_grad}. \\nShape: {sampler_qnn_input_grad}\"\n", 378 | ")\n", 379 | "print(\n", 380 | " f\"Weight gradients for SamplerQNN: {sampler_qnn_weight_grad}. \\nShape: {sampler_qnn_weight_grad.shape}\"\n", 381 | ")" 382 | ] 383 | }, 384 | { 385 | "cell_type": "markdown", 386 | "metadata": {}, 387 | "source": [ 388 | "### 4.2. 入力勾配のあるバックワード・パス\n", 389 | "\n", 390 | "`input_gradients` を有効にして、このオプションで期待される出力サイズを表示しましょう。" 391 | ] 392 | }, 393 | { 394 | "cell_type": "code", 395 | "execution_count": 13, 396 | "metadata": {}, 397 | "outputs": [], 398 | "source": [ 399 | "sampler_qnn.input_gradients = True" 400 | ] 401 | }, 402 | { 403 | "cell_type": "markdown", 404 | "metadata": {}, 405 | "source": [ 406 | "#### 4.2.2. `SamplerQNN` の例" 407 | ] 408 | }, 409 | { 410 | "cell_type": "markdown", 411 | "metadata": {}, 412 | "source": [ 413 | "`SamplerQNN` (カスタム interpret 関数なし) では、入力勾配に対する期待される出力形状は `(batch_size, 2**num_qubits, num_inputs)` になります。 カスタム interpret 関数を使用すると、出力形状は `(batch_size, output_shape, num_inputs)` になります。" 414 | ] 415 | }, 416 | { 417 | "cell_type": "code", 418 | "execution_count": 14, 419 | "metadata": {}, 420 | "outputs": [ 421 | { 422 | "name": "stdout", 423 | "output_type": "stream", 424 | "text": [ 425 | "Input gradients for SamplerQNN: [[[ 0.00854017 -0.4260793 ]\n", 426 | " [ 0.29208826 0.08375938]\n", 427 | " [-0.35915753 0.17972714]\n", 428 | " [ 0.05852911 0.16259278]]]. \n", 429 | "Shape: (1, 4, 2)\n", 430 | "Weight gradients for SamplerQNN: [[[ 0.00609879 -0.30661818 -0.1834591 -0.28341665]\n", 431 | " [-0.02969169 0.17866236 0.1834591 -0.20004909]\n", 432 | " [-0.37812738 0.30266095 -0.30904568 0.28341665]\n", 433 | " [ 0.40172028 -0.17470512 0.30904568 0.20004909]]]. \n", 434 | "Shape: (1, 4, 4)\n" 435 | ] 436 | } 437 | ], 438 | "source": [ 439 | "sampler_qnn_input_grad, sampler_qnn_weight_grad = sampler_qnn.backward(\n", 440 | " sampler_qnn_input, sampler_qnn_weights\n", 441 | ")\n", 442 | "\n", 443 | "print(\n", 444 | " f\"Input gradients for SamplerQNN: {sampler_qnn_input_grad}. \\nShape: {sampler_qnn_input_grad.shape}\"\n", 445 | ")\n", 446 | "print(\n", 447 | " f\"Weight gradients for SamplerQNN: {sampler_qnn_weight_grad}. \\nShape: {sampler_qnn_weight_grad.shape}\"\n", 448 | ")" 449 | ] 450 | }, 451 | { 452 | "cell_type": "markdown", 453 | "metadata": {}, 454 | "source": [ 455 | "## 5. 拡張機能" 456 | ] 457 | }, 458 | { 459 | "cell_type": "markdown", 460 | "metadata": {}, 461 | "source": [ 462 | "### カスタム `interpret` 付き `SamplerQNN`" 463 | ] 464 | }, 465 | { 466 | "cell_type": "markdown", 467 | "metadata": {}, 468 | "source": [ 469 | "\n", 470 | "`SamplerQNN` の一般的な `interpret` メソッドの 1 つは `parity` 関数で、バイナリ分類を行うことができます。 インスタンス作成のセクションで説明したように、interpret 関数を使うことで、フォワードとバックワード・パスの出力形状が変更されます。 パリティinterpret関数の場合、 `output_shape` は `2` に固定されます。 そこで期待される前方および重み勾配の形状は、おそれぞれ `(batch_size, 2)` と `(batch_size, 2, num_weights)` です。" 471 | ] 472 | }, 473 | { 474 | "cell_type": "code", 475 | "execution_count": 15, 476 | "metadata": {}, 477 | "outputs": [], 478 | "source": [ 479 | "parity = lambda x: \"{:b}\".format(x).count(\"1\") % 2\n", 480 | "output_shape = 2 # parity = 0, 1\n", 481 | "\n", 482 | "sampler_qnn2 = SamplerQNN(\n", 483 | " circuit=qc2,\n", 484 | " input_params=inputs2,\n", 485 | " weight_params=weights2,\n", 486 | " interpret=parity,\n", 487 | " output_shape=output_shape,\n", 488 | ")" 489 | ] 490 | }, 491 | { 492 | "cell_type": "code", 493 | "execution_count": 16, 494 | "metadata": {}, 495 | "outputs": [ 496 | { 497 | "name": "stdout", 498 | "output_type": "stream", 499 | "text": [ 500 | "Forward output for SamplerQNN1: (1, 4)\n", 501 | "Forward output for SamplerQNN2: (1, 2)\n", 502 | "Backward output for SamplerQNN1: (1, 4, 4)\n", 503 | "Backward output for SamplerQNN2: (1, 2, 4)\n" 504 | ] 505 | } 506 | ], 507 | "source": [ 508 | "sampler_qnn_forward2 = sampler_qnn2.forward(sampler_qnn_input, sampler_qnn_weights)\n", 509 | "sampler_qnn_input_grad2, sampler_qnn_weight_grad2 = sampler_qnn2.backward(\n", 510 | " sampler_qnn_input, sampler_qnn_weights\n", 511 | ")\n", 512 | "\n", 513 | "print(f\"Forward output for SamplerQNN1: {sampler_qnn_forward.shape}\")\n", 514 | "print(f\"Forward output for SamplerQNN2: {sampler_qnn_forward2.shape}\")\n", 515 | "print(f\"Backward output for SamplerQNN1: {sampler_qnn_weight_grad.shape}\")\n", 516 | "print(f\"Backward output for SamplerQNN2: {sampler_qnn_weight_grad2.shape}\")" 517 | ] 518 | }, 519 | { 520 | "cell_type": "markdown", 521 | "metadata": {}, 522 | "source": [ 523 | "## 6. 結論\n", 524 | "\n", 525 | "\n", 526 | "このチュートリアルでは、 `qiskit-machine-learning` によって提供される2つのニューラルネットワーク・クラス、つまり `EstimatorQNN` と `SamplerQNN` について紹介しました。 QNN初期化のための重要なステップ、フォワードおよびバックワード・パスでの基本的な使用法、および高度な機能のいくつかの理論的背景を提供しました。\n", 527 | "\n", 528 | "この問題設定を扱って、さまざまな回路のサイズ、入力、重みパラメーターの長さが、出力形状にどのように影響を与えるか確認することをお勧めします。" 529 | ] 530 | }, 531 | { 532 | "cell_type": "code", 533 | "execution_count": 48, 534 | "metadata": { 535 | "pycharm": { 536 | "name": "#%%\n" 537 | } 538 | }, 539 | "outputs": [ 540 | { 541 | "data": { 542 | "text/html": [ 543 | "

Version Information

Qiskit SoftwareVersion
qiskit-terra0.22.3
qiskit-machine-learning0.6.0
System information
Python version3.9.15
Python compilerClang 14.0.6
Python buildmain, Nov 24 2022 08:29:02
OSDarwin
CPUs8
Memory (Gb)64.0
Mon Jan 23 11:57:49 2023 CET
" 544 | ], 545 | "text/plain": [ 546 | "" 547 | ] 548 | }, 549 | "metadata": {}, 550 | "output_type": "display_data" 551 | }, 552 | { 553 | "data": { 554 | "text/html": [ 555 | "

This code is a part of Qiskit

© Copyright IBM 2017, 2023.

This code is licensed under the Apache License, Version 2.0. You may
obtain a copy of this license in the LICENSE.txt file in the root directory
of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.

Any modifications or derivative works of this code must retain this
copyright notice, and modified files need to carry a notice indicating
that they have been altered from the originals.

" 556 | ], 557 | "text/plain": [ 558 | "" 559 | ] 560 | }, 561 | "metadata": {}, 562 | "output_type": "display_data" 563 | } 564 | ], 565 | "source": [ 566 | "import qiskit.tools.jupyter\n", 567 | "\n", 568 | "%qiskit_version_table\n", 569 | "%qiskit_copyright" 570 | ] 571 | } 572 | ], 573 | "metadata": { 574 | "kernelspec": { 575 | "display_name": "Python 3", 576 | "language": "python", 577 | "name": "python3" 578 | }, 579 | "language_info": { 580 | "codemirror_mode": { 581 | "name": "ipython", 582 | "version": 3 583 | }, 584 | "file_extension": ".py", 585 | "mimetype": "text/x-python", 586 | "name": "python", 587 | "nbconvert_exporter": "python", 588 | "pygments_lexer": "ipython3", 589 | "version": "3.8.5" 590 | }, 591 | "widgets": { 592 | "application/vnd.jupyter.widget-state+json": { 593 | "state": {}, 594 | "version_major": 2, 595 | "version_minor": 0 596 | } 597 | } 598 | }, 599 | "nbformat": 4, 600 | "nbformat_minor": 5 601 | } 602 | -------------------------------------------------------------------------------- /Space_Combatant_Badge/2023/QE_Badge5_Lab2.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "id": "ddbd35fa", 6 | "metadata": {}, 7 | "source": [ 8 | "# Introduction to Quantum Neural Network Techniques - Tutorial\n", 9 | "\n", 10 | "This tutorial was generated from Qiskit Machine learning docs\n", 11 | "https://qiskit.org/ecosystem/machine-learning/tutorials/01_neural_networks.html" 12 | ] 13 | }, 14 | { 15 | "cell_type": "markdown", 16 | "id": "brilliant-cross", 17 | "metadata": {}, 18 | "source": [ 19 | "# Quantum Neural Networks\n", 20 | "\n", 21 | "## Overview\n", 22 | "This notebook demonstrates different quantum neural network (QNN) implementations provided in `qiskit-machine-learning`, and how they can be integrated into basic quantum machine learning (QML) workflows.\n", 23 | "\n", 24 | "The tutorial is structured as follows:\n", 25 | "\n", 26 | "1. [Introduction](#1.-Implementation-in-`qiskit-machine-learning`)\n", 27 | "2. [SamplerQNN](#2.`SamplerQNN`)\n", 28 | "3. [How to Run a Forward Pass](#3.-How-to-Run-a-Forward-Pass)\n", 29 | "4. [How to Run a Backward Pass](#4.-How-to-Run-a-Backward-Pass)\n", 30 | "5. [Advanced Functionality](#5.-Advanced-Functionality)\n", 31 | "6. [Conclusion](#6.-Conclusion)" 32 | ] 33 | }, 34 | { 35 | "cell_type": "markdown", 36 | "id": "f47d2070", 37 | "metadata": {}, 38 | "source": [ 39 | "## 1. Implementation in `qiskit-machine-learning`\n", 40 | "\n", 41 | "The QNNs in `qiskit-machine-learning` are meant as application-agnostic computational units that can be used for different use cases.\n", 42 | "\n", 43 | "The module contains an interface for the QNNs and two specific implementations:\n", 44 | "\n", 45 | "1. [NeuralNetwork](https://qiskit.org/ecosystem/machine-learning/stubs/qiskit_machine_learning.neural_networks.NeuralNetwork.html): The interface for neural networks. This is an abstract class all QNNs inherit from.\n", 46 | "2. [EstimatorQNN](https://qiskit.org/ecosystem/machine-learning/stubs/qiskit_machine_learning.neural_networks.EstimatorQNN.html): A network based on the evaluation of quantum mechanical observables.\n", 47 | "3. [SamplerQNN](https://qiskit.org/ecosystem/machine-learning/locale/fr_FR/stubs/qiskit_machine_learning.neural_networks.SamplerQNN.html): A network based on the samples resulting from measuring a quantum circuit.\n", 48 | "\n", 49 | "\n", 50 | "These implementations are based on the [qiskit primitives](https://qiskit.org/documentation/apidoc/primitives.html).\n", 51 | " Each implementation, `EstimatorQNN` and `SamplerQNN`, takes in an optional instance of its corresponding primitive, which can be any subclass of `BaseEstimator` and `BaseSampler`, respectively." 52 | ] 53 | }, 54 | { 55 | "cell_type": "markdown", 56 | "id": "ba316207", 57 | "metadata": {}, 58 | "source": [ 59 | "***\n", 60 | "\n", 61 | "Let's now look into specific examples for the two `NeuralNetwork` implementations. But first, let's set the algorithmic seed to ensure that the results don't change between runs." 62 | ] 63 | }, 64 | { 65 | "cell_type": "code", 66 | "execution_count": 1, 67 | "id": "annual-engine", 68 | "metadata": {}, 69 | "outputs": [], 70 | "source": [ 71 | "from qiskit.utils import algorithm_globals\n", 72 | "\n", 73 | "algorithm_globals.random_seed = 42" 74 | ] 75 | }, 76 | { 77 | "cell_type": "markdown", 78 | "id": "f1ac3811", 79 | "metadata": {}, 80 | "source": [ 81 | "## 2. `SamplerQNN`\n", 82 | "\n", 83 | "`SamplerQNN` is instantiated in a similar way to the `EstimatorQNN`\n", 84 | " - but because it directly consumes samples from measuring the quantum circuit, it does not require a custom observable.\n", 85 | "\n", 86 | "These output samples are interpreted by default as the probabilities of measuring the integer index corresponding to a bitstring. \n", 87 | "\n", 88 | "However, the `SamplerQNN` also allows us to specify an `interpret` function to post-process the samples. This function should be defined so that it takes a measured integer (from a bitstring) and maps it to a new value, i.e. non-negative integer.\n", 89 | "\n" 90 | ] 91 | }, 92 | { 93 | "cell_type": "markdown", 94 | "id": "82cc2353", 95 | "metadata": {}, 96 | "source": [ 97 | "Let's create a quantum circuit for the `SamplerQNN`. In this case, we will have two input parameters and four trainable weights that parametrize a two-local circuit." 98 | ] 99 | }, 100 | { 101 | "cell_type": "code", 102 | "execution_count": 5, 103 | "id": "acceptable-standing", 104 | "metadata": {}, 105 | "outputs": [ 106 | { 107 | "name": "stdout", 108 | "output_type": "stream", 109 | "text": [ 110 | "input parameters: ['input[0]', 'input[1]']\n", 111 | "weight parameters: ['weight[0]', 'weight[1]', 'weight[2]', 'weight[3]']\n" 112 | ] 113 | }, 114 | { 115 | "data": { 116 | "image/png": "iVBORw0KGgoAAAANSUhEUgAAAbIAAACuCAYAAABTEIhIAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjYuMywgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/P9b71AAAACXBIWXMAAA9hAAAPYQGoP6dpAAAisklEQVR4nO3deVxVdfrA8Q/3IoIsKoKBuAMC4oKomKklipW7WaZmVmbpTJmZjky/aWaaaswstEmbcZmZMnM0JzNTrNTc0zQMNRVLIEER0GFR2VSW+/vjJHqV5QL33sM5PO/Xixdy7lke/D6c5yzf8z0OJpPJhBBCCKFRBrUDEEIIIepCCpkQQghNk0ImhBBC06SQCSGE0DQpZEIIITRNCpkQQghNk0ImhBBC06SQCSGE0DQpZEIIITRNCpkQQghNk0ImhBBC06SQCSGE0DQpZEIIITRNCpkQQghNk0ImhBBC06SQCSGE0DQpZEIIITRNCpkQQghNk0ImhBBC06SQCSGE0DQpZEIIITRNCpkQQghNk0ImhBBC06SQCSGE0DQpZEIIITRNCpkQQghNk0ImhBBC06SQCSGE0DQpZEIIITRNCpkQQghNk0ImhBBC06SQCSGE0DQpZEIIIT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74b987k4/vzhKD56ORlnp5o9DGetnAB18yL/qvJ27ytFUFqm9EL1cFFywM25+uVtQXLAeuSMTJRzNDqRV5jN9EVhvDVtW7W9kFbEzuW7hE10bnePnSKsncaO0LGl8tVQ7Dv+GRv2vYvJZMJodOT3Ez6u8Q4M9JMTbs7KOIkNSUPKATkjqyf09G6i+nZGVh/pqb0tJXlhTnLAeqSzhxBCCE2TQiaEEELTpJAJIYTQNLlHVk+YTFBWrHYU1mFoVP9HCVebntrbUpIX5iQHrEcKmRBCCE2TS4tCCCE0TQqZEEIITZNCJoQQQtOkkAkhhNA0KWRCCCE0TQqZEEIITZNCJoQQQtOkkAkhhNA0KWRCCCE0TQqZEEIITZNCJoQQQtOkkAkhhNA0KWRCCCE0TQqZEEIITZNCJoQQQtOkkAkhhNA0KWRCCCE0TQqZEEIITZNCJoQQQtOkkAkhhNA0KWRCCCE0TQqZEEIITZNCJoQQQtOkkAkhhNA0KWRCCCE07f8BDl8krWor63UAAAAASUVORK5CYII=", 117 | "text/plain": [ 118 | "
" 119 | ] 120 | }, 121 | "execution_count": 5, 122 | "metadata": {}, 123 | "output_type": "execute_result" 124 | } 125 | ], 126 | "source": [ 127 | "from qiskit.circuit import QuantumCircuit, ParameterVector\n", 128 | "\n", 129 | "inputs2 = ParameterVector(\"input\", 2)\n", 130 | "weights2 = ParameterVector(\"weight\", 4)\n", 131 | "print(f\"input parameters: {[str(item) for item in inputs2.params]}\")\n", 132 | "print(f\"weight parameters: {[str(item) for item in weights2.params]}\")\n", 133 | "\n", 134 | "qc2 = QuantumCircuit(2)\n", 135 | "qc2.ry(inputs2[0], 0)\n", 136 | "qc2.ry(inputs2[1], 1)\n", 137 | "qc2.cx(0, 1)\n", 138 | "qc2.ry(weights2[0], 0)\n", 139 | "qc2.ry(weights2[1], 1)\n", 140 | "qc2.cx(0, 1)\n", 141 | "qc2.ry(weights2[2], 0)\n", 142 | "qc2.ry(weights2[3], 1)\n", 143 | "\n", 144 | "qc2.draw(output=\"mpl\")" 145 | ] 146 | }, 147 | { 148 | "cell_type": "markdown", 149 | "id": "1e86defb", 150 | "metadata": {}, 151 | "source": [ 152 | "Similarly to the `EstimatorQNN`, we must specify inputs and weights when instantiating the `SamplerQNN`. In this case, the keyword arguments will be:\n", 153 | "- `sampler`: optional primitive instance\n", 154 | "- `input_params`: list of quantum circuit parameters that should be treated as \"network inputs\"\n", 155 | "- `weight_params`: list of quantum circuit parameters that should be treated as \"network weights\"\n", 156 | "\n", 157 | "Please note that, once again, we are choosing not to set the `Sampler` instance to the QNN and relying on the default." 158 | ] 159 | }, 160 | { 161 | "cell_type": "code", 162 | "execution_count": 7, 163 | "id": "5c007d10", 164 | "metadata": {}, 165 | "outputs": [ 166 | { 167 | "data": { 168 | "text/plain": [ 169 | "" 170 | ] 171 | }, 172 | "execution_count": 7, 173 | "metadata": {}, 174 | "output_type": "execute_result" 175 | } 176 | ], 177 | "source": [ 178 | "from qiskit_machine_learning.neural_networks import SamplerQNN\n", 179 | "\n", 180 | "sampler_qnn = SamplerQNN(circuit=qc2, input_params=inputs2, weight_params=weights2)\n", 181 | "sampler_qnn" 182 | ] 183 | }, 184 | { 185 | "cell_type": "markdown", 186 | "id": "e8c56e76", 187 | "metadata": {}, 188 | "source": [ 189 | "In addition to the basic arguments shown above, the `SamplerQNN` accepts three more settings: `input_gradients`, `interpret`, and `output_shape`. These will be introduced in sections 4 and 5." 190 | ] 191 | }, 192 | { 193 | "cell_type": "markdown", 194 | "id": "0ac89b99", 195 | "metadata": {}, 196 | "source": [ 197 | "## 3. How to Run a Forward Pass" 198 | ] 199 | }, 200 | { 201 | "cell_type": "markdown", 202 | "id": "8589abbd", 203 | "metadata": {}, 204 | "source": [ 205 | "### 3.1. Set-Up\n", 206 | "In a real setting, the inputs would be defined by the dataset, and the weights would be defined by the training algorithm or as part of a pre-trained model. However, for the sake of this tutorial, we will specify random sets of input and weights of the right dimension:" 207 | ] 208 | }, 209 | { 210 | "cell_type": "code", 211 | "execution_count": 8, 212 | "id": "a0fd6253", 213 | "metadata": { 214 | "scrolled": true 215 | }, 216 | "outputs": [], 217 | "source": [ 218 | "sampler_qnn_input = algorithm_globals.random.random(sampler_qnn.num_inputs)\n", 219 | "sampler_qnn_weights = algorithm_globals.random.random(sampler_qnn.num_weights)" 220 | ] 221 | }, 222 | { 223 | "cell_type": "code", 224 | "execution_count": 9, 225 | "id": "a008cebc", 226 | "metadata": {}, 227 | "outputs": [ 228 | { 229 | "name": "stdout", 230 | "output_type": "stream", 231 | "text": [ 232 | "Number of input features for SamplerQNN: 2 \n", 233 | "Input: [0.77395605 0.43887844]\n", 234 | "Number of trainable weights for SamplerQNN: 4 \n", 235 | "Weights: [0.85859792 0.69736803 0.09417735 0.97562235]\n" 236 | ] 237 | } 238 | ], 239 | "source": [ 240 | "print(\n", 241 | " f\"Number of input features for SamplerQNN: {sampler_qnn.num_inputs} \\nInput: {sampler_qnn_input}\"\n", 242 | ")\n", 243 | "print(\n", 244 | " f\"Number of trainable weights for SamplerQNN: {sampler_qnn.num_weights} \\nWeights: {sampler_qnn_weights}\"\n", 245 | ")" 246 | ] 247 | }, 248 | { 249 | "cell_type": "markdown", 250 | "id": "7f1500df", 251 | "metadata": {}, 252 | "source": [ 253 | "Once we have the inputs and the weights, let's see the results for batched and non-batched passes." 254 | ] 255 | }, 256 | { 257 | "cell_type": "markdown", 258 | "id": "de7e7302", 259 | "metadata": {}, 260 | "source": [ 261 | "### 3.2. Non-batched Forward Pass" 262 | ] 263 | }, 264 | { 265 | "cell_type": "markdown", 266 | "id": "94473b35", 267 | "metadata": {}, 268 | "source": [ 269 | "For the `SamplerQNN` (without a custom interpret function), the expected output shape for the forward pass is `(1, 2**num_qubits)`. With a custom interpret function, the output shape will be `(1, output_shape)`, where `1` in our case is the number of samples:" 270 | ] 271 | }, 272 | { 273 | "cell_type": "code", 274 | "execution_count": 10, 275 | "id": "cb847a75", 276 | "metadata": {}, 277 | "outputs": [ 278 | { 279 | "name": "stdout", 280 | "output_type": "stream", 281 | "text": [ 282 | "Forward pass result for SamplerQNN: [[0.23851185 0.1411135 0.3367757 0.28359895]]. \n", 283 | "Shape: (1, 4)\n" 284 | ] 285 | } 286 | ], 287 | "source": [ 288 | "sampler_qnn_forward = sampler_qnn.forward(sampler_qnn_input, sampler_qnn_weights)\n", 289 | "\n", 290 | "print(\n", 291 | " f\"Forward pass result for SamplerQNN: {sampler_qnn_forward}. \\nShape: {sampler_qnn_forward.shape}\"\n", 292 | ")" 293 | ] 294 | }, 295 | { 296 | "cell_type": "markdown", 297 | "id": "1c843c95", 298 | "metadata": {}, 299 | "source": [ 300 | "### 3.3. Batched Forward Pass" 301 | ] 302 | }, 303 | { 304 | "cell_type": "markdown", 305 | "id": "48f7b7bb", 306 | "metadata": {}, 307 | "source": [ 308 | "For the `SamplerQNN` (without custom interpret function), the expected output shape for the forward pass is `(batch_size, 2**num_qubits)`. With a custom interpret function, the output shape will be `(batch_size, output_shape)`." 309 | ] 310 | }, 311 | { 312 | "cell_type": "code", 313 | "execution_count": 11, 314 | "id": "29eb2151", 315 | "metadata": {}, 316 | "outputs": [ 317 | { 318 | "name": "stdout", 319 | "output_type": "stream", 320 | "text": [ 321 | "Forward pass result for SamplerQNN: [[0.23851185 0.1411135 0.3367757 0.28359895]\n", 322 | " [0.23851185 0.1411135 0.3367757 0.28359895]]. \n", 323 | "Shape: (2, 4)\n" 324 | ] 325 | } 326 | ], 327 | "source": [ 328 | "sampler_qnn_forward_batched = sampler_qnn.forward(\n", 329 | " [sampler_qnn_input, sampler_qnn_input], sampler_qnn_weights\n", 330 | ")\n", 331 | "\n", 332 | "print(\n", 333 | " f\"Forward pass result for SamplerQNN: {sampler_qnn_forward_batched}. \\nShape: {sampler_qnn_forward_batched.shape}\"\n", 334 | ")" 335 | ] 336 | }, 337 | { 338 | "cell_type": "markdown", 339 | "id": "171b8ee1", 340 | "metadata": {}, 341 | "source": [ 342 | "## 4. How to Run a Backward Pass\n", 343 | "\n", 344 | "Let's take advantage of the inputs and weights defined above to show how the backward pass works. This pass returns a tuple `(input_gradients, weight_gradients)`. By default, the backward pass will only calculate gradients with respect to the weight parameters.\n", 345 | "\n", 346 | "If you want to enable gradients with respect to the input parameters, you should set the following flag during the QNN instantiation:\n", 347 | "\n", 348 | "```python\n", 349 | "qnn = ...QNN(..., input_gradients=True)\n", 350 | "```\n", 351 | "\n", 352 | "Please remember that input gradients are **required** for the use of `TorchConnector` for PyTorch integration." 353 | ] 354 | }, 355 | { 356 | "cell_type": "markdown", 357 | "id": "e5b90338", 358 | "metadata": {}, 359 | "source": [ 360 | "### 4.1. Backward Pass without Input Gradients" 361 | ] 362 | }, 363 | { 364 | "cell_type": "markdown", 365 | "id": "bebaa404", 366 | "metadata": {}, 367 | "source": [ 368 | "For the `SamplerQNN` (without custom interpret function), the expected output shape for the forward pass is `(batch_size, 2**num_qubits, num_weights)`. With a custom interpret function, the output shape will be `(batch_size, output_shape, num_weights)`.:" 369 | ] 370 | }, 371 | { 372 | "cell_type": "code", 373 | "execution_count": 12, 374 | "id": "eefacefe", 375 | "metadata": {}, 376 | "outputs": [ 377 | { 378 | "name": "stdout", 379 | "output_type": "stream", 380 | "text": [ 381 | "Input gradients for SamplerQNN: None. \n", 382 | "Shape: None\n", 383 | "Weight gradients for SamplerQNN: [[[ 0.00609879 -0.30661818 -0.1834591 -0.28341665]\n", 384 | " [-0.02969169 0.17866236 0.1834591 -0.20004909]\n", 385 | " [-0.37812738 0.30266095 -0.30904568 0.28341665]\n", 386 | " [ 0.40172028 -0.17470512 0.30904568 0.20004909]]]. \n", 387 | "Shape: (1, 4, 4)\n" 388 | ] 389 | } 390 | ], 391 | "source": [ 392 | "sampler_qnn_input_grad, sampler_qnn_weight_grad = sampler_qnn.backward(\n", 393 | " sampler_qnn_input, sampler_qnn_weights\n", 394 | ")\n", 395 | "\n", 396 | "print(\n", 397 | " f\"Input gradients for SamplerQNN: {sampler_qnn_input_grad}. \\nShape: {sampler_qnn_input_grad}\"\n", 398 | ")\n", 399 | "print(\n", 400 | " f\"Weight gradients for SamplerQNN: {sampler_qnn_weight_grad}. \\nShape: {sampler_qnn_weight_grad.shape}\"\n", 401 | ")" 402 | ] 403 | }, 404 | { 405 | "cell_type": "markdown", 406 | "id": "74d28a00", 407 | "metadata": {}, 408 | "source": [ 409 | "### 4.2. Backward Pass with Input Gradients\n", 410 | "\n", 411 | "Let's enable the `input_gradients` to show what the expected output sizes are for this option." 412 | ] 413 | }, 414 | { 415 | "cell_type": "code", 416 | "execution_count": 13, 417 | "id": "9ccc4641", 418 | "metadata": {}, 419 | "outputs": [], 420 | "source": [ 421 | "sampler_qnn.input_gradients = True" 422 | ] 423 | }, 424 | { 425 | "cell_type": "markdown", 426 | "id": "d3e50ff8", 427 | "metadata": {}, 428 | "source": [ 429 | "#### 4.2.2. `SamplerQNN` Example" 430 | ] 431 | }, 432 | { 433 | "cell_type": "markdown", 434 | "id": "b76da18a", 435 | "metadata": {}, 436 | "source": [ 437 | "For the `SamplerQNN` (without custom interpret function), the expected output shape for the input gradients is `(batch_size, 2**num_qubits, num_inputs)`. With a custom interpret function, the output shape will be `(batch_size, output_shape, num_inputs)`." 438 | ] 439 | }, 440 | { 441 | "cell_type": "code", 442 | "execution_count": 14, 443 | "id": "3339f869", 444 | "metadata": {}, 445 | "outputs": [ 446 | { 447 | "name": "stdout", 448 | "output_type": "stream", 449 | "text": [ 450 | "Input gradients for SamplerQNN: [[[ 0.00854017 -0.4260793 ]\n", 451 | " [ 0.29208826 0.08375938]\n", 452 | " [-0.35915753 0.17972714]\n", 453 | " [ 0.05852911 0.16259278]]]. \n", 454 | "Shape: (1, 4, 2)\n", 455 | "Weight gradients for SamplerQNN: [[[ 0.00609879 -0.30661818 -0.1834591 -0.28341665]\n", 456 | " [-0.02969169 0.17866236 0.1834591 -0.20004909]\n", 457 | " [-0.37812738 0.30266095 -0.30904568 0.28341665]\n", 458 | " [ 0.40172028 -0.17470512 0.30904568 0.20004909]]]. \n", 459 | "Shape: (1, 4, 4)\n" 460 | ] 461 | } 462 | ], 463 | "source": [ 464 | "sampler_qnn_input_grad, sampler_qnn_weight_grad = sampler_qnn.backward(\n", 465 | " sampler_qnn_input, sampler_qnn_weights\n", 466 | ")\n", 467 | "\n", 468 | "print(\n", 469 | " f\"Input gradients for SamplerQNN: {sampler_qnn_input_grad}. \\nShape: {sampler_qnn_input_grad.shape}\"\n", 470 | ")\n", 471 | "print(\n", 472 | " f\"Weight gradients for SamplerQNN: {sampler_qnn_weight_grad}. \\nShape: {sampler_qnn_weight_grad.shape}\"\n", 473 | ")" 474 | ] 475 | }, 476 | { 477 | "cell_type": "markdown", 478 | "id": "45871b6d", 479 | "metadata": {}, 480 | "source": [ 481 | "## 5. Advanced Functionality" 482 | ] 483 | }, 484 | { 485 | "cell_type": "markdown", 486 | "id": "788ec9f1", 487 | "metadata": {}, 488 | "source": [ 489 | "### `SamplerQNN` with custom `interpret`" 490 | ] 491 | }, 492 | { 493 | "cell_type": "markdown", 494 | "id": "378ef3ba", 495 | "metadata": {}, 496 | "source": [ 497 | "One common `interpret` method for `SamplerQNN` is the `parity` function, which allows it to perform binary classification. As explained in the instantiation section, using interpret functions will modify the output shape of the forward and backward passes. In the case of the parity interpret function, `output_shape` is fixed to `2`. Therefore, the expected forward and weight gradient shapes are `(batch_size, 2)` and `(batch_size, 2, num_weights)`, respectively:" 498 | ] 499 | }, 500 | { 501 | "cell_type": "code", 502 | "execution_count": 15, 503 | "id": "eed68d1a", 504 | "metadata": {}, 505 | "outputs": [], 506 | "source": [ 507 | "parity = lambda x: \"{:b}\".format(x).count(\"1\") % 2\n", 508 | "output_shape = 2 # parity = 0, 1\n", 509 | "\n", 510 | "sampler_qnn2 = SamplerQNN(\n", 511 | " circuit=qc2,\n", 512 | " input_params=inputs2,\n", 513 | " weight_params=weights2,\n", 514 | " interpret=parity,\n", 515 | " output_shape=output_shape,\n", 516 | ")" 517 | ] 518 | }, 519 | { 520 | "cell_type": "code", 521 | "execution_count": 16, 522 | "id": "c2888195", 523 | "metadata": {}, 524 | "outputs": [ 525 | { 526 | "name": "stdout", 527 | "output_type": "stream", 528 | "text": [ 529 | "Forward output for SamplerQNN1: (1, 4)\n", 530 | "Forward output for SamplerQNN2: (1, 2)\n", 531 | "Backward output for SamplerQNN1: (1, 4, 4)\n", 532 | "Backward output for SamplerQNN2: (1, 2, 4)\n" 533 | ] 534 | } 535 | ], 536 | "source": [ 537 | "sampler_qnn_forward2 = sampler_qnn2.forward(sampler_qnn_input, sampler_qnn_weights)\n", 538 | "sampler_qnn_input_grad2, sampler_qnn_weight_grad2 = sampler_qnn2.backward(\n", 539 | " sampler_qnn_input, sampler_qnn_weights\n", 540 | ")\n", 541 | "\n", 542 | "print(f\"Forward output for SamplerQNN1: {sampler_qnn_forward.shape}\")\n", 543 | "print(f\"Forward output for SamplerQNN2: {sampler_qnn_forward2.shape}\")\n", 544 | "print(f\"Backward output for SamplerQNN1: {sampler_qnn_weight_grad.shape}\")\n", 545 | "print(f\"Backward output for SamplerQNN2: {sampler_qnn_weight_grad2.shape}\")" 546 | ] 547 | }, 548 | { 549 | "cell_type": "markdown", 550 | "id": "66117e82", 551 | "metadata": {}, 552 | "source": [ 553 | "## 6. Conclusion\n", 554 | "\n", 555 | "In this tutorial, we introduced the two neural networks classes provided by `qiskit-machine-learning`, namely the `EstimatorQNN` and `SamplerQNN`, which extend the base `NeuralNetwork` class. We provided the key steps for QNN initialization, basic use in forward and backward passes, and advanced functionality.\n", 556 | "\n", 557 | "We now encourage you to play around with the problem setup and see how different circuit sizes, input, and weight parameter lengths influence the output shapes." 558 | ] 559 | }, 560 | { 561 | "cell_type": "code", 562 | "execution_count": 48, 563 | "id": "appointed-shirt", 564 | "metadata": { 565 | "pycharm": { 566 | "name": "#%%\n" 567 | } 568 | }, 569 | "outputs": [ 570 | { 571 | "data": { 572 | "text/html": [ 573 | "

Version Information

Qiskit SoftwareVersion
qiskit-terra0.22.3
qiskit-machine-learning0.6.0
System information
Python version3.9.15
Python compilerClang 14.0.6
Python buildmain, Nov 24 2022 08:29:02
OSDarwin
CPUs8
Memory (Gb)64.0
Mon Jan 23 11:57:49 2023 CET
" 574 | ], 575 | "text/plain": [ 576 | "" 577 | ] 578 | }, 579 | "metadata": {}, 580 | "output_type": "display_data" 581 | }, 582 | { 583 | "data": { 584 | "text/html": [ 585 | "

This code is a part of Qiskit

© Copyright IBM 2017, 2023.

This code is licensed under the Apache License, Version 2.0. You may
obtain a copy of this license in the LICENSE.txt file in the root directory
of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.

Any modifications or derivative works of this code must retain this
copyright notice, and modified files need to carry a notice indicating
that they have been altered from the originals.

" 586 | ], 587 | "text/plain": [ 588 | "" 589 | ] 590 | }, 591 | "metadata": {}, 592 | "output_type": "display_data" 593 | } 594 | ], 595 | "source": [ 596 | "import qiskit.tools.jupyter\n", 597 | "\n", 598 | "%qiskit_version_table\n", 599 | "%qiskit_copyright" 600 | ] 601 | } 602 | ], 603 | "metadata": { 604 | "kernelspec": { 605 | "display_name": "Python 3 (ipykernel)", 606 | "language": "python", 607 | "name": "python3" 608 | }, 609 | "language_info": { 610 | "codemirror_mode": { 611 | "name": "ipython", 612 | "version": 3 613 | }, 614 | "file_extension": ".py", 615 | "mimetype": "text/x-python", 616 | "name": "python", 617 | "nbconvert_exporter": "python", 618 | "pygments_lexer": "ipython3", 619 | "version": "3.10.8" 620 | }, 621 | "widgets": { 622 | "application/vnd.jupyter.widget-state+json": { 623 | "state": {}, 624 | "version_major": 2, 625 | "version_minor": 0 626 | } 627 | } 628 | }, 629 | "nbformat": 4, 630 | "nbformat_minor": 5 631 | } 632 | -------------------------------------------------------------------------------- /Space_Combatant_Badge/2023/QE_QML_Glossary-ja.md: -------------------------------------------------------------------------------- 1 | ### QML 用語集 2 | 3 | **精度 (Accuracy)**:機械学習モデルの性能を評価するための指標で、正しい予測値とすべての予測値の比率の合計を測定することで算出される。 4 | 5 | **振幅符号化 (Amplitude encoding)**: 量子状態の振幅内にデータを格納する方法。 6 | 7 | **クラスの不均衡 (Class imbalance)**: 分類データセットの比率が歪んでいる場合 (たとえば、バイナリー分類データセットで、一方のクラスのデータポイントが他方のクラスの 2 倍である場合)。 8 | 9 | **分類 (Classification)**: 教師あり機械学習問題の一種で、モデルが入力データポイントに対して特定のクラスラベルを予測すること。 10 | 11 | **クラスタリング (Clustering)**: 教師なし機械学習の一種で、モデルがデータ内のパターンを見つけて特徴量空間内のグループまたはクラスターを集めようとするもの。 12 | 13 | **共分散行列 (Covariance matrix)**: PCAで使用される行列で、変数のすべての可能なペアに関連する共分散を表す。 14 | 15 | **データマイニング (Data mining)**: データの抽出やその中のパターンの発見を含むデータの分析。 16 | 17 | **従属変数(Dependent variable)**: 実験や機械学習モデルの中でテストされる変数。 18 | 19 | **次元削減 (Dimensionality reduction)**: 次元数の多いデータをより少ない次元数に変換する手法。例としてPCAがある。 20 | 21 | **固有ベクトル (Eigenvectors) と固有値 (eigenvalues)**: 一次方程式に関連付けられたスカラー値の集合。詳細はこちら https://www.youtube.com/watch?v=PFDu9oVAE-g 22 | 23 | **フーリエ変換 (Fourier transform)**: 関数をサイン成分とコサイン成分に分解する数学的変換。フーリエ変換は信号処理、物理学、工学など多くの分野で応用されている。 24 | 25 | **ヒルベルト空間 (Hilbert space)**: 内積で与えられるノルムに関して完全なベクトル空間。詳細はこちら https://www.youtube.com/watch?v=7zx3MT9FgT0 26 | 27 | **独立変数 (Independent variable)**:実験でコントロールする変数で、人の年齢など実験の他の要因に影響されないもの。 28 | 29 | **K近傍法 ( K nearest neighbours)**: 距離測定基準を用いて特定のデータ点の最近傍を計算し、データ点が属するクラスを分類する教師あり学習分類器。 30 | 31 | **平均二乗誤差 (Mean squared error, MSE)**: 実際の値と予測値の間の平均二乗差。 MSE 低いほど良い。 32 | 33 | **過適合 (Over fitting)**: モデルが訓練データに適合しすぎて、テストデータに一般化できないこと。 34 | 35 | **主成分分析 (Principal component analysis, PCA)**: 最初の数個の主ベクトルを用いてデータの基底変更を行う次元削減法。 36 | 37 | **量子ランダム アクセス メモリ (Quantum random access memory, QRAM)**: 古典的なRAMに似ており、任意の順序で読み出したり変更したりできるデータ記憶装置であるが、量子状態の記憶も可能である。 38 | 39 | **R2スコア (R2 score)**: 回帰の評価指標であり、入力独立変数に対する出力従属変数の変動量である決定係数。 40 | 41 | **回帰 (Regression)**: 教師あり機械学習の一種で、モデルは独立変数と従属変数の間の関係を探索する。回帰には線形回帰、ロジスティック回帰、多項式回帰などの種類がある。 42 | 43 | **強化学習 (Reinforcement learnin)**: 機械学習の一分野であり、望ましい行動には報酬を与え、望ましくない行動には罰を与えるという学習方法を用いる。 44 | 45 | **教師あり学習 (Supervised learning)**: ラベル付けされた入力データセットを使用してモデルを学習する機械学習のカテゴリー。 46 | 47 | **サポートベクターマシン (Support vector machine, SVM)**: 教師あり機械学習の一種で、分類問題にも回帰問題にも使える。詳細はこちら https://scikit-learn.org/stable/modules/svm.html 48 | 49 | **フィッティング不足 (Under fitting)**: モデルが入力学習変数間の関係を捉えることができず、新しいデータを正確に予測するのに十分な強い関係を形成できない場合。 50 | 51 | **教師なし学習 (Unsupervised learning)**: ラベル付けされていない入力データセットを使ってモデルを学習する機械学習のカテゴリー。 52 | 53 | -------------------------------------------------------------------------------- /Space_Combatant_Badge/2023/QE_QML_Glossary.md: -------------------------------------------------------------------------------- 1 | ### QML Glossary 2 | 3 | **Accuracy**: a metric used to evaluate the performance of your machine learning model calculated by measuring the sum of the ratio between correct predictions and all the predictions. 4 | 5 | **Amplitude encoding**: a way to store data within the amplitude of a quantum state. 6 | 7 | **Class imbalance**: when a classification dataset has skewed proportions, for example in a binary classification dataset but one class has twice as many data points as the other class. 8 | 9 | **Classification**: a type of supervised machine learning problem where a model predicts a particular class label for an input data point. 10 | 11 | **Clustering**: a type of unsupervised machine learning where a model tries to find patterns in data to collect together groups or clusters in the feature space. 12 | 13 | **Covariance matrix**: a matrix used in PCA representing the covariances associated with all possible pairs of variables. 14 | 15 | **Data mining**: analysing data including extracting data and finding patterns within it. 16 | 17 | **Dependent variable**: the variable that is being tested within an experiment or machine learning model. 18 | 19 | **Dimensionality reduction**: the technique of transforming data with a large number of dimensions to a lower number of dimensions. An example technique is PCA. 20 | 21 | **Eigenvectors and eigenvalues**: a set of scalar values that are associated with a set of linear equations. See here for more info https://www.youtube.com/watch?v=PFDu9oVAE-g 22 | 23 | **Fourier transform**: a mathematical transformation that decomposes functions into sine and cosine components. There are many applications of the Fourier transform within signal processing, physics, engineering and much more. 24 | 25 | **Hilbert space**: a vector space that is complete with respect to the norm given by the inner product. See here for more info https://www.youtube.com/watch?v=7zx3MT9FgT0 26 | 27 | **Independent variable**: a variable that you control in an experiment that isn’t influenced by other factors of the experiment, such as a person’s age. 28 | 29 | **K nearest neighbours**: a supervised learning classifier that uses distance metrics to calculate the nearest neighbours of a particular data point in order to classify the class it may belong to. 30 | 31 | **Mean squared error (MSE)**: the average squared difference between the actual and predicted values. The lower the MSE the better. 32 | 33 | **Over fitting**: when a model fits the training data so well that it is unable to generalise to the testing data. 34 | 35 | **Principal component analysis (PCA)**: a method of dimensionality reduction that uses the first few principal vectors to perform a change of basis on the data. 36 | 37 | **Quantum random access memory (QRAM)**: similar to classical RAM, it is data storage that can be read and changed in any order but also allows the storage of quantum states. 38 | 39 | **R2 score**: the coefficient of determination is an evaluation metric for regression that is the amount of variation in the output dependent variable to the input independent variable. 40 | 41 | **Regression**: a type of supervised machine learning where the model looks for a relationship between independent variable/s and a dependent variable. There are different types of regression such as linear regression, logistic regression and polynomial regression. 42 | 43 | **Reinforcement learning**: an area of machine learning that uses a training method based on rewarding desired actions and/or punishing undesired ones. 44 | 45 | **Supervised learning**: a category of machine learning that trains models using labelled input datasets. 46 | 47 | **Support vector machine (SVM)**: a type of supervised machine learning that can be used for both classification and regression problems. See here for more info https://scikit-learn.org/stable/modules/svm.html 48 | 49 | **Under fitting**: when a model is unable to capture a relationship between the input training variables and thus cannot form a strong enough relationship to predict any new data accurately as well. 50 | 51 | **Unsupervised learning**: a category of machine learning that trains models using unlabelled input datasets. 52 | 53 | -------------------------------------------------------------------------------- /Space_Combatant_Badge/2023/QE_QML_References.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qiskit-community/quantum-explorers/597fec6917327884425c9121257bcbf027df5f16/Space_Combatant_Badge/2023/QE_QML_References.pdf -------------------------------------------------------------------------------- /Time_Traveler_Badge/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qiskit-community/quantum-explorers/597fec6917327884425c9121257bcbf027df5f16/Time_Traveler_Badge/.DS_Store -------------------------------------------------------------------------------- /Time_Traveler_Badge/2023/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qiskit-community/quantum-explorers/597fec6917327884425c9121257bcbf027df5f16/Time_Traveler_Badge/2023/.DS_Store -------------------------------------------------------------------------------- /Time_Traveler_Badge/2023/QE_Badge4_Lab3_QEM_Advanced-ja.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": { 6 | "tags": [] 7 | }, 8 | "source": [ 9 | "#### **Quantum Explorers 2023**\n", 10 | "---\n", 11 | "# Time Traveler バッジ - 量子エラー訂正と緩和 モジュール\n", 12 | "#### **発展教材 - 量子エラー緩和手法と実装**\n", 13 | " [IBM Quantum Challenge Fall 2022, Lab 1 (和訳)](https://github.com/qiskit-community/ibm-quantum-challenge-fall-22/blob/main/content/lab-1/lab1-ja.ipynb) より作成しました。" 14 | ] 15 | }, 16 | { 17 | "cell_type": "markdown", 18 | "metadata": {}, 19 | "source": [ 20 | "### T-REX\n", 21 | "\n", 22 | "T-REXは、 **Twirled Readout Error eXtinction** の略で、ゲートを\"twirling\"(トワリング、何回もくるくると作用)させる実装法です。ノイズを完全な回路実装の上に乗っている余分な確率的ゲート集合と見なすと、回路を実行するたびに、このノイズゲートの集合と「トワリング・セット」と呼ばれるゲートの集合からランダムに選ばれたゲートを結合させるという意味でトワリングと呼ぶことができます。このゲート集合をパウリ演算子の集合に選ぶと、「パウリ・トワリング」と呼ばれ、これは最もよく使われるトワリング・テクニックの1つです。\n", 23 | "\n", 24 | "パウリ・トワリングはランダム化コンパイルの一種で、エンタングルゲートの前後にパウリゲート(I、X、Y、Z)のペアを挿入し、全体のユニタリーは同じままで、実装の仕方が異なるようにするものです。これにより、コヒーレントな誤差を確率的な誤差に変換し、十分な平均化によって除去することができます。これは、平均化の効果を得るために何度も行われます。注意:現在、すべての誤差を打ち消すのに十分な基底セットを使用しない場合があります。**[[1]](https://github.com/qiskit-research/qiskit-research/blob/main/docs/getting_started.ipynb)**\n", 25 | "\n", 26 | "パウリ・トワリングについて詳しくは、[Nick Knows](https://www.youtube.com/watch?v=4MLHvmmpSQ8) のビデオをご覧ください。\n", 27 | "\n", 28 | "options で `resilience_level=1` を設定すると、 `Estimator` 上でT-REXを有効にすることができます。 `resilience_level` が指定されていない場合、T-REXは実行時にデフォルトでアクティブになります。Qiskit Runtimeでは、T-REXを選択すると実行ごとに結果が変わることがあります。これは、トワリングに選択されるゲートセットが毎回異なるためで、結果がランダムな特性を持つ一因となっています。\n", 29 | "\n", 30 | "T-REXについての詳細は [こちら](https://qiskit.org/ecosystem/ibm-runtime/locale/ja_JP/tutorials/Error-Suppression-and-Error-Mitigation.html#%E3%83%88%E3%83%AF%E3%82%A4%E3%83%AB%E8%AA%AD%E3%81%BF%E5%87%BA%E3%81%97%E3%82%A8%E3%83%A9%E3%83%BC%E6%B6%88%E5%8E%BB%E6%B3%95) をご覧ください。" 31 | ] 32 | }, 33 | { 34 | "cell_type": "markdown", 35 | "metadata": { 36 | "tags": [] 37 | }, 38 | "source": [ 39 | "### デジタルZNE(ゼロノイズ外挿)\n", 40 | "\n", 41 | "デジタルZNE(Zero Noise Extrapolation)は、ノイズの多い量子コンピューターの誤差を、量子リソースを追加することなく軽減するための一般的な手法です。量子コンピューターのプログラムを変更し、異なるノイズレベルで計算を実行します。計算結果は、ノイズのない状態での推定値に外挿されます。\n", 42 | "\n", 43 | "デジタルZNEでは、適切な値を求めるために、まず上記で説明したようにノイズをスケーリングします。スケーリングの方法には、アナログとデジタルの2種類があります。それぞれの方法の詳しい説明は下記で確認できます。どちらの方式が良いかは、まだ研究課題です。ここでのデジタルな方法は、物理的な量子パルスには作用させない手法です。\n", 44 | "\n", 45 | "- パルス波の引き伸ばし(アナログ): 同じパルス波を物理的により大きな時間に沿って引き伸ばしたものを回路に適用します。原理的には同じ回路だが、実効ノイズが大きくなります。 **[[2]](https://arxiv.org/pdf/1612.02058.pdf)**\n", 46 | "- ローカル・フォールディング(デジタル):入力回路をより多くのゲートでコンパイルします。各ゲート $G$ を $G$, $G^\\dagger$, $G$ に置き換えます。シミュレーターでは回路に何もしませんが、実機を使用すると、ノイズが増加していくのがわかります。\n", 47 | "- グローバル・フォールディング(デジタル):ローカル・フォールディングと同じ操作ですが、このトリックを回路全体に適用します。\n", 48 | "\n", 49 | "ノイズの多い期待値をゼロノイズ限界まで外挿する。これは一般的な回帰法で行われます。\n", 50 | "\n", 51 | "デジタルZNE についての詳細は [こちら](https://qiskit.org/ecosystem/ibm-runtime/locale/ja_JP/tutorials/Error-Suppression-and-Error-Mitigation.html#%E3%82%BC%E3%83%AD%E3%83%BB%E3%83%8E%E3%82%A4%E3%82%BA%E5%A4%96%E6%8C%BF) をご覧ください。\n" 52 | ] 53 | }, 54 | { 55 | "cell_type": "markdown", 56 | "metadata": {}, 57 | "source": [ 58 | "### PEC\n", 59 | "\n", 60 | "PEC(Probabilistic Error Cancellation、確率的エラーキャンセル)は、相関ノイズを捕らえることができるスパースノイズモデルを学習し、反転させることによってエラーを軽減するものです。PECは学習されたノイズモデルが緩和時に実際のノイズモデルを忠実に表す限り、バイアスのない期待値の推定値を返します。\n", 61 | "\n", 62 | "PECは、学習したノイズを反転させる効果を模倣するために準確率法を使用します。これには、ユーザーの元の回路に関連するランダムな回路ファミリーからのサンプリングが必要です。PECを適用すると、入力回路と特性評価回路の両方で回路あたりのサンプル数も増やさない限り、返される期待値の推定値のばらつきが大きくなります。このばらつきに対処するために必要なサンプルの量は、緩和された回路のノイズ強度に応じて指数関数的に増加します。**[[3]](\n", 63 | ")**\n", 64 | "\n", 65 | "PEC についての詳細は [こちら](https://qiskit.org/ecosystem/ibm-runtime/locale/ja_JP/tutorials/Error-Suppression-and-Error-Mitigation.html#%E7%A2%BA%E7%8E%87%E7%9A%84%E3%82%A8%E3%83%A9%E3%83%BC%E3%83%BB%E3%82%AD%E3%83%A3%E3%83%B3%E3%82%BB%E3%83%AB) をご覧ください。\n" 66 | ] 67 | }, 68 | { 69 | "cell_type": "markdown", 70 | "metadata": { 71 | "tags": [] 72 | }, 73 | "source": [ 74 | "
\n", 75 | " \n", 76 | "

量子エラー緩和技術の実装

\n", 77 | "\n", 78 | "Qiskit runtime の resilience level は、エラーに対する回復力をどの程度構築するか、つまりエラー緩和のレベルを指定するための指標です。レベルが高いほど、処理時間が長くなる代わりに、より正確な結果が生成されます。Qiskit runtime でより高いレベルの弾力性を有効にすることができますが、 **この機能は現在ベータ版** であり、期待通りの結果が得られない可能性があることに注意してください!以下のコードブロックの指示に従って自由に試してみてください!\n", 79 | "\n", 80 | "以下のリソースが便利です:\n", 81 | "\n", 82 | "- [Qiskit ドキュメント: Options](https://qiskit.org/ecosystem/ibm-runtime/stubs/qiskit_ibm_runtime.options.Options.html)\n", 83 | "- [エラー緩和の設定](https://qiskit.org/ecosystem/ibm-runtime/locale/ja_JP/how_to/error-mitigation.html)" 84 | ] 85 | }, 86 | { 87 | "cell_type": "code", 88 | "execution_count": null, 89 | "metadata": { 90 | "tags": [] 91 | }, 92 | "outputs": [], 93 | "source": [ 94 | "#import required libraries\n", 95 | "import time\n", 96 | "import numpy as np\n", 97 | "from qiskit import *\n", 98 | "from qiskit.circuit import Parameter\n", 99 | "from qiskit.quantum_info import Statevector, Pauli, SparsePauliOp\n", 100 | "from qiskit.circuit.library import RealAmplitudes\n", 101 | "import matplotlib.pyplot as plt\n", 102 | "import matplotlib.ticker as tck\n", 103 | "from qiskit.tools.visualization import plot_histogram\n", 104 | "from qiskit_ibm_runtime import QiskitRuntimeService, Session, Options, Sampler, Estimator\n", 105 | "from qiskit.providers.fake_provider import FakeManila\n", 106 | "from qiskit_aer.noise import NoiseModel\n", 107 | "\n", 108 | "# Import FakeBackend\n", 109 | "fake_backend = FakeManila()\n", 110 | "noise_model = NoiseModel.from_backend(fake_backend)" 111 | ] 112 | }, 113 | { 114 | "cell_type": "code", 115 | "execution_count": null, 116 | "metadata": { 117 | "tags": [] 118 | }, 119 | "outputs": [], 120 | "source": [ 121 | "# Save the Runtime account credentials if you have not done so already\n", 122 | "# If you need to overwrite the account info, please add `overwrite=True`\n", 123 | "# QiskitRuntimeService.save_account(channel='ibm_quantum', token='my_token', overwrite=True)\n", 124 | "\n", 125 | "service = QiskitRuntimeService(channel=\"ibm_quantum\", instance='ibm-q/open/main')\n", 126 | "\n", 127 | "backend = service.backends(simulator=True)[0]\n", 128 | "print(backend)" 129 | ] 130 | }, 131 | { 132 | "cell_type": "code", 133 | "execution_count": null, 134 | "metadata": { 135 | "tags": [] 136 | }, 137 | "outputs": [], 138 | "source": [ 139 | "# This is the circuit you used in the main syllabus for learning M3\n", 140 | "theta = Parameter('theta')\n", 141 | "\n", 142 | "qc = QuantumCircuit(2)\n", 143 | "qc.x(1)\n", 144 | "qc.h(0)\n", 145 | "qc.cp(theta,0,1)\n", 146 | "qc.h(0)\n", 147 | "\n", 148 | "qc.draw()" 149 | ] 150 | }, 151 | { 152 | "cell_type": "markdown", 153 | "metadata": {}, 154 | "source": [ 155 | "次のセルのコードにあるように、 resilience level を値 `[1, 2, 3]` のいずれかに変更し、Estimator を実行して、resilience level に応じて出力がどのように変化するかを確認してください。" 156 | ] 157 | }, 158 | { 159 | "cell_type": "code", 160 | "execution_count": null, 161 | "metadata": { 162 | "tags": [] 163 | }, 164 | "outputs": [], 165 | "source": [ 166 | "phases = np.linspace(0, 2*np.pi, 50)\n", 167 | "individual_phases = [[ph] for ph in phases]\n", 168 | "ZZ = SparsePauliOp.from_list([(\"ZZ\", 1)])\n", 169 | "\n", 170 | "options = Options(\n", 171 | " simulator={\n", 172 | " \"noise_model\": noise_model,\n", 173 | " \"seed_simulator\": 42,\n", 174 | " }, \n", 175 | " resilience_level=0\n", 176 | ")\n", 177 | "\n", 178 | "options_with_em = Options(\n", 179 | " simulator={\n", 180 | " \"noise_model\": noise_model,\n", 181 | " \"seed_simulator\": 42,\n", 182 | " }, \n", 183 | " resilience_level=1 ### Change the value in this line ###\n", 184 | ")" 185 | ] 186 | }, 187 | { 188 | "cell_type": "code", 189 | "execution_count": null, 190 | "metadata": { 191 | "tags": [] 192 | }, 193 | "outputs": [], 194 | "source": [ 195 | "with Session(service=service, backend=backend): \n", 196 | " estimator = Estimator(options=options)\n", 197 | " job = estimator.run(circuits=[qc]*len(phases), parameter_values=individual_phases, observables=[ZZ]*len(phases))\n", 198 | " param_results = job.result()\n", 199 | " exp_values = param_results.values\n", 200 | " \n", 201 | " estimator = Estimator(options=options_with_em)\n", 202 | " job = estimator.run(circuits=[qc]*len(phases), parameter_values=individual_phases, observables=[ZZ]*len(phases))\n", 203 | " param_results = job.result()\n", 204 | " exp_values_with_em = param_results.values" 205 | ] 206 | }, 207 | { 208 | "cell_type": "code", 209 | "execution_count": null, 210 | "metadata": { 211 | "tags": [] 212 | }, 213 | "outputs": [], 214 | "source": [ 215 | "plt.plot(phases, exp_values, 'o', label='noisy')\n", 216 | "plt.plot(phases, exp_values_with_em, 'o', label='mitigated')\n", 217 | "plt.plot(phases, 2*np.sin(phases/2,)**2-1, label='theory')\n", 218 | "plt.xlabel('Phase')\n", 219 | "plt.ylabel('Expectation')\n", 220 | "plt.legend();" 221 | ] 222 | }, 223 | { 224 | "cell_type": "markdown", 225 | "metadata": {}, 226 | "source": [ 227 | "
\n", 228 | " \n", 229 | "

オプション: 実機のバックエンドでの実行

\n", 230 | "\n", 231 | "上記のコードを **実機の量子バックエンド** で自由にテストして、QPU で実行したときに結果がどのように変化するかを確認してください。 Quantum Explorer の場合、`hub`, `group`, `project` が割り当てられています。 以下のセルを自由に設定して、結果を試してみてください。\n", 232 | " \n", 233 | "
" 234 | ] 235 | }, 236 | { 237 | "cell_type": "code", 238 | "execution_count": null, 239 | "metadata": { 240 | "tags": [] 241 | }, 242 | "outputs": [], 243 | "source": [ 244 | "# Get the least-busy backend, this step may take a while\n", 245 | "real_backend = service.least_busy(min_num_qubits=2, simulator=False)\n", 246 | "\n", 247 | "print(f\"The least busy backend is {real_backend.name}.\")" 248 | ] 249 | }, 250 | { 251 | "cell_type": "markdown", 252 | "metadata": {}, 253 | "source": [ 254 | "`Estimator` で実機のバックエンドを使用します:" 255 | ] 256 | }, 257 | { 258 | "cell_type": "code", 259 | "execution_count": null, 260 | "metadata": { 261 | "tags": [] 262 | }, 263 | "outputs": [], 264 | "source": [ 265 | "with Session(service=service, backend=real_backend): \n", 266 | " estimator = Estimator(options=options)\n", 267 | " job = estimator.run(circuits=[qc]*len(phases), parameter_values=individual_phases, observables=[ZZ]*len(phases))\n", 268 | " print(f\"First job ID: {job.job_id()}\")\n", 269 | " \n", 270 | " estimator = Estimator(options=options_with_em)\n", 271 | " job = estimator.run(circuits=[qc]*len(phases), parameter_values=individual_phases, observables=[ZZ]*len(phases))\n", 272 | " print(f\"Second job ID: {job.job_id()}\")" 273 | ] 274 | }, 275 | { 276 | "cell_type": "code", 277 | "execution_count": null, 278 | "metadata": { 279 | "tags": [] 280 | }, 281 | "outputs": [], 282 | "source": [ 283 | "#Get job results\n", 284 | "job = service.job('place first job ID here')\n", 285 | "param_results = job.result()\n", 286 | "exp_values = param_results.values\n", 287 | "\n", 288 | "job_with_em = service.job('place second job ID here')\n", 289 | "param_results_with_em = job_with_em.result()\n", 290 | "exp_values_with_em = param_results_with_em.values" 291 | ] 292 | }, 293 | { 294 | "cell_type": "markdown", 295 | "metadata": {}, 296 | "source": [ 297 | "Job の実行中、job を monitor できます。いずれかの実行に対して表示された job ID をコピーし、 **[ここ](https://quantum-computing.ibm.com/jobs)** の検索バーに入力するだけです。このページにアクセスするには、IBM Quantum Platform にログインしていることを確認してください。" 298 | ] 299 | }, 300 | { 301 | "cell_type": "code", 302 | "execution_count": null, 303 | "metadata": { 304 | "tags": [] 305 | }, 306 | "outputs": [], 307 | "source": [ 308 | "plt.plot(phases, exp_values, 'o', label='noisy')\n", 309 | "plt.plot(phases, exp_values_with_em, 'o', label='mitigated')\n", 310 | "plt.plot(phases, 2*np.sin(phases/2,)**2-1, label='theory')\n", 311 | "plt.xlabel('Phase')\n", 312 | "plt.ylabel('Expectation')\n", 313 | "plt.legend();" 314 | ] 315 | }, 316 | { 317 | "cell_type": "markdown", 318 | "metadata": {}, 319 | "source": [ 320 | "# 参考文献\n", 321 | "- [1] **[Getting Started - Qiskit Research](https://github.com/qiskit-research/qiskit-research/blob/main/docs/getting_started.ipynb)**\n", 322 | "- [2] **[Error mitigation for short-depth quantum circuits - Kristan Temme, Sergey Bravyi and Jay M. Gambetta](https://arxiv.org/pdf/1612.02058.pdf)**\n", 323 | "- [3] **[Configure error mitigation](https://qiskit.org/ecosystem/ibm-runtime/locale/ja_JP/how_to/error-mitigation.html)**" 324 | ] 325 | }, 326 | { 327 | "cell_type": "markdown", 328 | "metadata": {}, 329 | "source": [ 330 | "Translated and adapted by: Kifumi Numata" 331 | ] 332 | }, 333 | { 334 | "cell_type": "code", 335 | "execution_count": 1, 336 | "metadata": { 337 | "tags": [] 338 | }, 339 | "outputs": [ 340 | { 341 | "data": { 342 | "text/html": [ 343 | "

Version Information

Qiskit SoftwareVersion
qiskit-terra0.24.1
qiskit-aer0.12.1
qiskit-ibmq-provider0.20.2
qiskit0.43.2
qiskit-nature0.6.2
qiskit-finance0.3.4
qiskit-optimization0.5.0
qiskit-machine-learning0.6.1
System information
Python version3.10.8
Python compilerGCC 10.4.0
Python buildmain, Nov 22 2022 08:26:04
OSLinux
CPUs8
Memory (Gb)31.211322784423828
Wed Jul 12 04:36:16 2023 UTC
" 344 | ], 345 | "text/plain": [ 346 | "" 347 | ] 348 | }, 349 | "metadata": {}, 350 | "output_type": "display_data" 351 | } 352 | ], 353 | "source": [ 354 | "from qiskit.tools.jupyter import *\n", 355 | "%qiskit_version_table" 356 | ] 357 | } 358 | ], 359 | "metadata": { 360 | "kernelspec": { 361 | "display_name": "Python 3", 362 | "language": "python", 363 | "name": "python3" 364 | }, 365 | "language_info": { 366 | "codemirror_mode": { 367 | "name": "ipython", 368 | "version": 3 369 | }, 370 | "file_extension": ".py", 371 | "mimetype": "text/x-python", 372 | "name": "python", 373 | "nbconvert_exporter": "python", 374 | "pygments_lexer": "ipython3", 375 | "version": "3.8.5" 376 | }, 377 | "vscode": { 378 | "interpreter": { 379 | "hash": "2314985414265184cbcbf39283c3ac2af8a6b2659fa88be3910ade054ec8b29d" 380 | } 381 | }, 382 | "widgets": { 383 | "application/vnd.jupyter.widget-state+json": { 384 | "state": { 385 | "106f5a473c7940a7a32e5a4c36b03b26": { 386 | "model_module": "@jupyter-widgets/controls", 387 | "model_module_version": "2.0.0", 388 | "model_name": "HBoxModel", 389 | "state": { 390 | "children": [ 391 | "IPY_MODEL_ecd4c505b4954dc8ab510a6d2cefe7ad", 392 | "IPY_MODEL_8ccacb4ee6644f1e8dfdd809fe5b28b0", 393 | "IPY_MODEL_1cb499addaf5456e9c7e6402d664247f", 394 | "IPY_MODEL_9275d435ca99492393c311f738733385", 395 | "IPY_MODEL_a14b92773e484d3a95f92280575d1052" 396 | ], 397 | "layout": "IPY_MODEL_63d1e1533c7647c88f5e027c7f22fc01" 398 | } 399 | }, 400 | "18ab7cec7c994c919bda4c561a538e55": { 401 | "model_module": "@jupyter-widgets/controls", 402 | "model_module_version": "2.0.0", 403 | "model_name": "HTMLStyleModel", 404 | "state": { 405 | "description_width": "", 406 | "font_size": null, 407 | "text_color": null 408 | } 409 | }, 410 | "1cb499addaf5456e9c7e6402d664247f": { 411 | "model_module": "@jupyter-widgets/controls", 412 | "model_module_version": "2.0.0", 413 | "model_name": "HTMLModel", 414 | "state": { 415 | "layout": "IPY_MODEL_267063972f98462b903b04e80054da8b", 416 | "style": "IPY_MODEL_a155f68cb75a40cc9bece01a2733f62e", 417 | "value": "
Status
" 418 | } 419 | }, 420 | "22156f77e1eb435fae2439f275e6e1be": { 421 | "model_module": "@jupyter-widgets/base", 422 | "model_module_version": "2.0.0", 423 | "model_name": "LayoutModel", 424 | "state": { 425 | "width": "190px" 426 | } 427 | }, 428 | "243eaa616bdb49fe9bfbbb687965af3e": { 429 | "model_module": "@jupyter-widgets/controls", 430 | "model_module_version": "2.0.0", 431 | "model_name": "HTMLStyleModel", 432 | "state": { 433 | "description_width": "", 434 | "font_size": null, 435 | "text_color": null 436 | } 437 | }, 438 | "267063972f98462b903b04e80054da8b": { 439 | "model_module": "@jupyter-widgets/base", 440 | "model_module_version": "2.0.0", 441 | "model_name": "LayoutModel", 442 | "state": { 443 | "width": "95px" 444 | } 445 | }, 446 | "2f838f75a38b4b2eaf3f2f45d1aaa6dd": { 447 | "model_module": "@jupyter-widgets/controls", 448 | "model_module_version": "2.0.0", 449 | "model_name": "GridBoxModel", 450 | "state": { 451 | "children": [ 452 | "IPY_MODEL_adbeaeff15a540fd8cfb09ab242e0577" 453 | ], 454 | "layout": "IPY_MODEL_73880c531b1140aab2baba2789e4b0e4" 455 | } 456 | }, 457 | "32a8865864e34ad29b7b83e65df1c666": { 458 | "model_module": "@jupyter-widgets/base", 459 | "model_module_version": "2.0.0", 460 | "model_name": "LayoutModel", 461 | "state": { 462 | "grid_area": "right", 463 | "padding": "0px 0px 0px 0px", 464 | "width": "70px" 465 | } 466 | }, 467 | "446976232f8749aeb7d0407469ad7025": { 468 | "model_module": "@jupyter-widgets/controls", 469 | "model_module_version": "2.0.0", 470 | "model_name": "HTMLStyleModel", 471 | "state": { 472 | "description_width": "", 473 | "font_size": null, 474 | "text_color": null 475 | } 476 | }, 477 | "45fb2f3111224340a6e3eadf7ce0b0c3": { 478 | "model_module": "@jupyter-widgets/controls", 479 | "model_module_version": "2.0.0", 480 | "model_name": "HTMLModel", 481 | "state": { 482 | "layout": "IPY_MODEL_daf43e8b5fbd4ddea15a42955b92df50", 483 | "style": "IPY_MODEL_446976232f8749aeb7d0407469ad7025", 484 | "value": "

Circuit Properties

" 485 | } 486 | }, 487 | "639c5f72f32e4e619ccca4608495ade7": { 488 | "model_module": "@jupyter-widgets/controls", 489 | "model_module_version": "2.0.0", 490 | "model_name": "ButtonStyleModel", 491 | "state": { 492 | "font_family": null, 493 | "font_size": null, 494 | "font_style": null, 495 | "font_variant": null, 496 | "font_weight": null, 497 | "text_color": null, 498 | "text_decoration": null 499 | } 500 | }, 501 | "63d1e1533c7647c88f5e027c7f22fc01": { 502 | "model_module": "@jupyter-widgets/base", 503 | "model_module_version": "2.0.0", 504 | "model_name": "LayoutModel", 505 | "state": { 506 | "margin": "0px 0px 0px 37px", 507 | "width": "600px" 508 | } 509 | }, 510 | "71b87bf858134484b9d93e3713fdcbb3": { 511 | "model_module": "@jupyter-widgets/base", 512 | "model_module_version": "2.0.0", 513 | "model_name": "LayoutModel", 514 | "state": { 515 | "width": "70px" 516 | } 517 | }, 518 | "73880c531b1140aab2baba2789e4b0e4": { 519 | "model_module": "@jupyter-widgets/base", 520 | "model_module_version": "2.0.0", 521 | "model_name": "LayoutModel", 522 | "state": { 523 | "grid_template_areas": "\n \". . . . right \"\n ", 524 | "grid_template_columns": "20% 20% 20% 20% 20%", 525 | "width": "100%" 526 | } 527 | }, 528 | "8ccacb4ee6644f1e8dfdd809fe5b28b0": { 529 | "model_module": "@jupyter-widgets/controls", 530 | "model_module_version": "2.0.0", 531 | "model_name": "HTMLModel", 532 | "state": { 533 | "layout": "IPY_MODEL_cb20ccbcd79e4c429652025bff6cae08", 534 | "style": "IPY_MODEL_c517d44276414ce6b0f3c1afbdc71319", 535 | "value": "
Backend
" 536 | } 537 | }, 538 | "9275d435ca99492393c311f738733385": { 539 | "model_module": "@jupyter-widgets/controls", 540 | "model_module_version": "2.0.0", 541 | "model_name": "HTMLModel", 542 | "state": { 543 | "layout": "IPY_MODEL_71b87bf858134484b9d93e3713fdcbb3", 544 | "style": "IPY_MODEL_243eaa616bdb49fe9bfbbb687965af3e", 545 | "value": "
Queue
" 546 | } 547 | }, 548 | "9a2dda626f0e49568f09c45c7c992042": { 549 | "model_module": "@jupyter-widgets/base", 550 | "model_module_version": "2.0.0", 551 | "model_name": "LayoutModel", 552 | "state": {} 553 | }, 554 | "a14b92773e484d3a95f92280575d1052": { 555 | "model_module": "@jupyter-widgets/controls", 556 | "model_module_version": "2.0.0", 557 | "model_name": "HTMLModel", 558 | "state": { 559 | "layout": "IPY_MODEL_9a2dda626f0e49568f09c45c7c992042", 560 | "style": "IPY_MODEL_ea27d52c5d384d1c95af83a034a3937c", 561 | "value": "
Message
" 562 | } 563 | }, 564 | "a155f68cb75a40cc9bece01a2733f62e": { 565 | "model_module": "@jupyter-widgets/controls", 566 | "model_module_version": "2.0.0", 567 | "model_name": "HTMLStyleModel", 568 | "state": { 569 | "description_width": "", 570 | "font_size": null, 571 | "text_color": null 572 | } 573 | }, 574 | "adbeaeff15a540fd8cfb09ab242e0577": { 575 | "model_module": "@jupyter-widgets/controls", 576 | "model_module_version": "2.0.0", 577 | "model_name": "ButtonModel", 578 | "state": { 579 | "button_style": "primary", 580 | "description": "Clear", 581 | "layout": "IPY_MODEL_32a8865864e34ad29b7b83e65df1c666", 582 | "style": "IPY_MODEL_639c5f72f32e4e619ccca4608495ade7", 583 | "tooltip": null 584 | } 585 | }, 586 | "c517d44276414ce6b0f3c1afbdc71319": { 587 | "model_module": "@jupyter-widgets/controls", 588 | "model_module_version": "2.0.0", 589 | "model_name": "HTMLStyleModel", 590 | "state": { 591 | "description_width": "", 592 | "font_size": null, 593 | "text_color": null 594 | } 595 | }, 596 | "cb20ccbcd79e4c429652025bff6cae08": { 597 | "model_module": "@jupyter-widgets/base", 598 | "model_module_version": "2.0.0", 599 | "model_name": "LayoutModel", 600 | "state": { 601 | "width": "145px" 602 | } 603 | }, 604 | "daf43e8b5fbd4ddea15a42955b92df50": { 605 | "model_module": "@jupyter-widgets/base", 606 | "model_module_version": "2.0.0", 607 | "model_name": "LayoutModel", 608 | "state": { 609 | "margin": "0px 0px 10px 0px" 610 | } 611 | }, 612 | "ea27d52c5d384d1c95af83a034a3937c": { 613 | "model_module": "@jupyter-widgets/controls", 614 | "model_module_version": "2.0.0", 615 | "model_name": "HTMLStyleModel", 616 | "state": { 617 | "description_width": "", 618 | "font_size": null, 619 | "text_color": null 620 | } 621 | }, 622 | "ecd4c505b4954dc8ab510a6d2cefe7ad": { 623 | "model_module": "@jupyter-widgets/controls", 624 | "model_module_version": "2.0.0", 625 | "model_name": "HTMLModel", 626 | "state": { 627 | "layout": "IPY_MODEL_22156f77e1eb435fae2439f275e6e1be", 628 | "style": "IPY_MODEL_18ab7cec7c994c919bda4c561a538e55", 629 | "value": "
Job ID
" 630 | } 631 | } 632 | }, 633 | "version_major": 2, 634 | "version_minor": 0 635 | } 636 | } 637 | }, 638 | "nbformat": 4, 639 | "nbformat_minor": 5 640 | } 641 | -------------------------------------------------------------------------------- /Time_Traveler_Badge/2023/QE_Badge4_Lab3_QEM_Advanced.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "attachments": {}, 5 | "cell_type": "markdown", 6 | "id": "8a533677", 7 | "metadata": { 8 | "tags": [] 9 | }, 10 | "source": [ 11 | "#### **Quantum Explorers 2023**\n", 12 | "---\n", 13 | "# Time Traveler Badge - Quantum Error Correction & Mitigation Module\n", 14 | "#### **Advanced Syllabus - Quantum Error Mitigation Methods and Implementation**\n", 15 | "Adapted from [IBM Quantum Challenge Fall 2022, Lab 1](https://github.com/qiskit-community/ibm-quantum-challenge-fall-22/tree/main/content/lab-1)" 16 | ] 17 | }, 18 | { 19 | "attachments": {}, 20 | "cell_type": "markdown", 21 | "id": "b5fd7239-13b4-4796-a498-343767d61498", 22 | "metadata": {}, 23 | "source": [ 24 | "### T-REX\n", 25 | "\n", 26 | "T-REX stands for **Twirled Readout Error eXtinction** which is an implementation which involves \"twirling\" of gates. If we were to view noise as a set of extra probabilistic gates on top of our perfect circuit implementation, twirling is something that can be considered in the sense that every time we execute the circuit, we conjugate this noisy gate set with a gate randomly chosen from a set of gates called as a \"twirling set\". If we are to choose this gate set to be a set of Pauli operators, we can term this as \"Pauli twirling: which is one of the most commonly used twirling techniques available.\n", 27 | "\n", 28 | "Pauli twirling is a form of randomized compiling that inserts pairs of Pauli gates (I, X, Y, Z) before and after entangling gates such that the overall unitary is the same, but the way it is implemented is different. This has the effect of turning coherent errors into stochastic errors, which can then be eliminated by sufficient averaging. This is done a number of times for the benefit of averaging. Note: we may not use a sufficient basis set to currently cancel all errors. **[[1]](https://github.com/qiskit-research/qiskit-research/blob/main/docs/getting_started.ipynb)**\n", 29 | "\n", 30 | "For more information on Pauli Twirling, watch [this Nick Knows video](https://www.youtube.com/watch?v=4MLHvmmpSQ8).\n", 31 | "\n", 32 | "You can use activate T-REX on Estimator by setting `resilience_level=1` in options. T-REX will be active by default on runtime if no `resilience_level` is being specified. You may notice with Qiskit Runtime that the results may change every run when selecting T-REX. This is because the gate set selected for twirling is different everytime which contributes to the random characteristics observed in the result.\n", 33 | "\n", 34 | "You can read more about T-REX [here](https://qiskit.org/ecosystem/ibm-runtime/tutorials/Error-Suppression-and-Error-Mitigation.html#Twirled-readout-error-extinction)." 35 | ] 36 | }, 37 | { 38 | "attachments": {}, 39 | "cell_type": "markdown", 40 | "id": "032e117e-3c43-48f1-9008-83225411b4ce", 41 | "metadata": { 42 | "tags": [] 43 | }, 44 | "source": [ 45 | "### Digital ZNE\n", 46 | "\n", 47 | "Digital Zero Noise Extrapolation (ZNE) is a popular technique for mitigating errors in noisy quantum computers without the need for additional quantum resources. A quantum program is altered to run at different effect levels of processor noise. The result of the computation is extrapolated to an estimated value at a noiseless level.\n", 48 | "\n", 49 | "To find the proper value, Digital ZNE firstly scales noise as explained above. There are two kinds of methods for scaling it: analog and digital. You can check the detailed description of each method below. It is still an active research question around which method is the best to use. Note that the digital way is by not acting on the physical quantum pulses.\n", 50 | "\n", 51 | "- Pulse stretching (analog): Applying the same one stretched along a larger amount of time for a circuit - take physical pulses and stretch it in time. In principle its the same circuit - but you are increasing the effective noise. **[[2]](https://arxiv.org/pdf/1612.02058.pdf)**\n", 52 | "- Local folding (digital): Compiling the input circuit with a larger number of gates. Each gate $G$ is replaced by $G$, $G^\\dagger$, $G$. If you are on a simulator, you do nothing to the circuit. If you use a real device, you can see the increasing noise.\n", 53 | "- Global folding (digital): Working the same way as local folding - but instead you apply this trick to the full circuit.\n", 54 | "\n", 55 | "The noisy expectation values are then extrapolated to the zero-noise limit. Thhis is generally done with general regression methods. \n", 56 | "\n", 57 | "You can read more about Digital ZNE [here](https://qiskit.org/ecosystem/ibm-runtime/tutorials/Error-Suppression-and-Error-Mitigation.html#Zero-noise-extrapolation).\n" 58 | ] 59 | }, 60 | { 61 | "attachments": {}, 62 | "cell_type": "markdown", 63 | "id": "64be824f-5d15-4ac7-bc44-64927f2b5de6", 64 | "metadata": {}, 65 | "source": [ 66 | "### PEC\n", 67 | "\n", 68 | "Probabilistic Error Cancellation (PEC) is an approach that mitigates error by learning and inverting a sparse noise model that is able to capture correlated noise. PEC returns an unbiased estimate of an expectation value so long as learned noise model faithfully represents the actual noise model at the time of mitigation. \n", 69 | "\n", 70 | "PEC uses a quasi-probability method to mimic the effect of inverting the learned noise. This requires sampling from a randomized circuit family associated with the user’s original circuit. Applying PEC will increase the variability of the returned expectation value estimates unless the number of samples per circuit is also increased for both input and characterization circuits. The amount of samples required to counter this variability scales exponentially with the noise strength of the mitigated circuit. **[[3]](https://qiskit.org/ecosystem/ibm-runtime/how_to/error-mitigation.html)**\n", 71 | "\n", 72 | "You can read more about PEC [here](https://qiskit.org/ecosystem/ibm-runtime/tutorials/Error-Suppression-and-Error-Mitigation.html#Probabilistic-error-cancellation).\n" 73 | ] 74 | }, 75 | { 76 | "attachments": {}, 77 | "cell_type": "markdown", 78 | "id": "23169b2a-40f1-4bc6-bce8-54728c65f5fc", 79 | "metadata": { 80 | "tags": [] 81 | }, 82 | "source": [ 83 | "
\n", 84 | " \n", 85 | "

Implementation of Quantum Error Mitigation Techniques

\n", 86 | "\n", 87 | "The resilience level in Qiskit runtime is a metric to specify how much resilience to build against errors, and therefore the level of error mitigation. Higher levels generate more accurate results, at the expense of longer processing times. You can activate higher levels of resilience on Qiskit runtime but please do note that **this feature is currently in beta** and the results may not be as expected, but feel free to experiment with them where you are directed below in the code blocks!\n", 88 | "\n", 89 | "You may find these resources handy:\n", 90 | "\n", 91 | "- [Qiskit Documentation: Options](https://qiskit.org/ecosystem/ibm-runtime/stubs/qiskit_ibm_runtime.options.Options.html)\n", 92 | "- [Configuring error mitigation](https://qiskit.org/ecosystem/ibm-runtime/how_to/error-mitigation.html)\n", 93 | " \n" 94 | ] 95 | }, 96 | { 97 | "cell_type": "code", 98 | "execution_count": null, 99 | "id": "4f9ad94a-fed1-48af-864b-300fb08b82e1", 100 | "metadata": { 101 | "tags": [] 102 | }, 103 | "outputs": [], 104 | "source": [ 105 | "#import required libraries\n", 106 | "import time\n", 107 | "import numpy as np\n", 108 | "from qiskit import *\n", 109 | "from qiskit.circuit import Parameter\n", 110 | "from qiskit.quantum_info import Statevector, Pauli, SparsePauliOp\n", 111 | "from qiskit.circuit.library import RealAmplitudes\n", 112 | "import matplotlib.pyplot as plt\n", 113 | "import matplotlib.ticker as tck\n", 114 | "from qiskit.tools.visualization import plot_histogram\n", 115 | "from qiskit_ibm_runtime import QiskitRuntimeService, Session, Options, Sampler, Estimator\n", 116 | "from qiskit.providers.fake_provider import FakeManila\n", 117 | "from qiskit_aer.noise import NoiseModel\n", 118 | "\n", 119 | "# Import FakeBackend\n", 120 | "fake_backend = FakeManila()\n", 121 | "noise_model = NoiseModel.from_backend(fake_backend)" 122 | ] 123 | }, 124 | { 125 | "cell_type": "code", 126 | "execution_count": null, 127 | "id": "1b178af8-3640-4d60-922f-1dacd656681e", 128 | "metadata": { 129 | "tags": [] 130 | }, 131 | "outputs": [], 132 | "source": [ 133 | "# Save the Runtime account credentials if you have not done so already\n", 134 | "# If you need to overwrite the account info, please add `overwrite=True`\n", 135 | "# QiskitRuntimeService.save_account(channel='ibm_quantum', token='my_token', overwrite=True)\n", 136 | "\n", 137 | "service = QiskitRuntimeService(channel=\"ibm_quantum\", instance='ibm-q/open/main')\n", 138 | "\n", 139 | "backend = service.backends(simulator=True)[0]\n", 140 | "print(backend)" 141 | ] 142 | }, 143 | { 144 | "cell_type": "code", 145 | "execution_count": null, 146 | "id": "6bb61fc5-a06d-478e-9e3f-c003427c1d11", 147 | "metadata": { 148 | "tags": [] 149 | }, 150 | "outputs": [], 151 | "source": [ 152 | "# This is the circuit you used in the main syllabus for learning M3\n", 153 | "theta = Parameter('theta')\n", 154 | "\n", 155 | "qc = QuantumCircuit(2)\n", 156 | "qc.x(1)\n", 157 | "qc.h(0)\n", 158 | "qc.cp(theta,0,1)\n", 159 | "qc.h(0)\n", 160 | "\n", 161 | "qc.draw()" 162 | ] 163 | }, 164 | { 165 | "attachments": {}, 166 | "cell_type": "markdown", 167 | "id": "f07ef407-2918-4a44-9060-f7b5b90c0334", 168 | "metadata": {}, 169 | "source": [ 170 | "In the next cell, in the line of code as indicated, change the resilience level to any of the values `[1, 2, 3]` and run the Estimator to see how output changes with resilience level" 171 | ] 172 | }, 173 | { 174 | "cell_type": "code", 175 | "execution_count": null, 176 | "id": "87ecd033-dda0-4ba4-979f-7294bcbae16c", 177 | "metadata": { 178 | "tags": [] 179 | }, 180 | "outputs": [], 181 | "source": [ 182 | "phases = np.linspace(0, 2*np.pi, 50)\n", 183 | "individual_phases = [[ph] for ph in phases]\n", 184 | "ZZ = SparsePauliOp.from_list([(\"ZZ\", 1)])\n", 185 | "\n", 186 | "options = Options(\n", 187 | " simulator={\n", 188 | " \"noise_model\": noise_model,\n", 189 | " \"seed_simulator\": 42,\n", 190 | " }, \n", 191 | " resilience_level=0\n", 192 | ")\n", 193 | "\n", 194 | "options_with_em = Options(\n", 195 | " simulator={\n", 196 | " \"noise_model\": noise_model,\n", 197 | " \"seed_simulator\": 42,\n", 198 | " }, \n", 199 | " resilience_level=1 ### Change the value in this line ###\n", 200 | ")" 201 | ] 202 | }, 203 | { 204 | "cell_type": "code", 205 | "execution_count": null, 206 | "id": "05414212-af71-4ebf-afc8-260967588399", 207 | "metadata": { 208 | "tags": [] 209 | }, 210 | "outputs": [], 211 | "source": [ 212 | "with Session(service=service, backend=backend): \n", 213 | " estimator = Estimator(options=options)\n", 214 | " job = estimator.run(circuits=[qc]*len(phases), parameter_values=individual_phases, observables=[ZZ]*len(phases))\n", 215 | " param_results = job.result()\n", 216 | " exp_values = param_results.values\n", 217 | " \n", 218 | " estimator = Estimator(options=options_with_em)\n", 219 | " job = estimator.run(circuits=[qc]*len(phases), parameter_values=individual_phases, observables=[ZZ]*len(phases))\n", 220 | " param_results = job.result()\n", 221 | " exp_values_with_em = param_results.values" 222 | ] 223 | }, 224 | { 225 | "cell_type": "code", 226 | "execution_count": null, 227 | "id": "2bd54d85-78b4-481f-9d44-4f8db4092745", 228 | "metadata": { 229 | "tags": [] 230 | }, 231 | "outputs": [], 232 | "source": [ 233 | "plt.plot(phases, exp_values, 'o', label='noisy')\n", 234 | "plt.plot(phases, exp_values_with_em, 'o', label='mitigated')\n", 235 | "plt.plot(phases, 2*np.sin(phases/2,)**2-1, label='theory')\n", 236 | "plt.xlabel('Phase')\n", 237 | "plt.ylabel('Expectation')\n", 238 | "plt.legend();" 239 | ] 240 | }, 241 | { 242 | "attachments": {}, 243 | "cell_type": "markdown", 244 | "id": "7e5af1e1-5a51-48d5-84c2-916a0e8ecb8c", 245 | "metadata": {}, 246 | "source": [ 247 | "
\n", 248 | " \n", 249 | "

Optional: Run the above on a real backend

\n", 250 | "\n", 251 | "Feel free to test the above code on a **real quantum backend** to see how the result varies when running on a QPU. For Quantum Explorers, you have a `hub`, `group`, and `project` allocated to you. Feel free to configure the cell below and experiment with the results!\n", 252 | " \n", 253 | "
" 254 | ] 255 | }, 256 | { 257 | "cell_type": "code", 258 | "execution_count": null, 259 | "id": "6319e3e3-24fa-4263-941b-1f6d25202632", 260 | "metadata": { 261 | "tags": [] 262 | }, 263 | "outputs": [], 264 | "source": [ 265 | "# Get the least-busy backend, this step may take a while\n", 266 | "real_backend = service.least_busy(min_num_qubits=2, simulator=False)\n", 267 | "\n", 268 | "print(f\"The least busy backend is {real_backend.name}.\")" 269 | ] 270 | }, 271 | { 272 | "attachments": {}, 273 | "cell_type": "markdown", 274 | "id": "b3daf9d4-e553-41c7-852d-636e87e94272", 275 | "metadata": {}, 276 | "source": [ 277 | "Using the real backend for `Estimator`:" 278 | ] 279 | }, 280 | { 281 | "cell_type": "code", 282 | "execution_count": null, 283 | "id": "ef4f5b6e-5bd0-4257-9dc6-5e32dafb5cd0", 284 | "metadata": { 285 | "tags": [] 286 | }, 287 | "outputs": [], 288 | "source": [ 289 | "with Session(service=service, backend=real_backend): \n", 290 | " estimator = Estimator(options=options)\n", 291 | " job = estimator.run(circuits=[qc]*len(phases), parameter_values=individual_phases, observables=[ZZ]*len(phases))\n", 292 | " print(f\"First job ID: {job.job_id()}\")\n", 293 | " \n", 294 | " estimator = Estimator(options=options_with_em)\n", 295 | " job = estimator.run(circuits=[qc]*len(phases), parameter_values=individual_phases, observables=[ZZ]*len(phases))\n", 296 | " print(f\"Second job ID: {job.job_id()}\")" 297 | ] 298 | }, 299 | { 300 | "cell_type": "code", 301 | "execution_count": null, 302 | "id": "62a6fcad-16ac-4288-a1c0-2970afd76f81", 303 | "metadata": { 304 | "tags": [] 305 | }, 306 | "outputs": [], 307 | "source": [ 308 | "#Get job results\n", 309 | "job = service.job('place first job ID here')\n", 310 | "param_results = job.result()\n", 311 | "exp_values = param_results.values\n", 312 | "\n", 313 | "job_with_em = service.job('place second job ID here')\n", 314 | "param_results_with_em = job_with_em.result()\n", 315 | "exp_values_with_em = param_results_with_em.values" 316 | ] 317 | }, 318 | { 319 | "attachments": {}, 320 | "cell_type": "markdown", 321 | "id": "8a6b7aae-1300-403f-802d-4366d17c1319", 322 | "metadata": {}, 323 | "source": [ 324 | "While your jobs are running, you can monitor them! Simply copy the Job ID printed out for you for one of the runs and enter it into the search bar **[here](https://quantum-computing.ibm.com/jobs)**! Make sure you are logged into the IBM Quantum Platform to access this page. " 325 | ] 326 | }, 327 | { 328 | "cell_type": "code", 329 | "execution_count": null, 330 | "id": "ef101938-b6c7-4f54-8fa9-418c5540bd76", 331 | "metadata": { 332 | "tags": [] 333 | }, 334 | "outputs": [], 335 | "source": [ 336 | "plt.plot(phases, exp_values, 'o', label='noisy')\n", 337 | "plt.plot(phases, exp_values_with_em, 'o', label='mitigated')\n", 338 | "plt.plot(phases, 2*np.sin(phases/2,)**2-1, label='theory')\n", 339 | "plt.xlabel('Phase')\n", 340 | "plt.ylabel('Expectation')\n", 341 | "plt.legend();" 342 | ] 343 | }, 344 | { 345 | "attachments": {}, 346 | "cell_type": "markdown", 347 | "id": "1cbb2b3c-aa1c-4a12-9462-d9528651640b", 348 | "metadata": {}, 349 | "source": [ 350 | "# References\n", 351 | "- [1] **[Getting Started - Qiskit Research](https://github.com/qiskit-research/qiskit-research/blob/main/docs/getting_started.ipynb)**\n", 352 | "- [2] **[Error mitigation for short-depth quantum circuits - Kristan Temme, Sergey Bravyi and Jay M. Gambetta](https://arxiv.org/pdf/1612.02058.pdf)**\n", 353 | "- [3] **[Configure error mitigation](https://qiskit.org/ecosystem/ibm-runtime/how_to/error-mitigation.html)**" 354 | ] 355 | }, 356 | { 357 | "cell_type": "code", 358 | "execution_count": 1, 359 | "id": "184a135d", 360 | "metadata": { 361 | "tags": [] 362 | }, 363 | "outputs": [ 364 | { 365 | "data": { 366 | "text/html": [ 367 | "

Version Information

Qiskit SoftwareVersion
qiskit-terra0.24.1
qiskit-aer0.12.1
qiskit-ibmq-provider0.20.2
qiskit0.43.2
qiskit-nature0.6.2
qiskit-finance0.3.4
qiskit-optimization0.5.0
qiskit-machine-learning0.6.1
System information
Python version3.10.8
Python compilerGCC 10.4.0
Python buildmain, Nov 22 2022 08:26:04
OSLinux
CPUs8
Memory (Gb)31.211322784423828
Wed Jul 12 04:36:16 2023 UTC
" 368 | ], 369 | "text/plain": [ 370 | "" 371 | ] 372 | }, 373 | "metadata": {}, 374 | "output_type": "display_data" 375 | } 376 | ], 377 | "source": [ 378 | "from qiskit.tools.jupyter import *\n", 379 | "%qiskit_version_table" 380 | ] 381 | } 382 | ], 383 | "metadata": { 384 | "kernelspec": { 385 | "display_name": "Python 3 (ipykernel)", 386 | "language": "python", 387 | "name": "python3" 388 | }, 389 | "language_info": { 390 | "codemirror_mode": { 391 | "name": "ipython", 392 | "version": 3 393 | }, 394 | "file_extension": ".py", 395 | "mimetype": "text/x-python", 396 | "name": "python", 397 | "nbconvert_exporter": "python", 398 | "pygments_lexer": "ipython3", 399 | "version": "3.10.8" 400 | }, 401 | "vscode": { 402 | "interpreter": { 403 | "hash": "2314985414265184cbcbf39283c3ac2af8a6b2659fa88be3910ade054ec8b29d" 404 | } 405 | }, 406 | "widgets": { 407 | "application/vnd.jupyter.widget-state+json": { 408 | "state": { 409 | "106f5a473c7940a7a32e5a4c36b03b26": { 410 | "model_module": "@jupyter-widgets/controls", 411 | "model_module_version": "2.0.0", 412 | "model_name": "HBoxModel", 413 | "state": { 414 | "children": [ 415 | "IPY_MODEL_ecd4c505b4954dc8ab510a6d2cefe7ad", 416 | "IPY_MODEL_8ccacb4ee6644f1e8dfdd809fe5b28b0", 417 | "IPY_MODEL_1cb499addaf5456e9c7e6402d664247f", 418 | "IPY_MODEL_9275d435ca99492393c311f738733385", 419 | "IPY_MODEL_a14b92773e484d3a95f92280575d1052" 420 | ], 421 | "layout": "IPY_MODEL_63d1e1533c7647c88f5e027c7f22fc01" 422 | } 423 | }, 424 | "18ab7cec7c994c919bda4c561a538e55": { 425 | "model_module": "@jupyter-widgets/controls", 426 | "model_module_version": "2.0.0", 427 | "model_name": "HTMLStyleModel", 428 | "state": { 429 | "description_width": "", 430 | "font_size": null, 431 | "text_color": null 432 | } 433 | }, 434 | "1cb499addaf5456e9c7e6402d664247f": { 435 | "model_module": "@jupyter-widgets/controls", 436 | "model_module_version": "2.0.0", 437 | "model_name": "HTMLModel", 438 | "state": { 439 | "layout": "IPY_MODEL_267063972f98462b903b04e80054da8b", 440 | "style": "IPY_MODEL_a155f68cb75a40cc9bece01a2733f62e", 441 | "value": "
Status
" 442 | } 443 | }, 444 | "22156f77e1eb435fae2439f275e6e1be": { 445 | "model_module": "@jupyter-widgets/base", 446 | "model_module_version": "2.0.0", 447 | "model_name": "LayoutModel", 448 | "state": { 449 | "width": "190px" 450 | } 451 | }, 452 | "243eaa616bdb49fe9bfbbb687965af3e": { 453 | "model_module": "@jupyter-widgets/controls", 454 | "model_module_version": "2.0.0", 455 | "model_name": "HTMLStyleModel", 456 | "state": { 457 | "description_width": "", 458 | "font_size": null, 459 | "text_color": null 460 | } 461 | }, 462 | "267063972f98462b903b04e80054da8b": { 463 | "model_module": "@jupyter-widgets/base", 464 | "model_module_version": "2.0.0", 465 | "model_name": "LayoutModel", 466 | "state": { 467 | "width": "95px" 468 | } 469 | }, 470 | "2f838f75a38b4b2eaf3f2f45d1aaa6dd": { 471 | "model_module": "@jupyter-widgets/controls", 472 | "model_module_version": "2.0.0", 473 | "model_name": "GridBoxModel", 474 | "state": { 475 | "children": [ 476 | "IPY_MODEL_adbeaeff15a540fd8cfb09ab242e0577" 477 | ], 478 | "layout": "IPY_MODEL_73880c531b1140aab2baba2789e4b0e4" 479 | } 480 | }, 481 | "32a8865864e34ad29b7b83e65df1c666": { 482 | "model_module": "@jupyter-widgets/base", 483 | "model_module_version": "2.0.0", 484 | "model_name": "LayoutModel", 485 | "state": { 486 | "grid_area": "right", 487 | "padding": "0px 0px 0px 0px", 488 | "width": "70px" 489 | } 490 | }, 491 | "446976232f8749aeb7d0407469ad7025": { 492 | "model_module": "@jupyter-widgets/controls", 493 | "model_module_version": "2.0.0", 494 | "model_name": "HTMLStyleModel", 495 | "state": { 496 | "description_width": "", 497 | "font_size": null, 498 | "text_color": null 499 | } 500 | }, 501 | "45fb2f3111224340a6e3eadf7ce0b0c3": { 502 | "model_module": "@jupyter-widgets/controls", 503 | "model_module_version": "2.0.0", 504 | "model_name": "HTMLModel", 505 | "state": { 506 | "layout": "IPY_MODEL_daf43e8b5fbd4ddea15a42955b92df50", 507 | "style": "IPY_MODEL_446976232f8749aeb7d0407469ad7025", 508 | "value": "

Circuit Properties

" 509 | } 510 | }, 511 | "639c5f72f32e4e619ccca4608495ade7": { 512 | "model_module": "@jupyter-widgets/controls", 513 | "model_module_version": "2.0.0", 514 | "model_name": "ButtonStyleModel", 515 | "state": { 516 | "font_family": null, 517 | "font_size": null, 518 | "font_style": null, 519 | "font_variant": null, 520 | "font_weight": null, 521 | "text_color": null, 522 | "text_decoration": null 523 | } 524 | }, 525 | "63d1e1533c7647c88f5e027c7f22fc01": { 526 | "model_module": "@jupyter-widgets/base", 527 | "model_module_version": "2.0.0", 528 | "model_name": "LayoutModel", 529 | "state": { 530 | "margin": "0px 0px 0px 37px", 531 | "width": "600px" 532 | } 533 | }, 534 | "71b87bf858134484b9d93e3713fdcbb3": { 535 | "model_module": "@jupyter-widgets/base", 536 | "model_module_version": "2.0.0", 537 | "model_name": "LayoutModel", 538 | "state": { 539 | "width": "70px" 540 | } 541 | }, 542 | "73880c531b1140aab2baba2789e4b0e4": { 543 | "model_module": "@jupyter-widgets/base", 544 | "model_module_version": "2.0.0", 545 | "model_name": "LayoutModel", 546 | "state": { 547 | "grid_template_areas": "\n \". . . . right \"\n ", 548 | "grid_template_columns": "20% 20% 20% 20% 20%", 549 | "width": "100%" 550 | } 551 | }, 552 | "8ccacb4ee6644f1e8dfdd809fe5b28b0": { 553 | "model_module": "@jupyter-widgets/controls", 554 | "model_module_version": "2.0.0", 555 | "model_name": "HTMLModel", 556 | "state": { 557 | "layout": "IPY_MODEL_cb20ccbcd79e4c429652025bff6cae08", 558 | "style": "IPY_MODEL_c517d44276414ce6b0f3c1afbdc71319", 559 | "value": "
Backend
" 560 | } 561 | }, 562 | "9275d435ca99492393c311f738733385": { 563 | "model_module": "@jupyter-widgets/controls", 564 | "model_module_version": "2.0.0", 565 | "model_name": "HTMLModel", 566 | "state": { 567 | "layout": "IPY_MODEL_71b87bf858134484b9d93e3713fdcbb3", 568 | "style": "IPY_MODEL_243eaa616bdb49fe9bfbbb687965af3e", 569 | "value": "
Queue
" 570 | } 571 | }, 572 | "9a2dda626f0e49568f09c45c7c992042": { 573 | "model_module": "@jupyter-widgets/base", 574 | "model_module_version": "2.0.0", 575 | "model_name": "LayoutModel", 576 | "state": {} 577 | }, 578 | "a14b92773e484d3a95f92280575d1052": { 579 | "model_module": "@jupyter-widgets/controls", 580 | "model_module_version": "2.0.0", 581 | "model_name": "HTMLModel", 582 | "state": { 583 | "layout": "IPY_MODEL_9a2dda626f0e49568f09c45c7c992042", 584 | "style": "IPY_MODEL_ea27d52c5d384d1c95af83a034a3937c", 585 | "value": "
Message
" 586 | } 587 | }, 588 | "a155f68cb75a40cc9bece01a2733f62e": { 589 | "model_module": "@jupyter-widgets/controls", 590 | "model_module_version": "2.0.0", 591 | "model_name": "HTMLStyleModel", 592 | "state": { 593 | "description_width": "", 594 | "font_size": null, 595 | "text_color": null 596 | } 597 | }, 598 | "adbeaeff15a540fd8cfb09ab242e0577": { 599 | "model_module": "@jupyter-widgets/controls", 600 | "model_module_version": "2.0.0", 601 | "model_name": "ButtonModel", 602 | "state": { 603 | "button_style": "primary", 604 | "description": "Clear", 605 | "layout": "IPY_MODEL_32a8865864e34ad29b7b83e65df1c666", 606 | "style": "IPY_MODEL_639c5f72f32e4e619ccca4608495ade7", 607 | "tooltip": null 608 | } 609 | }, 610 | "c517d44276414ce6b0f3c1afbdc71319": { 611 | "model_module": "@jupyter-widgets/controls", 612 | "model_module_version": "2.0.0", 613 | "model_name": "HTMLStyleModel", 614 | "state": { 615 | "description_width": "", 616 | "font_size": null, 617 | "text_color": null 618 | } 619 | }, 620 | "cb20ccbcd79e4c429652025bff6cae08": { 621 | "model_module": "@jupyter-widgets/base", 622 | "model_module_version": "2.0.0", 623 | "model_name": "LayoutModel", 624 | "state": { 625 | "width": "145px" 626 | } 627 | }, 628 | "daf43e8b5fbd4ddea15a42955b92df50": { 629 | "model_module": "@jupyter-widgets/base", 630 | "model_module_version": "2.0.0", 631 | "model_name": "LayoutModel", 632 | "state": { 633 | "margin": "0px 0px 10px 0px" 634 | } 635 | }, 636 | "ea27d52c5d384d1c95af83a034a3937c": { 637 | "model_module": "@jupyter-widgets/controls", 638 | "model_module_version": "2.0.0", 639 | "model_name": "HTMLStyleModel", 640 | "state": { 641 | "description_width": "", 642 | "font_size": null, 643 | "text_color": null 644 | } 645 | }, 646 | "ecd4c505b4954dc8ab510a6d2cefe7ad": { 647 | "model_module": "@jupyter-widgets/controls", 648 | "model_module_version": "2.0.0", 649 | "model_name": "HTMLModel", 650 | "state": { 651 | "layout": "IPY_MODEL_22156f77e1eb435fae2439f275e6e1be", 652 | "style": "IPY_MODEL_18ab7cec7c994c919bda4c561a538e55", 653 | "value": "
Job ID
" 654 | } 655 | } 656 | }, 657 | "version_major": 2, 658 | "version_minor": 0 659 | } 660 | } 661 | }, 662 | "nbformat": 4, 663 | "nbformat_minor": 5 664 | } 665 | -------------------------------------------------------------------------------- /Time_Traveler_Badge/2023/quantum-error-suppression-mitigation-correction-ja.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "# エラー抑制、エラー緩和、エラー訂正の違いとは?\n", 8 | "\n", 9 | "「[What’s the difference between error suppression, error mitigation, and error correction?](https://research.ibm.com/blog/quantum-error-suppression-mitigation-correction)」の抄訳です。" 10 | ] 11 | }, 12 | { 13 | "cell_type": "markdown", 14 | "metadata": {}, 15 | "source": [ 16 | "#### 量子コンピューターは、変革をもたらす可能性を秘めています。しかしそれは、宇宙の物理的限界で動作する、ノイズが多く高感度なシステムに固有のエラーに対処できる場合に限られます。エラー処理は単純な作業ではなく、システム設計のあらゆる段階でこのエラーを予測し、修正する必要があります。" 17 | ] 18 | }, 19 | { 20 | "cell_type": "markdown", 21 | "metadata": {}, 22 | "source": [ 23 | "コンピューター内でエラーが発生するのは自然なことです。量子状態は、実行される量子回路によって規定されたとおりに進化するはずです。しかし、実際の量子状態や量子ビットは、外部環境やハードウェア自体の様々な不可避な外乱(ノイズと呼ばれる外乱)により、異なる進化を遂げ、計算に誤差を生じる可能性があります。しかし、量子ビットのエラーは古典ビットのエラーよりも複雑です。量子ビットの0か1の値が変化するだけでなく、量子ビットには位相があります。量子ビットが指す方向のようなものです。私たちは、システムの各レベルでこれらの種類のエラーの両方を処理する方法を見つける必要があります。計算ハードウェア自体の制御を改善し、ハードウェアに冗長性を持たせることで、1つまたは数個の量子ビットがエラーになっても、計算のために正確な値を取り出すことができるようにするのです。\n", 24 | "\n", 25 | "このようなエラーを処理する方法はいくつかありますが、専門用語が多すぎて混乱することもあります。各用語が正確に何を意味するかについては、分野内でも意見の相違があります。エラー処理は、エラー抑制、エラー緩和、エラー訂正という独自の研究開発上の考慮事項を持つ 3 つのコア部分に分けることができます。特に抑制と緩和の違いは微妙で、完全に定義されているわけではないことに注意してください。" 26 | ] 27 | }, 28 | { 29 | "cell_type": "markdown", 30 | "metadata": {}, 31 | "source": [ 32 | "## エラー抑制\n", 33 | "\n", 34 | "エラー抑制は、エラー処理の最も基本的なレベルです。エラー抑制とは、望ましくない影響に関する知識を利用して、それらの影響の可能性を予測し、回避するカスタマイズを導入するテクニックを指します。多くの場合、エラー抑制について話すときは、ハードウェアに最も近いレベルでのエラー処理について話しています。このような手法は、ユーザーの知らないところで行われることが多く、プロセッサーが望ましい結果を返すように制御信号を変更したり追加したりすることが多いです。\n", 35 | "\n", 36 | "エラー抑制技術の歴史は数十年前にさかのぼり、磁気共鳴画像法(MRI)の核磁気共鳴(NMR)装置など、制御可能な最初の量子システムで開発されました。量子コンピューターは、スピンエコー(量子ビットの焦点を再調整し、量子状態をより長く維持できるようにする一連のパルス)など、これらの技術のいくつかを採用しています。スピン・エコーは、ダイナミック・デカップリングと呼ばれる技術の一部です。ダイナミック・デカップリングは、アイドル状態の量子ビットにパルスを送り、その値を元の状態にリセットします。これは基本的に、計算で使用されている量子ビットからの潜在的な影響を元に戻すためです。\n", 37 | "\n", 38 | "断熱ゲートによる微分除去(DRAG)は、標準的なパルス形状に成分を追加し、計算に使用する0と1の状態よりも高い状態に入る量子ビットを減らします。その他にも数十年かけて開発された数多くの技術があり、私たちはそれを研究し、必要に応じて私たち自身のハードウェアに実装しています。[Qiskit Pulse](https://qiskit.org/documentation/apidoc/pulse.html)では、ユーザーが独自にエラー抑制を探求するためにカスタムパルスを生成することができます。[ぜひお試しください。](https://ja.learn.qiskit.org/course/quantum-hardware-pulses/calibrating-qubits-using-qiskit-pulse)" 39 | ] 40 | }, 41 | { 42 | "cell_type": "markdown", 43 | "metadata": {}, 44 | "source": [ 45 | "## エラー緩和\n", 46 | "\n", 47 | "一方、エラー緩和は、回路のアンサンブル出力を用いて、期待値を推定する際のノイズの影響を低減または除去します。我々は、近い将来、有用な量子コンピュータを実現する鍵は、エラー緩和であると考えています。\n", 48 | "\n", 49 | "(エラー緩和:フォールト・トレランスが究極の目標である以上、エラー緩和こそが量子コンピューティングを有用なものにする道である。[続きを読む](https://research.ibm.com/blog/gammabar-for-quantum-advantage)。)\n", 50 | "\n", 51 | "私たちのチームは、さまざまなエラー緩和技術のポートフォリオを探求し、開発しています。例えば、確率的エラー・キャンセル(PEC)は、平均してノイズを打ち消すチャンネルを模倣する回路の集まりからサンプルが抽出されます。このプロセスは、ノイズキャンセリングヘッドフォンの仕組みに少し似ていますが、ショットごとにノイズをキャンセルするのではなく、平均的に機能します。ゼロノイズ外挿(ZNE)は、異なるノイズ強度における量子回路の測定結果を外挿することで、ノイズの多い量子回路の測定結果に影響を与えるノイズを低減し、実際の値がどうあるべきかを決定します。M3やTREX(Twirled Readout Error eXtinction)のような他の方法は、特に量子測定のノイズを減らすことに焦点を当てています。\n", 52 | "\n", 53 | "重要なのは、これらの方法にはそれぞれオーバーヘッドがあり、精度のレベルもそれぞれ異なるということです。例えば、これらの手法の中で最も強力なものは、指数関数的なオーバーヘッドを伴います。つまり、実行にかかる時間は、量子ビット数と回路の深さで定義される問題の大きさに応じて指数関数的に増加します。手法のポートフォリオを用意することで、ユーザーは精度の要求とどの程度のオーバーヘッドを許容するかに基づいて、自分の問題に最も理にかなった手法を選択することができます。\n", 54 | "\n", 55 | "これらの手法の中で最も強力な手法を使用すると、ノイズのない(バイアスのかかっていない)期待値を計算できるため、エラー緩和に興奮しています。期待値は様々な特性や問題をエンコードできます。例えば、スピン系の磁化や相関関数、分子配置のエネルギー、あるいはコスト関数などです。ただし、これらは通常、|00110⟩ などの特定の量子状態の確率では表しません。私たちは、研究コミュニティーや IBM Quantum Network のメンバーが、演算子の期待値をコアprimitive として利用する新しいアルゴリズムやアプリケーションを開発することを奨励しています。\n", 56 | "\n", 57 | "オーバーヘッドがあるにもかかわらず、数百量子ビットの範囲では、等価な回路深さで、エラー緩和が依然として実用的である可能性があることを願っています。等価な回路深さを持つ数百量子ビット以上になると、量子エラー訂正とエラー緩和技術のハイブリッドの可能性を想定しています。 " 58 | ] 59 | }, 60 | { 61 | "cell_type": "markdown", 62 | "metadata": {}, 63 | "source": [ 64 | "## エラー訂正\n", 65 | "\n", 66 | "エラー訂正は、我々の究極の目標であるフォールト・トレラント量子計算を達成する方法であり、冗長性を構築することで、数個の量子ビットにエラーが発生しても、システムはプロセッサー上で実行されるどんなものに対しても正確な答えを返すことができます。エラー訂正は、エラーが発生したかどうかをチェックできるように、情報が冗長性を持ってエンコードされる古典的なコンピューティングの標準的な技術です。\n", 67 | "\n", 68 | "量子エラー訂正も同じ考え方ですが、前述の新しいタイプの誤りを考慮する必要があるという点に注意が必要です。さらに、状態が崩れないようにシステムを注意深く測定しなければなりません。量子エラー訂正では、論理量子ビットと呼ばれる単一の量子ビットの値を複数の物理量子ビットにまたがって符号化し、物理量子ビットのファブリックを本質的にエラーのない論理量子ビットとして扱うことができるゲートを実装します。エラーを検出し訂正するために、エラー訂正コードと呼ばれる特定の演算と測定のセットを実行します。しきい値定理によれば、エラー訂正を適用する前にハードウェアが達成しなければならない、ハードウェア依存の最小エラー率があることがわかっています。\n", 69 | "\n", 70 | "(しきい値定理:量子のパイオニアが考える、量子アルゴリズムに取り組む人がもっと必要だと考える理由: [量子しきい値定理](https://medium.com/qiskit/why-this-quantum-pioneer-thinks-we-need-more-people-working-on-quantum-algorithms-3020729c61e1)の重要な立役者の一人、Dorit Aharonov について読む。)\n", 71 | "\n", 72 | "しかし、エラー訂正は単なる工学的課題ではなく、物理学と数学の問題です。現在の主要なコードである表面符号は、1つの論理量子ビットに対してO(d^2)という多くの物理量子ビットを必要とします。ここで、d は距離と呼ばれるコードの特徴であり、訂正できるエラーの数に関係します。QECコードがフォールトトレランスを達成するのに十分なエラーを訂正するためには、コードのエラー訂正能力と量子デバイスのエラーレートが一致するように、距離dを十分に高く選択する必要があります。現在の量子デバイスはかなりノイズが多く、エラー率は1e-3に近いため、表面符号で量子エラー訂正を使用するために必要な量子ビットの数が現時点では非現実的です。前進するためには、デバイスの物理エラー率を1e-4まで下げると同時に、より少ない物理量子ビットで済む新しいコードを発見する必要があります。\n", 73 | "\n", 74 | "世界中の理論家たちは、現在もさまざまなエラー訂正戦略や量子ビットのレイアウトを考案し、どれが将来的に最も有望かを見極めています。昨年、理論家たちは2次関数的なオーバーヘッドO(d^2)を克服する方法を発見し、ロバスト性に線形にスケールするコードを明らかにしました。ロバストネスが2倍になるということは、量子ビット数が2倍になるということです。これによって、オーバーヘッドを大幅に削減したエラー訂正が可能になるかもしれません。IBM Quantum は最近、この分野のさらなる研究に拍車をかけるため、[サマースクール](https://www.ibm.com/quantum/summer-school)を開催しました。一方、ハードウェア・エンジニアは理論家と協力して、理論家の最良のアイデアを確実に実現できるように取り組んでいます。\n", 75 | "\n", 76 | "エラー抑制、エラー緩和、エラー訂正は似ているように聞こえるかもしれませんが、それぞれ独自の専門知識と考慮事項が必要であり、量子コンピューターが真の価値をもたらすためにはそれぞれが極めて重要です。量子コンピューターがどのような問題を解決したいかは分かっていますが、実際にその問題を解決するには、エラーやノイズを実用的でスケーラブルな方法で処理する必要があり、そこに到達する方法はまだ明らかではありません。エラー抑制、緩和、訂正のいずれかの分野が改善されれば、実用的な量子コンピューティングの実現に近づきます。これらの分野は一体となって、量子コンピューティングのオーバーヘッドを低減するための継続的な道筋を提供します。IBM Quantum は、量子中心のスーパーコンピューティングの時代をもたらすために、これらすべての分野で前進を続けています。 " 77 | ] 78 | }, 79 | { 80 | "cell_type": "markdown", 81 | "metadata": {}, 82 | "source": [ 83 | "Translated and adapted by: Kifumi Numata" 84 | ] 85 | } 86 | ], 87 | "metadata": { 88 | "kernelspec": { 89 | "display_name": "Python 3", 90 | "language": "python", 91 | "name": "python3" 92 | }, 93 | "language_info": { 94 | "codemirror_mode": { 95 | "name": "ipython", 96 | "version": 3 97 | }, 98 | "file_extension": ".py", 99 | "mimetype": "text/x-python", 100 | "name": "python", 101 | "nbconvert_exporter": "python", 102 | "pygments_lexer": "ipython3", 103 | "version": "3.8.5" 104 | } 105 | }, 106 | "nbformat": 4, 107 | "nbformat_minor": 4 108 | } 109 | -------------------------------------------------------------------------------- /credly.md: -------------------------------------------------------------------------------- 1 | 2 | # Quantum Explorers Digital Credentials 3 | 4 | Quantum Explorers is our self-paced, game-based quantum computing learning program for high school students and above. There are seven themed achievements to unlock. Each achievement has a learning module, event, or set of tasks associated with it that must be completed in order to unlock its achievement. Based on the number of achievements a learner unlocks, they will be issued an IBM digital credential. 5 | 6 | For program information, visit [qisk.it/quantum-explorers](http://qisk.it/quantum-explorers). 7 | 8 | ![Image](images/credly_badges.png) 9 | 10 | ## Badge Pages 11 | 12 | Click on the links below for more information about each badge: 13 | 14 | - [Participant](https://www.credly.com/org/ibm/badge/quantum-explorer-2023-participant) - 1/3 community achievements 15 | - [Foundational](https://www.credly.com/org/ibm/badge/quantum-explorer-2023-foundational) - 1/4 learning achievements 16 | - [Intermediate](https://www.credly.com/org/ibm/badge/quantum-explorer-2023-intermediate) - 4/4 learning achievements 17 | - [Advanced](https://www.credly.com/org/ibm/badge/quantum-explorer-2023-advanced) - 7/7 total achievements 18 | 19 | 20 | 21 | 22 | ## Privacy Statement 23 | 24 | NOTICE: IBM leverages the services of Credly, a 3rd party data processor authorized by IBM and located in the United States, to assist in the administration of the IBM Digital Badge program. In order to issue you an IBM Digital Badge, your personal information (name, email address, and badge earned) will be shared with Credly. You will receive an email notification from Credly with instructions for claiming the badge. Your personal information is used to issue your badge and for program reporting and operational purposes. IBM may share the personal information collected with IBM subsidiaries and third parties globally. It will be handled in a manner consistent with IBM privacy practices. The IBM Privacy Statement can be viewed [here](https://www.ibm.com/us-en/privacy). 25 | 26 | 27 | Contact email address: qiskit.events@us.ibm.com 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /images/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qiskit-community/quantum-explorers/597fec6917327884425c9121257bcbf027df5f16/images/.DS_Store -------------------------------------------------------------------------------- /images/QE Medium Banner.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qiskit-community/quantum-explorers/597fec6917327884425c9121257bcbf027df5f16/images/QE Medium Banner.jpg -------------------------------------------------------------------------------- /images/credly_badges.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qiskit-community/quantum-explorers/597fec6917327884425c9121257bcbf027df5f16/images/credly_badges.png -------------------------------------------------------------------------------- /images/incoming message.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qiskit-community/quantum-explorers/597fec6917327884425c9121257bcbf027df5f16/images/incoming message.jpg -------------------------------------------------------------------------------- /images/qe_banner.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qiskit-community/quantum-explorers/597fec6917327884425c9121257bcbf027df5f16/images/qe_banner.jpg --------------------------------------------------------------------------------