Skip to content

Instantly share code, notes, and snippets.

Created August 5, 2021 19:16
What would you like to do?
GHZ quantum circuit in Qiskit.

A GHZ quantum circuit is a quantum computing system that includes 3 entangled qubits.

A Greenberger–Horne–Zeilinger state (GHZ state) is a certain type of entangled quantum state that involves at least three subsystems.

Demo in IBM Quantum Composer.

def ghz():
Create a GHZ (entangled 3-qubit system) quantum circuit.
qc = QuantumCircuit(3)
qc.h(0), 1), 2)
job = qiskit.execute(qc, qiskit.BasicAer.get_backend('qasm_simulator'), shots=1000)
{'000': 481, '111': 519}
Copy link


Copy link

Hi. Are the 3-qubit GHZ and the 3-qubit cluster states exactly the same? If not, what is the difference?

Because from what I know, to generate a 3-qubit cluster state, we perform a Hadamard to all the 3 initial qubits (q0, q1, and q2). Why for the GHZ state we need to perform the Hadamard only on the first qubit?

Thank you.

Copy link

Great question. They actually are different. A GHZ only uses an H on the first qubit and then CNOT (controlled inverse) for the other two qubits, which ties them all together in an entangled state. At this point, any change to the first qubit will be reflected on the other two entangled qubits.

If the qubits, instead, each had their own H gate, they would not be entangled. Changes on any one of the qubits would not effect the others.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment