unitaryfund / mitiq

Mitiq is an open source toolkit for implementing error mitigation techniques on most current intermediate-scale quantum computers.
https://mitiq.readthedocs.io
GNU General Public License v3.0
363 stars 163 forks source link

2 Qubit rotated RB circuits for calibrator #2311

Open bdg221 opened 7 months ago

bdg221 commented 7 months ago

Issue Description

This is a continuation of #2065 which handled the 1 qubit rotated rb circuit. In this issue, we are looking to address the 2 qubit scenario.

The primary task of this issue is to determine the ideal distribution of the 2 qubit rotated RB circuits and then update the code similar to #2248 which is the PR that handled the 1 qubit case.

Additional References

Below are some references from #2065 : Volumes of Compact Manifolds A Parametrization of Bipartite Systems Based on SU (4) Euler Angles

bdg221 commented 7 months ago

The first step will be do some numerical simulations of the rotated_rb circuits and plot the probabilities. This will give a rough idea of the expected results.

bdg221 commented 6 months ago

Here is the code I used for generating the probability of 00 along with the resulting graph:

n_qubits = 2
depth = 10
trials = 1
results= {}

for i in range(101):
    theta = (4 / 100) * math.pi * i
    circ = generate_rotated_rb_circuits(
            n_qubits=n_qubits, num_cliffords=depth, theta=theta, trials=trials, return_type="cirq"
        )
    results[str(theta)] = mitiq_cirq.compute_density_matrix(circuit=circ[0], noise_level=(0.0,))

plt.xlabel('theta')
plt.ylabel(' prob of 00')

tick_lbls = ['1/2 pi', 'pi', '3/2 pi', '2 pi', '5/2 pi', '3 pi', '7/2 pi', '4 pi']
plt.xticks(np.round(np.arange(math.pi/2, 9*math.pi/2, step=(math.pi/2)), 2).tolist(), tick_lbls)

plt.plot([float(k) for k in results.keys()], [results[str(t)][0][0]**2 for t in results.keys()], 's')

image

bdg221 commented 6 months ago

I realized that I squared the [0][0] value from the results. Here is the correct plot: image

FarLab commented 6 months ago

So I think you are having the same confusion as I had previously when I worked on this problem :) You are plotting the distribution for just one random rotated rb circuit, where we actually need to take an average over many different samples of these circuits (this is also the reason why you are seeing probability 1 sometimes out of nowhere). Concretely, you would have to set trials=100 or some other large number and then take the average of the distributions each circuit creates. I did this and I get the following for measuring 00 and 11. output If you want, you could try to get the distribution for 01 and 10. Let me know if something is unclear. @bdg221

bdg221 commented 6 months ago

I was able to complete the plot for measuring 00, 01, 10, and 11. You were correct about increasing the number of trials.

image