This is the third internship lecture. Finally, we are going to start quantum computation.
Quantum States and State Vectors
Unlike today's computers, the data used in a quantum computer is handled differently: a single qubit is represented using a sphere. A qubit has a |0> state and a |1> state, which can be represented by a vector.
∣0⟩=[10],∣1⟩=[01]
∣ψ⟩=α∣0⟩+β∣1⟩=α[10]+β[01]=[αβ]
The following conditions are satisfied
∣α∣2+∣β∣2=1
∣ψ⟩ is called the state vector (wave function) and represents the quantum state of a qubit. The α and β are complex numbers and are called "amplitudes", and squaring them gives the probability of occurrence of the corresponding computational basis, and ∣α∣2 and ∣β∣2 can be obtained by "measurement".
Polar coordinate representation of quantum states
The Bloch sphere is a notation for representing quantum states on the unit sphere that can be expressed as a superposition of two orthogonal pure states.
You can also use angle-based parameter notation, such as Remember that quantum data is expressed in terms of angles.
Manipulating state vectors and quantum gates
To manipulate state vectors, quantum gates are used. The basic Pauli gate, arbitrary rotation gate, and Hadamar gate are mainly used in variational algorithms.
There are three types of Pauli gates, XYZ, each of which implies a 180-degree rotation around the XYZ axis in the Bloch sphere, and the corresponding matrices are
X=[0110],Y=[0i−i0],Z=[100−1]
Also, arbitrary rotation around the XYZ axes is made with the RX, RY, and RZ gates, and
The quantum state can be changed by acting these quantum gates on the state vector.
X[10]=[0110][10]=[01]
The Hadamar gate is a convenient gate that rotates around the XZ axis.
H=21[111−1]
Eigenvalue and eigenvector problems
Various problems can be solved if eigenvalues and eigenvectors for a given matrix can be found. For a given matrix H (called the Hamiltonian), if the eigenvalues are E0 and the eigenvectors are ∣ψ⟩.
H∣ψ⟩=E0∣ψ⟩
The objective is to find E0 and ∣ψ⟩ such that The ∣ψ⟩ is called the state vector (wave function).
Most quantum computer problems correspond to this eigenvalue problem. We set the problem on the matrix H and look for the eigenvalues E.
Quantum Variational Principle
Finding eigenvalues is the main optimization used in NISQ. We learned how to use numerical optimization on the seconde lecture.
⟨ψ(θ)∣H∣ψ(θ)⟩≥E0
Since it is tough to find the eigenvalues directly, we drop indirectly into an optimization calculation that brings us as close as possible to the expected value of the eigenvalues. Since the Hamiltonian H is a given expression, all we can do is to find a state vector ∣ψ(θ)⟩ as close as possible to the eigenstates as an optimization calculation of the angle is the goal of this project. The search for the state vector is achieved by creating a circuit called ansatz.
Hamiltonian and its expectation value
The Hamiltonian H is a Hermitian matrix consisting of a Pauli gate XYZ and a unit matrix I. The expected value E of the Hamiltonian H, given a certain quantum state ∣ψ⟩, is obtained by multiplying both of the above equations by ⟨ψ∣ from the left
⟨ψ∣H∣ψ⟩=⟨ψ∣E∣ψ⟩⟨ψ∣H∣ψ⟩=E⟨ψ∣ψ⟩⟨ψ∣H∣ψ⟩=E
As an example of a single qubit, from any quantum state ∣ψ⟩ and any Hamiltonian H, we have
⟨ψ∣H∣ψ⟩=[α∗β∗][acbd][αβ]
Find the expected value of the Hamiltonian Z
The expected value of the Hamiltonian at any state vector when H=Z is
⟨ψ∣H∣ψ⟩=[α∗β∗][100−1][αβ]=∣α∣2−∣β∣2
The expected value of the Hamiltonian H when H=X is
⟨ψ∣H∣ψ⟩=[α∗β∗][0110][αβ]=α∗β+αβ∗
but this value cannot be obtained by ordinary measurement, so the solution is obtained through a deformation of the Hamiltonian.
Transformation of Hamiltonian
If the Hamiltonian H is Z, we can calculate the expected value, but we cannot find it for X or Y. Therefore, we use a deformation of the Hamiltonian.
X=HZH
⟨ψ∣X∣ψ⟩=⟨ψ∣HZH∣ψ⟩=⟨ψ′∣Z∣ψ′⟩
In the case of Y, this can be handled by transforming the state vector as in
Y=RX(−π/2)ZRX(π/2)
⟨ψ∣Y∣ψ⟩=⟨ψ∣RX(−π/2)ZRX(π/2)∣ψ⟩=⟨ψ′′∣Z∣ψ′′⟩
These can be used to calculate the expected values by putting the above H and RX gates in the measurement just before the quantum circuit measurement.
Linear Combining
In fact, the Hamiltonian H is given by the Hermitian matrix, in the form of a unitary matrix sum, which can be decomposed as follows
can be calculated by doing the calculations individually and finding the sum, as in the example.
Quantum adiabatic computation
Quantum adiabatic calculation is a theory that allows time evolution while keeping the ground state by intermittently changing the state vector.
Let Hstart be the Hamiltonian of the initial state and Hfinal be the Hamiltonian of the final problem to be solved, then from the time t and the overall schedule T, we have
Htemp=(1−Tt)Hstart+TtHfinal
Then T→∞, the state vector changed in time evolution can follow the instantaneous Hamiltonian, take eigenstates and have eigenvalue.
Htemp∣ψ⟩=E0temp∣ψ⟩
The time evolution is aquired by,
∣ψt+1⟩=U∣ψt⟩=e−iHt∣ψt⟩
The challenge is where the ground state and the first excited state are closest, but we can keep the ground state by paying attention to the energy difference between E1(t)−E0(t).
QAOA circuit
QAOA is the time evolution calculation of the above quantum adiabatic calculation applied to a variational algorithm as ansatz.
The overall structure can be divided into two main parts
1.Selecting a mixer determines the initial state
2. create a formulation in QUBO or Z
The second formulation is automatically time evolved.
The leftmost formulation creates the initial eigenstate|+>. The corresponding Hamiltonian X comes out in Rx in the form of a time evolution. Usually the mixer chooses X by default, and H⊗N is often used to create the corresponding|+> initial state.
Also, CX-Rz-CX (orRZZ) corresponds to the weight of the Hamiltonian in the problem setup, and the next Rz corresponds to the bias of the Hamiltonian.
blueqat's QaoaAnsatz will automatically construct this time evolution ansatz for you if you decide on the Hamiltonian and the number of step divisions. Since the library does the appropriate calculations for us, all we have to do is formulate the Hamiltonian and select the mixer. Let's solve a simple formulation.
Ising Formulation
A physical model called the Ising model is used to solve combinatorial optimization problems. In the Ising model, the problem is usually formulated using up and down spins. The formulation uses Z as the operator, where Z has the expected value of +1 and -1.
H=−Z0−Z0∗Z1
QUBO
Next, we will check QUBO, which is derived from the Hamiltonian Z formulation above and formulated in terms of 0s and 1s. QUBO is a rewriting of the Z formulation, but blueqat has a tool that automatically converts it.
The formulation is
H=2q1−4q0q1
Copy
from blueqat import Circuit
from blueqat.utils import qaoa
from blueqat.pauli import qubo_bit as q
from blueqat.pauli import X,Y,Z,I
hamiltonian = 2*q(1)-4*q(0)*q(1)
step = 1
result = qaoa(hamiltonian, step)
result.circuit.run(shots=100)