qiskit-community / qiskit-qcgpu-provider

A provider which allows Qiskit to use the QCGPU simulator
http://qcgpu.github.io/
Apache License 2.0
25 stars 12 forks source link

QCGPUSimulatorError: 'Measurements are only supported at the end' #6

Open cogig opened 5 years ago

cogig commented 5 years ago

image

adamisntdead commented 5 years ago

Hello!

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

cogig commented 5 years ago

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 commented 5 years ago

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

cogig commented 5 years ago

Is there a temporary solution to fix the problem?

adamisntdead commented 5 years ago

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

adamisntdead commented 5 years ago

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

pittcat commented 5 years ago

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

adamisntdead commented 5 years ago

Sorry, can you rephrase?

cogig commented 5 years ago

Oh,many thanks.

adamisntdead commented 5 years ago

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.

cogig commented 5 years ago

Ok,you can establish a new branch.

adamisntdead commented 5 years ago

It should be on master

cogig commented 5 years ago

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 commented 5 years ago

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

cogig commented 5 years ago
# 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

adamisntdead commented 5 years ago

Okay, I will have a look at this tonight