qiskit-qcgpu-provider icon indicating copy to clipboard operation
qiskit-qcgpu-provider copied to clipboard

QCGPUSimulatorError: 'Measurements are only supported at the end'

Open cogig opened this issue 6 years ago • 16 comments

image

cogig avatar Jan 26 '19 20:01 cogig

Hello!

Can you tell me what circuit you were trying to run?

adamisntdead avatar Jan 26 '19 20:01 adamisntdead

The circuit image size is oversize and worrisome.After i remove all "reset" operation,it works well.But in my circuit ,"reset" operation is very import .How can I fix the error?

cogig avatar Jan 26 '19 20:01 cogig

https://qiskit.org/documentation/summary_of_quantum_operations.html#reset image

cogig avatar Jan 26 '19 20:01 cogig

Is there a temporary solution to fix the problem?

cogig avatar Jan 26 '19 20:01 cogig

Is it possible to do the reset operations once you have got the results?

adamisntdead avatar Jan 26 '19 20:01 adamisntdead

Okay, I will try add the resets, give me a few minutes

adamisntdead avatar Jan 26 '19 21:01 adamisntdead

@adamisntdead In our project,the number of quantum circuit is our primary consideration.So the reutilization of quantum circuit is very import.

pittcat avatar Jan 26 '19 21:01 pittcat

Sorry, can you rephrase?

adamisntdead avatar Jan 26 '19 21:01 adamisntdead

Oh,many thanks.

cogig avatar Jan 26 '19 21:01 cogig

Okay, can you try installing both this module and qcgpu from source? I am away from my computer (this is on an iPad)so I don’t want to release until I add and run tests.

adamisntdead avatar Jan 26 '19 21:01 adamisntdead

Ok,you can establish a new branch.

cogig avatar Jan 26 '19 21:01 cogig

It should be on master

adamisntdead avatar Jan 26 '19 22:01 adamisntdead

After I removed old packages,I cloned the both qiskit-qcgpu-provider and qcgpu to home and installed the two packages successfully by "python3 setup.py install --user".The same error take place when i add "reset" operation to the circuit.There may be something wrong by my incorrect operation.But I can't dope out a solution to the problem.

cogig avatar Jan 27 '19 03:01 cogig

I also tried pip3 install https://github.com/qcgpu/qcgpu ,but it doesn't take effect.

cogig avatar Jan 27 '19 03:01 cogig

# In[3]:


import numpy as np
from qiskit.tools.visualization import plot_histogram
from qiskit import QuantumCircuit, ClassicalRegister, QuantumRegister
from qiskit import execute, BasicAer
from qiskit_qcgpu_provider import QCGPUProvider


# In[4]:


col=2
state=6
reg_counts = 10

qr = QuantumRegister(reg_counts, 'qr')
cr = ClassicalRegister(reg_counts, 'cr')
circuit = QuantumCircuit(qr)
measurement_circuit=QuantumCircuit(cr)
for i in range(col, state):
    circuit.h(qr[i])
circuit.ccx(qr[8],qr[9],qr[0])
circuit.cx(qr[8],qr[1])


# In[5]:


circuit.reset(qr[6])


# In[6]:



Provider = QCGPUProvider()

circuit.add_register(cr)
circuit.measure(qr,cr)



print("QCGPU backends: ", Provider.backends())
backend_sim = Provider.get_backend('qasm_simulator')


job_sim = execute(circuit, backend_sim)
result_sim = job_sim.result()




counts=result_sim.get_counts(circuit)
counts


all_lst=list(counts.keys())
all_lst

If deleting the line that contains "reset" operation ,the error will fade away and you can check the code

cogig avatar Jan 27 '19 03:01 cogig

Okay, I will have a look at this tonight

adamisntdead avatar Jan 28 '19 09:01 adamisntdead