0
$\begingroup$

Is it possible to get the statevector while running quantum circuits on IBMQ real hardware? If getting the statevector is not possible can I still calculate the fidelity of a qubit somehow?. What I want is to calculate the fidelity of q0, q1 and q2 in the following circuit after running it on real quantum hardware.

enter image description here

The code I am using is as follows:

import numpy as np
from qiskit import QuantumCircuit, QuantumRegister, ClassicalRegister
from qiskit import IBMQ, Aer, transpile, assemble
from qiskit.visualization import plot_histogram, plot_bloch_multivector, array_to_latex
from qiskit.extensions import Initialize
from qiskit.tools.monitor import job_monitor
from qiskit.quantum_info import random_statevector,partial_trace,state_fidelity
from math import pi, sqrt
from qiskit import IBMQ, transpile
from qiskit import IBMQ


IBMQ.load_account()
IBMQ.providers()
provider = IBMQ.get_provider(hub='ibm-q')  # replace by your runtime provider
backend = provider.get_backend('ibmq_lima')
psi= random_statevector(2)
fidelityQ00=[]

# Display it nicely
display(array_to_latex(psi, prefix="|\\psi\\rangle ="))
# Show it on a Bloch sphere
plot_bloch_multivector(psi)

qc = QuantumCircuit(3)
qc.initialize(psi, 0)

qc.u(np.arccos(1/sqrt(5)), 0,0,1)
qc.cx(1,2)
qc.u(np.arccos(sqrt(5)/3), 0,0,2)
qc.cx(2,1)
qc.u(np.arccos(2/sqrt(5)), 0,0,1)
qc.cx(0,1)
qc.cx(0,2)
qc.cx(1,0)
qc.cx(2,0)
qc.draw(output='mpl')
#qc.save_statevector()


#t_qc = transpile(qc, backend, optimization_level=3)
#job = backend.run(t_qc)
#job_monitor(job)
#exp_result = job.result()
#exp_counts = exp_result.get_statevector(qc)


  
$\endgroup$
1
  • 2
    $\begingroup$ See the answers here, and here $\endgroup$ Commented Jun 25, 2022 at 11:46

1 Answer 1

1
$\begingroup$

I’m almost sure that results from real devices will be in the form of counts so you can’t turn that into a statevector. Each shot of the experiment will end up in a different statevector after all.

But if you want to compare fidelity between count distributions you can use this: https://qiskit.org/documentation/stubs/qiskit.quantum_info.hellinger_fidelity.html

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.