# what's the point of the first barrier in this circuit?

Does the barrier here won't simplify the circuit between the two H-gates?

• probably just for illustrative purposes... to break the circuit into stages but nothing else Commented Jun 2, 2022 at 15:37
• take a look at these two videos from qiskit, youtube.com/watch?v=CdoCPz6TC9k , youtube.com/watch?v=tS2CMOyWFMQ
– poig
Commented Jun 20, 2022 at 19:29

Correct, quoting What is a "barrier" in Qiskit Circuits?:

The barrier acts as a directive for circuit compilation to separate pieces of a circuit so that any optimizations or re-writes are constrained to only act between barriers (and if there are no barriers they act on the whole circuit)

However, in this example, the circuit cannot be further simplified, so transpiling the circuit without the barriers will not have any effect:

from qiskit import QuantumCircuit

qc = QuantumCircuit(3,1)
qc.h(0)
qc.cnot(0,1)
qc.h(2)
qc.h(0)

qc.draw()

     ┌───┐     ┌───┐
q_0: ┤ H ├──■──┤ H ├
└───┘┌─┴─┐└───┘
q_1: ─────┤ X ├─────
┌───┐└───┘
q_2: ┤ H ├──────────
└───┘
c: 1/═══════════════

from qiskit.compiler import transpile

qc_transp = transpile(qc)

qc_transp.draw()

     ┌───┐     ┌───┐
q_0: ┤ H ├──■──┤ H ├
└───┘┌─┴─┐└───┘
q_1: ─────┤ X ├─────
┌───┐└───┘
q_2: ┤ H ├──────────
└───┘
c: 1/═══════════════


Therefore, for the circuit you've given, the inclusion of the barriers does not serve any computational purpose. If more instructions were to be added, then the barriers could once again come into play.