0
$\begingroup$

This is the code that I have used. Why can't i use get_statevecto when i use quantum computer. I got a state_vector when i have used qasm_simulator.

qcomp = provider.get_backend('ibmq_5_yorktown') 
fidelitycount = 0
shots = 1
for i in range(shots):
    num_qubits = 5
    adj_matrix_fcg = np.ones((num_qubits,num_qubits),dtype=int)
    circuit_fcg_5 = qiskit.circuit.library.GraphState(adj_matrix_fcg)
    sv2 = execute(circuit_fcg_5, qcomp).result().get_statevector(circuit_fcg_5)
    #fidelity = qiskit.quantum_info.state_fidelity(sv1)
    #fidelitycount += fidelity

print(sv2)

and this is the error

enter image description here

$\endgroup$
3
$\begingroup$

When running on real backends you can't get a statevector since you can't return the quantum state of the device, only get measurement outcomes. The get_statevector method on the Result class only works if the backend (in this case a simulator) returns a statevector after executing the circuit.

That being said you can however try to use quantum tomography to reconstruct the state. You can see examples in the tutorial on how to do this here:

https://github.com/Qiskit/qiskit-tutorials/blob/master/tutorials/noise/8_tomography.ipynb

| improve this answer | |
$\endgroup$
  • $\begingroup$ Thanks. My aim was to create a graph state using a quantum simulator and device to verify the state fidelity. Is there any way to do that? $\endgroup$ – Rishwi binnu Sep 8 at 16:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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