# Simulate a quantum channel with a certain fidelity

I am looking for an easy-to-use framework for simulating a quantum channel that can accept the desired average fidelity of the channel as input.

For example, if I want a channel with 98% average fidelity, I can just call a function like:

new_channel = create_channel(0.98)

Then, I can pass individual qubits into that channel and get an output, like this:

almost_the_same_as_arbitrary_state_1 = new_channel(arbitrary_state_1)

Any suggestions? I prefer matlab and python but can work with any language.

edit: as outlined in a comment below, this question may have 2 answers, one where:

1. the underlying physical process of the channel is unimportant
2. the underlying physical process of the channel is important

Suggestions on how to implement either one of these from scratch is also much appreciated.

• Is the physical process the channel describes important to you? Either a depolarizing channel or dephasing channel could result in the same fidelity, as could some combination of these two common channels. Jan 6, 2021 at 0:44
• are those the only two types of ways to add error to a channel? I think if there is a library that is fairly straightforward to use that has these types of functionality built in (and satisfies the other criteria of my question), that would be great. Perhaps a second answer could be provided for the case where the physical process of the channel is not important: which sounds pretty easy to implement, probably I could just make an implementation of that simulation myself Jan 6, 2021 at 1:40

In the first case, when the details of the physical process do not matter, you can choose any quantum channel type that can achieve your target average fidelity. Depolarizing channel may be a good choice.

In the second case, you need to know what class of physical processes are acceptable. For example, if you are modeling energy decay, amplitude damping channel may be appropriate. Once you describe the relevant processes as a parametrized quantum channel, then the next step is to identify the parameter values that yield your target average fidelity. In general, this can be done by solving the following equation for parameters $$p$$ of the channel $$\mathcal{E}_p$$

$$\overline F(\mathcal{E}_p) = F\tag1$$

where $$F$$ is the target fidelity and $$\overline F$$ is the average fidelity

$$\overline F(\mathcal{E}_p) = \int \langle\psi|\mathcal{E}_p(|\psi\rangle\langle\psi|)|\psi\rangle d\psi\tag2$$

where the integral is with respect to the Haar measure normalized so that $$\int d\psi=1$$ over the entire state space.

In order to illustrate the procedure, we are going to solve $$(1)$$ for depolarizing channel $$\mathcal{D}_\lambda$$

$$\mathcal{D}_\lambda(\rho) = \lambda\rho + (1 - \lambda) \frac{I}{N}\tag3$$

where $$\lambda$$ is a parameter and $$\rho$$ the input quantum state on a $$N$$-dimensional Hilbert space. Using $$(2)$$ and $$(3)$$ we obtain the following expression for the average fidelity of a depolarizing channel

\begin{align} \overline F(\mathcal{D}_\lambda) &= \int \langle\psi|\left(\lambda|\psi\rangle\langle\psi| + (1 - \lambda) \frac{I}{N}\right)|\psi\rangle d\psi \\ &= \int \lambda\langle\psi|\psi\rangle\langle\psi|\psi\rangle d\psi + \int (1 - \lambda) \frac{\langle\psi|I|\psi\rangle}{N} d\psi \\ &= \lambda \int d\psi + (1 - \lambda) \frac{1}{N}\int d\psi \\ &= \lambda + (1 - \lambda) \frac{1}{N} \\ &= \frac{N-1}{N}\lambda + \frac{1}{N} \end{align}

where we used the facts that $$\langle\psi|\psi\rangle = 1$$ and $$\int d\psi=1$$. Substituting this into $$(1)$$, we get

$$\frac{N-1}{N}\lambda + \frac{1}{N} = F$$

which we solve to get

$$\lambda = \frac{FN - 1}{N - 1}.$$

For example, if you are targeting $$98\%$$ average fidelity on a qubit ($$N = 2$$) then you can use depolarizing channel with $$\lambda = 0.96$$.

You can implement the channel in software using equation $$(3)$$. For example, in python using numpy arrays to store density matrices

def make_depolarizing_channel(p: float) -> Callable[[np.ndarray], np.ndarray]:

def depolarizing_channel(rho: np.ndarray) -> np.ndarray:
N = rho.shape[0]
return p * rho + (1 - p) * np.eye(N) / N

return depolarizing_channel


where p corresponds to $$\lambda$$.

• Thanks, very well explained! would you also be able to elaborate a bit on how you simplified the expression for the average fidelity of a depolarizing channel? I don't see how each step leads to the next. perhaps add in a couple of steps and noting any rules used. Jan 6, 2021 at 18:38
• Sure! Added intermediate steps and comments on some facts I exploited. Jan 6, 2021 at 19:18
• awesome! just want to further clarify though: you use the variable 'd' for two different things, correct? one is for indicating the derivative of ket and one is a parameter a part of the depolarizing channel equation?... a bit confusing having it in two places. Jan 7, 2021 at 19:37
• Ah, indeed. I'll edit the answer to fix this. Jan 7, 2021 at 19:53
• perfect. thanks a bunch. Jan 7, 2021 at 19:56