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')
Create a function that returns a quantum circuit implementing a depolarizing channels with parameter $p$ on a specified qubit system
, using three ancillary qubits ancillae = [a1, a2, a3]
.
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...
Write a circuit prepare_state
that prepares the system
qubit in an initial state that has non-zero populations and coherences (both real and imaginary parts)
# 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]
For different values of $p \in [0, 1]$:
prepare_state
and depolarizing_channel
in a circuit and create the corresponding tomography_circuits
(check the preliminaries for help with the tomography).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)
Up to the statistical errors due to the finite number of shots, the simulated points should match the analytical prediction.
Perform Tasks 3-5 on a real device, and include error mitigation (check the preliminaries for instructions). Compare the results with the simulation.