0
$\begingroup$

For the following code

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

Q1: What this vertical dotted line represent in the below circuit diagram?

Q2: 'meas' wire in the circuit is what kind of wire? is this classical wire or qubit wire?

Q3: How qc.measure_all() is different from qc.measure([0,1],[0,1])[couldn't find a simple answer on internet]

Circuit Diagram

$\endgroup$

2 Answers 2

1
$\begingroup$

Re Q1:

Be careful with vertical dotted line being treated only as visual logical separation of circuits. It looks like it may be interpreted by transpilers:

https://medium.com/arnaldo-gunzi-quantum/what-is-the-barrier-in-qiskit-for-7d1547bebd1

Reference:

https://quantum-computing.ibm.com/composer/docs/iqx/operations_glossary

Barrier operation

To make your quantum program more efficient, the compiler will try to combine gates. The barrier is an instruction to the compiler to prevent these combinations being made. Additionally, it is useful for visualizations.

Here is more information about barrier operation in another already answered questions:

  1. What is a "barrier" in Qiskit circuits?

  2. Is there a physical definition of barrier operation in qiskit?

$\endgroup$
2
$\begingroup$
  1. the vertical line is a barrier
  2. meas are classical bits , it will have the output of the measure_all function
  3. measure_all adds new bits to the circuit ,you don't have to define them, when you use measure you have to first define the classical bits. The 2 examples here show that , in the first one 2 qubits and 2 classical bits are defined , while in the second one 5 qubits are defined from qiskit import QuantumCircuit qc = QuantumCircuit(2, 2) qc.h(0) qc.cx(0, 1) qc.measure([0, 1], [0, 1]) qc.draw() from qiskit import QuantumCircuit qc = QuantumCircuit(5) qc.h(0) qc.cx(0, range(1, 5)) qc.measure_all()
$\endgroup$
2
  • $\begingroup$ vertical line or barrier is used for what purpose? $\endgroup$ Commented Apr 8, 2022 at 9:45
  • 1
    $\begingroup$ in this specific circuit , it doesn't have a purpose , I don't know why it is showing actually, but in general the barrier is used so that no optimization or simplification on the circuit happen between the 2 sides of the barrier. you can check this $\endgroup$
    – kibrahim
    Commented Apr 8, 2022 at 10:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.