Skip to content

Commit

Permalink
fixed doc section labels
Browse files Browse the repository at this point in the history
  • Loading branch information
ajrazander committed Sep 29, 2022
1 parent f751a2d commit a092126
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 56 deletions.
6 changes: 3 additions & 3 deletions docs/protein_folding/protein_folding.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -1083,7 +1083,7 @@
"hash": "94561c5514d6ed309ef55bb744ee9b24e97b38d0ec7b9028efe679e2a743ca0e"
},
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
Expand All @@ -1097,9 +1097,9 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.12"
"version": "3.8.8"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
}
2 changes: 1 addition & 1 deletion docs/tutorial_quantum_sim/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Tutorial on quantum simulation
==============================

This experiment simulates the time evolution under a tight binding model on IBM Quantum hardware.
The results are published at `arXiv:2209.02795`_.
The results are published on the arXiv `arXiv:2209.02795`_.
The documentation for this module consists of one notebook that contains background information, shows how the building blocks of the experiment were implemented, collects experimental data, analyzes data, and generates plots.

.. _arXiv:2209.02795: https://arxiv.org/abs/2209.02795
Expand Down
74 changes: 22 additions & 52 deletions docs/tutorial_quantum_sim/qsim-tight-binding-model.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@
"id": "2ca79375-3c1b-441c-93fe-3dd942762f26",
"metadata": {},
"source": [
"# Introduction\n",
"# Quantum Simulation on Noisy Superconducting Quantum Computers\n",
"\n",
"This notebook is a companion to our paper \\[1\\] on quantum simulation. This notebook is not written as a research paper nor is it an introductory level tutorial; the context for some techniques will be missing as well as rigorous theoretical explanations. (These can be found in the paper \\[1\\] and subsequent citations.) Instead, this notebook aims to demonstrate minimal working examples of state-of-the-art techniques using Qiskit with the intent for you to build on. We demonstrate the time evolution of a simple tight binding model and various error mitigation techniques. Note that this tight-binding model can be solved exactly because it is a quadratic fermionic Hamiltonian, but we will be Trotterizing it for expository purposes. We hope you find the source code useful to jump start your own quantum research in more complicated models and methods.\n",
"## Introduction\n",
"\n",
"This notebook is a companion to our paper \\[1\\] on quantum simulation. This notebook is not written as a research paper nor is it an introductory level tutorial; the context for some techniques will be missing as well as rigorous theoretical explanations. (These can be found in the paper \\[1\\] and subsequent citations.) Instead, this notebook aims to demonstrate minimal working examples of state-of-the-art techniques using Qiskit with the intent for you to build upon them. We demonstrate the time evolution of a simple tight binding model and various error mitigation techniques. Note that this tight-binding model can be solved exactly because it is a quadratic fermionic Hamiltonian, but we will be Trotterizing it for expository purposes. We hope you find the source code useful to jump start your own quantum research into more complicated models and methods.\n",
"\n",
"We would love to see how you build on these ideas and methods for your own work!\n",
"\n",
Expand All @@ -19,11 +21,11 @@
"id": "78d8727d",
"metadata": {},
"source": [
"# The Tight Binding Model\n",
"## The Tight Binding Model\n",
"\n",
"The [tight-binding model](https://en.wikipedia.org/wiki/Tight_binding) is an exemplary model for physical systems with tightly bound particles. For example, physical systems where electrons are tightly bond to nuclei can be approximated by a tight binding model. It is also apart of other, more complicated, models, which we briefly discuss in the [paper](https://arxiv.org/abs/2209.02795). This makes it a nice minimal example, because it can be added upon in various ways to model many other types of systems.\n",
"\n",
"In this specific example, we'll consider the case of a single particle that can \"hop\" between 5 lattice cites. There is a \"hopping strength\" $tau$ to hop between different binding sites. We ignore any spin degree of freedom to the particle. We include a defect in the way of a hopping term that has a different value $tau_d$. The particle will initially start on the left most site of the lattice. **Our goal is to measure the state dynamics of the particle.**\n",
"In this specific example, we'll consider the case of a single particle that can \"hop\" between 5 lattice sites. There is a \"hopping strength\" $\\tau$ to hop between different binding sites. We ignore any spin degree of freedom to the particle. We include a defect in the way of a hopping term that has a different value $\\tau_d$. The particle will initially start on the left most site of the lattice. **Our goal is to measure the state dynamics of the particle.**\n",
"\n",
"The tight binding model (ignoring spin and no defect) follows the Hamiltonian\n",
"$$\n",
Expand Down Expand Up @@ -56,7 +58,7 @@
"metadata": {},
"source": [
"### Transformation to Pauli Operators\n",
"We transform the fermionic Hamiltonian to a spin Hamiltonian. (See the [paper](https://arxiv.org/abs/2209.02795) for details literature references.)\n",
"We transform the fermionic Hamiltonian to a spin Hamiltonian, so it can be simulated on a quantum computer. (See the [paper](https://arxiv.org/abs/2209.02795) and literature references for more details.)\n",
"\n",
"In mapping annihilation and creation operators to Pauli operators (labeled $X$, $Y$, $Z$, and the identity as $I$), we are mapping whether a site is occupied or not. Remember that we are ignoring any spin degree of freedom."
]
Expand All @@ -67,35 +69,25 @@
"metadata": {},
"source": [
"### Creation and Annihilation Operators\n",
"Action of the creation operator on the vacuum \"creates\" or \"raises\" the state $c^{\\dagger}|0\\rangle = |1\\rangle$. Action of the annihilation operator on the vacuum \"annihilates\" or \"lowers\" the state to zero $c|1\\rangle = |0\\rangle$. Following the Jordan-Wigner transformation (but making adjustments to ignore the spin of the particle and accounting for only nearest-neighbor interactions), the creation $c^{\\dagger}$ and annihilation $c$ operators map to Pauli raising $\\sigma_+$ and lowering $\\sigma_-$ operators (we can ignore the $Z$s in the end for this model).\n",
"The action of the creation operator on the vacuum state \"creates\" or \"raises\" the state $c^{\\dagger}|0\\rangle = |1\\rangle$. Action of the annihilation operator on the vacuum \"annihilates\" or \"lowers\" the state to zero $c|1\\rangle = |0\\rangle$. Following the Jordan-Wigner transformation (but making adjustments to ignore the spin of the particle), the creation $c^{\\dagger}$ and annihilation $c$ operators map to Pauli raising $\\sigma_+$ and lowering $\\sigma_-$ operators.\n",
"\n",
"$$\n",
"\\begin{align}\n",
"c_i &= \\sigma_{-} = \\dfrac{X_i + i Y_i}{2} \\\\\n",
"c^{\\dagger}_i &= \\sigma_{+} = \\dfrac{X_i - i Y_i}{2}\n",
"c^{\\dagger}_i &= \\sigma_{+} = Z_0 \\dots Z_{i-1} \\left( \\dfrac{X_i - i Y_i}{2} \\right) I_{i+1} \\dots I_N \\\\\n",
"c_i &= \\sigma_{-} = Z_0 \\dots Z_{i-1} \\left( \\dfrac{X_i + i Y_i}{2} \\right) I_{i+1} \\dots I_N\n",
"\\end{align}\n",
"$$\n",
"\n",
"Note that this these definitions are switched for spin states.\n",
"\n",
"In terms of Pauli operators, the Hamiltonian without a defect is\n",
"$$\n",
"\\begin{align}\n",
"H &= -\\frac{\\tau}{4} \\sum_{i=0}^{3} \\left( (X_i - i Y_i) (X_{i+1} + i Y_{i+1}) + (X_{i+1} - i Y_{i+1}) (X_i + i Y_i) \\right) \\\\\n",
"H &= -\\frac{\\tau}{4} \\sum_{i=0}^{3} \\left( X_i X_{i+1} - i Y_i X_{i+1} + i X_i Y_{i+1} + Y_i Y_{i+1} + X_{i+1}X_i + i X_{i+1} Y_i - i Y_{i+1}X_i - Y_{i+1}Y_i \\right) \\\\\n",
"H &= -\\frac{\\tau}{4} \\sum_{i=0}^{3} \\left( X_i X_{i+1} + Y_i Y_{i+1} + X_{i+1} X_i - Y_{i+1}Y_i \\right) \\\\\n",
"H &= -\\frac{\\tau}{2} \\sum_{i=0}^{3} \\left( X_i X_{i+1} + Y_i Y_{i+1} \\right) \\\\\n",
"\\end{align}\n",
"$$\n",
"Note that these definitions are typically switched when working in the spin-1/2 basis.\n",
"\n",
"Including the defect between sites 2 and 3 (as described in the paper),\n",
"Applying the transformation, and including the defect between sites 2 and 3 (as described in the paper), the Hamiltonian becomes\n",
"$$\n",
"\\begin{equation}\n",
"H = -\\frac{\\tau}{2} \\sum_{i=(0,1,3)} \\left( X_i X_{i+1} + Y_i Y_{i+1} \\right) -\\frac{\\tau_d}{2} \\left( X_2 X_{3} + Y_2 Y_{3} \\right)\n",
"\\end{equation}\n",
"$$\n",
"\n",
"We're now ready to write this Hamiltonian using Qiskit."
"We're now ready to write this Hamiltonian in Qiskit."
]
},
{
Expand Down Expand Up @@ -126,7 +118,7 @@
"id": "a6b61705-78fa-4a6b-9e27-a192a00f1d20",
"metadata": {},
"source": [
"**Qiskit nature method.** If we want to start from fermionic operator form of the Hamiltonian $H = -\\tau \\sum_{i=(0,1,3)} \\left( c_{i}^{\\dagger} c_{i+1} + c_{i+1}^{\\dagger} c_{i} \\right) - \\tau_d \\left( c_{2}^{\\dagger} c_{3} + c_{3}^{\\dagger} c_{2} \\right) \\;,$ we can use functionality from [Qiskit nature](https://qiskit.org/documentation/nature/) to define the Hamiltonian in terms of fermionic second quantization operators and have it do the Jordan-Wigner transformation to Pauli operators. This is shown below but not currently used in the notebook as FermionicOp does not currently support [Parameters](https://qiskit.org/documentation/stubs/qiskit.circuit.Parameter.html)."
"**Qiskit nature method.** If we want to start from fermionic operator form of the Hamiltonian $H = -\\tau \\sum_{i=(0,1,3)} \\left( c_{i}^{\\dagger} c_{i+1} + c_{i+1}^{\\dagger} c_{i} \\right) - \\tau_d \\left( c_{2}^{\\dagger} c_{3} + c_{3}^{\\dagger} c_{2} \\right) \\;,$ we can use functionality from [Qiskit nature](https://qiskit.org/documentation/nature/) to define the Hamiltonian in terms of fermionic second quantization operators and have qiskit do the Jordan-Wigner transformation to Pauli operators. This is shown below but not currently used in the notebook as FermionicOp does not currently support [Parameters](https://qiskit.org/documentation/stubs/qiskit.circuit.Parameter.html)."
]
},
{
Expand Down Expand Up @@ -310,7 +302,7 @@
"id": "1ed21f06-5bc3-4707-b871-88f07b046276",
"metadata": {},
"source": [
"The observable we are interested in is the expectation values of the number operator $\\langle n_i(t)\\rangle$ at a given site $i$ after an evolution of time $t$. This observable $\\langle n_i(t)\\rangle$ is the probability of the particle to occupy site $i$. Using the same transformations we did to find the Hamiltonian operators in terms of Pauli operators, $\\langle n_i(t)\\rangle$ in terms of Pauli operators is\n",
"The observables we are interested in are the expectation values of the number operators $\\langle n_i(t)\\rangle$ at a given site $i$ after an evolution time $t$. In the case of a single particle, the number operator $\\langle n_i(t)\\rangle$ is the probability of the particle to occupy site $i$. Using the same JW transformation we used on the Hamiltonian, $\\langle n_i(t)\\rangle$ in terms of Pauli operators is\n",
"\n",
"$$\n",
"\\begin{equation}\n",
Expand Down Expand Up @@ -361,7 +353,7 @@
"id": "62f454fe-11ab-430c-baff-63c28fd98301",
"metadata": {},
"source": [
"# Classical Simulation\n",
"### Classical Simulation\n",
"We can now classically simulate the state evolution and measure the observables of interest."
]
},
Expand Down Expand Up @@ -485,7 +477,7 @@
"id": "20ae5744-0713-4dd1-9a67-dcb4d5db8e8d",
"metadata": {},
"source": [
"### Particle conservation check\n",
"#### Particle conservation check\n",
"\n",
"It's always a good idea to test if a computer is giving something that makes sense. One such test, and a rather low effort one, is to compute the probability of finding the particle across all sites at each time point. Since we know there is only one particle to begin with and particle number is conserved, we should calculate 1 for all time steps. We will later use this fact in post-processing our quantum computer data by throwing out any measurements that don't preserve particle number."
]
Expand Down Expand Up @@ -537,7 +529,7 @@
}
],
"source": [
"# Confirm the variane of the sum of the number operators is zero to confirm particle number conservation.\n",
"# Confirm the variance of the number of particles is zero to confirm particle number conservation.\n",
"\n",
"plt.figure(figsize=(8, 3))\n",
"plt.plot(times, var_matrix)\n",
Expand All @@ -555,7 +547,7 @@
"metadata": {},
"source": [
"### Trotterization\n",
"To simulate these state dynamics, we've chosen to use the Trotter-Suzuki decomposition of the time evolution. Remember that this tight-binding model can be solved exactly because it is a quadratic fermionic Hamiltonian, but here, we will use it to illustrate the Trotter-Suzuki decomposition and subsequent techniques. This is covered more thoroughly in the [paper](https://arxiv.org/abs/2209.02795) and the references therein.\n",
"To simulate these state dynamics on a quantum computer, we've chosen to use the Trotter-Suzuki decomposition of the time evolution. Remember that this tight-binding model can be solved exactly because it is a quadratic fermionic Hamiltonian, but here, we will use it to illustrate the Trotter-Suzuki decomposition and subsequent techniques. This is covered more thoroughly in the [paper](https://arxiv.org/abs/2209.02795) and the references therein.\n",
"\n",
"Trotterization of defect free Hamiltonian. (Defect version shown later on.)\n",
"$$\n",
Expand Down Expand Up @@ -820,9 +812,9 @@
"id": "7a5ccf82",
"metadata": {},
"source": [
"# Noisy Quantum Computer Implementation\n",
"## Noisy Quantum Computer Implementation\n",
"\n",
"We know what to expect from the quantum computer, so we're ready for a first-pass implementation! Let's get started with the usual Qiskit imports, provider access, backends, backend properties, and whatnot.\n",
"We know what to expect from the quantum computer, so we're ready for a first-pass implementation! Let's get started with the usual Qiskit imports, provider access, backends, and backend properties.\n",
"\n",
"### Import Qiskit, IBM credentials, and helper functions"
]
Expand Down Expand Up @@ -1014,35 +1006,13 @@
"warnings.filterwarnings(\"ignore\")"
]
},
{
"cell_type": "code",
"execution_count": 18,
"id": "e62281ea-8729-4da2-af6a-9d6a70af9b6e",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"0.008056749855903877"
]
},
"execution_count": 18,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"sim = FakeLagos()\n",
"sim.properties().gate_error(\"cx\", (0, 1))"
]
},
{
"cell_type": "markdown",
"id": "7b461292-9189-4015-b084-87d71d1c4f2c",
"metadata": {},
"source": [
"### Access backends and their info\n",
"We will work with the ibm_lagos device. To estimate circuit performance and other information, lagos's properties, configuration, defaults, and native gate set can be accessed."
"We will work with the ibm_lagos device. To estimate circuit performance and other information, lagos's properties, configuration, defaults, and native gate set can be accessed. In the paper, we accessed the real backend. For ease of access, we'll implement everything with a simulator that emulates ibm_lagos's noise profile."
]
},
{
Expand Down

0 comments on commit a092126

Please sign in to comment.