2
$\begingroup$

If I want to run a circuit on a real quantum computer, I have to measure it before running it. For example:

qc=QuantumCircuit(2)
qc.x(0)
qc.x(1)
qc.cx(0,1)
**qc.measure_all()**

To run on a quantum computer:

#Import IBMQ
from qiskit import IBMQ #different companies(IBM ic)'s quantum provider
from qiskit.providers.ibmq import least_busy

#ask for the least busy quantum computer
provider = IBMQ.get_provider(hub='ibm-q')
backend = least_busy(provider.backends(filters=lambda x: x.configuration().n_qubits >= 2 
                                       and not x.configuration().simulator #dont want a simulator, want a actual machine
                                       and x.status().operational==True)) #want an operational machine
#tell us what the least busy one is
print("least busy backend: ", backend)

# send the job to a quantum computer
job = execute(qc, backend=backend, shots=100)
result = job.result()

#then we plot our histogram as usual
counts = result.get_counts(qc)
plot_histogram(counts)

I am wondering why do we have to measure the circuit before sending it to the real quantum computer? I know that we shouldn't measure the circuit if we send it to a statevector simulator.

New contributor
Cheryl is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
$\endgroup$
5
$\begingroup$

The simple answer is that you can't get the statevector information out of a real quantum computer; or, more generally, a quantum system. For the real computer to extract information from the qubits, they have to collapse to some basis state $\left(|0\rangle \; \text{or} \; |1\rangle \right)$. And this collapse is performed by measuring the qubits.

$\endgroup$
6
$\begingroup$

Note that you do not measure anything before sending to QC. What you actually send to QC is a sequence of instructions telling QC what to do. The measurement is the last instruction necessary for obtaining results as pointed out in the other answer.

$\endgroup$

Your Answer

Cheryl is a new contributor. Be nice, and check out our Code of Conduct.

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.