Path: blob/main/notebooks/ch-quantum-hardware/hamiltonian-tomography.ipynb
3855 views
Hamiltonian Tomography
Introduction
The cross resonance gate for entangling qubits was introduced in this section of the Qiskit Textbook, where it is assumed the transmon is a qubit and the Schrieffer-Wolff transformation is applied to yield an effective Hamiltonian
where is the difference between the dressed frequencies of the qubits, is the cross resonance drive strength, and is the qubit-qubit coupling. We will use a common simplified notation for these interaction terms where the Pauli matrix is represented by a capital letter (with a hat to denote that it is an operator) and the qubit is represented by its position in a string, so for example we wish to isolate the interaction that is used to build the controlled-NOT gate from the and terms. Here the matrix represents the identity matrix on qubit .
In addition to understanding these extra terms, since the transmon has higher energy levels and actual experiments may have other interactions, due to crosstalk for example, when applying an entangling operation, it is not always obvious which Pauli rotations will be generated. Here we assume a cross resonance Hamiltonian of the following form:
where we will omit the Kronecker product symbol for succinctness. We refer to the first Pauli operator acting on the control qubit and second operators acting on the target qubits, as in the effective Hamiltonian above. While the form of the cross resonance Hamiltonian is known, the individual coefficients are not known. Note that these coefficients are also referred to as the strengths of the interaction they correspond to, i.e. is the interaction rate, etc. We must then find a way of extracting the coefficients from measurements made on the system after the cross resonance pulse is applied for different durations. Before we proceed, it should be noted that cross resonance operation also generates a interaction arising from a Stark shift (off-resonant drive that dressed the qubit frequency). This term can be extracted by preforming a Ramsey experiment on the control qubit. We will discuss this Ramsey procedure later on, so for now let us focus on the Hamiltonian that we wrote down.
The coefficients (interaction rates) will be extracted by taking six different measurements as a function of the duration of the pulse. The six measurements are of the expectation value of each Pauli term on the target qubit with the control qubit either in the ground or excited state. In the next section we will show how these measurements give us information about the coefficients.
Fitting Functions
In order to extract the coefficients , we need to know what function we expect to fit to the measurement data. The data we will be looking at will be the expectation value of Pauli operators as a function of pulse duration. In the Heisenberg picture of quantum mechanics, the evolution of the expectation value of an operator can be given as
Let be an infinitesimally small time increment. Then we have
to first order in . We can evaluate the commutator for each of the Pauli operators:
$$&\left[\hat{H}, \hat{I}\hat{X}\right] = 2 i \left(a_{y} \hat{Z}\hat{Z} - a_{z} \hat{Z}\hat{Y} + b_{y} \hat{I}\hat{Z} - b_{z} \hat{I}\hat{Y}\right) \\$$$$&\left[\hat{H},\hat{I}\hat{Y}\right] = 2 i \left(-a_{x} \hat{Z}\hat{Z} + a_{z} \hat{Z}\hat{X} - b_{x} \hat{I}\hat{Z} + b_{z} \hat{I}\hat{X}\right)\\$$ParseError: KaTeX parse error: Expected 'EOF', got '&' at position 1: &̲\left[\hat{H}, …If we let be the expectation value of the Pauli operator on the control qubit, then we can write down these commutators in terms of the expectation values of the target qubit:
ParseError: KaTeX parse error: Expected 'EOF', got '&' at position 1: &̲i\langle\left[\…ParseError: KaTeX parse error: Expected 'EOF', got '&' at position 1: &̲i\langle\left[\…ParseError: KaTeX parse error: Expected 'EOF', got '&' at position 1: &̲i\langle\left[\…where the expectation values on the right hand side are understood to be those of the target qubit, which will also be the case of the following discussion. Let us define then we can use these commutators to write down a matrix equation for the time dependence of depending on the Pauli- value of the state of the control qubit. Then putting the above equations together
or more compactly,
where
Since is time independent we can easily integrate the differential equation with the initial state corresponding to , yielding
We can find the matrix exponential, , by finding the eigenvalues and eigenvectors of . The eigenvalues of are
where for notational simplicity, the subscript denotes the appropriate values of given the state of the control qubit. We will not write down the eigenvectors because they are too cumbersome but it is straightforward to find them. Let be the transformation into the eigenbasis and let be the diagonal matrix of the eigenvalues. Then we can rewrite the time dependence of as
Setting (which corresponds the target qubit starting in the state) we have that
ParseError: KaTeX parse error: Expected 'EOF', got '&' at position 1: &̲\langle \hat{X}…ParseError: KaTeX parse error: Expected 'EOF', got '&' at position 1: &̲\langle \hat{Y}…ParseError: KaTeX parse error: Expected 'EOF', got '&' at position 1: &̲\langle \hat{Z}…where for each control qubit preparation . In the subsequent sections, we will often drop the hat (^) on the operators.
We will simulate on a model of a real device using the Pulse Simulator. First, load necessary libraries.
Warning:
This chapter uses PulseSimulator backend in Qiskit Aer. There is a bug in the latest stable version regarding the measurement, and thus this installs stable/0.7. See Qiskit/qiskit-aer#1257 for details.
Next, save the fake backend configuration and the sampling time . We will save the Hamiltonian parameters here for building a Duffing oscillator model later.
First we grab all the pulse-level gate calibrations, then we get the CNOT operation between two qubits. We already know from experience with this particular backend that the CNOT operation contains a CR pulse implemented as a GaussianSquare on a particular channel, ControlChannel(1) . We use this knowledge we have about the form of that instruction to extract it from the overall CNOT pulse.Schedule by using the filter method.
Cross resonance pulses are of type GaussianSquare, a square pulse with a Gaussian rise and fall. Currently, the waveform samples are returned from the instruction_schedule_map, so we must elucidate the GaussianSquare parameters to easily build our own cross resonance pulses. We can declare parameter as below:
Let's build a test schedule to visualize the default cross resonance pulse against the one we just constructed.
Pretty good! This will be close enough for the Hamiltonian tomography experiment. Now, this pulse nominally executes corresponding to the RZXGate because the cross resonance pulse is echoed: the first half will be a positive rotation dependent on the state of the control qubit, followed by an "echo pulse" that flips the control qubit, followed by a negative rotation dependent on the new state of the control qubit. This turns out to be equivalent to a , but we are just dealing with the first part of the pulse so that we can observe the full effect of the cross resonance interaction. We keep this in mind because this particular duration of cross resonance pulse will only take us an angle of around the Bloch sphere, and for the Hamiltonian tomography experiment we wish to traverse the Bloch sphere several times.
Note how the final schedule consists of the control in the state due to the -pulse on d1 channel before the cross resonance pulse and this is measured in the -basis.
Run Experiment on Backend Model Simulation
We will construct a Duffing oscillator model based on the Hamiltonian model of ibmq_athens by using PulseSystemModel. Then we collect the relevant Hamiltonian from the backend configuration.
Warning! The Pulse Simulator is computationally intensive and each experiment consisting of runs of 21 schedules with 6 different options and 2048 shots may take tens of minutes up to hours depending on CPU performance. The schedules with longer cross resonance pulses are more computationally intensive than those with shorter ones.
126 / 126
Fitting the Simulated Results
Using the scipy package, the fitting functions below will fit the Hamiltonian tomography data, Pauli expectations of the target qubit , for the control prepared in either the ground or excited state. Note that we must use a trick to concatenate all the data into a single array by tileing the time array and vstacking the data so we can use the curve_fit function.
Plotting Functions
The above fits provide the parameters , and for the control qubit prepared in states (corresponding to in the equations above). The interaction rates (coefficients of the operators) are then determined as
Fit and Plot
Note here that the magnitude of the interaction is a lot larger than the desired interaction. This is because the cross resonance pulse is out of phase with the single-qubit drive on the target qubit (not the here induced by the cross resonance pulse). We can determine this from the interaction rates and shift the phase of the cross resonance pulse in the next Hamiltonian tomography experiment.
126 / 126
Now we can see that the bulk of the cross resonance pulse provides the -interaction that we can use to entangle qubits. Note that the scale of the Pauli expectation graph of differs from the other graphs.
Measure ZI (Stark Shift) via CR Ramsey Experiment
Here we measure the interaction term via a Ramsey experiment, recalling that the resulting oscillation are a result of the difference between the qubit and drive frequency. Since the frequency (Stark) shift and interaction are equivalent because a frequency shift induces a -rotation on the control qubit, we can measure this shift and compensate for it with a frame change.
21 / 21
Fitting Functions for the CR Ramsey Experiment
We will fit the results to a decaying sinusoid, where the frequency of oscillation is the frequency offset. We will also need to take care of the relation between the control and target qubit frequencies, because that will effect whether the control qubit Stark shift is higher or lower in frequency.
Now we will rebuild the Ramsey schedule to compensate for the Stark shift and rerun the experiment.
21 / 21
We can see that we have substantially (but not totally) reduced the frequency shift (due to higher-order levels, etc.). At this point, we could return to the Hamiltonian tomography experiment
However, since the frame change only affects the control qubit, the results would be identical to the second one.
References
[1] S Sheldon, E Magesan, JM Chow, and JM Gambetta, "Procedure for systematically tuning up crosstalk in the cross resonance gate," Phys Rev A 93, 060302 (2016)
[2] T Alexander, N Kanazawa, DJ Egger, L Capelluto, CJ Wood, A Javadi-Abhari and DC McKay, "Qiskit pulse: programming quantum computers through the cloud with pulses", Quantum Sci. Technol. 5 044006 (2020)
[3] DC McKay, CJ Wood, S Sheldon, JM Chow, and JM Gambetta, "Efficient Z-Gates for Quantum Computing," Phys Rev A 96, 022330 (2017)