Error while running Qiskit code on real quantum computer

I was trying to run this code on a quantum computer but I was getting an error can anyone suggest how to resolve this error?

enter preformatted text here
vector = [(159+625j), (3+71j)]
norm = np.linalg.norm(vector)
qc = QuantumCircuit(1)  # Create a quantum circuit with one qubit
initial_state = vector/np.linalg.norm(vector)
print('initial state is')
print(initial_state)
qc.initialize(initial_state, 0)
qc.x(0) ###### for not gate
qc.snapshot('final', snapshot_type='statevector')
a = qc.draw()
print(a)
#provider = IBMQ.get_provider = ('ibm-q')
qcomp= provider.get_backend('ibmq_belem')
job = execute(qc,backend=qcomp)
from qiskit.tools.monitor import  job_monitor
job_monitor(job)
result = job.result()
plot_histogram(result.get_counts(qc))


When I ran this through the quantum computer I am getting this error:

Cannot unroll the circuit to the given basis, ['id', 'rz', 'sx', 'x', 'cx', 'reset'].
No rule to expand instruction multiplex1_dg.

• I was unable to reproduce the error. Which qiskit version are you using? – luciano Mar 5 at 8:31

As commented by @Luciano and @Patrick, it probably has to do with the qiskit version that you are using. Patrick pointed out in the comment that if you are using qiskit version 0.20.0 or later then you wouldn't have the unroll error.

However, there is also a problem with your circuit of not having measurement but then you tried to get the counts value of the experiment to plot the histogram... so I took what you did and fixed it. What you have should work now once you upgrade your qiskit to a later version.

from qiskit import QuantumCircuit, execute, QuantumRegister, ClassicalRegister, IBMQ
from qiskit.tools.monitor import  job_monitor
from qiskit.visualization import plot_histogram
%matplotlib inline
import numpy as np

vector = [(159+625j), (3+71j)]
norm = np.linalg.norm(vector)
qc = QuantumCircuit(1,1)  # Create a quantum circuit with one qubit
initial_state = vector/np.linalg.norm(vector)
print('initial state is')
print(initial_state)
qc.initialize(initial_state, 0)
qc.x(0) ###### for not gate
qc.measure([0],[0])
qc.snapshot('final', snapshot_type='statevector')
print(qc)
job = execute(qc,backend=provider.get_backend('ibmq_belem'))
job_monitor(job)
result = job.result()
plot_histogram(result.get_counts(qc))


The output would be something like:

initial state is
[0.24506358+0.96330023j 0.00462384+0.10943091j]
┌────────────────────────────────────────────────┐┌───┐┌───┐┌─┐ ░
q_0: ┤ initialize(0.24506+0.9633j,0.0046238+0.10943j) ├┤ X ├┤ H ├┤M├─░─
└────────────────────────────────────────────────┘└───┘└───┘└╥┘ ░
c: 1/═════════════════════════════════════════════════════════════╩════
0
Job Status: job has successfully run


• I'm searching for the specific fix and I could not find it. Is it because the measurement? – luciano Mar 5 at 8:32
• @luciano Hum... I guess the fix is to use a version of qiskit 0.20.0 and later .. using an old Qiskit version (0.19.2) i reproduced the unroll pb .... Using version 0.20.6 that works well .. :-) – Patrick Mensac Mar 5 at 15:38
• @PatrickMensac You are right. Ha. I thought it was the measurement because the OP tried to plot the histogram of the results... but the would have given the 'No counts for experiment' error instead.... stupid me... – KAJ226 Mar 5 at 16:09
• @luciano I thought it was but that would have given a different error... – KAJ226 Mar 5 at 16:47