1
$\begingroup$

This was sent to qasm_simulator, and the results look like:

results

It seems qasm has added classical bits but why there are gates on the right side of the line. What do they mean?

Also, what does the result mean? with the pair like data?

Circuit :

qasm_simulator_example

$\endgroup$
3
  • 1
    $\begingroup$ Hi, could you post the code you used to create your circuit? This is a strange behaviour but it would be useful to have the code just to check if there are any mistakes there :) $\endgroup$
    – Lena
    Nov 25 at 14:13
  • $\begingroup$ I did a qubit entanglement, then measured it. Post this, I made some modification on the qubit gates, and measured again. Is this the reason i got a weird circuit? $\endgroup$
    – Kittu A
    Nov 25 at 14:27
  • 2
    $\begingroup$ Did you call measure_all() twice? $\endgroup$ Nov 25 at 19:14
1
$\begingroup$

As @Egretta.Thula pointed out, this usual due to you applying two measurements on each of the qubit. For instance,

import qiskit.quantum_info as qi
from qiskit.circuit import QuantumCircuit
from qiskit import Aer 
from qiskit.aqua import QuantumInstance
qc1 = QuantumCircuit(3)
qc1.h(0)
for i in range(1,3):
    qc1.cx(0,i)
qc1.measure_all() 
qc1.h(0)
for i in range(2):
    qc1.cx(i,i+1)
qc1.measure_all() 
print(qc1)
quantum_instance = QuantumInstance(backend= Aer.get_backend('qasm_simulator') )
results = quantum_instance.execute(qc1)
results.get_counts()

         ┌───┐           ░ ┌─┐┌───┐           ░ ┌─┐      
    q_0: ┤ H ├──■────■───░─┤M├┤ H ├──■────────░─┤M├──────
         └───┘┌─┴─┐  │   ░ └╥┘└┬─┬┘┌─┴─┐      ░ └╥┘┌─┐   
    q_1: ─────┤ X ├──┼───░──╫──┤M├─┤ X ├──■───░──╫─┤M├───
              └───┘┌─┴─┐ ░  ║  └╥┘ └┬─┬┘┌─┴─┐ ░  ║ └╥┘┌─┐
    q_2: ──────────┤ X ├─░──╫───╫───┤M├─┤ X ├─░──╫──╫─┤M├
                   └───┘ ░  ║   ║   └╥┘ └───┘ ░  ║  ║ └╥┘
 meas: 3/═══════════════════╩═══╩════╩═══════════╬══╬══╬═
                            0   1    2           ║  ║  ║ 
                                                 ║  ║  ║ 
meas5: 3/════════════════════════════════════════╩══╩══╩═
                                                 0  1  2 
{'111 000': 279, '000 000': 257, '101 111': 248, '010 111': 240}

here the value '111 000' indicates the state you collapsed to on the first and second measurement.

If you split the circuit into two different circuits then this won't happen. For instance,

import qiskit.quantum_info as qi
from qiskit.circuit import QuantumCircuit
from qiskit import Aer 
from qiskit.aqua import QuantumInstance
qc1= QuantumCircuit(5)
qc1.h(0)
for i in range(1,5):
    qc1.cx(0,i)
qc1.measure_all()
print(qc1)

quantum_instance = QuantumInstance(backend= Aer.get_backend('qasm_simulator') )
results = quantum_instance.execute(qc1)
print( results.get_counts() ) 
        ┌───┐                     ░ ┌─┐            
   q_0: ┤ H ├──■────■────■────■───░─┤M├────────────
        └───┘┌─┴─┐  │    │    │   ░ └╥┘┌─┐         
   q_1: ─────┤ X ├──┼────┼────┼───░──╫─┤M├─────────
             └───┘┌─┴─┐  │    │   ░  ║ └╥┘┌─┐      
   q_2: ──────────┤ X ├──┼────┼───░──╫──╫─┤M├──────
                  └───┘┌─┴─┐  │   ░  ║  ║ └╥┘┌─┐   
   q_3: ───────────────┤ X ├──┼───░──╫──╫──╫─┤M├───
                       └───┘┌─┴─┐ ░  ║  ║  ║ └╥┘┌─┐
   q_4: ────────────────────┤ X ├─░──╫──╫──╫──╫─┤M├
                            └───┘ ░  ║  ║  ║  ║ └╥┘
meas: 5/═════════════════════════════╩══╩══╩══╩══╩═
                                     0  1  2  3  4 
{'00000': 513, '11111': 511}


qc2 =  QuantumCircuit(5)
qc2.h(0)
for i in range(2):
    qc2.cx(i,i+1)
qc2.measure_all() 
print(qc2)
quantum_instance = QuantumInstance(backend= Aer.get_backend('qasm_simulator') )
results = quantum_instance.execute(qc2)
results.get_counts()
print( results.get_counts() ) 


        ┌───┐                     ░ ┌─┐            
   q_0: ┤ H ├──■──────────────────░─┤M├────────────
        └───┘┌─┴─┐                ░ └╥┘┌─┐         
   q_1: ─────┤ X ├──■─────────────░──╫─┤M├─────────
             └───┘┌─┴─┐           ░  ║ └╥┘┌─┐      
   q_2: ──────────┤ X ├──■────────░──╫──╫─┤M├──────
                  └───┘┌─┴─┐      ░  ║  ║ └╥┘┌─┐   
   q_3: ───────────────┤ X ├──■───░──╫──╫──╫─┤M├───
                       └───┘┌─┴─┐ ░  ║  ║  ║ └╥┘┌─┐
   q_4: ────────────────────┤ X ├─░──╫──╫──╫──╫─┤M├
                            └───┘ ░  ║  ║  ║  ║ └╥┘
meas: 5/═════════════════════════════╩══╩══╩══╩══╩═
                                     0  1  2  3  4 
{'11111': 511, '00000': 513}
```
$\endgroup$

Your Answer

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.