GRAPE calculation of control fields for toffoli implementation

Robert Johansson ([email protected])

In [20]:
%matplotlib inline
import matplotlib.pyplot as plt
import time
In [21]:
from qutip import *
qutip.settings.auto_tidyup = False
In [22]:
T = 1
times = np.linspace(0, T, 500)
In [23]:
U = toffoli()

R = 5000
H_ops = [# qubit 1: single-qubit control
         tensor(sigmax(), identity(2), identity(2)),
         tensor(sigmay(), identity(2), identity(2)),
         tensor(sigmaz(), identity(2), identity(2)),
         # qubit 1: single-qubit control
         tensor(identity(2), sigmax(), identity(2)),
         tensor(identity(2), sigmay(), identity(2)),
         tensor(identity(2), sigmaz(), identity(2)),
         # qubit 3: single-qubit control
         tensor(identity(2), identity(2), sigmax()),
         tensor(identity(2), identity(2), sigmay()),
         tensor(identity(2), identity(2), sigmaz()),
         # pairwise X-X interactions
         tensor(sigmax(), sigmax(), identity(2)),
         tensor(identity(2), sigmax(), sigmax()),
         tensor(sigmax(), identity(2), sigmax()),
         # pairwise Y-Y interactions
         tensor(sigmay(), sigmay(), identity(2)),
         tensor(identity(2), sigmay(), sigmay()),
         tensor(sigmay(), identity(2), sigmay()),
         # pairwise Z-Z interactions
         tensor(sigmaz(), sigmaz(), identity(2)),
         tensor(identity(2), sigmaz(), sigmaz()),
         tensor(sigmaz(), identity(2), sigmaz()),
         ]

H_labels = [r'$u_{1x}$',
            r'$u_{1y}$',
            r'$u_{1z}$',
            
            r'$u_{2x}$',
            r'$u_{2y}$',
            r'$u_{2z}$',
            
            r'$u_{3x}$',
            r'$u_{3y}$',
            r'$u_{3z}$',
            
            r'$u_{xxi}$',
            r'$u_{ixx}$',
            r'$u_{xix}$',
            
            r'$u_{yyi}$',
            r'$u_{iyy}$',
            r'$u_{yiy}$',
            
            r'$u_{zzi}$',
            r'$u_{izz}$',
            r'$u_{ziz}$',
        ]
In [24]:
H0 = 2 * pi * (tensor(sigmaz(), identity(2), identity(2)) + 
               tensor(identity(2), sigmaz(), identity(2)) + 
               tensor(identity(2), identity(2), sigmaz()))

c_ops = []

GRAPE

In [25]:
from qutip.control.grape import cy_grape_unitary, grape_unitary_adaptive, plot_grape_control_fields, _overlap
In [26]:
from scipy.interpolate import interp1d
from qutip.ui.progressbar import TextProgressBar
In [27]:
u0 = np.array([np.random.rand(len(times)) * 2 * pi * 0.01 for _ in range(len(H_ops))])

u0 = [np.convolve(np.ones(10)/10, u0[idx,:], mode='same') for idx in range(len(H_ops))]
In [28]:
result = cy_grape_unitary(U, H0, H_ops, R, times, phase_sensitive=False,
                          u_start=u0, progress_bar=TextProgressBar(),
                          eps=2*pi*5)
10.0%. Run time: 7294.54s. Est. time left: 00:18:14:10
20.0%. Run time: 14496.27s. Est. time left: 00:16:06:25
30.0%. Run time: 21717.01s. Est. time left: 00:14:04:33
40.0%. Run time: 28999.50s. Est. time left: 00:12:04:59
50.0%. Run time: 36309.58s. Est. time left: 00:10:05:09
60.0%. Run time: 43601.52s. Est. time left: 00:08:04:27
70.0%. Run time: 50901.11s. Est. time left: 00:06:03:34
80.0%. Run time: 58095.38s. Est. time left: 00:04:02:03
90.0%. Run time: 65290.81s. Est. time left: 00:02:00:54
Total run time: 72533.56s

Plot control fields for the toffoli gate in the presense of single-qubit tunnelling

In [29]:
plot_grape_control_fields(times, result.u / (2 * pi), H_labels, uniform_axes=True);

Fidelity of the resutling GRAPE gate

In [30]:
U
Out[30]:
Quantum object: dims = [[2, 2, 2], [2, 2, 2]], shape = [8, 8], type = oper, isherm = True\begin{equation*}\left(\begin{array}{*{11}c}1.0 & 0.0 & 0.0 & 0.0 & 0.0 & 0.0 & 0.0 & 0.0\\0.0 & 1.0 & 0.0 & 0.0 & 0.0 & 0.0 & 0.0 & 0.0\\0.0 & 0.0 & 1.0 & 0.0 & 0.0 & 0.0 & 0.0 & 0.0\\0.0 & 0.0 & 0.0 & 1.0 & 0.0 & 0.0 & 0.0 & 0.0\\0.0 & 0.0 & 0.0 & 0.0 & 1.0 & 0.0 & 0.0 & 0.0\\0.0 & 0.0 & 0.0 & 0.0 & 0.0 & 1.0 & 0.0 & 0.0\\0.0 & 0.0 & 0.0 & 0.0 & 0.0 & 0.0 & 0.0 & 1.0\\0.0 & 0.0 & 0.0 & 0.0 & 0.0 & 0.0 & 1.0 & 0.0\\\end{array}\right)\end{equation*}
In [31]:
result.U_f.tidyup(1e-1)
Out[31]:
Quantum object: dims = [[2, 2, 2], [2, 2, 2]], shape = [8, 8], type = oper, isherm = False\begin{equation*}\left(\begin{array}{*{11}c}(0.924-0.383j) & 0.0 & 0.0 & 0.0 & 0.0 & 0.0 & 0.0 & 0.0\\0.0 & (0.924-0.383j) & 0.0 & 0.0 & 0.0 & 0.0 & 0.0 & 0.0\\0.0 & 0.0 & (0.924-0.383j) & 0.0 & 0.0 & 0.0 & 0.0 & 0.0\\0.0 & 0.0 & 0.0 & (0.924-0.383j) & 0.0 & 0.0 & 0.0 & 0.0\\0.0 & 0.0 & 0.0 & 0.0 & (0.924-0.383j) & 0.0 & 0.0 & 0.0\\0.0 & 0.0 & 0.0 & 0.0 & 0.0 & (0.924-0.383j) & 0.0 & 0.0\\0.0 & 0.0 & 0.0 & 0.0 & 0.0 & 0.0 & 0.0 & (0.924-0.383j)\\0.0 & 0.0 & 0.0 & 0.0 & 0.0 & 0.0 & (0.924-0.383j) & 0.0\\\end{array}\right)\end{equation*}
In [32]:
result.U_f / result.U_f[0,0] #.tidyup(1e-1)
Out[32]:
Quantum object: dims = [[2, 2, 2], [2, 2, 2]], shape = [8, 8], type = oper, isherm = False\begin{equation*}\left(\begin{array}{*{11}c}1.0 & 0.0 & 0.0 & 0.0 & 0.0 & 0.0 & 0.0 & 0.0\\0.0 & (1.000-1.207\times10^{-06}j) & 0.0 & 0.0 & 0.0 & 0.0 & 0.0 & 0.0\\0.0 & 0.0 & (1.000+6.379\times10^{-07}j) & 0.0 & 0.0 & 0.0 & 0.0 & 0.0\\0.0 & 0.0 & 0.0 & (1.000-1.363\times10^{-06}j) & 0.0 & 0.0 & 0.0 & 0.0\\0.0 & 0.0 & 0.0 & 0.0 & (1.000+2.402\times10^{-06}j) & 0.0 & 0.0 & 0.0\\0.0 & 0.0 & 0.0 & 0.0 & 0.0 & (1.000+1.344\times10^{-06}j) & 0.0 & 0.0\\0.0 & 0.0 & 0.0 & 0.0 & 0.0 & 0.0 & 0.0 & (1.000+1.653\times10^{-08}j)\\0.0 & 0.0 & 0.0 & 0.0 & 0.0 & 0.0 & (1.000-4.466\times10^{-07}j) & 0.0\\\end{array}\right)\end{equation*}
In [33]:
abs(_overlap(U, result.U_f))**2
Out[33]:
0.99999986070155344

Quantum process tomography of the ideal and GRAPE gates

Ideal toffoli gate

In [39]:
op_basis = [[qeye(2), sigmax(), sigmay(), sigmaz()]] * 3
op_label = [["i", "x", "y", "z"]] * 3
In [40]:
fig = plt.figure(figsize=(16,12))

SU = spre(U) * spost(U.dag())

chi = qpt(SU, op_basis)

fig = qpt_plot_combined(chi, op_label, fig=fig, threshold=0.001)

Toffoli gate calculated using GRAPE

In [41]:
fig = plt.figure(figsize=(16,12))

SU = spre(result.U_f) * spost(result.U_f.dag())

chi = qpt(SU, op_basis)

fig = qpt_plot_combined(chi, op_label, fig=fig, threshold=0.001)

Versions

In [42]:
from qutip.ipynbtools import version_table

version_table()
Out[42]:
SoftwareVersion
IPython3.0.0-dev
QuTiP3.1.0.dev-275f5b2
Python3.4.0 (default, Apr 11 2014, 13:05:11) [GCC 4.8.2]
OSposix [linux]
Cython0.20.1
matplotlib1.4.x
SciPy0.14.0
Numpy1.9.0
Sat Sep 13 11:38:35 2014 JST