Project 1: Depolarizing channel
In this project we will implement the depolarizing channel in qiskit and test it with state tomography on the simulator and on a real device.
We introduced the depolarizing channel in Chapter 5 where we showed the circuit that implements it.
Here it is again, for reference
# imports
import numpy as np
from qiskit import QuantumRegister, QuantumCircuit
####################################
# Depolarizing channel on IBMQX2 #
####################################
# Quantum register
q = QuantumRegister(4, name="q")
# Quantum circuit
depolarizing = QuantumCircuit(q)
# Depolarizing channel acting on q_2
## Qubit identification
system = 0
a_0 = 1
a_1 = 2
a_2 = 3
## Define rotation angle
theta = 0.0
## Construct circuit
depolarizing.ry(theta, q[a_0])
depolarizing.ry(theta, q[a_1])
depolarizing.ry(theta, q[a_2])
depolarizing.cx(q[a_0], q[system])
depolarizing.cy(q[a_1], q[system])
depolarizing.cz(q[a_2], q[system])
# Draw circuit
depolarizing.draw(output='mpl')
def depolarizing_channel(q, p, system, ancillae):
"""Returns a QuantumCircuit implementing depolarizing channel on q[system]
Args:
q (QuantumRegister): the register to use for the circuit
p (float): the probability for the channel between 0 and 1
system (int): index of the system qubit
ancillae (list): list of indices for the ancillary qubits
Returns:
A QuantumCircuit object
"""
# Write the code here...
# Let's fix the quantum register and the qubit assignments
# We create the quantum circuit
q = QuantumRegister(5, name='q')
# Index of the system qubit
system = 2
# Indices of the ancillary qubits
ancillae = [1, 3, 4]
Task 3
For different values of $p \in [0, 1]$:
- Concatenate
prepare_state
anddepolarizing_channel
in a circuit and create the correspondingtomography_circuits
(check the preliminaries for help with the tomography). - Execute the
tomography_circuits
in the simulator and collect the rsults
# For example, let's consider 10 equally spaced values of p
p_values = np.linspace(0, 1, 10)
Task 4
- Process the results of the simulation by performing the tomographic reconstruction.
- Find analytically what is the density matrix of the system qubit after the depolarizing channel as a function of $p$.
- Plot the values of $\rho_{11}$, $\rho_{22}$, $\Re \rho_{12}$, $\Im \rho_{12}$ as functions of $p$ and compare them to the analytical prediction.
Up to the statistical errors due to the finite number of shots, the simulated points should match the analytical prediction.
Homework
Perform Tasks 3-5 on a real device, and include error mitigation (check the preliminaries for instructions). Compare the results with the simulation.