Skip to content
This repository has been archived by the owner on Feb 8, 2024. It is now read-only.

Commit

Permalink
Pull in updates from Qiskit/textbook (#2171)
Browse files Browse the repository at this point in the history
* Pull in updates from Qiskit/textbook

* adjust toc
  • Loading branch information
frankharkins authored Jul 20, 2023
1 parent 68c063e commit 543b658
Show file tree
Hide file tree
Showing 17 changed files with 1,196 additions and 1,707 deletions.
53 changes: 3 additions & 50 deletions notebooks/toc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -760,7 +760,7 @@
title: Applied quantum algorithms
type: chapter
url: /v1_ch-applications
- id: quantum-hardware
- id: ch-quantum-hardware
overviewInfo:
description:
long: 'Most gate-based quantum computers share similar challenges with noise
Expand Down Expand Up @@ -817,51 +817,6 @@
title: The density matrix and mixed states
url: v1/ch-quantum-hardware/density-matrix
uuid: 9f785388-6fab-4c13-b323-4d98cf215c03
title: Investigating quantum hardware using quantum circuits
type: chapter
url: /v1_quantum-hardware
- id: quantum-hardware-pulses
overviewInfo:
description:
long: 'The Qiskit Textbook mostly assumes we have a quantum computer that can
carry out quantum operations, and doesn''t worry about how the devices
actually work. These pages go a step deeper, exploring the physics of
superconducting qubits, and using Qiskit to program operations on these
devices at the level of microwave pulses.
'
short: 'In this chapter, we get a level closer to the real quantum machines.
Learn about the physics of these devices, and how to program them at
the level of microwave pulses.
'
prerequisites:
- description: 'With the basics down, this chapter explores the consequences of
these
new quantum effects, and sets us up with tools to understand quantum
algorithms.
'
link: https://learn.qiskit.org/course/ch-gates/introduction
title: Multiple Qubits and Entanglement
- description: 'Python is a programming language where you don''t need to compile.
You
can just run it line by line...
'
link: https://learn.qiskit.org/course/ch-prerequisites/introduction-to-python-and-jupyter-notebooks
title: Python and Jupyter Notebooks
thumbnailUrl: /ch-quantum-hardware/overview/header-pulses.png
sections:
- id: calibrating-qubits-pulse
previewImgUrl: /ch-quantum-hardware/overview/calibrating-qubits-pulse.png
title: Calibrating qubits with Qiskit Pulse
Expand Down Expand Up @@ -897,9 +852,9 @@
title: Hamiltonian tomography
url: v1/ch-quantum-hardware/hamiltonian-tomography
uuid: 37cc881f-a795-43b1-85b6-cb94f9cda622
title: Investigating quantum hardware using microwave pulses
title: Investigating quantum hardware
type: chapter
url: /v1_quantum-hardware-pulses
url: /v1_ch-quantum-hardware
- id: ch-labs
overviewInfo:
description:
Expand Down Expand Up @@ -1078,8 +1033,6 @@
url: /v1_ch-demos




#---- Below was added by machine ---

- id: basics-quantum-information
Expand Down
52 changes: 26 additions & 26 deletions notebooks/v1/ch-algorithms/quantum-walk-search-algorithm.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"cells": [
{
"cell_type": "markdown",
"id": "0f353c6f",
"id": "789a3892",
"metadata": {
"tags": [
"remove_cell"
Expand All @@ -14,7 +14,7 @@
},
{
"cell_type": "markdown",
"id": "6a696cd9",
"id": "7062b169",
"metadata": {},
"source": [
"Quantum walks are the quantum equivalence of a classical Markov chain and have become key in many quantum algorithms. In this section, we implement a quantum walk search algorithm that finds marked elements in a graph. The algorithm has a quadratic speedup compared to its classical counterpart. \n",
Expand Down Expand Up @@ -168,7 +168,7 @@
{
"cell_type": "code",
"execution_count": 2,
"id": "8402d335",
"id": "208ec8b2",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -188,7 +188,7 @@
},
{
"cell_type": "markdown",
"id": "efc61c2b",
"id": "63b14e4b",
"metadata": {},
"source": [
"The circuit will have 6 qubits, 4 that represents the position and 2 that represents the coin. As we mentioned previously, the coin is a Grover coin, which is the diffuser in Grover's algorithm. We start by implementing this. "
Expand All @@ -197,7 +197,7 @@
{
"cell_type": "code",
"execution_count": 3,
"id": "7483f2e6",
"id": "1c565b0f",
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -226,7 +226,7 @@
},
{
"cell_type": "markdown",
"id": "2e2dcc18",
"id": "cacb9b5c",
"metadata": {},
"source": [
"Now, let us implement the shift operator. We know that the walker can only move to neighboring nodes, and all neighboring nodes differ by only one bit. We want to move the walker according to the coin, and we move the walker by applying a NOT gate to one of the node qubits. If the coin is in state $\\ket{11}$, we move the walker to the state in which the first node qubit differ. If the coin is $\\ket{10}$ or $\\ket{01}$, the walker moves to the state where the second and third qubit, respectively, differ. Finally, if the Grover coin is $\\ket{00}$, we flip the fourth qubit. We implement this with CCNOT- and NOT gates after the Grover coin. Together, they are one step of a quantum walk on a 4-dimensional hypercube. "
Expand All @@ -235,7 +235,7 @@
{
"cell_type": "code",
"execution_count": 4,
"id": "562d63b6",
"id": "7c99ea89",
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -269,7 +269,7 @@
},
{
"cell_type": "markdown",
"id": "73e329ff",
"id": "86e61b23",
"metadata": {},
"source": [
"## 4. Quantum walk search algorithm <a name=\"qwalkalgo\"></a>\n",
Expand Down Expand Up @@ -326,7 +326,7 @@
},
{
"cell_type": "markdown",
"id": "78afba68",
"id": "e580d1d2",
"metadata": {},
"source": [
"For this algorithm we will need to use the inverse of the one step gate implemented earlier. We get this by using the built in circuit function inverse()."
Expand All @@ -335,7 +335,7 @@
{
"cell_type": "code",
"execution_count": 5,
"id": "257cb2e4",
"id": "fa21fd41",
"metadata": {},
"outputs": [
{
Expand All @@ -358,7 +358,7 @@
},
{
"cell_type": "markdown",
"id": "c026ba67",
"id": "2182b987",
"metadata": {},
"source": [
"The inversed one step gate will be used to reverse the phase estimation later. We need to make controlled gates from both the one step gate that we implemented in section 3 and its inverse. We will later use them depending on the value of the control qubit. "
Expand All @@ -367,7 +367,7 @@
{
"cell_type": "code",
"execution_count": 6,
"id": "c13dc3a1",
"id": "0520f182",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -380,7 +380,7 @@
},
{
"cell_type": "markdown",
"id": "e3b2de86",
"id": "33509a78",
"metadata": {},
"source": [
"Both the controlled one step gate and the controlled inversed one step gate will be used in the phase estimation. Another thing we will use in the phase estimation is the Quantum Fourier Transform. Qiskit has a function, QFT, which implements the Quantum Fourier Transform. The phase estimation uses the inverse Quantum Fourier Transform but we also will need to use the ordinary QFT to reverse the phase estimation."
Expand All @@ -389,7 +389,7 @@
{
"cell_type": "code",
"execution_count": 7,
"id": "de85ac13",
"id": "f9c7b584",
"metadata": {},
"outputs": [
{
Expand All @@ -415,7 +415,7 @@
},
{
"cell_type": "markdown",
"id": "6096d0dd",
"id": "59c8de1b",
"metadata": {},
"source": [
"Before we implement the phase estimation, we implement a phase oracle that marks the states 1011 and 1111. Then, we make it a circuit. This is step 2(a) of the algorithm."
Expand All @@ -424,7 +424,7 @@
{
"cell_type": "code",
"execution_count": 8,
"id": "4a93bcfb",
"id": "5286be30",
"metadata": {
"scrolled": true
},
Expand Down Expand Up @@ -464,7 +464,7 @@
},
{
"cell_type": "markdown",
"id": "a91335f4",
"id": "1e10513b",
"metadata": {},
"source": [
"We will now implement a gate that rotates an auxiliary qubit if the other qubits are non-zero. We will use this gate in the phase estimation, where it will rotate the auxiliary qubit if $\\theta \\neq 0$. "
Expand All @@ -473,7 +473,7 @@
{
"cell_type": "code",
"execution_count": 9,
"id": "825f9d6c",
"id": "ede560cd",
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -505,7 +505,7 @@
},
{
"cell_type": "markdown",
"id": "4fad4857",
"id": "f211880a",
"metadata": {},
"source": [
"Now, we will implement step 2(b) of the algorithm. This step consists of a phase estimation one step of the quantum walk followed by an auxiliary qubit that we rotate if $\\theta \\neq 0$. For this, we use the mark_auxiliary_gate that we just created. Thereafter, we reverse the phase estimation. "
Expand All @@ -514,7 +514,7 @@
{
"cell_type": "code",
"execution_count": 11,
"id": "5bdc78d0",
"id": "cb444542",
"metadata": {
"scrolled": false
},
Expand Down Expand Up @@ -565,7 +565,7 @@
},
{
"cell_type": "markdown",
"id": "5c8c53bc",
"id": "f95647a5",
"metadata": {},
"source": [
"Now we implement the whole quantum walk search algorithm using the gates we made previously. We start by applying Hadamard gates to node and coin qubits, which is step 1 in the algorithm. Thereafter, we iteratively apply the phase oracle gate and the phase estimation gate (steps 2(a) and 2(b)). We need $O(1/\\sqrt{\\epsilon})$ iterations as stated in the description of the algorithm in section 4. Lastly, we measure the node qubits. "
Expand All @@ -574,7 +574,7 @@
{
"cell_type": "code",
"execution_count": 12,
"id": "160eb345",
"id": "18f74668",
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -616,7 +616,7 @@
},
{
"cell_type": "markdown",
"id": "1b8ae6fa",
"id": "1571cb59",
"metadata": {},
"source": [
"Finally we run the implementation on the qasm simulator. We see that the circuit collapse to the marked states a clear majority of the times. "
Expand All @@ -625,7 +625,7 @@
{
"cell_type": "code",
"execution_count": 13,
"id": "ec69c953",
"id": "bf5d9a24",
"metadata": {},
"outputs": [
{
Expand All @@ -651,7 +651,7 @@
},
{
"cell_type": "markdown",
"id": "3792ca7d",
"id": "ca83111a",
"metadata": {},
"source": [
"## 6. References <a id='references'></a>\n",
Expand All @@ -665,7 +665,7 @@
{
"cell_type": "code",
"execution_count": 14,
"id": "d257ed54",
"id": "f143caba",
"metadata": {},
"outputs": [
{
Expand Down
2 changes: 1 addition & 1 deletion notebooks/v1/ch-algorithms/shor.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@
"source": [
"## 2. The Solution\n",
"\n",
"Shor’s solution was to use [quantum phase estimation](./quantum-phase-estimation) on the unitary operator:\n",
"Shor’s solution was to use [quantum phase estimation](./quantum-phase-estimation.html) on the unitary operator:\n",
"\n",
"$$ U|y\\rangle \\equiv |ay \\bmod N \\rangle $$\n",
"\n",
Expand Down
Loading

0 comments on commit 543b658

Please sign in to comment.