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


and this is the error

enter image description here


1 Answer 1


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:


  • $\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$ Sep 8, 2020 at 16:29

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.