Path: blob/main/notebooks/summer-school/2022/resources/lab-notebooks/lab-4.ipynb
3855 views
1 Introduction
1-1 Quantum Simulation
One of the leading uses for quantum computers will be to simulate quantum systems such as molecules or engineered materials. Actually executing a quantum simulation on a current quantum computer, however, can be difficult and error prone. Your objective for this lab is to complete the exercises and then improve on them to get the highest state tomography score (more details in Section 2).
The quantum system you will simulate is a quantum spin-1/2 model, where each qubit represents a quantum spin-1/2 particle in a 1D chain. Quantum spin models have some amazing properties and uses. Computationally speaking, certain optimization problems can be mapped to spin models and hence minimized on a quantum computer. Physically speaking, spin models show a variety of quantum behavior such as large entangled states, quantum phases of matter, quantum many-body affects, and many other open questions in physics research.
There are many different spin models, but we will focus on the Heisenberg spin model. Though it is not as well known as the transverse-field Ising model, the Heisenberg model is of practical and theoretical interest. It can also be difficult to simulate, which is where you come in.
The notebook is organized as follows:
Section 1 (labeled 1-X) provides you with brief introductions to the Heisenberg model, time evolving a Hamiltonian, and decomposing a time evolution operator into gates for a quantum computer to execute.
Section 2 (labeled 2-X) outlines the specific requirements and boundaries associated with completing the exercises and competing for the best score. Completing the exercises will give you an example solution. Once you've completed the exercises, feel free to modify your answers to get the best score.
1-2 The Heisenberg Spin Model
To simulate a quantum system, we first need to define how the quantum particles that make up the system interact with each other. In quantum physics, this is done by defining a Hamiltonian operator. For this lab, you will work with the Heisenberg Hamiltonian as defined below
is the number of spin-1/2 particles in model. The operators , , and are Pauli operators where the and superscripts label which qubit they act on. For example, would be the operator acting on only qubit 1 (which is the 2nd qubit since indexing starts at 0). This version of the general Heisenberg spin model is called because the same value multiplies each pair of Pauli operators. The sum notation means the sum is over nearest neighbors (only qubits next to each other interact), and is the interaction strength, which we will set .
You will work with the explicit case of with the 3 spins arranged in a line. Written out fully, the Hamiltonian is Now that we have a Hamiltonian (), we can use it to determine how the quantum system of 3 spin-1/2 particles changes in time.
1-3 Using OpFlow
Qiskit offers functionality for mathematically working with quantum states and operators called opflow with tutorials found here. Opflow is especially convenient when dealing with large numbers of qubits as tensor products can become unwieldy when using numpy both in size and syntax. Your first exercise is to write the above Hamiltonian in opflow.
1-4 Time Evolution
Knowing the Hamiltonian, we can determine how quantum states of that system evolve in time by solving the Schrödinger equation
For simplicity, let's set . We know that the Hamiltonian does not change in time, so the solution to the Schrödinger equation is an exponential of the Hamiltonian operator .
Now that we have the time evolution operator , we can simulate changes in a state of the system () over time .
Using opflow methods again, your second exercise is to compute the unitary time evolution under the Hamiltonian you constructed from exercise 1 for a given time t.
1-5 Classical Simulation of
Now that we have the operator which describes how any state of the quantum system changes in time, we can simulate the Heisenberg spin model! Just for fun, let's simulate the system using a classical computer first.
(Fun fact: Notice the size of in matrix form. It's represented by an x matrix. This is because there are states in the system. If the simulation were of particles (), would be approximately x! Well beyond the capacity of today's computers.)
1-6 Decomposition of Into Quantum Gates
To execute on a circuit model quantum computer, we must decompose into a product of single and two-qubit gates that are native to that quantum computer. There are a variety of techniques to do this. For this lab, you will only use Trotterization (which is sometimes referred to as the Suzuki-Trotterization decomposition, Trotter formulas, product formulas, and other names).
Below, we show an example Trotterization as outlined in [1-2].
Since the Pauli operators do not commute with each other, the exponential cannot be split into a product of simpler exponentials. However, we can approximate as a product of simpler exponentials through Trotterization. Consider a subsystem of 2 spin-1/2 particles within the larger 3 spin system. The Hamiltonian on spins and () would be . Rewriting in terms of the two possible subsystems within the total system you will simulate,
and do not commute, so . But, this product decomposition can be approximated with Trotterization which says is approximately a short evolution of (time = ) and followed by a short evolution of (time = ) repeated times
is the number of Trotter steps, and as increases, the approximation becomes more accurate. (Note that how a unitary is split up into subsystems for Trotterization is not necessarily unique.) The decomposition goes further. Within each 2 spin subsystems, the Pauli operator pairs (, , and ) commute. This means we can decompose the exponential of a subsystem Hamiltonian () into a product of even simpler exponentials getting us closer to a gate implementation of
For simplicity, and to use more common notation, let's rename the products with , , and and rewrite the Trotterized And that's it! We have now approximately decomposed into two-qubit gates , , and . Note that these gates are not native to superconducting qubits, but in Section 2, they will be further decomposed into native single and two-qubit gates.
[1] Y. Salathe, et al., Digital Quantum Simulation of Spin Models with Circuit Quantum Electrodynamics, Phys. Rev. X 5, 021027 (2015)
[2] F. Tacchino, et al., Quantum Computers as Universal Quantum Simulators: State-of-the-Art and Perspectives, Adv. Quantum Technol. 3 3 (2020) [free arXiv version]
2 Contest: Optimal Time Evolution
2-1 Contest Details
For this lab, we will have a fun, no pressure contest to get the best quantum simulation. Below is an outline of contest guidelines.
You are to time evolve the state to time under the Heisenberg model Hamiltonian as defined in Section 1. This will be done on the ibmq_manila quantum computer and noisy simulator. The qubits in the state could correspond to any three qubits of ibmq_manila. The evolution must be done using Trotterization with at least 4 steps (). You will compete based on the fidelity of the evolved state at time using state tomography. State tomography is a way of determining the exact quantum state--even phase information--at the end of a quantum circuit by running the circuit multiple times and measuring in different bases. The closer your final quantum state to the expected state, the higher the fidelity. As you work on your solution, other important elements to consider are clarity of your code and how many different techniques you can learn and bring together. This is a great time to practice a variety of skills. Ibmq_manila's remaining two qubits will not be evaluated by the state tomography calculation, so you may use them as you wish. You do not need to follow the same decomposition given in the example above, but your solution must be a Trotterization of with at least 4 steps (). You will find it useful to implement ideas and techniques you learned during this summer school that reduce errors and improve qubit coherence.
2-2 Import Qiskit
Feel free to import packages as needed. However, please keep to free packages and those obtained through pip install or conda install.
2-3 Quantum Devices
Connect to IBM provider and connect to a real or simulated backend. Final submissions must be run on a real backend, but simulated devices are faster for debugging and testing.
2-4 Decomposition of into Quantum Gates (Example)
The following circuit code is written based on the example given in Section 1. This is where you write your solution.
YOUR TROTTERIZATION GOES HERE -- START (beginning of example)
Combine subcircuits into single gate representing one () trotter step.
YOUR TROTTERIZATION GOES HERE -- FINISH (end of example)
2-5 Trotterized Time Evolution
Time evolve the state from to under . Although manila has five qubits, only three of the qubits will be used for the state . From left to right, the qubits in the state could correspond to any of the five qubits. State tomography will evaluate how well the quantum simulation matches to the expected state at . (Note the two remaining qubits will not part of the state tomography calculation.)
You choose how many trotter steps (trotter_steps) to take in the simulation, but it must be at least 4. The code below is written to be generic enough for you may add to it if necessary for your solution.
2-6 Execute
For your final submission, you will need to execute your solution on a real backend with four repetitions. For faster debugging, considering using a simulated backend and/or 1 repetition.
We can monitor the status of the jobs using Qiskit's job monitoring tools.
2-7 Results Analysis
Extract the results for the completed jobs and compute the state tomography fidelity for each repetition. You may choose to include other post-processing analyses here as well.